aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs104
-rw-r--r--OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs87
-rw-r--r--OpenSim/Framework/Serialization/External/OspResolver.cs (renamed from OpenSim/Framework/Communications/Osp/OspResolver.cs)2
-rw-r--r--OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs39
-rw-r--r--OpenSim/Framework/Util.cs20
-rw-r--r--OpenSim/Region/Application/OpenSim.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs11
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs28
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs54
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs5
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs42
-rw-r--r--OpenSim/Services/HypergridService/HGAssetService.cs44
-rw-r--r--OpenSim/Services/HypergridService/UserAccountCache.cs105
-rw-r--r--prebuild.xml59
17 files changed, 390 insertions, 263 deletions
diff --git a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs b/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs
deleted file mode 100644
index bcd1eee..0000000
--- a/OpenSim/Framework/Communications/Osp/OspInventoryWrapperPlugin.cs
+++ /dev/null
@@ -1,104 +0,0 @@
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 OpenSimulator 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.Collections.Generic;
29using OpenSim.Data;
30using OpenMetaverse;
31using OpenSim.Services.Interfaces;
32
33namespace OpenSim.Framework.Communications.Osp
34{
35 /// <summary>
36 /// Wrap other inventory data plugins so that we can perform OSP related post processing for items
37 /// </summary>
38 public class OspInventoryWrapperPlugin : IInventoryDataPlugin
39 {
40 protected IInventoryDataPlugin m_wrappedPlugin;
41 //protected CommunicationsManager m_commsManager;
42 protected IUserAccountService m_userAccountService;
43
44 public OspInventoryWrapperPlugin(IInventoryDataPlugin wrappedPlugin, IUserAccountService userService)
45 {
46 m_wrappedPlugin = wrappedPlugin;
47 m_userAccountService = userService;
48 }
49
50 public string Name { get { return "OspInventoryWrapperPlugin"; } }
51 public string Version { get { return "0.1"; } }
52 public void Initialise() {}
53 public void Initialise(string connect) {}
54 public void Dispose() {}
55
56 public InventoryItemBase getInventoryItem(UUID item)
57 {
58 return PostProcessItem(m_wrappedPlugin.getInventoryItem(item));
59 }
60
61 // XXX: Why on earth does this exist as it appears to duplicate getInventoryItem?
62 public InventoryItemBase queryInventoryItem(UUID item)
63 {
64 return PostProcessItem(m_wrappedPlugin.queryInventoryItem(item));
65 }
66
67 public List<InventoryItemBase> getInventoryInFolder(UUID folderID)
68 {
69 List<InventoryItemBase> items = m_wrappedPlugin.getInventoryInFolder(folderID);
70
71 foreach (InventoryItemBase item in items)
72 PostProcessItem(item);
73
74 return items;
75 }
76
77 public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
78 {
79 return m_wrappedPlugin.fetchActiveGestures(avatarID);
80
81 // Presuming that no post processing is needed here as gestures don't refer to creator information (?)
82 }
83
84 protected InventoryItemBase PostProcessItem(InventoryItemBase item)
85 {
86 item.CreatorIdAsUuid = OspResolver.ResolveOspa(item.CreatorId, m_userAccountService);
87 return item;
88 }
89
90 public List<InventoryFolderBase> getFolderHierarchy(UUID parentID) { return m_wrappedPlugin.getFolderHierarchy(parentID); }
91 public List<InventoryFolderBase> getUserRootFolders(UUID user) { return m_wrappedPlugin.getUserRootFolders(user); }
92 public InventoryFolderBase getUserRootFolder(UUID user) { return m_wrappedPlugin.getUserRootFolder(user); }
93 public List<InventoryFolderBase> getInventoryFolders(UUID parentID) { return m_wrappedPlugin.getInventoryFolders(parentID); }
94 public InventoryFolderBase getInventoryFolder(UUID folder) { return m_wrappedPlugin.getInventoryFolder(folder); }
95 public void addInventoryItem(InventoryItemBase item) { m_wrappedPlugin.addInventoryItem(item); }
96 public void updateInventoryItem(InventoryItemBase item) { m_wrappedPlugin.updateInventoryItem(item); }
97 public void deleteInventoryItem(UUID item) { m_wrappedPlugin.deleteInventoryItem(item); }
98 public InventoryFolderBase queryInventoryFolder(UUID folder) { return m_wrappedPlugin.queryInventoryFolder(folder); }
99 public void addInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.addInventoryFolder(folder); }
100 public void updateInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.updateInventoryFolder(folder); }
101 public void moveInventoryFolder(InventoryFolderBase folder) { m_wrappedPlugin.moveInventoryFolder(folder); }
102 public void deleteInventoryFolder(UUID folder) { m_wrappedPlugin.deleteInventoryFolder(folder); }
103 }
104}
diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
new file mode 100644
index 0000000..5c0630c
--- /dev/null
+++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
@@ -0,0 +1,87 @@
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 OpenSimulator 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 */
27using System;
28using System.Collections.Generic;
29using System.IO;
30using System.Xml;
31
32using OpenMetaverse;
33using OpenSim.Services.Interfaces;
34
35namespace OpenSim.Framework.Serialization.External
36{
37 public class ExternalRepresentationUtils
38 {
39 public static string RewriteSOP(string xml, string profileURL, IUserAccountService userService, UUID scopeID)
40 {
41 if (xml == string.Empty || profileURL == string.Empty || userService == null)
42 return xml;
43
44 XmlDocument doc = new XmlDocument();
45 doc.LoadXml(xml);
46 XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart");
47
48 foreach (XmlNode sop in sops)
49 {
50 UserAccount creator = null;
51 bool hasCreatorData = false;
52 XmlNodeList nodes = sop.ChildNodes;
53 foreach (XmlNode node in nodes)
54 {
55 if (node.Name == "CreatorID")
56 {
57 UUID uuid = UUID.Zero;
58 UUID.TryParse(node.InnerText, out uuid);
59 creator = userService.GetUserAccount(scopeID, uuid);
60 }
61 if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
62 hasCreatorData = true;
63
64 //if (node.Name == "OwnerID")
65 //{
66 // UserAccount owner = GetUser(node.InnerText);
67 // if (owner != null)
68 // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName;
69 //}
70 }
71 if (!hasCreatorData && creator != null)
72 {
73 XmlElement creatorData = doc.CreateElement("CreatorData");
74 creatorData.InnerText = profileURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName;
75 sop.AppendChild(creatorData);
76 }
77 }
78
79 using (StringWriter wr = new StringWriter())
80 {
81 doc.Save(wr);
82 return wr.ToString();
83 }
84
85 }
86 }
87}
diff --git a/OpenSim/Framework/Communications/Osp/OspResolver.cs b/OpenSim/Framework/Serialization/External/OspResolver.cs
index 24ea64d..53c35ff 100644
--- a/OpenSim/Framework/Communications/Osp/OspResolver.cs
+++ b/OpenSim/Framework/Serialization/External/OspResolver.cs
@@ -32,7 +32,7 @@ using OpenMetaverse;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
34 34
35namespace OpenSim.Framework.Communications.Osp 35namespace OpenSim.Framework.Serialization
36{ 36{
37 /// <summary> 37 /// <summary>
38 /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for 38 /// Resolves OpenSim Profile Anchors (OSPA). An OSPA is a string used to provide information for
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
index df9af32..d5e84c7 100644
--- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
+++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs
@@ -35,6 +35,7 @@ using System.Xml;
35using log4net; 35using log4net;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Services.Interfaces;
38 39
39namespace OpenSim.Framework.Serialization.External 40namespace OpenSim.Framework.Serialization.External
40{ 41{
@@ -56,6 +57,8 @@ namespace OpenSim.Framework.Serialization.External
56 m_InventoryItemXmlProcessors.Add("ID", ProcessID); 57 m_InventoryItemXmlProcessors.Add("ID", ProcessID);
57 m_InventoryItemXmlProcessors.Add("InvType", ProcessInvType); 58 m_InventoryItemXmlProcessors.Add("InvType", ProcessInvType);
58 m_InventoryItemXmlProcessors.Add("CreatorUUID", ProcessCreatorUUID); 59 m_InventoryItemXmlProcessors.Add("CreatorUUID", ProcessCreatorUUID);
60 m_InventoryItemXmlProcessors.Add("CreatorID", ProcessCreatorID);
61 m_InventoryItemXmlProcessors.Add("CreatorData", ProcessCreatorData);
59 m_InventoryItemXmlProcessors.Add("CreationDate", ProcessCreationDate); 62 m_InventoryItemXmlProcessors.Add("CreationDate", ProcessCreationDate);
60 m_InventoryItemXmlProcessors.Add("Owner", ProcessOwner); 63 m_InventoryItemXmlProcessors.Add("Owner", ProcessOwner);
61 m_InventoryItemXmlProcessors.Add("Description", ProcessDescription); 64 m_InventoryItemXmlProcessors.Add("Description", ProcessDescription);
@@ -94,6 +97,12 @@ namespace OpenSim.Framework.Serialization.External
94 item.CreatorId = reader.ReadElementContentAsString("CreatorUUID", String.Empty); 97 item.CreatorId = reader.ReadElementContentAsString("CreatorUUID", String.Empty);
95 } 98 }
96 99
100 private static void ProcessCreatorID(InventoryItemBase item, XmlTextReader reader)
101 {
102 // when it exists, this overrides the previous
103 item.CreatorId = reader.ReadElementContentAsString("CreatorID", String.Empty);
104 }
105
97 private static void ProcessCreationDate(InventoryItemBase item, XmlTextReader reader) 106 private static void ProcessCreationDate(InventoryItemBase item, XmlTextReader reader)
98 { 107 {
99 item.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty); 108 item.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty);
@@ -161,12 +170,12 @@ namespace OpenSim.Framework.Serialization.External
161 170
162 private static void ProcessGroupOwned(InventoryItemBase item, XmlTextReader reader) 171 private static void ProcessGroupOwned(InventoryItemBase item, XmlTextReader reader)
163 { 172 {
164 //item.GroupOwned = reader.ReadElementContentAsBoolean("GroupOwned", String.Empty); 173 item.GroupOwned = Util.ReadBoolean(reader);
165 // We don't do that, because ReadElementContentAsBoolean assumes lower case strings, 174 }
166 // and they may not be lower case 175
167 reader.ReadStartElement(); // GroupOwned 176 private static void ProcessCreatorData(InventoryItemBase item, XmlTextReader reader)
168 item.GroupOwned = Boolean.Parse(reader.ReadContentAsString().ToLower()); 177 {
169 reader.ReadEndElement(); 178 item.CreatorData = reader.ReadElementContentAsString("CreatorData", String.Empty);
170 } 179 }
171 180
172 #endregion 181 #endregion
@@ -231,7 +240,7 @@ namespace OpenSim.Framework.Serialization.External
231 240
232 } 241 }
233 242
234 public static string Serialize(InventoryItemBase inventoryItem) 243 public static string Serialize(InventoryItemBase inventoryItem, Dictionary<string, object> options, IUserAccountService userAccountService)
235 { 244 {
236 StringWriter sw = new StringWriter(); 245 StringWriter sw = new StringWriter();
237 XmlTextWriter writer = new XmlTextWriter(sw); 246 XmlTextWriter writer = new XmlTextWriter(sw);
@@ -250,7 +259,7 @@ namespace OpenSim.Framework.Serialization.External
250 writer.WriteString(inventoryItem.InvType.ToString()); 259 writer.WriteString(inventoryItem.InvType.ToString());
251 writer.WriteEndElement(); 260 writer.WriteEndElement();
252 writer.WriteStartElement("CreatorUUID"); 261 writer.WriteStartElement("CreatorUUID");
253 writer.WriteString(inventoryItem.CreatorId); 262 writer.WriteString(OspResolver.MakeOspa(inventoryItem.CreatorIdAsUuid, userAccountService));
254 writer.WriteEndElement(); 263 writer.WriteEndElement();
255 writer.WriteStartElement("CreationDate"); 264 writer.WriteStartElement("CreationDate");
256 writer.WriteString(inventoryItem.CreationDate.ToString()); 265 writer.WriteString(inventoryItem.CreationDate.ToString());
@@ -294,6 +303,20 @@ namespace OpenSim.Framework.Serialization.External
294 writer.WriteStartElement("GroupOwned"); 303 writer.WriteStartElement("GroupOwned");
295 writer.WriteString(inventoryItem.GroupOwned.ToString()); 304 writer.WriteString(inventoryItem.GroupOwned.ToString());
296 writer.WriteEndElement(); 305 writer.WriteEndElement();
306 if (inventoryItem.CreatorData != null && inventoryItem.CreatorData != string.Empty)
307 writer.WriteElementString("CreatorData", inventoryItem.CreatorData);
308 else if (options.ContainsKey("profile"))
309 {
310 if (userAccountService != null)
311 {
312 UserAccount account = userAccountService.GetUserAccount(UUID.Zero, inventoryItem.CreatorIdAsUuid);
313 if (account != null)
314 {
315 writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + inventoryItem.CreatorIdAsUuid + ";" + account.FirstName + " " + account.LastName);
316 }
317 writer.WriteElementString("CreatorID", inventoryItem.CreatorId);
318 }
319 }
297 320
298 writer.WriteEndElement(); 321 writer.WriteEndElement();
299 322
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 101ece4..8d1671a 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -1558,6 +1558,16 @@ namespace OpenSim.Framework
1558 return string.Empty; 1558 return string.Empty;
1559 } 1559 }
1560 1560
1561 #region Xml Serialization Utilities
1562 public static bool ReadBoolean(XmlTextReader reader)
1563 {
1564 reader.ReadStartElement();
1565 bool result = Boolean.Parse(reader.ReadContentAsString().ToLower());
1566 reader.ReadEndElement();
1567
1568 return result;
1569 }
1570
1561 public static UUID ReadUUID(XmlTextReader reader, string name) 1571 public static UUID ReadUUID(XmlTextReader reader, string name)
1562 { 1572 {
1563 UUID id; 1573 UUID id;
@@ -1619,5 +1629,15 @@ namespace OpenSim.Framework
1619 return quat; 1629 return quat;
1620 } 1630 }
1621 1631
1632 public static T ReadEnum<T>(XmlTextReader reader, string name)
1633 {
1634 string value = reader.ReadElementContentAsString(name, String.Empty);
1635 // !!!!! to deal with flags without commas
1636 if (value.Contains(" ") && !value.Contains(","))
1637 value = value.Replace(" ", ", ");
1638
1639 return (T)Enum.Parse(typeof(T), value); ;
1640 }
1641 #endregion
1622 } 1642 }
1623} 1643}
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 6127c2d..ae2d836 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -265,10 +265,10 @@ namespace OpenSim
265 LoadOar); 265 LoadOar);
266 266
267 m_console.Commands.AddCommand("region", false, "save oar", 267 m_console.Commands.AddCommand("region", false, "save oar",
268 "save oar [-v|--version=N] [-p|--profile=url] [<OAR path>]", 268 "save oar [-v|--version=<N>] [-p|--profile=<url>] [<OAR path>]",
269 "Save a region's data to an OAR archive.", 269 "Save a region's data to an OAR archive.",
270 "-v|--version=N generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine 270 "-v|--version=<N> generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine
271 + "-p|--profile=url adds the url of the profile service to the saved user information" + Environment.NewLine 271 + "-p|--profile=<url> adds the url of the profile service to the saved user information" + Environment.NewLine
272 + "The OAR path must be a filesystem path." 272 + "The OAR path must be a filesystem path."
273 + " If this is not given then the oar is saved to region.oar in the current directory.", 273 + " If this is not given then the oar is saved to region.oar in the current directory.",
274 SaveOar); 274 SaveOar);
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 046b05f..870ead2 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -37,12 +37,11 @@ using System.Xml.Linq;
37using log4net; 37using log4net;
38using OpenMetaverse; 38using OpenMetaverse;
39using OpenSim.Framework; 39using OpenSim.Framework;
40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Osp;
42using OpenSim.Framework.Serialization; 40using OpenSim.Framework.Serialization;
43using OpenSim.Framework.Serialization.External; 41using OpenSim.Framework.Serialization.External;
44using OpenSim.Region.CoreModules.World.Archiver; 42using OpenSim.Region.CoreModules.World.Archiver;
45using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Interfaces;
46using OpenSim.Services.Interfaces; 45using OpenSim.Services.Interfaces;
47 46
48namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver 47namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
@@ -398,16 +397,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
398 // Don't use the item ID that's in the file 397 // Don't use the item ID that's in the file
399 item.ID = UUID.Random(); 398 item.ID = UUID.Random();
400 399
401 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); 400 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService);
402 if (UUID.Zero != ospResolvedId) 401 if (UUID.Zero != ospResolvedId) // The user exists in this grid
403 { 402 {
404 item.CreatorIdAsUuid = ospResolvedId; 403 item.CreatorIdAsUuid = ospResolvedId;
405 404
406 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the 405 // XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the
407 // database). Instead, replace with the UUID that we found. 406 // database). Instead, replace with the UUID that we found.
408 item.CreatorId = ospResolvedId.ToString(); 407 item.CreatorId = ospResolvedId.ToString();
408
409 item.CreatorData = string.Empty;
409 } 410 }
410 else 411 else if (item.CreatorData == null || item.CreatorData == String.Empty)
411 { 412 {
412 item.CreatorIdAsUuid = m_userInfo.PrincipalID; 413 item.CreatorIdAsUuid = m_userInfo.PrincipalID;
413 } 414 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index d81703a..cab341d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -36,8 +36,6 @@ using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Serialization; 37using OpenSim.Framework.Serialization;
38using OpenSim.Framework.Serialization.External; 38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Communications.Osp;
41using OpenSim.Region.CoreModules.World.Archiver; 39using OpenSim.Region.CoreModules.World.Archiver;
42using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
43using OpenSim.Services.Interfaces; 41using OpenSim.Services.Interfaces;
@@ -139,20 +137,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
139 m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException); 137 m_id, succeeded, m_userInfo, m_invPath, m_saveStream, reportedException);
140 } 138 }
141 139
142 protected void SaveInvItem(InventoryItemBase inventoryItem, string path) 140 protected void SaveInvItem(InventoryItemBase inventoryItem, string path, Dictionary<string, object> options, IUserAccountService userAccountService)
143 { 141 {
144 string filename = path + CreateArchiveItemName(inventoryItem); 142 string filename = path + CreateArchiveItemName(inventoryItem);
145 143
146 // Record the creator of this item for user record purposes (which might go away soon) 144 // Record the creator of this item for user record purposes (which might go away soon)
147 m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; 145 m_userUuids[inventoryItem.CreatorIdAsUuid] = 1;
148 146
149 InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone(); 147 string serialization = UserInventoryItemSerializer.Serialize(inventoryItem, options, userAccountService);
150 saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.UserAccountService);
151
152 string serialization = UserInventoryItemSerializer.Serialize(saveItem);
153 m_archiveWriter.WriteFile(filename, serialization); 148 m_archiveWriter.WriteFile(filename, serialization);
154 149
155 m_assetGatherer.GatherAssetUuids(saveItem.AssetID, (AssetType)saveItem.AssetType, m_assetUuids); 150 m_assetGatherer.GatherAssetUuids(inventoryItem.AssetID, (AssetType)inventoryItem.AssetType, m_assetUuids);
156 } 151 }
157 152
158 /// <summary> 153 /// <summary>
@@ -161,7 +156,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
161 /// <param name="inventoryFolder">The inventory folder to save</param> 156 /// <param name="inventoryFolder">The inventory folder to save</param>
162 /// <param name="path">The path to which the folder should be saved</param> 157 /// <param name="path">The path to which the folder should be saved</param>
163 /// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param> 158 /// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param>
164 protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself) 159 protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself, Dictionary<string, object> options, IUserAccountService userAccountService)
165 { 160 {
166 if (saveThisFolderItself) 161 if (saveThisFolderItself)
167 { 162 {
@@ -176,19 +171,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
176 171
177 foreach (InventoryFolderBase childFolder in contents.Folders) 172 foreach (InventoryFolderBase childFolder in contents.Folders)
178 { 173 {
179 SaveInvFolder(childFolder, path, true); 174 SaveInvFolder(childFolder, path, true, options, userAccountService);
180 } 175 }
181 176
182 foreach (InventoryItemBase item in contents.Items) 177 foreach (InventoryItemBase item in contents.Items)
183 { 178 {
184 SaveInvItem(item, path); 179 SaveInvItem(item, path, options, userAccountService);
185 } 180 }
186 } 181 }
187 182
188 /// <summary> 183 /// <summary>
189 /// Execute the inventory write request 184 /// Execute the inventory write request
190 /// </summary> 185 /// </summary>
191 public void Execute() 186 public void Execute(Dictionary<string, object> options, IUserAccountService userAccountService)
192 { 187 {
193 try 188 try
194 { 189 {
@@ -266,7 +261,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
266 m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath); 261 m_invPath == String.Empty ? InventoryFolderImpl.PATH_DELIMITER : m_invPath);
267 262
268 //recurse through all dirs getting dirs and files 263 //recurse through all dirs getting dirs and files
269 SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly); 264 SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !saveFolderContentsOnly, options, userAccountService);
270 } 265 }
271 else if (inventoryItem != null) 266 else if (inventoryItem != null)
272 { 267 {
@@ -274,14 +269,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
274 "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}", 269 "[INVENTORY ARCHIVER]: Found item {0} {1} at {2}",
275 inventoryItem.Name, inventoryItem.ID, m_invPath); 270 inventoryItem.Name, inventoryItem.ID, m_invPath);
276 271
277 SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH); 272 SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH, options, userAccountService);
278 } 273 }
279 274
280 // Don't put all this profile information into the archive right now. 275 // Don't put all this profile information into the archive right now.
281 //SaveUsers(); 276 //SaveUsers();
282 277
283 new AssetsRequest( 278 new AssetsRequest(
284 new AssetsArchiver(m_archiveWriter), m_assetUuids, m_scene.AssetService, ReceivedAllAssets).Execute(); 279 new AssetsArchiver(m_archiveWriter),
280 m_assetUuids, m_scene.AssetService,
281 m_scene.UserAccountService, m_scene.RegionInfo.ScopeID,
282 options, ReceivedAllAssets).Execute();
285 } 283 }
286 catch (Exception) 284 catch (Exception)
287 { 285 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 2eaca49..421ea30 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -75,6 +75,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
75 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); 75 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
76 private Scene m_aScene; 76 private Scene m_aScene;
77 77
78 private IUserAccountService m_UserAccountService;
79 protected IUserAccountService UserAccountService
80 {
81 get
82 {
83 if (m_UserAccountService == null)
84 // What a strange thing to do...
85 foreach (Scene s in m_scenes.Values)
86 {
87 m_UserAccountService = s.RequestModuleInterface<IUserAccountService>();
88 break;
89 }
90
91 return m_UserAccountService;
92 }
93 }
94
95
78 public InventoryArchiverModule() {} 96 public InventoryArchiverModule() {}
79 97
80 public InventoryArchiverModule(bool disablePresenceChecks) 98 public InventoryArchiverModule(bool disablePresenceChecks)
@@ -106,11 +124,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
106 124
107 scene.AddCommand( 125 scene.AddCommand(
108 this, "save iar", 126 this, "save iar",
109 "save iar <first> <last> <inventory path> <password> [<IAR path>]", 127 "save iar <first> <last> <inventory path> <password> [--p|-profile=<url>] [<IAR path>]",
110 "Save user inventory archive (IAR).", 128 "Save user inventory archive (IAR).",
111 "<first> is the user's first name." + Environment.NewLine 129 "<first> is the user's first name." + Environment.NewLine
112 + "<last> is the user's last name." + Environment.NewLine 130 + "<last> is the user's last name." + Environment.NewLine
113 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine 131 + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine
132 + "-p|--profile=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
114 + "<IAR path> is the filesystem path at which to save the IAR." 133 + "<IAR path> is the filesystem path at which to save the IAR."
115 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), 134 + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME),
116 HandleSaveInvConsoleCommand); 135 HandleSaveInvConsoleCommand);
@@ -157,7 +176,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
157 { 176 {
158 try 177 try
159 { 178 {
160 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); 179 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(options, UserAccountService);
161 } 180 }
162 catch (EntryPointNotFoundException e) 181 catch (EntryPointNotFoundException e)
163 { 182 {
@@ -197,7 +216,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
197 { 216 {
198 try 217 try
199 { 218 {
200 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); 219 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(options, UserAccountService);
201 } 220 }
202 catch (EntryPointNotFoundException e) 221 catch (EntryPointNotFoundException e)
203 { 222 {
@@ -368,10 +387,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
368 protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams) 387 protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams)
369 { 388 {
370 Guid id = Guid.NewGuid(); 389 Guid id = Guid.NewGuid();
371 390
391 Dictionary<string, object> options = new Dictionary<string, object>();
392
393 OptionSet ops = new OptionSet();
394 //ops.Add("v|version=", delegate(string v) { options["version"] = v; });
395 ops.Add("p|profile=", delegate(string v) { options["profile"] = v; });
396
397 List<string> mainParams = ops.Parse(cmdparams);
398
372 try 399 try
373 { 400 {
374 if (cmdparams.Length < 6) 401 if (mainParams.Count < 6)
375 { 402 {
376 m_log.Error( 403 m_log.Error(
377 "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]"); 404 "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]");
@@ -379,18 +406,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
379 } 406 }
380 407
381 m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME."); 408 m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME.");
382 409 if (options.ContainsKey("profile"))
383 string firstName = cmdparams[2]; 410 m_log.WarnFormat("[INVENTORY ARCHIVER]: Please be aware that inventory archives with creator information are not compatible with OpenSim 0.7.0.2 and earlier. Do not use the -profile option if you want to produce a compatible IAR");
384 string lastName = cmdparams[3]; 411
385 string invPath = cmdparams[4]; 412 string firstName = mainParams[2];
386 string pass = cmdparams[5]; 413 string lastName = mainParams[3];
387 string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME); 414 string invPath = mainParams[4];
415 string pass = mainParams[5];
416 string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME);
388 417
389 m_log.InfoFormat( 418 m_log.InfoFormat(
390 "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", 419 "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}",
391 savePath, invPath, firstName, lastName); 420 savePath, invPath, firstName, lastName);
392 421
393 ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, new Dictionary<string, object>()); 422 ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options);
394 } 423 }
395 catch (InventoryArchiverException e) 424 catch (InventoryArchiverException e)
396 { 425 {
@@ -518,5 +547,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
518 547
519 return false; 548 return false;
520 } 549 }
550
521 } 551 }
522} 552}
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index 938886b2..1e39c39 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -38,7 +38,6 @@ using OpenSim.Framework;
38using OpenSim.Framework.Serialization; 38using OpenSim.Framework.Serialization;
39using OpenSim.Framework.Serialization.External; 39using OpenSim.Framework.Serialization.External;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Framework.Communications.Osp;
42using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; 41using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
43using OpenSim.Region.CoreModules.World.Serialiser; 42using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
@@ -103,7 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
103 102
104 string item1FileName 103 string item1FileName
105 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); 104 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
106 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); 105 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), null));
107 tar.Close(); 106 tar.Close();
108 m_iarStream = new MemoryStream(archiveWriteStream.ToArray()); 107 m_iarStream = new MemoryStream(archiveWriteStream.ToArray());
109 } 108 }
@@ -551,7 +550,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
551 550
552 string item1FileName 551 string item1FileName
553 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); 552 = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName);
554 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); 553 tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string,object>(), null));
555 tar.Close(); 554 tar.Close();
556 555
557 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); 556 MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray());
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 1ff1a47..1ebccd1 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -799,9 +799,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
799 protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID) 799 protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID)
800 { 800 {
801 IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>(); 801 IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>();
802 InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, agentID); 802 InventoryItemBase item = new InventoryItemBase(itemID, agentID);
803 assetRequestItem = invService.GetItem(assetRequestItem); 803 item = invService.GetItem(item);
804 return assetRequestItem; 804
805 if (item.CreatorData != null && item.CreatorData != string.Empty)
806 UserManagementModule.AddUser(item.CreatorIdAsUuid, item.CreatorData);
807
808 return item;
805 } 809 }
806 810
807 #endregion 811 #endregion
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
index b987b5a..0699407 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestPreparation.cs
@@ -190,7 +190,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
190 190
191 new AssetsRequest( 191 new AssetsRequest(
192 new AssetsArchiver(archiveWriter), assetUuids, 192 new AssetsArchiver(archiveWriter), assetUuids,
193 m_scene.AssetService, awre.ReceivedAllAssets).Execute(); 193 m_scene.AssetService, m_scene.UserAccountService,
194 m_scene.RegionInfo.ScopeID, options, awre.ReceivedAllAssets).Execute();
194 } 195 }
195 catch (Exception) 196 catch (Exception)
196 { 197 {
@@ -238,10 +239,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
238 } 239 }
239 240
240 m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion); 241 m_log.InfoFormat("[ARCHIVER]: Creating version {0}.{1} OAR", majorVersion, minorVersion);
241 if (majorVersion == 1) 242 //if (majorVersion == 1)
242 { 243 //{
243 m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR"); 244 // m_log.WarnFormat("[ARCHIVER]: Please be aware that version 1.0 OARs are not compatible with OpenSim 0.7.0.2 and earlier. Please use the --version=0 option if you want to produce a compatible OAR");
244 } 245 //}
245 246
246 StringWriter sw = new StringWriter(); 247 StringWriter sw = new StringWriter();
247 XmlTextWriter xtw = new XmlTextWriter(sw); 248 XmlTextWriter xtw = new XmlTextWriter(sw);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index d4a09b4..5da1656 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -34,6 +34,7 @@ using log4net;
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.Services.Interfaces; 38using OpenSim.Services.Interfaces;
38 39
39namespace OpenSim.Region.CoreModules.World.Archiver 40namespace OpenSim.Region.CoreModules.World.Archiver
@@ -100,17 +101,26 @@ namespace OpenSim.Region.CoreModules.World.Archiver
100 /// Asset service used to request the assets 101 /// Asset service used to request the assets
101 /// </value> 102 /// </value>
102 protected IAssetService m_assetService; 103 protected IAssetService m_assetService;
104 protected IUserAccountService m_userAccountService;
105 protected UUID m_scopeID; // the grid ID
103 106
104 protected AssetsArchiver m_assetsArchiver; 107 protected AssetsArchiver m_assetsArchiver;
105 108
109 protected Dictionary<string, object> m_options;
110
106 protected internal AssetsRequest( 111 protected internal AssetsRequest(
107 AssetsArchiver assetsArchiver, IDictionary<UUID, AssetType> uuids, 112 AssetsArchiver assetsArchiver, IDictionary<UUID, AssetType> uuids,
108 IAssetService assetService, AssetsRequestCallback assetsRequestCallback) 113 IAssetService assetService, IUserAccountService userService,
114 UUID scope, Dictionary<string, object> options,
115 AssetsRequestCallback assetsRequestCallback)
109 { 116 {
110 m_assetsArchiver = assetsArchiver; 117 m_assetsArchiver = assetsArchiver;
111 m_uuids = uuids; 118 m_uuids = uuids;
112 m_assetsRequestCallback = assetsRequestCallback; 119 m_assetsRequestCallback = assetsRequestCallback;
113 m_assetService = assetService; 120 m_assetService = assetService;
121 m_userAccountService = userService;
122 m_scopeID = scope;
123 m_options = options;
114 m_repliesRequired = uuids.Count; 124 m_repliesRequired = uuids.Count;
115 125
116 m_requestCallbackTimer = new System.Timers.Timer(TIMEOUT); 126 m_requestCallbackTimer = new System.Timers.Timer(TIMEOUT);
@@ -241,7 +251,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
241 { 251 {
242// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id); 252// m_log.DebugFormat("[ARCHIVER]: Writing asset {0}", id);
243 m_foundAssetUuids.Add(asset.FullID); 253 m_foundAssetUuids.Add(asset.FullID);
244 m_assetsArchiver.WriteAsset(asset); 254
255 m_assetsArchiver.WriteAsset(PostProcess(asset));
245 } 256 }
246 else 257 else
247 { 258 {
@@ -288,5 +299,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
288 "[ARCHIVER]: Terminating archive creation since asset requster callback failed with {0}", e); 299 "[ARCHIVER]: Terminating archive creation since asset requster callback failed with {0}", e);
289 } 300 }
290 } 301 }
302
303 protected AssetBase PostProcess(AssetBase asset)
304 {
305 if (asset.Type == (sbyte)AssetType.Object && asset.Data != null && m_options.ContainsKey("profile"))
306 {
307 //m_log.DebugFormat("[ARCHIVER]: Rewriting object data for {0}", asset.ID);
308 string xml = ExternalRepresentationUtils.RewriteSOP(Utils.BytesToString(asset.Data), m_options["profile"].ToString(), m_userAccountService, m_scopeID);
309 asset.Data = Utils.StringToBytes(xml);
310 }
311 return asset;
312 }
291 } 313 }
292} 314}
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index da25e80..6c9826f 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -409,7 +409,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
409 #region SOPXmlProcessors 409 #region SOPXmlProcessors
410 private static void ProcessAllowedDrop(SceneObjectPart obj, XmlTextReader reader) 410 private static void ProcessAllowedDrop(SceneObjectPart obj, XmlTextReader reader)
411 { 411 {
412 obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty); 412 obj.AllowedDrop = Util.ReadBoolean(reader);
413 } 413 }
414 414
415 private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader) 415 private static void ProcessCreatorID(SceneObjectPart obj, XmlTextReader reader)
@@ -459,7 +459,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
459 459
460 private static void ProcessPassTouches(SceneObjectPart obj, XmlTextReader reader) 460 private static void ProcessPassTouches(SceneObjectPart obj, XmlTextReader reader)
461 { 461 {
462 obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty); 462 obj.PassTouches = Util.ReadBoolean(reader);
463 } 463 }
464 464
465 private static void ProcessRegionHandle(SceneObjectPart obj, XmlTextReader reader) 465 private static void ProcessRegionHandle(SceneObjectPart obj, XmlTextReader reader)
@@ -654,11 +654,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
654 654
655 private static void ProcessFlags(SceneObjectPart obj, XmlTextReader reader) 655 private static void ProcessFlags(SceneObjectPart obj, XmlTextReader reader)
656 { 656 {
657 string value = reader.ReadElementContentAsString("Flags", String.Empty); 657 obj.Flags = Util.ReadEnum<PrimFlags>(reader, "Flags");
658 // !!!!! to deal with flags without commas
659 if (value.Contains(" ") && !value.Contains(","))
660 value = value.Replace(" ", ", ");
661 obj.Flags = (PrimFlags)Enum.Parse(typeof(PrimFlags), value);
662 } 658 }
663 659
664 private static void ProcessCollisionSound(SceneObjectPart obj, XmlTextReader reader) 660 private static void ProcessCollisionSound(SceneObjectPart obj, XmlTextReader reader)
@@ -808,7 +804,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
808 804
809 private static void ProcessTIOwnerChanged(TaskInventoryItem item, XmlTextReader reader) 805 private static void ProcessTIOwnerChanged(TaskInventoryItem item, XmlTextReader reader)
810 { 806 {
811 item.OwnerChanged = reader.ReadElementContentAsBoolean("OwnerChanged", String.Empty); 807 item.OwnerChanged = Util.ReadBoolean(reader);
812 } 808 }
813 809
814 #endregion 810 #endregion
@@ -932,20 +928,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
932 928
933 private static void ProcessShpProfileShape(PrimitiveBaseShape shp, XmlTextReader reader) 929 private static void ProcessShpProfileShape(PrimitiveBaseShape shp, XmlTextReader reader)
934 { 930 {
935 string value = reader.ReadElementContentAsString("ProfileShape", String.Empty); 931 shp.ProfileShape = Util.ReadEnum<ProfileShape>(reader, "ProfileShape");
936 // !!!!! to deal with flags without commas
937 if (value.Contains(" ") && !value.Contains(","))
938 value = value.Replace(" ", ", ");
939 shp.ProfileShape = (ProfileShape)Enum.Parse(typeof(ProfileShape), value);
940 } 932 }
941 933
942 private static void ProcessShpHollowShape(PrimitiveBaseShape shp, XmlTextReader reader) 934 private static void ProcessShpHollowShape(PrimitiveBaseShape shp, XmlTextReader reader)
943 { 935 {
944 string value = reader.ReadElementContentAsString("HollowShape", String.Empty); 936 shp.HollowShape = Util.ReadEnum<HollowShape>(reader, "HollowShape");
945 // !!!!! to deal with flags without commas
946 if (value.Contains(" ") && !value.Contains(","))
947 value = value.Replace(" ", ", ");
948 shp.HollowShape = (HollowShape)Enum.Parse(typeof(HollowShape), value);
949 } 937 }
950 938
951 private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlTextReader reader) 939 private static void ProcessShpSculptTexture(PrimitiveBaseShape shp, XmlTextReader reader)
@@ -1045,17 +1033,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1045 1033
1046 private static void ProcessShpFlexiEntry(PrimitiveBaseShape shp, XmlTextReader reader) 1034 private static void ProcessShpFlexiEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1047 { 1035 {
1048 shp.FlexiEntry = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty); 1036 shp.FlexiEntry = Util.ReadBoolean(reader);
1049 } 1037 }
1050 1038
1051 private static void ProcessShpLightEntry(PrimitiveBaseShape shp, XmlTextReader reader) 1039 private static void ProcessShpLightEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1052 { 1040 {
1053 shp.LightEntry = reader.ReadElementContentAsBoolean("LightEntry", String.Empty); 1041 shp.LightEntry = Util.ReadBoolean(reader);
1054 } 1042 }
1055 1043
1056 private static void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlTextReader reader) 1044 private static void ProcessShpSculptEntry(PrimitiveBaseShape shp, XmlTextReader reader)
1057 { 1045 {
1058 shp.SculptEntry = reader.ReadElementContentAsBoolean("SculptEntry", String.Empty); 1046 shp.SculptEntry = Util.ReadBoolean(reader);
1059 } 1047 }
1060 1048
1061 private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlTextReader reader) 1049 private static void ProcessShpMedia(PrimitiveBaseShape shp, XmlTextReader reader)
@@ -1220,16 +1208,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1220 1208
1221 static void WriteFlags(XmlTextWriter writer, string name, string flagsStr, Dictionary<string, object> options) 1209 static void WriteFlags(XmlTextWriter writer, string name, string flagsStr, Dictionary<string, object> options)
1222 { 1210 {
1223 // Older versions of serialization can't cope with commas 1211 // Older versions of serialization can't cope with commas, so we eliminate the commas
1224 if (options.ContainsKey("version")) 1212 writer.WriteElementString(name, flagsStr.Replace(",", ""));
1225 {
1226 float version = 0.5F;
1227 float.TryParse(options["version"].ToString(), out version);
1228 if (version < 0.5)
1229 flagsStr = flagsStr.Replace(",", "");
1230 }
1231
1232 writer.WriteElementString(name, flagsStr);
1233 } 1213 }
1234 1214
1235 static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary<string, object> options, Scene scene) 1215 static void WriteTaskInventory(XmlTextWriter writer, TaskInventoryDictionary tinv, Dictionary<string, object> options, Scene scene)
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs
index 9b098a0..584ab6f 100644
--- a/OpenSim/Services/HypergridService/HGAssetService.cs
+++ b/OpenSim/Services/HypergridService/HGAssetService.cs
@@ -35,6 +35,7 @@ using log4net;
35using OpenMetaverse; 35using OpenMetaverse;
36 36
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Serialization.External;
38using OpenSim.Server.Base; 39using OpenSim.Server.Base;
39using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
40using OpenSim.Services.AssetService; 41using OpenSim.Services.AssetService;
@@ -131,48 +132,7 @@ namespace OpenSim.Services.HypergridService
131 protected byte[] AdjustIdentifiers(byte[] data) 132 protected byte[] AdjustIdentifiers(byte[] data)
132 { 133 {
133 string xml = Utils.BytesToString(data); 134 string xml = Utils.BytesToString(data);
134 return Utils.StringToBytes(RewriteSOP(xml)); 135 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero));
135 }
136
137 protected string RewriteSOP(string xml)
138 {
139 XmlDocument doc = new XmlDocument();
140 doc.LoadXml(xml);
141 XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart");
142
143 foreach (XmlNode sop in sops)
144 {
145 UserAccount creator = null;
146 bool hasCreatorData = false;
147 XmlNodeList nodes = sop.ChildNodes;
148 foreach (XmlNode node in nodes)
149 {
150 if (node.Name == "CreatorID")
151 creator = m_Cache.GetUser(node.InnerText);
152 if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
153 hasCreatorData = true;
154
155 //if (node.Name == "OwnerID")
156 //{
157 // UserAccount owner = GetUser(node.InnerText);
158 // if (owner != null)
159 // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName;
160 //}
161 }
162 if (!hasCreatorData && creator != null)
163 {
164 XmlElement creatorData = doc.CreateElement("CreatorData");
165 creatorData.InnerText = m_ProfileServiceURL + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName;
166 sop.AppendChild(creatorData);
167 }
168 }
169
170 using (StringWriter wr = new StringWriter())
171 {
172 doc.Save(wr);
173 return wr.ToString();
174 }
175
176 } 136 }
177 137
178 } 138 }
diff --git a/OpenSim/Services/HypergridService/UserAccountCache.cs b/OpenSim/Services/HypergridService/UserAccountCache.cs
new file mode 100644
index 0000000..3e9aea1
--- /dev/null
+++ b/OpenSim/Services/HypergridService/UserAccountCache.cs
@@ -0,0 +1,105 @@
1using System;
2using System.Collections.Generic;
3using System.Reflection;
4
5using log4net;
6using OpenMetaverse;
7
8using OpenSim.Services.Interfaces;
9
10namespace OpenSim.Services.HypergridService
11{
12 public class UserAccountCache : IUserAccountService
13 {
14 private const double CACHE_EXPIRATION_SECONDS = 120000.0; // 33 hours!
15
16 private static readonly ILog m_log =
17 LogManager.GetLogger(
18 MethodBase.GetCurrentMethod().DeclaringType);
19 private ExpiringCache<UUID, UserAccount> m_UUIDCache;
20
21 private IUserAccountService m_UserAccountService;
22
23 private static UserAccountCache m_Singleton;
24
25 public static UserAccountCache CreateUserAccountCache(IUserAccountService u)
26 {
27 if (m_Singleton == null)
28 m_Singleton = new UserAccountCache(u);
29
30 return m_Singleton;
31 }
32
33 private UserAccountCache(IUserAccountService u)
34 {
35 m_UUIDCache = new ExpiringCache<UUID, UserAccount>();
36 m_UserAccountService = u;
37 }
38
39 public void Cache(UUID userID, UserAccount account)
40 {
41 // Cache even null accounts
42 m_UUIDCache.AddOrUpdate(userID, account, CACHE_EXPIRATION_SECONDS);
43
44 //m_log.DebugFormat("[USER CACHE]: cached user {0}", userID);
45 }
46
47 public UserAccount Get(UUID userID, out bool inCache)
48 {
49 UserAccount account = null;
50 inCache = false;
51 if (m_UUIDCache.TryGetValue(userID, out account))
52 {
53 //m_log.DebugFormat("[USER CACHE]: Account {0} {1} found in cache", account.FirstName, account.LastName);
54 inCache = true;
55 return account;
56 }
57
58 return null;
59 }
60
61 public UserAccount GetUser(string id)
62 {
63 UUID uuid = UUID.Zero;
64 UUID.TryParse(id, out uuid);
65 bool inCache = false;
66 UserAccount account = Get(uuid, out inCache);
67 if (!inCache)
68 {
69 account = m_UserAccountService.GetUserAccount(UUID.Zero, uuid);
70 Cache(uuid, account);
71 }
72
73 return account;
74 }
75
76 #region IUserAccountService
77 public UserAccount GetUserAccount(UUID scopeID, UUID userID)
78 {
79 return GetUser(userID.ToString());
80 }
81
82 public UserAccount GetUserAccount(UUID scopeID, string FirstName, string LastName)
83 {
84 return null;
85 }
86
87 public UserAccount GetUserAccount(UUID scopeID, string Email)
88 {
89 return null;
90 }
91
92 public List<UserAccount> GetUserAccounts(UUID scopeID, string query)
93 {
94 return null;
95 }
96
97 public bool StoreUserAccount(UserAccount data)
98 {
99 return false;
100 }
101 #endregion
102
103 }
104
105}
diff --git a/prebuild.xml b/prebuild.xml
index 6f24bfc..9f2ef43 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -175,6 +175,34 @@
175 </Files> 175 </Files>
176 </Project> 176 </Project>
177 177
178 <Project frameworkVersion="v3_5" name="OpenSim.Services.Interfaces" path="OpenSim/Services/Interfaces" type="Library">
179 <Configuration name="Debug">
180 <Options>
181 <OutputPath>../../../bin/</OutputPath>
182 </Options>
183 </Configuration>
184 <Configuration name="Release">
185 <Options>
186 <OutputPath>../../../bin/</OutputPath>
187 </Options>
188 </Configuration>
189
190 <ReferencePath>../../../bin/</ReferencePath>
191 <Reference name="System"/>
192 <Reference name="OpenMetaverseTypes" path="../../../bin/"/>
193 <Reference name="OpenMetaverse" path="../../../bin/"/>
194 <Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
195 <Reference name="OpenSim.Framework"/>
196 <Reference name="OpenSim.Framework.Console"/>
197 <Reference name="OpenSim.Framework.Servers.HttpServer"/>
198 <Reference name="Nini" path="../../../bin/"/>
199 <Reference name="log4net" path="../../../bin/"/>
200
201 <Files>
202 <Match pattern="*.cs" recurse="true"/>
203 </Files>
204 </Project>
205
178 <Project frameworkVersion="v3_5" name="OpenSim.Framework.Serialization" path="OpenSim/Framework/Serialization" type="Library"> 206 <Project frameworkVersion="v3_5" name="OpenSim.Framework.Serialization" path="OpenSim/Framework/Serialization" type="Library">
179 <Configuration name="Debug"> 207 <Configuration name="Debug">
180 <Options> 208 <Options>
@@ -194,6 +222,7 @@
194 <Reference name="OpenMetaverse" path="../../../bin/"/> 222 <Reference name="OpenMetaverse" path="../../../bin/"/>
195 <Reference name="OpenMetaverseTypes" path="../../../bin/"/> 223 <Reference name="OpenMetaverseTypes" path="../../../bin/"/>
196 <Reference name="OpenSim.Framework"/> 224 <Reference name="OpenSim.Framework"/>
225 <Reference name="OpenSim.Services.Interfaces"/>
197 226
198 <Files> 227 <Files>
199 <Match pattern="*.cs" recurse="true"> 228 <Match pattern="*.cs" recurse="true">
@@ -631,35 +660,6 @@
631 </Files> 660 </Files>
632 </Project> 661 </Project>
633 662
634 <Project frameworkVersion="v3_5" name="OpenSim.Services.Interfaces" path="OpenSim/Services/Interfaces" type="Library">
635 <Configuration name="Debug">
636 <Options>
637 <OutputPath>../../../bin/</OutputPath>
638 </Options>
639 </Configuration>
640 <Configuration name="Release">
641 <Options>
642 <OutputPath>../../../bin/</OutputPath>
643 </Options>
644 </Configuration>
645
646 <ReferencePath>../../../bin/</ReferencePath>
647 <Reference name="System"/>
648 <Reference name="OpenMetaverseTypes" path="../../../bin/"/>
649 <Reference name="OpenMetaverse" path="../../../bin/"/>
650 <Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
651 <Reference name="OpenSim.Framework"/>
652 <Reference name="OpenSim.Framework.Console"/>
653 <Reference name="OpenSim.Framework.Servers.HttpServer"/>
654 <Reference name="Nini" path="../../../bin/"/>
655 <Reference name="log4net" path="../../../bin/"/>
656
657 <Files>
658 <Match pattern="*.cs" recurse="true"/>
659 </Files>
660 </Project>
661
662
663 <Project frameworkVersion="v3_5" name="OpenSim.Framework.Capabilities" path="OpenSim/Framework/Capabilities" type="Library"> 663 <Project frameworkVersion="v3_5" name="OpenSim.Framework.Capabilities" path="OpenSim/Framework/Capabilities" type="Library">
664 <Configuration name="Debug"> 664 <Configuration name="Debug">
665 <Options> 665 <Options>
@@ -1253,6 +1253,7 @@
1253 <Reference name="OpenMetaverseTypes" path="../../../bin/"/> 1253 <Reference name="OpenMetaverseTypes" path="../../../bin/"/>
1254 <Reference name="OpenMetaverse" path="../../../bin/"/> 1254 <Reference name="OpenMetaverse" path="../../../bin/"/>
1255 <Reference name="OpenSim.Framework"/> 1255 <Reference name="OpenSim.Framework"/>
1256 <Reference name="OpenSim.Framework.Serialization"/>
1256 <Reference name="OpenSim.Framework.Console"/> 1257 <Reference name="OpenSim.Framework.Console"/>
1257 <Reference name="OpenSim.Framework.Servers.HttpServer"/> 1258 <Reference name="OpenSim.Framework.Servers.HttpServer"/>
1258 <Reference name="OpenSim.Services.Interfaces"/> 1259 <Reference name="OpenSim.Services.Interfaces"/>