aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-04-23 20:15:05 +0000
committerJustin Clarke Casey2009-04-23 20:15:05 +0000
commit1ccc99a3f9d96fbdea478be7e7df427a9e5377a7 (patch)
tree713222af91ebef24e5604efffc9e6b1c68a7700b /OpenSim
parent* Allow interested user data plugins to store temporary user profiles (diff)
downloadopensim-SC_OLD-1ccc99a3f9d96fbdea478be7e7df427a9e5377a7.zip
opensim-SC_OLD-1ccc99a3f9d96fbdea478be7e7df427a9e5377a7.tar.gz
opensim-SC_OLD-1ccc99a3f9d96fbdea478be7e7df427a9e5377a7.tar.bz2
opensim-SC_OLD-1ccc99a3f9d96fbdea478be7e7df427a9e5377a7.tar.xz
* refactor: move archive user inventory item serialization out to a separate file
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs8
-rw-r--r--OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs198
-rw-r--r--OpenSim/Framework/Serialization/External/UserProfileSerializer.cs4
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs73
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs97
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs68
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs68
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs2
8 files changed, 295 insertions, 223 deletions
diff --git a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
index 3ee9e1b..232ad4e 100644
--- a/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/RegionSettingsSerializer.cs
@@ -34,16 +34,14 @@ using OpenSim.Framework;
34namespace OpenSim.Framework.Serialization.External 34namespace OpenSim.Framework.Serialization.External
35{ 35{
36 /// <summary> 36 /// <summary>
37 /// Serialize and deserialize region settings for an archive file format. 37 /// Serialize and deserialize region settings as an external format.
38 /// </summary> 38 /// </summary>
39 /// We didn't simply use automatic .NET serializagion for OpenSim.Framework.RegionSettings since this is really
40 /// a file format rather than an object serialization.
41 public class RegionSettingsSerializer 39 public class RegionSettingsSerializer
42 { 40 {
43 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); 41 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
44 42
45 /// <summary> 43 /// <summary>
46 /// Deserialize region settings 44 /// Deserialize settings
47 /// </summary> 45 /// </summary>
48 /// <param name="serializedSettings"></param> 46 /// <param name="serializedSettings"></param>
49 /// <returns></returns> 47 /// <returns></returns>
@@ -54,7 +52,7 @@ namespace OpenSim.Framework.Serialization.External
54 } 52 }
55 53
56 /// <summary> 54 /// <summary>
57 /// Deserialize region settings 55 /// Deserialize settings
58 /// </summary> 56 /// </summary>
59 /// <param name="serializedSettings"></param> 57 /// <param name="serializedSettings"></param>
60 /// <returns></returns> 58 /// <returns></returns>
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
new file mode 100644
index 0000000..d51107d
--- /dev/null
+++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
@@ -0,0 +1,198 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.IO;
30using System.Text;
31using System.Xml;
32using OpenMetaverse;
33using OpenSim.Framework;
34
35namespace OpenSim.Framework.Serialization.External
36{
37 /// <summary>
38 /// Serialize and deserialize user inventory items as an external format.
39 /// </summary>
40 /// XXX: Please do not use yet.
41 public class UserInventoryItemSerializer
42 {
43 protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding();
44
45 /// <summary>
46 /// Deserialize item
47 /// </summary>
48 /// <param name="serializedSettings"></param>
49 /// <returns></returns>
50 /// <exception cref="System.Xml.XmlException"></exception>
51 public static InventoryItemBase Deserialize(byte[] serialization)
52 {
53 return Deserialize(m_asciiEncoding.GetString(serialization, 0, serialization.Length));
54 }
55
56 /// <summary>
57 /// Deserialize settings
58 /// </summary>
59 /// <param name="serializedSettings"></param>
60 /// <returns></returns>
61 /// <exception cref="System.Xml.XmlException"></exception>
62 public static InventoryItemBase Deserialize(string serialization)
63 {
64 InventoryItemBase item = new InventoryItemBase();
65
66 StringReader sr = new StringReader(serialization);
67 XmlTextReader reader = new XmlTextReader(sr);
68
69 reader.ReadStartElement("InventoryItem");
70 reader.ReadStartElement("Name");
71 item.Name = reader.ReadString();
72 reader.ReadEndElement();
73 reader.ReadStartElement("ID");
74 item.ID = UUID.Parse(reader.ReadString());
75 reader.ReadEndElement();
76 reader.ReadStartElement("InvType");
77 item.InvType = Convert.ToInt32(reader.ReadString());
78 reader.ReadEndElement();
79 reader.ReadStartElement("CreatorUUID");
80 item.CreatorId = reader.ReadString();
81 reader.ReadEndElement();
82 reader.ReadStartElement("CreationDate");
83 item.CreationDate = Convert.ToInt32(reader.ReadString());
84 reader.ReadEndElement();
85 reader.ReadStartElement("Owner");
86 item.Owner = UUID.Parse(reader.ReadString());
87 reader.ReadEndElement();
88 reader.ReadElementString("Description");
89 reader.ReadStartElement("AssetType");
90 item.AssetType = Convert.ToInt32(reader.ReadString());
91 reader.ReadEndElement();
92 reader.ReadStartElement("AssetID");
93 item.AssetID = UUID.Parse(reader.ReadString());
94 reader.ReadEndElement();
95 reader.ReadStartElement("SaleType");
96 item.SaleType = Convert.ToByte(reader.ReadString());
97 reader.ReadEndElement();
98 reader.ReadStartElement("SalePrice");
99 item.SalePrice = Convert.ToInt32(reader.ReadString());
100 reader.ReadEndElement();
101 reader.ReadStartElement("BasePermissions");
102 item.BasePermissions = Convert.ToUInt32(reader.ReadString());
103 reader.ReadEndElement();
104 reader.ReadStartElement("CurrentPermissions");
105 item.CurrentPermissions = Convert.ToUInt32(reader.ReadString());
106 reader.ReadEndElement();
107 reader.ReadStartElement("EveryOnePermssions");
108 item.EveryOnePermissions = Convert.ToUInt32(reader.ReadString());
109 reader.ReadEndElement();
110 reader.ReadStartElement("NextPermissions");
111 item.NextPermissions = Convert.ToUInt32(reader.ReadString());
112 reader.ReadEndElement();
113 reader.ReadStartElement("Flags");
114 item.Flags = Convert.ToUInt32(reader.ReadString());
115 reader.ReadEndElement();
116 reader.ReadStartElement("GroupID");
117 item.GroupID = UUID.Parse(reader.ReadString());
118 reader.ReadEndElement();
119 reader.ReadStartElement("GroupOwned");
120 item.GroupOwned = Convert.ToBoolean(reader.ReadString());
121 reader.ReadEndElement();
122
123 return item;
124 }
125
126 public static string Serialize(InventoryItemBase inventoryItem)
127 {
128 StringWriter sw = new StringWriter();
129 XmlTextWriter writer = new XmlTextWriter(sw);
130 writer.Formatting = Formatting.Indented;
131 writer.WriteStartDocument();
132
133 writer.WriteStartElement("InventoryItem");
134
135 writer.WriteStartElement("Name");
136 writer.WriteString(inventoryItem.Name);
137 writer.WriteEndElement();
138 writer.WriteStartElement("ID");
139 writer.WriteString(inventoryItem.ID.ToString());
140 writer.WriteEndElement();
141 writer.WriteStartElement("InvType");
142 writer.WriteString(inventoryItem.InvType.ToString());
143 writer.WriteEndElement();
144 writer.WriteStartElement("CreatorUUID");
145 writer.WriteString(inventoryItem.CreatorId);
146 writer.WriteEndElement();
147 writer.WriteStartElement("CreationDate");
148 writer.WriteString(inventoryItem.CreationDate.ToString());
149 writer.WriteEndElement();
150 writer.WriteStartElement("Owner");
151 writer.WriteString(inventoryItem.Owner.ToString());
152 writer.WriteEndElement();
153 writer.WriteStartElement("Description");
154 writer.WriteString(inventoryItem.Description);
155 writer.WriteEndElement();
156 writer.WriteStartElement("AssetType");
157 writer.WriteString(inventoryItem.AssetType.ToString());
158 writer.WriteEndElement();
159 writer.WriteStartElement("AssetID");
160 writer.WriteString(inventoryItem.AssetID.ToString());
161 writer.WriteEndElement();
162 writer.WriteStartElement("SaleType");
163 writer.WriteString(inventoryItem.SaleType.ToString());
164 writer.WriteEndElement();
165 writer.WriteStartElement("SalePrice");
166 writer.WriteString(inventoryItem.SalePrice.ToString());
167 writer.WriteEndElement();
168 writer.WriteStartElement("BasePermissions");
169 writer.WriteString(inventoryItem.BasePermissions.ToString());
170 writer.WriteEndElement();
171 writer.WriteStartElement("CurrentPermissions");
172 writer.WriteString(inventoryItem.CurrentPermissions.ToString());
173 writer.WriteEndElement();
174 writer.WriteStartElement("EveryOnePermssions");
175 writer.WriteString(inventoryItem.EveryOnePermissions.ToString());
176 writer.WriteEndElement();
177 writer.WriteStartElement("NextPermissions");
178 writer.WriteString(inventoryItem.NextPermissions.ToString());
179 writer.WriteEndElement();
180 writer.WriteStartElement("Flags");
181 writer.WriteString(inventoryItem.Flags.ToString());
182 writer.WriteEndElement();
183 writer.WriteStartElement("GroupID");
184 writer.WriteString(inventoryItem.GroupID.ToString());
185 writer.WriteEndElement();
186 writer.WriteStartElement("GroupOwned");
187 writer.WriteString(inventoryItem.GroupOwned.ToString());
188 writer.WriteEndElement();
189
190 writer.WriteEndElement();
191
192 writer.Close();
193 sw.Close();
194
195 return sw.ToString();
196 }
197 }
198}
diff --git a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
index 544d13d..6bf56c2 100644
--- a/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/UserProfileSerializer.cs
@@ -33,10 +33,8 @@ using OpenSim.Framework;
33namespace OpenSim.Framework.Serialization.External 33namespace OpenSim.Framework.Serialization.External
34{ 34{
35 /// <summary> 35 /// <summary>
36 /// Serialize and deserialize region settings for an archive file format. 36 /// Serialize and deserialize region settings as an external format.
37 /// </summary> 37 /// </summary>
38 /// We didn't use automatic .NET serialization since this is really
39 /// a file format rather than an object serialization.
40 public class UserProfileSerializer 38 public class UserProfileSerializer
41 { 39 {
42 public const int MAJOR_VERSION = 0; 40 public const int MAJOR_VERSION = 0;
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs
index e19160a..7f41de5 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs
+++ b/OpenSim/Grid/AssetInventoryServer/Plugins/InventoryArchivePlugin.cs
@@ -34,6 +34,7 @@ using System.Reflection;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Serialization; 36using OpenSim.Framework.Serialization;
37using OpenSim.Framework.Serialization.External;
37using OpenSim.Framework.Servers; 38using OpenSim.Framework.Servers;
38using log4net; 39using log4net;
39 40
@@ -178,7 +179,8 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
178 return rootFolder; 179 return rootFolder;
179 } 180 }
180 181
181 private static void WriteInventoryFolderToArchive(TarArchiveWriter archive, InventoryFolderWithChildren folder, string path) 182 private static void WriteInventoryFolderToArchive(
183 TarArchiveWriter archive, InventoryFolderWithChildren folder, string path)
182 { 184 {
183 path += string.Format("{0}{1}{2}/", folder.Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folder.ID); 185 path += string.Format("{0}{1}{2}/", folder.Name, ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, folder.ID);
184 archive.WriteDir(path); 186 archive.WriteDir(path);
@@ -199,72 +201,9 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins
199 private static void WriteInventoryItemToArchive(TarArchiveWriter archive, InventoryItemBase item, string path) 201 private static void WriteInventoryItemToArchive(TarArchiveWriter archive, InventoryItemBase item, string path)
200 { 202 {
201 string filename = string.Format("{0}{1}_{2}.xml", path, item.Name, item.ID); 203 string filename = string.Format("{0}{1}_{2}.xml", path, item.Name, item.ID);
202 204 string serialization = UserInventoryItemSerializer.Serialize(item);
203 StringWriter sw = new StringWriter(); 205 archive.WriteFile(filename, serialization);
204 XmlTextWriter writer = new XmlTextWriter(sw); 206
205 writer.Formatting = Formatting.Indented;
206
207 writer.WriteStartElement("InventoryItem");
208
209 writer.WriteStartElement("Name");
210 writer.WriteString(item.Name);
211 writer.WriteEndElement();
212 writer.WriteStartElement("ID");
213 writer.WriteString(item.ID.ToString());
214 writer.WriteEndElement();
215 writer.WriteStartElement("InvType");
216 writer.WriteString(item.InvType.ToString());
217 writer.WriteEndElement();
218 writer.WriteStartElement("CreatorUUID");
219 writer.WriteString(item.CreatorId);
220 writer.WriteEndElement();
221 writer.WriteStartElement("CreationDate");
222 writer.WriteString(item.CreationDate.ToString());
223 writer.WriteEndElement();
224 writer.WriteStartElement("Owner");
225 writer.WriteString(item.Owner.ToString());
226 writer.WriteEndElement();
227 writer.WriteStartElement("Description");
228 writer.WriteString(item.Description);
229 writer.WriteEndElement();
230 writer.WriteStartElement("AssetType");
231 writer.WriteString(item.AssetType.ToString());
232 writer.WriteEndElement();
233 writer.WriteStartElement("AssetID");
234 writer.WriteString(item.AssetID.ToString());
235 writer.WriteEndElement();
236 writer.WriteStartElement("SaleType");
237 writer.WriteString(item.SaleType.ToString());
238 writer.WriteEndElement();
239 writer.WriteStartElement("SalePrice");
240 writer.WriteString(item.SalePrice.ToString());
241 writer.WriteEndElement();
242 writer.WriteStartElement("BasePermissions");
243 writer.WriteString(item.BasePermissions.ToString());
244 writer.WriteEndElement();
245 writer.WriteStartElement("CurrentPermissions");
246 writer.WriteString(item.CurrentPermissions.ToString());
247 writer.WriteEndElement();
248 writer.WriteStartElement("EveryOnePermssions");
249 writer.WriteString(item.EveryOnePermissions.ToString());
250 writer.WriteEndElement();
251 writer.WriteStartElement("NextPermissions");
252 writer.WriteString(item.NextPermissions.ToString());
253 writer.WriteEndElement();
254 writer.WriteStartElement("Flags");
255 writer.WriteString(item.Flags.ToString());
256 writer.WriteEndElement();
257 writer.WriteStartElement("GroupID");
258 writer.WriteString(item.GroupID.ToString());
259 writer.WriteEndElement();
260 writer.WriteStartElement("GroupOwned");
261 writer.WriteString(item.GroupOwned.ToString());
262 writer.WriteEndElement();
263
264 writer.WriteEndElement();
265
266 archive.WriteFile(filename, sw.ToString());
267
268 //m_assetGatherer.GatherAssetUuids(item.AssetID, (AssetType) item.AssetType, assetUuids); 207 //m_assetGatherer.GatherAssetUuids(item.AssetID, (AssetType) item.AssetType, assetUuids);
269 } 208 }
270 } 209 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 8732e2e..2d6187f 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -36,6 +36,7 @@ using log4net;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Serialization; 38using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
40using OpenSim.Framework.Communications.Cache; 41using OpenSim.Framework.Communications.Cache;
41using OpenSim.Region.CoreModules.World.Archiver; 42using OpenSim.Region.CoreModules.World.Archiver;
@@ -78,71 +79,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
78 this.commsManager = commsManager; 79 this.commsManager = commsManager;
79 } 80 }
80 81
81 protected InventoryItemBase LoadInvItem(string contents)
82 {
83 InventoryItemBase item = new InventoryItemBase();
84 StringReader sr = new StringReader(contents);
85 XmlTextReader reader = new XmlTextReader(sr);
86
87 if (contents.Equals("")) return null;
88
89 reader.ReadStartElement("InventoryItem");
90 reader.ReadStartElement("Name");
91 item.Name = reader.ReadString();
92 reader.ReadEndElement();
93 reader.ReadStartElement("ID");
94 item.ID = UUID.Parse(reader.ReadString());
95 reader.ReadEndElement();
96 reader.ReadStartElement("InvType");
97 item.InvType = Convert.ToInt32(reader.ReadString());
98 reader.ReadEndElement();
99 reader.ReadStartElement("CreatorUUID");
100 item.CreatorId = reader.ReadString();
101 reader.ReadEndElement();
102 reader.ReadStartElement("CreationDate");
103 item.CreationDate = Convert.ToInt32(reader.ReadString());
104 reader.ReadEndElement();
105 reader.ReadStartElement("Owner");
106 item.Owner = UUID.Parse(reader.ReadString());
107 reader.ReadEndElement();
108 reader.ReadElementString("Description");
109 reader.ReadStartElement("AssetType");
110 item.AssetType = Convert.ToInt32(reader.ReadString());
111 reader.ReadEndElement();
112 reader.ReadStartElement("AssetID");
113 item.AssetID = UUID.Parse(reader.ReadString());
114 reader.ReadEndElement();
115 reader.ReadStartElement("SaleType");
116 item.SaleType = Convert.ToByte(reader.ReadString());
117 reader.ReadEndElement();
118 reader.ReadStartElement("SalePrice");
119 item.SalePrice = Convert.ToInt32(reader.ReadString());
120 reader.ReadEndElement();
121 reader.ReadStartElement("BasePermissions");
122 item.BasePermissions = Convert.ToUInt32(reader.ReadString());
123 reader.ReadEndElement();
124 reader.ReadStartElement("CurrentPermissions");
125 item.CurrentPermissions = Convert.ToUInt32(reader.ReadString());
126 reader.ReadEndElement();
127 reader.ReadStartElement("EveryOnePermssions");
128 item.EveryOnePermissions = Convert.ToUInt32(reader.ReadString());
129 reader.ReadEndElement();
130 reader.ReadStartElement("NextPermissions");
131 item.NextPermissions = Convert.ToUInt32(reader.ReadString());
132 reader.ReadEndElement();
133 reader.ReadStartElement("Flags");
134 item.Flags = Convert.ToUInt32(reader.ReadString());
135 reader.ReadEndElement();
136 reader.ReadStartElement("GroupID");
137 item.GroupID = UUID.Parse(reader.ReadString());
138 reader.ReadEndElement();
139 reader.ReadStartElement("GroupOwned");
140 item.GroupOwned = Convert.ToBoolean(reader.ReadString());
141 reader.ReadEndElement();
142
143 return item;
144 }
145
146 /// <summary> 82 /// <summary>
147 /// Execute the request 83 /// Execute the request
148 /// </summary> 84 /// </summary>
@@ -322,27 +258,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
322 258
323 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType) 259 if (TarArchiveReader.TarEntryType.TYPE_DIRECTORY != entryType)
324 { 260 {
325 InventoryItemBase item = LoadInvItem(m_asciiEncoding.GetString(data)); 261 InventoryItemBase item = UserInventoryItemSerializer.Deserialize(data);
262
263 // Don't use the item ID that's in the file
264 item.ID = UUID.Random();
326 265
327 if (item != null) 266 item.CreatorId = m_userInfo.UserProfile.ID.ToString();
328 { 267 item.Owner = m_userInfo.UserProfile.ID;
329 // Don't use the item ID that's in the file
330 item.ID = UUID.Random();
331
332 item.CreatorId = m_userInfo.UserProfile.ID.ToString();
333 item.Owner = m_userInfo.UserProfile.ID;
334 268
335 // Reset folder ID to the one in which we want to load it 269 // Reset folder ID to the one in which we want to load it
336 item.Folder = foundFolder.ID; 270 item.Folder = foundFolder.ID;
337 271
338 m_userInfo.AddItem(item); 272 m_userInfo.AddItem(item);
339 successfulItemRestores++; 273 successfulItemRestores++;
340 274
341 // If we're loading an item directly into the given destination folder then we need to record 275 // If we're loading an item directly into the given destination folder then we need to record
342 // it separately from any loaded root folders 276 // it separately from any loaded root folders
343 if (rootDestinationFolder == foundFolder) 277 if (rootDestinationFolder == foundFolder)
344 nodesLoaded.Add(item); 278 nodesLoaded.Add(item);
345 }
346 } 279 }
347 } 280 }
348 } 281 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index f302696..833b64a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -123,71 +123,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
123 123
124 protected void SaveInvItem(InventoryItemBase inventoryItem, string path) 124 protected void SaveInvItem(InventoryItemBase inventoryItem, string path)
125 { 125 {
126 string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID); 126 string filename = string.Format("{0}{1}_{2}.xml", path, inventoryItem.Name, inventoryItem.ID);
127 StringWriter sw = new StringWriter(); 127 string serialization = UserInventoryItemSerializer.Serialize(inventoryItem);
128 XmlTextWriter writer = new XmlTextWriter(sw); 128 m_archive.WriteFile(filename, serialization);
129 writer.Formatting = Formatting.Indented;
130
131 writer.WriteStartElement("InventoryItem");
132
133 writer.WriteStartElement("Name");
134 writer.WriteString(inventoryItem.Name);
135 writer.WriteEndElement();
136 writer.WriteStartElement("ID");
137 writer.WriteString(inventoryItem.ID.ToString());
138 writer.WriteEndElement();
139 writer.WriteStartElement("InvType");
140 writer.WriteString(inventoryItem.InvType.ToString());
141 writer.WriteEndElement();
142 writer.WriteStartElement("CreatorUUID");
143 writer.WriteString(inventoryItem.CreatorId);
144 writer.WriteEndElement();
145 writer.WriteStartElement("CreationDate");
146 writer.WriteString(inventoryItem.CreationDate.ToString());
147 writer.WriteEndElement();
148 writer.WriteStartElement("Owner");
149 writer.WriteString(inventoryItem.Owner.ToString());
150 writer.WriteEndElement();
151 writer.WriteStartElement("Description");
152 writer.WriteString(inventoryItem.Description);
153 writer.WriteEndElement();
154 writer.WriteStartElement("AssetType");
155 writer.WriteString(inventoryItem.AssetType.ToString());
156 writer.WriteEndElement();
157 writer.WriteStartElement("AssetID");
158 writer.WriteString(inventoryItem.AssetID.ToString());
159 writer.WriteEndElement();
160 writer.WriteStartElement("SaleType");
161 writer.WriteString(inventoryItem.SaleType.ToString());
162 writer.WriteEndElement();
163 writer.WriteStartElement("SalePrice");
164 writer.WriteString(inventoryItem.SalePrice.ToString());
165 writer.WriteEndElement();
166 writer.WriteStartElement("BasePermissions");
167 writer.WriteString(inventoryItem.BasePermissions.ToString());
168 writer.WriteEndElement();
169 writer.WriteStartElement("CurrentPermissions");
170 writer.WriteString(inventoryItem.CurrentPermissions.ToString());
171 writer.WriteEndElement();
172 writer.WriteStartElement("EveryOnePermssions");
173 writer.WriteString(inventoryItem.EveryOnePermissions.ToString());
174 writer.WriteEndElement();
175 writer.WriteStartElement("NextPermissions");
176 writer.WriteString(inventoryItem.NextPermissions.ToString());
177 writer.WriteEndElement();
178 writer.WriteStartElement("Flags");
179 writer.WriteString(inventoryItem.Flags.ToString());
180 writer.WriteEndElement();
181 writer.WriteStartElement("GroupID");
182 writer.WriteString(inventoryItem.GroupID.ToString());
183 writer.WriteEndElement();
184 writer.WriteStartElement("GroupOwned");
185 writer.WriteString(inventoryItem.GroupOwned.ToString());
186 writer.WriteEndElement();
187
188 writer.WriteEndElement();
189
190 m_archive.WriteFile(filename, sw.ToString());
191 129
192 UUID creatorId = inventoryItem.CreatorIdAsUuid; 130 UUID creatorId = inventoryItem.CreatorIdAsUuid;
193 131
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 8e6b461..e471160 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -188,5 +188,73 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
188 188
189 // TODO: Test presence of more files and contents of files. 189 // TODO: Test presence of more files and contents of files.
190 } 190 }
191
192 /*
193 /// <summary>
194 /// Test loading a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet).
195 /// </summary>
196 [Test]
197 public void TestLoadIarV0p1()
198 {
199 //log4net.Config.XmlConfigurator.Configure();
200
201 MemoryStream archiveWriteStream = new MemoryStream();
202 TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream);
203
204 string item1FileName = string.Format("{0}{1}/{2}", INVENTORY_PATH, "a", "b.lsl");
205 tar.WriteFile(item1FileName, item1.
206
207 string part1Name = "object1";
208 PrimitiveBaseShape shape = PrimitiveBaseShape.CreateCylinder();
209 Vector3 groupPosition = new Vector3(90, 80, 70);
210 Quaternion rotationOffset = new Quaternion(60, 70, 80, 90);
211 Vector3 offsetPosition = new Vector3(20, 25, 30);
212
213 SerialiserModule serialiserModule = new SerialiserModule();
214 ArchiverModule archiverModule = new ArchiverModule();
215
216 Scene scene = SceneSetupHelpers.SetupScene();
217 SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
218
219 SceneObjectPart part1
220 = new SceneObjectPart(
221 UUID.Zero, shape, groupPosition, rotationOffset, offsetPosition);
222 part1.Name = part1Name;
223 SceneObjectGroup object1 = new SceneObjectGroup(part1);
224 scene.AddNewSceneObject(object1, false);
225
226 string object1FileName = string.Format(
227 "{0}_{1:000}-{2:000}-{3:000}__{4}.xml",
228 part1Name,
229 Math.Round(groupPosition.X), Math.Round(groupPosition.Y), Math.Round(groupPosition.Z),
230 part1.UUID);
231 tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, object1.ToXmlString2());
232
233 tar.Close();
234
235 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
236
237 // SerialiserModule serialiserModule = new SerialiserModule();
238 // ArchiverModule archiverModule = new ArchiverModule();
239
240 // Scene scene = SceneSetupHelpers.SetupScene();
241 // SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule);
242
243 archiverModule.DearchiveRegion(archiveReadStream);
244
245 SceneObjectPart object1PartLoaded = scene.GetSceneObjectPart(part1Name);
246
247 Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded");
248 Assert.That(object1PartLoaded.Name, Is.EqualTo(part1Name), "object1 names not identical");
249 Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(groupPosition), "object1 group position not equal");
250 Assert.That(
251 object1PartLoaded.RotationOffset, Is.EqualTo(rotationOffset), "object1 rotation offset not equal");
252 Assert.That(
253 object1PartLoaded.OffsetPosition, Is.EqualTo(offsetPosition), "object1 offset position not equal");
254
255 // Temporary
256 Console.WriteLine("Successfully completed {0}", MethodBase.GetCurrentMethod());
257 }
258 */
191 } 259 }
192} 260}
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index a25b25f..323d62b 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -44,7 +44,7 @@ using OpenSim.Tests.Common.Setup;
44 44
45namespace OpenSim.Region.CoreModules.World.Archiver.Tests 45namespace OpenSim.Region.CoreModules.World.Archiver.Tests
46{ 46{
47 [TestFixture, LongRunning] 47 [TestFixture]
48 public class ArchiverTests 48 public class ArchiverTests
49 { 49 {
50 private Guid m_lastRequestId; 50 private Guid m_lastRequestId;