diff options
Diffstat (limited to 'OpenSim')
28 files changed, 998 insertions, 368 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 | |||
28 | using System.Collections.Generic; | ||
29 | using OpenSim.Data; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Services.Interfaces; | ||
32 | |||
33 | namespace 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 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.IO; | ||
30 | using System.Xml; | ||
31 | |||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Services.Interfaces; | ||
34 | |||
35 | namespace 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..7e3dd1b 100644 --- a/OpenSim/Framework/Communications/Osp/OspResolver.cs +++ b/OpenSim/Framework/Serialization/External/OspResolver.cs | |||
@@ -32,7 +32,7 @@ using OpenMetaverse; | |||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Services.Interfaces; | 33 | using OpenSim.Services.Interfaces; |
34 | 34 | ||
35 | namespace OpenSim.Framework.Communications.Osp | 35 | namespace 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 |
@@ -57,6 +57,12 @@ namespace OpenSim.Framework.Communications.Osp | |||
57 | /// <returns>The OSPA. Null if a user with the given UUID could not be found.</returns> | 57 | /// <returns>The OSPA. Null if a user with the given UUID could not be found.</returns> |
58 | public static string MakeOspa(UUID userId, IUserAccountService userService) | 58 | public static string MakeOspa(UUID userId, IUserAccountService userService) |
59 | { | 59 | { |
60 | if (userService == null) | ||
61 | { | ||
62 | m_log.Warn("[OSP RESOLVER]: UserService is null"); | ||
63 | return userId.ToString(); | ||
64 | } | ||
65 | |||
60 | UserAccount account = userService.GetUserAccount(UUID.Zero, userId); | 66 | UserAccount account = userService.GetUserAccount(UUID.Zero, userId); |
61 | if (account != null) | 67 | if (account != null) |
62 | return MakeOspa(account.FirstName, account.LastName); | 68 | return MakeOspa(account.FirstName, account.LastName); |
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs index 862cc72..d5e84c7 100644 --- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs | |||
@@ -26,11 +26,16 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.IO; | 30 | using System.IO; |
31 | using System.Reflection; | ||
30 | using System.Text; | 32 | using System.Text; |
31 | using System.Xml; | 33 | using System.Xml; |
34 | |||
35 | using log4net; | ||
32 | using OpenMetaverse; | 36 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Services.Interfaces; | ||
34 | 39 | ||
35 | namespace OpenSim.Framework.Serialization.External | 40 | namespace OpenSim.Framework.Serialization.External |
36 | { | 41 | { |
@@ -40,6 +45,141 @@ namespace OpenSim.Framework.Serialization.External | |||
40 | /// XXX: Please do not use yet. | 45 | /// XXX: Please do not use yet. |
41 | public class UserInventoryItemSerializer | 46 | public class UserInventoryItemSerializer |
42 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private delegate void InventoryItemXmlProcessor(InventoryItemBase item, XmlTextReader reader); | ||
51 | private static Dictionary<string, InventoryItemXmlProcessor> m_InventoryItemXmlProcessors = new Dictionary<string, InventoryItemXmlProcessor>(); | ||
52 | |||
53 | #region InventoryItemBase Processor initialization | ||
54 | static UserInventoryItemSerializer() | ||
55 | { | ||
56 | m_InventoryItemXmlProcessors.Add("Name", ProcessName); | ||
57 | m_InventoryItemXmlProcessors.Add("ID", ProcessID); | ||
58 | m_InventoryItemXmlProcessors.Add("InvType", ProcessInvType); | ||
59 | m_InventoryItemXmlProcessors.Add("CreatorUUID", ProcessCreatorUUID); | ||
60 | m_InventoryItemXmlProcessors.Add("CreatorID", ProcessCreatorID); | ||
61 | m_InventoryItemXmlProcessors.Add("CreatorData", ProcessCreatorData); | ||
62 | m_InventoryItemXmlProcessors.Add("CreationDate", ProcessCreationDate); | ||
63 | m_InventoryItemXmlProcessors.Add("Owner", ProcessOwner); | ||
64 | m_InventoryItemXmlProcessors.Add("Description", ProcessDescription); | ||
65 | m_InventoryItemXmlProcessors.Add("AssetType", ProcessAssetType); | ||
66 | m_InventoryItemXmlProcessors.Add("AssetID", ProcessAssetID); | ||
67 | m_InventoryItemXmlProcessors.Add("SaleType", ProcessSaleType); | ||
68 | m_InventoryItemXmlProcessors.Add("SalePrice", ProcessSalePrice); | ||
69 | m_InventoryItemXmlProcessors.Add("BasePermissions", ProcessBasePermissions); | ||
70 | m_InventoryItemXmlProcessors.Add("CurrentPermissions", ProcessCurrentPermissions); | ||
71 | m_InventoryItemXmlProcessors.Add("EveryOnePermissions", ProcessEveryOnePermissions); | ||
72 | m_InventoryItemXmlProcessors.Add("NextPermissions", ProcessNextPermissions); | ||
73 | m_InventoryItemXmlProcessors.Add("Flags", ProcessFlags); | ||
74 | m_InventoryItemXmlProcessors.Add("GroupID", ProcessGroupID); | ||
75 | m_InventoryItemXmlProcessors.Add("GroupOwned", ProcessGroupOwned); | ||
76 | } | ||
77 | #endregion | ||
78 | |||
79 | #region InventoryItemBase Processors | ||
80 | private static void ProcessName(InventoryItemBase item, XmlTextReader reader) | ||
81 | { | ||
82 | item.Name = reader.ReadElementContentAsString("Name", String.Empty); | ||
83 | } | ||
84 | |||
85 | private static void ProcessID(InventoryItemBase item, XmlTextReader reader) | ||
86 | { | ||
87 | item.ID = Util.ReadUUID(reader, "ID"); | ||
88 | } | ||
89 | |||
90 | private static void ProcessInvType(InventoryItemBase item, XmlTextReader reader) | ||
91 | { | ||
92 | item.InvType = reader.ReadElementContentAsInt("InvType", String.Empty); | ||
93 | } | ||
94 | |||
95 | private static void ProcessCreatorUUID(InventoryItemBase item, XmlTextReader reader) | ||
96 | { | ||
97 | item.CreatorId = reader.ReadElementContentAsString("CreatorUUID", String.Empty); | ||
98 | } | ||
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 | |||
106 | private static void ProcessCreationDate(InventoryItemBase item, XmlTextReader reader) | ||
107 | { | ||
108 | item.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty); | ||
109 | } | ||
110 | |||
111 | private static void ProcessOwner(InventoryItemBase item, XmlTextReader reader) | ||
112 | { | ||
113 | item.Owner = Util.ReadUUID(reader, "Owner"); | ||
114 | } | ||
115 | |||
116 | private static void ProcessDescription(InventoryItemBase item, XmlTextReader reader) | ||
117 | { | ||
118 | item.Description = reader.ReadElementContentAsString("Description", String.Empty); | ||
119 | } | ||
120 | |||
121 | private static void ProcessAssetType(InventoryItemBase item, XmlTextReader reader) | ||
122 | { | ||
123 | item.AssetType = reader.ReadElementContentAsInt("AssetType", String.Empty); | ||
124 | } | ||
125 | |||
126 | private static void ProcessAssetID(InventoryItemBase item, XmlTextReader reader) | ||
127 | { | ||
128 | item.AssetID = Util.ReadUUID(reader, "AssetID"); | ||
129 | } | ||
130 | |||
131 | private static void ProcessSaleType(InventoryItemBase item, XmlTextReader reader) | ||
132 | { | ||
133 | item.SaleType = (byte)reader.ReadElementContentAsInt("SaleType", String.Empty); | ||
134 | } | ||
135 | |||
136 | private static void ProcessSalePrice(InventoryItemBase item, XmlTextReader reader) | ||
137 | { | ||
138 | item.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty); | ||
139 | } | ||
140 | |||
141 | private static void ProcessBasePermissions(InventoryItemBase item, XmlTextReader reader) | ||
142 | { | ||
143 | item.BasePermissions = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty); | ||
144 | } | ||
145 | |||
146 | private static void ProcessCurrentPermissions(InventoryItemBase item, XmlTextReader reader) | ||
147 | { | ||
148 | item.CurrentPermissions = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty); | ||
149 | } | ||
150 | |||
151 | private static void ProcessEveryOnePermissions(InventoryItemBase item, XmlTextReader reader) | ||
152 | { | ||
153 | item.EveryOnePermissions = (uint)reader.ReadElementContentAsInt("EveryOnePermissions", String.Empty); | ||
154 | } | ||
155 | |||
156 | private static void ProcessNextPermissions(InventoryItemBase item, XmlTextReader reader) | ||
157 | { | ||
158 | item.NextPermissions = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty); | ||
159 | } | ||
160 | |||
161 | private static void ProcessFlags(InventoryItemBase item, XmlTextReader reader) | ||
162 | { | ||
163 | item.Flags = (uint)reader.ReadElementContentAsInt("Flags", String.Empty); | ||
164 | } | ||
165 | |||
166 | private static void ProcessGroupID(InventoryItemBase item, XmlTextReader reader) | ||
167 | { | ||
168 | item.GroupID = Util.ReadUUID(reader, "GroupID"); | ||
169 | } | ||
170 | |||
171 | private static void ProcessGroupOwned(InventoryItemBase item, XmlTextReader reader) | ||
172 | { | ||
173 | item.GroupOwned = Util.ReadBoolean(reader); | ||
174 | } | ||
175 | |||
176 | private static void ProcessCreatorData(InventoryItemBase item, XmlTextReader reader) | ||
177 | { | ||
178 | item.CreatorData = reader.ReadElementContentAsString("CreatorData", String.Empty); | ||
179 | } | ||
180 | |||
181 | #endregion | ||
182 | |||
43 | /// <summary> | 183 | /// <summary> |
44 | /// Deserialize item | 184 | /// Deserialize item |
45 | /// </summary> | 185 | /// </summary> |
@@ -60,40 +200,47 @@ namespace OpenSim.Framework.Serialization.External | |||
60 | public static InventoryItemBase Deserialize(string serialization) | 200 | public static InventoryItemBase Deserialize(string serialization) |
61 | { | 201 | { |
62 | InventoryItemBase item = new InventoryItemBase(); | 202 | InventoryItemBase item = new InventoryItemBase(); |
63 | 203 | ||
64 | StringReader sr = new StringReader(serialization); | 204 | using (XmlTextReader reader = new XmlTextReader(new StringReader(serialization))) |
65 | XmlTextReader xtr = new XmlTextReader(sr); | 205 | { |
66 | 206 | reader.ReadStartElement("InventoryItem"); | |
67 | xtr.ReadStartElement("InventoryItem"); | 207 | |
68 | 208 | string nodeName = string.Empty; | |
69 | item.Name = xtr.ReadElementString("Name"); | 209 | while (reader.NodeType != XmlNodeType.EndElement) |
70 | item.ID = UUID.Parse( xtr.ReadElementString("ID")); | 210 | { |
71 | item.InvType = Convert.ToInt32( xtr.ReadElementString("InvType")); | 211 | nodeName = reader.Name; |
72 | item.CreatorId = xtr.ReadElementString("CreatorUUID"); | 212 | InventoryItemXmlProcessor p = null; |
73 | item.CreationDate = Convert.ToInt32( xtr.ReadElementString("CreationDate")); | 213 | if (m_InventoryItemXmlProcessors.TryGetValue(reader.Name, out p)) |
74 | item.Owner = UUID.Parse( xtr.ReadElementString("Owner")); | 214 | { |
75 | item.Description = xtr.ReadElementString("Description"); | 215 | //m_log.DebugFormat("[XXX] Processing: {0}", reader.Name); |
76 | item.AssetType = Convert.ToInt32( xtr.ReadElementString("AssetType")); | 216 | try |
77 | item.AssetID = UUID.Parse( xtr.ReadElementString("AssetID")); | 217 | { |
78 | item.SaleType = Convert.ToByte( xtr.ReadElementString("SaleType")); | 218 | p(item, reader); |
79 | item.SalePrice = Convert.ToInt32( xtr.ReadElementString("SalePrice")); | 219 | } |
80 | item.BasePermissions = Convert.ToUInt32( xtr.ReadElementString("BasePermissions")); | 220 | catch (Exception e) |
81 | item.CurrentPermissions = Convert.ToUInt32( xtr.ReadElementString("CurrentPermissions")); | 221 | { |
82 | item.EveryOnePermissions = Convert.ToUInt32( xtr.ReadElementString("EveryOnePermissions")); | 222 | m_log.DebugFormat("[InventoryItemSerializer]: exception while parsing {0}: {1}", nodeName, e); |
83 | item.NextPermissions = Convert.ToUInt32( xtr.ReadElementString("NextPermissions")); | 223 | if (reader.NodeType == XmlNodeType.EndElement) |
84 | item.Flags = Convert.ToUInt32( xtr.ReadElementString("Flags")); | 224 | reader.Read(); |
85 | item.GroupID = UUID.Parse( xtr.ReadElementString("GroupID")); | 225 | } |
86 | item.GroupOwned = Convert.ToBoolean(xtr.ReadElementString("GroupOwned")); | 226 | } |
87 | 227 | else | |
88 | xtr.ReadEndElement(); | 228 | { |
89 | 229 | // m_log.DebugFormat("[InventoryItemSerializer]: caught unknown element {0}", nodeName); | |
90 | xtr.Close(); | 230 | reader.ReadOuterXml(); // ignore |
91 | sr.Close(); | 231 | } |
92 | 232 | ||
233 | } | ||
234 | |||
235 | reader.ReadEndElement(); // InventoryItem | ||
236 | } | ||
237 | |||
238 | //m_log.DebugFormat("[XXX]: parsed InventoryItemBase {0} - {1}", obj.Name, obj.UUID); | ||
93 | return item; | 239 | return item; |
240 | |||
94 | } | 241 | } |
95 | 242 | ||
96 | public static string Serialize(InventoryItemBase inventoryItem) | 243 | public static string Serialize(InventoryItemBase inventoryItem, Dictionary<string, object> options, IUserAccountService userAccountService) |
97 | { | 244 | { |
98 | StringWriter sw = new StringWriter(); | 245 | StringWriter sw = new StringWriter(); |
99 | XmlTextWriter writer = new XmlTextWriter(sw); | 246 | XmlTextWriter writer = new XmlTextWriter(sw); |
@@ -112,7 +259,7 @@ namespace OpenSim.Framework.Serialization.External | |||
112 | writer.WriteString(inventoryItem.InvType.ToString()); | 259 | writer.WriteString(inventoryItem.InvType.ToString()); |
113 | writer.WriteEndElement(); | 260 | writer.WriteEndElement(); |
114 | writer.WriteStartElement("CreatorUUID"); | 261 | writer.WriteStartElement("CreatorUUID"); |
115 | writer.WriteString(inventoryItem.CreatorId); | 262 | writer.WriteString(OspResolver.MakeOspa(inventoryItem.CreatorIdAsUuid, userAccountService)); |
116 | writer.WriteEndElement(); | 263 | writer.WriteEndElement(); |
117 | writer.WriteStartElement("CreationDate"); | 264 | writer.WriteStartElement("CreationDate"); |
118 | writer.WriteString(inventoryItem.CreationDate.ToString()); | 265 | writer.WriteString(inventoryItem.CreationDate.ToString()); |
@@ -156,6 +303,20 @@ namespace OpenSim.Framework.Serialization.External | |||
156 | writer.WriteStartElement("GroupOwned"); | 303 | writer.WriteStartElement("GroupOwned"); |
157 | writer.WriteString(inventoryItem.GroupOwned.ToString()); | 304 | writer.WriteString(inventoryItem.GroupOwned.ToString()); |
158 | 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 | } | ||
159 | 320 | ||
160 | writer.WriteEndElement(); | 321 | writer.WriteEndElement(); |
161 | 322 | ||
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index e8f8e01..8d1671a 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1558,5 +1558,86 @@ 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 | |||
1571 | public static UUID ReadUUID(XmlTextReader reader, string name) | ||
1572 | { | ||
1573 | UUID id; | ||
1574 | string idStr; | ||
1575 | |||
1576 | reader.ReadStartElement(name); | ||
1577 | |||
1578 | if (reader.Name == "Guid") | ||
1579 | idStr = reader.ReadElementString("Guid"); | ||
1580 | else if (reader.Name == "UUID") | ||
1581 | idStr = reader.ReadElementString("UUID"); | ||
1582 | else // no leading tag | ||
1583 | idStr = reader.ReadContentAsString(); | ||
1584 | UUID.TryParse(idStr, out id); | ||
1585 | reader.ReadEndElement(); | ||
1586 | |||
1587 | return id; | ||
1588 | } | ||
1589 | |||
1590 | public static Vector3 ReadVector(XmlTextReader reader, string name) | ||
1591 | { | ||
1592 | Vector3 vec; | ||
1593 | |||
1594 | reader.ReadStartElement(name); | ||
1595 | vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x | ||
1596 | vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y | ||
1597 | vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z | ||
1598 | reader.ReadEndElement(); | ||
1599 | |||
1600 | return vec; | ||
1601 | } | ||
1602 | |||
1603 | public static Quaternion ReadQuaternion(XmlTextReader reader, string name) | ||
1604 | { | ||
1605 | Quaternion quat = new Quaternion(); | ||
1606 | |||
1607 | reader.ReadStartElement(name); | ||
1608 | while (reader.NodeType != XmlNodeType.EndElement) | ||
1609 | { | ||
1610 | switch (reader.Name.ToLower()) | ||
1611 | { | ||
1612 | case "x": | ||
1613 | quat.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1614 | break; | ||
1615 | case "y": | ||
1616 | quat.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1617 | break; | ||
1618 | case "z": | ||
1619 | quat.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1620 | break; | ||
1621 | case "w": | ||
1622 | quat.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1623 | break; | ||
1624 | } | ||
1625 | } | ||
1626 | |||
1627 | reader.ReadEndElement(); | ||
1628 | |||
1629 | return quat; | ||
1630 | } | ||
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 | ||
1561 | } | 1642 | } |
1562 | } | 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..acf2c3e 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; | |||
37 | using log4net; | 37 | using log4net; |
38 | using OpenMetaverse; | 38 | using OpenMetaverse; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Communications; | ||
41 | using OpenSim.Framework.Communications.Osp; | ||
42 | using OpenSim.Framework.Serialization; | 40 | using OpenSim.Framework.Serialization; |
43 | using OpenSim.Framework.Serialization.External; | 41 | using OpenSim.Framework.Serialization.External; |
44 | using OpenSim.Region.CoreModules.World.Archiver; | 42 | using OpenSim.Region.CoreModules.World.Archiver; |
45 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using OpenSim.Region.Framework.Interfaces; | ||
46 | using OpenSim.Services.Interfaces; | 45 | using OpenSim.Services.Interfaces; |
47 | 46 | ||
48 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | 47 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver |
@@ -398,20 +397,22 @@ 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 | } |
414 | 415 | ||
415 | item.Owner = m_userInfo.PrincipalID; | 416 | item.Owner = m_userInfo.PrincipalID; |
416 | 417 | ||
417 | // Reset folder ID to the one in which we want to load it | 418 | // Reset folder ID to the one in which we want to load it |
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; | |||
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Serialization; | 37 | using OpenSim.Framework.Serialization; |
38 | using OpenSim.Framework.Serialization.External; | 38 | using OpenSim.Framework.Serialization.External; |
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Framework.Communications.Osp; | ||
41 | using OpenSim.Region.CoreModules.World.Archiver; | 39 | using OpenSim.Region.CoreModules.World.Archiver; |
42 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
43 | using OpenSim.Services.Interfaces; | 41 | using 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..b33c2b1 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 | { |
@@ -235,14 +254,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
235 | if (m_scenes.Count > 0) | 254 | if (m_scenes.Count > 0) |
236 | { | 255 | { |
237 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); | 256 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); |
238 | 257 | ||
239 | if (userInfo != null) | 258 | if (userInfo != null) |
240 | { | 259 | { |
241 | if (CheckPresence(userInfo.PrincipalID)) | 260 | if (CheckPresence(userInfo.PrincipalID)) |
242 | { | 261 | { |
262 | |||
243 | InventoryArchiveReadRequest request; | 263 | InventoryArchiveReadRequest request; |
244 | bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false); | 264 | bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false); |
245 | 265 | ||
246 | try | 266 | try |
247 | { | 267 | { |
248 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream, merge); | 268 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream, merge); |
@@ -256,7 +276,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
256 | 276 | ||
257 | return false; | 277 | return false; |
258 | } | 278 | } |
259 | 279 | ||
260 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 280 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
261 | 281 | ||
262 | return true; | 282 | return true; |
@@ -268,6 +288,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
268 | userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID); | 288 | userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID); |
269 | } | 289 | } |
270 | } | 290 | } |
291 | else | ||
292 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: User {0} {1} not found", | ||
293 | firstName, lastName); | ||
271 | } | 294 | } |
272 | 295 | ||
273 | return false; | 296 | return false; |
@@ -368,10 +391,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
368 | protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams) | 391 | protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams) |
369 | { | 392 | { |
370 | Guid id = Guid.NewGuid(); | 393 | Guid id = Guid.NewGuid(); |
371 | 394 | ||
395 | Dictionary<string, object> options = new Dictionary<string, object>(); | ||
396 | |||
397 | OptionSet ops = new OptionSet(); | ||
398 | //ops.Add("v|version=", delegate(string v) { options["version"] = v; }); | ||
399 | ops.Add("p|profile=", delegate(string v) { options["profile"] = v; }); | ||
400 | |||
401 | List<string> mainParams = ops.Parse(cmdparams); | ||
402 | |||
372 | try | 403 | try |
373 | { | 404 | { |
374 | if (cmdparams.Length < 6) | 405 | if (mainParams.Count < 6) |
375 | { | 406 | { |
376 | m_log.Error( | 407 | m_log.Error( |
377 | "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]"); | 408 | "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]"); |
@@ -379,18 +410,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
379 | } | 410 | } |
380 | 411 | ||
381 | m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME."); | 412 | m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME."); |
382 | 413 | if (options.ContainsKey("profile")) | |
383 | string firstName = cmdparams[2]; | 414 | 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]; | 415 | |
385 | string invPath = cmdparams[4]; | 416 | string firstName = mainParams[2]; |
386 | string pass = cmdparams[5]; | 417 | string lastName = mainParams[3]; |
387 | string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME); | 418 | string invPath = mainParams[4]; |
419 | string pass = mainParams[5]; | ||
420 | string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); | ||
388 | 421 | ||
389 | m_log.InfoFormat( | 422 | m_log.InfoFormat( |
390 | "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", | 423 | "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", |
391 | savePath, invPath, firstName, lastName); | 424 | savePath, invPath, firstName, lastName); |
392 | 425 | ||
393 | ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, new Dictionary<string, object>()); | 426 | ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options); |
394 | } | 427 | } |
395 | catch (InventoryArchiverException e) | 428 | catch (InventoryArchiverException e) |
396 | { | 429 | { |
@@ -518,5 +551,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
518 | 551 | ||
519 | return false; | 552 | return false; |
520 | } | 553 | } |
554 | |||
521 | } | 555 | } |
522 | } | 556 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 938886b2..2747e15 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; | |||
38 | using OpenSim.Framework.Serialization; | 38 | using OpenSim.Framework.Serialization; |
39 | using OpenSim.Framework.Serialization.External; | 39 | using OpenSim.Framework.Serialization.External; |
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Framework.Communications.Osp; | ||
42 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; | 41 | using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver; |
43 | using OpenSim.Region.CoreModules.World.Serialiser; | 42 | using OpenSim.Region.CoreModules.World.Serialiser; |
44 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
@@ -96,14 +95,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
96 | item1.Name = m_item1Name; | 95 | item1.Name = m_item1Name; |
97 | item1.AssetID = UUID.Random(); | 96 | item1.AssetID = UUID.Random(); |
98 | item1.GroupID = UUID.Random(); | 97 | item1.GroupID = UUID.Random(); |
99 | item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName); | 98 | //item1.CreatorId = OspResolver.MakeOspa(m_ua2.FirstName, m_ua2.LastName); |
100 | //item1.CreatorId = userUuid.ToString(); | 99 | //item1.CreatorId = userUuid.ToString(); |
101 | //item1.CreatorId = "00000000-0000-0000-0000-000000000444"; | 100 | item1.CreatorId = m_ua2.PrincipalID.ToString(); |
102 | item1.Owner = UUID.Zero; | 101 | item1.Owner = UUID.Zero; |
103 | 102 | ||
103 | Scene scene = SceneSetupHelpers.SetupScene("Inventory"); | ||
104 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); | ||
105 | |||
104 | string item1FileName | 106 | string item1FileName |
105 | = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); | 107 | = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); |
106 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); | 108 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string, object>(), scene.UserAccountService)); |
107 | tar.Close(); | 109 | tar.Close(); |
108 | m_iarStream = new MemoryStream(archiveWriteStream.ToArray()); | 110 | m_iarStream = new MemoryStream(archiveWriteStream.ToArray()); |
109 | } | 111 | } |
@@ -386,7 +388,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
386 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); | 388 | Scene scene = SceneSetupHelpers.SetupScene("inventory"); |
387 | 389 | ||
388 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); | 390 | SceneSetupHelpers.SetupSceneModules(scene, serialiserModule, archiverModule); |
389 | 391 | ||
390 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); | 392 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua1, "meowfood"); |
391 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); | 393 | UserProfileTestUtils.CreateUserWithInventory(scene, m_ua2, "hampshire"); |
392 | 394 | ||
@@ -551,7 +553,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
551 | 553 | ||
552 | string item1FileName | 554 | string item1FileName |
553 | = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); | 555 | = string.Format("{0}{1}", ArchiveConstants.INVENTORY_PATH, archiveItemName); |
554 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1)); | 556 | tar.WriteFile(item1FileName, UserInventoryItemSerializer.Serialize(item1, new Dictionary<string,object>(), null)); |
555 | tar.Close(); | 557 | tar.Close(); |
556 | 558 | ||
557 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | 559 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index ccb892e..81b65c5 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs | |||
@@ -27,8 +27,11 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Threading; | 32 | using System.Threading; |
33 | using System.Xml; | ||
34 | |||
32 | using log4net; | 35 | using log4net; |
33 | using OpenMetaverse; | 36 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
@@ -52,14 +55,16 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
52 | // private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); | 55 | // private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); |
53 | 56 | ||
54 | private Scene m_scene; | 57 | private Scene m_scene; |
58 | private string m_ProfileServerURI; | ||
55 | 59 | ||
56 | #endregion | 60 | #endregion |
57 | 61 | ||
58 | #region Constructor | 62 | #region Constructor |
59 | 63 | ||
60 | public HGAssetMapper(Scene scene) | 64 | public HGAssetMapper(Scene scene, string profileURL) |
61 | { | 65 | { |
62 | m_scene = scene; | 66 | m_scene = scene; |
67 | m_ProfileServerURI = profileURL; | ||
63 | } | 68 | } |
64 | 69 | ||
65 | #endregion | 70 | #endregion |
@@ -95,16 +100,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
95 | try | 100 | try |
96 | { | 101 | { |
97 | asset1.ID = url + "/" + asset.ID; | 102 | asset1.ID = url + "/" + asset.ID; |
98 | // UUID temp = UUID.Zero; | ||
99 | // TODO: if the creator is local, stick this grid's URL in front | ||
100 | //if (UUID.TryParse(asset.Metadata.CreatorID, out temp)) | ||
101 | // asset1.Metadata.CreatorID = ??? + "/" + asset.Metadata.CreatorID; | ||
102 | } | 103 | } |
103 | catch | 104 | catch |
104 | { | 105 | { |
105 | m_log.Warn("[HG ASSET MAPPER]: Oops."); | 106 | m_log.Warn("[HG ASSET MAPPER]: Oops."); |
106 | } | 107 | } |
107 | 108 | ||
109 | AdjustIdentifiers(asset1.Metadata); | ||
110 | if (asset1.Metadata.Type == (sbyte)AssetType.Object) | ||
111 | asset1.Data = AdjustIdentifiers(asset.Data); | ||
112 | else | ||
113 | asset1.Data = asset.Data; | ||
114 | |||
108 | m_scene.AssetService.Store(asset1); | 115 | m_scene.AssetService.Store(asset1); |
109 | m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); | 116 | m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); |
110 | } | 117 | } |
@@ -118,7 +125,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
118 | 125 | ||
119 | private void Copy(AssetBase from, AssetBase to) | 126 | private void Copy(AssetBase from, AssetBase to) |
120 | { | 127 | { |
121 | to.Data = from.Data; | 128 | //to.Data = from.Data; // don't copy this, it's copied elsewhere |
122 | to.Description = from.Description; | 129 | to.Description = from.Description; |
123 | to.FullID = from.FullID; | 130 | to.FullID = from.FullID; |
124 | to.ID = from.ID; | 131 | to.ID = from.ID; |
@@ -129,6 +136,70 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
129 | 136 | ||
130 | } | 137 | } |
131 | 138 | ||
139 | private void AdjustIdentifiers(AssetMetadata meta) | ||
140 | { | ||
141 | if (meta.CreatorID != null && meta.CreatorID != string.Empty) | ||
142 | { | ||
143 | UUID uuid = UUID.Zero; | ||
144 | UUID.TryParse(meta.CreatorID, out uuid); | ||
145 | UserAccount creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid); | ||
146 | if (creator != null) | ||
147 | meta.CreatorID = m_ProfileServerURI + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; | ||
148 | } | ||
149 | } | ||
150 | |||
151 | protected byte[] AdjustIdentifiers(byte[] data) | ||
152 | { | ||
153 | string xml = Utils.BytesToString(data); | ||
154 | return Utils.StringToBytes(RewriteSOP(xml)); | ||
155 | } | ||
156 | |||
157 | protected string RewriteSOP(string xml) | ||
158 | { | ||
159 | XmlDocument doc = new XmlDocument(); | ||
160 | doc.LoadXml(xml); | ||
161 | XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart"); | ||
162 | |||
163 | foreach (XmlNode sop in sops) | ||
164 | { | ||
165 | UserAccount creator = null; | ||
166 | bool hasCreatorData = false; | ||
167 | XmlNodeList nodes = sop.ChildNodes; | ||
168 | foreach (XmlNode node in nodes) | ||
169 | { | ||
170 | if (node.Name == "CreatorID") | ||
171 | { | ||
172 | UUID uuid = UUID.Zero; | ||
173 | UUID.TryParse(node.InnerText, out uuid); | ||
174 | creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid); | ||
175 | } | ||
176 | if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty) | ||
177 | hasCreatorData = true; | ||
178 | |||
179 | //if (node.Name == "OwnerID") | ||
180 | //{ | ||
181 | // UserAccount owner = GetUser(node.InnerText); | ||
182 | // if (owner != null) | ||
183 | // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName; | ||
184 | //} | ||
185 | } | ||
186 | |||
187 | if (!hasCreatorData && creator != null) | ||
188 | { | ||
189 | XmlElement creatorData = doc.CreateElement("CreatorData"); | ||
190 | creatorData.InnerText = m_ProfileServerURI + "/" + creator.PrincipalID + ";" + creator.FirstName + " " + creator.LastName; | ||
191 | sop.AppendChild(creatorData); | ||
192 | } | ||
193 | } | ||
194 | |||
195 | using (StringWriter wr = new StringWriter()) | ||
196 | { | ||
197 | doc.Save(wr); | ||
198 | return wr.ToString(); | ||
199 | } | ||
200 | |||
201 | } | ||
202 | |||
132 | // TODO: unused | 203 | // TODO: unused |
133 | // private void Dump(Dictionary<UUID, bool> lst) | 204 | // private void Dump(Dictionary<UUID, bool> lst) |
134 | // { | 205 | // { |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 125a397..34b8114 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -54,6 +54,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
54 | get { return m_assMapper; } | 54 | get { return m_assMapper; } |
55 | } | 55 | } |
56 | 56 | ||
57 | private string m_ProfileServerURI; | ||
58 | |||
57 | // private bool m_Initialized = false; | 59 | // private bool m_Initialized = false; |
58 | 60 | ||
59 | #region INonSharedRegionModule | 61 | #region INonSharedRegionModule |
@@ -73,6 +75,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
73 | { | 75 | { |
74 | m_Enabled = true; | 76 | m_Enabled = true; |
75 | m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); | 77 | m_log.InfoFormat("[HG INVENTORY ACCESS MODULE]: {0} enabled.", Name); |
78 | |||
79 | IConfig thisModuleConfig = source.Configs["HGInventoryAccessModule"]; | ||
80 | if (thisModuleConfig != null) | ||
81 | m_ProfileServerURI = thisModuleConfig.GetString("ProfileServerURI", string.Empty); | ||
82 | else | ||
83 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); | ||
76 | } | 84 | } |
77 | } | 85 | } |
78 | } | 86 | } |
@@ -83,7 +91,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
83 | return; | 91 | return; |
84 | 92 | ||
85 | base.AddRegion(scene); | 93 | base.AddRegion(scene); |
86 | m_assMapper = new HGAssetMapper(scene); | 94 | m_assMapper = new HGAssetMapper(scene, m_ProfileServerURI); |
87 | scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; | 95 | scene.EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; |
88 | 96 | ||
89 | } | 97 | } |
@@ -97,7 +105,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
97 | string userAssetServer = string.Empty; | 105 | string userAssetServer = string.Empty; |
98 | if (IsForeignUser(avatarID, out userAssetServer)) | 106 | if (IsForeignUser(avatarID, out userAssetServer)) |
99 | { | 107 | { |
100 | m_assMapper.Post(assetID, avatarID, userAssetServer); | 108 | Util.FireAndForget(delegate { m_assMapper.Post(assetID, avatarID, userAssetServer); }); |
101 | } | 109 | } |
102 | } | 110 | } |
103 | 111 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 67732ff..1ebccd1 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -53,6 +53,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
53 | 53 | ||
54 | protected bool m_Enabled = false; | 54 | protected bool m_Enabled = false; |
55 | protected Scene m_Scene; | 55 | protected Scene m_Scene; |
56 | protected IUserManagement m_UserManagement; | ||
57 | protected IUserManagement UserManagementModule | ||
58 | { | ||
59 | get | ||
60 | { | ||
61 | if (m_UserManagement == null) | ||
62 | m_UserManagement = m_Scene.RequestModuleInterface<IUserManagement>(); | ||
63 | return m_UserManagement; | ||
64 | } | ||
65 | } | ||
66 | |||
56 | 67 | ||
57 | #region INonSharedRegionModule | 68 | #region INonSharedRegionModule |
58 | 69 | ||
@@ -542,6 +553,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
542 | SceneObjectGroup group | 553 | SceneObjectGroup group |
543 | = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); | 554 | = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); |
544 | 555 | ||
556 | Util.FireAndForget(delegate { AddUserData(group); }); | ||
557 | |||
545 | group.RootPart.FromFolderID = item.Folder; | 558 | group.RootPart.FromFolderID = item.Folder; |
546 | 559 | ||
547 | // If it's rezzed in world, select it. Much easier to | 560 | // If it's rezzed in world, select it. Much easier to |
@@ -699,6 +712,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
699 | return null; | 712 | return null; |
700 | } | 713 | } |
701 | 714 | ||
715 | protected void AddUserData(SceneObjectGroup sog) | ||
716 | { | ||
717 | UserManagementModule.AddUser(sog.RootPart.CreatorID, sog.RootPart.CreatorData); | ||
718 | foreach (SceneObjectPart sop in sog.Parts) | ||
719 | UserManagementModule.AddUser(sop.CreatorID, sop.CreatorData); | ||
720 | } | ||
721 | |||
702 | public virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) | 722 | public virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) |
703 | { | 723 | { |
704 | } | 724 | } |
@@ -779,9 +799,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
779 | protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID) | 799 | protected virtual InventoryItemBase GetItem(UUID agentID, UUID itemID) |
780 | { | 800 | { |
781 | IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>(); | 801 | IInventoryService invService = m_Scene.RequestModuleInterface<IInventoryService>(); |
782 | InventoryItemBase assetRequestItem = new InventoryItemBase(itemID, agentID); | 802 | InventoryItemBase item = new InventoryItemBase(itemID, agentID); |
783 | assetRequestItem = invService.GetItem(assetRequestItem); | 803 | item = invService.GetItem(item); |
784 | return assetRequestItem; | 804 | |
805 | if (item.CreatorData != null && item.CreatorData != string.Empty) | ||
806 | UserManagementModule.AddUser(item.CreatorIdAsUuid, item.CreatorData); | ||
807 | |||
808 | return item; | ||
785 | } | 809 | } |
786 | 810 | ||
787 | #endregion | 811 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 0d94baa..bf84100 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -275,6 +275,11 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
275 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL); | 275 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL); |
276 | } | 276 | } |
277 | 277 | ||
278 | public void AddUser(UUID uuid, string first, string last, string profileURL) | ||
279 | { | ||
280 | AddUser(uuid, profileURL + ";" + first + " " + last); | ||
281 | } | ||
282 | |||
278 | //public void AddUser(UUID uuid, string userData) | 283 | //public void AddUser(UUID uuid, string userData) |
279 | //{ | 284 | //{ |
280 | // if (m_UserCache.ContainsKey(uuid)) | 285 | // if (m_UserCache.ContainsKey(uuid)) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs index 2324380..e25700d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs | |||
@@ -91,9 +91,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset | |||
91 | { | 91 | { |
92 | m_Registered = true; | 92 | m_Registered = true; |
93 | 93 | ||
94 | m_log.Info("[RegionAssetService]: Starting..."); | 94 | m_log.Info("[HGAssetService]: Starting..."); |
95 | 95 | ||
96 | Object[] args = new Object[] { m_Config, MainServer.Instance, string.Empty }; | 96 | |
97 | Object[] args = new Object[] { m_Config, MainServer.Instance, "HGAssetService" }; | ||
97 | 98 | ||
98 | ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:AssetServiceConnector", args); | 99 | ServerUtils.LoadPlugin<IServiceConnector>("OpenSim.Server.Handlers.dll:AssetServiceConnector", args); |
99 | } | 100 | } |
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; | |||
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Serialization; | 36 | using OpenSim.Framework.Serialization; |
37 | using OpenSim.Framework.Serialization.External; | ||
37 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
38 | 39 | ||
39 | namespace OpenSim.Region.CoreModules.World.Archiver | 40 | namespace 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/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs index 1a5cb7e..2904ee8 100644 --- a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs +++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs | |||
@@ -9,5 +9,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
9 | { | 9 | { |
10 | string GetUserName(UUID uuid); | 10 | string GetUserName(UUID uuid); |
11 | void AddUser(UUID uuid, string userData); | 11 | void AddUser(UUID uuid, string userData); |
12 | void AddUser(UUID uuid, string firstName, string lastName, string profileURL); | ||
12 | } | 13 | } |
13 | } | 14 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 06f8ac1..2cf0ced 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -416,6 +416,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
416 | 416 | ||
417 | if ((item != null) && (item.Owner == senderId)) | 417 | if ((item != null) && (item.Owner == senderId)) |
418 | { | 418 | { |
419 | IUserManagement uman = RequestModuleInterface<IUserManagement>(); | ||
420 | if (uman != null) | ||
421 | uman.AddUser(item.CreatorIdAsUuid, item.CreatorData); | ||
422 | |||
419 | if (!Permissions.BypassPermissions()) | 423 | if (!Permissions.BypassPermissions()) |
420 | { | 424 | { |
421 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | 425 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index b1216c5..90223b1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2560,6 +2560,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2560 | } | 2560 | } |
2561 | else | 2561 | else |
2562 | m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned true", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); | 2562 | m_log.DebugFormat("[SCENE]: User Client Verification for {0} {1} in {2} returned true", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); |
2563 | |||
2563 | } | 2564 | } |
2564 | } | 2565 | } |
2565 | 2566 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 9cf5a39..6c9826f 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -409,12 +409,12 @@ 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) |
416 | { | 416 | { |
417 | obj.CreatorID = ReadUUID(reader, "CreatorID"); | 417 | obj.CreatorID = Util.ReadUUID(reader, "CreatorID"); |
418 | } | 418 | } |
419 | 419 | ||
420 | private static void ProcessCreatorData(SceneObjectPart obj, XmlTextReader reader) | 420 | private static void ProcessCreatorData(SceneObjectPart obj, XmlTextReader reader) |
@@ -424,7 +424,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
424 | 424 | ||
425 | private static void ProcessFolderID(SceneObjectPart obj, XmlTextReader reader) | 425 | private static void ProcessFolderID(SceneObjectPart obj, XmlTextReader reader) |
426 | { | 426 | { |
427 | obj.FolderID = ReadUUID(reader, "FolderID"); | 427 | obj.FolderID = Util.ReadUUID(reader, "FolderID"); |
428 | } | 428 | } |
429 | 429 | ||
430 | private static void ProcessInventorySerial(SceneObjectPart obj, XmlTextReader reader) | 430 | private static void ProcessInventorySerial(SceneObjectPart obj, XmlTextReader reader) |
@@ -439,7 +439,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
439 | 439 | ||
440 | private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader) | 440 | private static void ProcessUUID(SceneObjectPart obj, XmlTextReader reader) |
441 | { | 441 | { |
442 | obj.UUID = ReadUUID(reader, "UUID"); | 442 | obj.UUID = Util.ReadUUID(reader, "UUID"); |
443 | } | 443 | } |
444 | 444 | ||
445 | private static void ProcessLocalId(SceneObjectPart obj, XmlTextReader reader) | 445 | private static void ProcessLocalId(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) |
@@ -474,32 +474,32 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
474 | 474 | ||
475 | private static void ProcessGroupPosition(SceneObjectPart obj, XmlTextReader reader) | 475 | private static void ProcessGroupPosition(SceneObjectPart obj, XmlTextReader reader) |
476 | { | 476 | { |
477 | obj.GroupPosition = ReadVector(reader, "GroupPosition"); | 477 | obj.GroupPosition = Util.ReadVector(reader, "GroupPosition"); |
478 | } | 478 | } |
479 | 479 | ||
480 | private static void ProcessOffsetPosition(SceneObjectPart obj, XmlTextReader reader) | 480 | private static void ProcessOffsetPosition(SceneObjectPart obj, XmlTextReader reader) |
481 | { | 481 | { |
482 | obj.OffsetPosition = ReadVector(reader, "OffsetPosition"); ; | 482 | obj.OffsetPosition = Util.ReadVector(reader, "OffsetPosition"); ; |
483 | } | 483 | } |
484 | 484 | ||
485 | private static void ProcessRotationOffset(SceneObjectPart obj, XmlTextReader reader) | 485 | private static void ProcessRotationOffset(SceneObjectPart obj, XmlTextReader reader) |
486 | { | 486 | { |
487 | obj.RotationOffset = ReadQuaternion(reader, "RotationOffset"); | 487 | obj.RotationOffset = Util.ReadQuaternion(reader, "RotationOffset"); |
488 | } | 488 | } |
489 | 489 | ||
490 | private static void ProcessVelocity(SceneObjectPart obj, XmlTextReader reader) | 490 | private static void ProcessVelocity(SceneObjectPart obj, XmlTextReader reader) |
491 | { | 491 | { |
492 | obj.Velocity = ReadVector(reader, "Velocity"); | 492 | obj.Velocity = Util.ReadVector(reader, "Velocity"); |
493 | } | 493 | } |
494 | 494 | ||
495 | private static void ProcessAngularVelocity(SceneObjectPart obj, XmlTextReader reader) | 495 | private static void ProcessAngularVelocity(SceneObjectPart obj, XmlTextReader reader) |
496 | { | 496 | { |
497 | obj.AngularVelocity = ReadVector(reader, "AngularVelocity"); | 497 | obj.AngularVelocity = Util.ReadVector(reader, "AngularVelocity"); |
498 | } | 498 | } |
499 | 499 | ||
500 | private static void ProcessAcceleration(SceneObjectPart obj, XmlTextReader reader) | 500 | private static void ProcessAcceleration(SceneObjectPart obj, XmlTextReader reader) |
501 | { | 501 | { |
502 | obj.Acceleration = ReadVector(reader, "Acceleration"); | 502 | obj.Acceleration = Util.ReadVector(reader, "Acceleration"); |
503 | } | 503 | } |
504 | 504 | ||
505 | private static void ProcessDescription(SceneObjectPart obj, XmlTextReader reader) | 505 | private static void ProcessDescription(SceneObjectPart obj, XmlTextReader reader) |
@@ -553,7 +553,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
553 | 553 | ||
554 | private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader) | 554 | private static void ProcessScale(SceneObjectPart obj, XmlTextReader reader) |
555 | { | 555 | { |
556 | obj.Scale = ReadVector(reader, "Scale"); | 556 | obj.Scale = Util.ReadVector(reader, "Scale"); |
557 | } | 557 | } |
558 | 558 | ||
559 | private static void ProcessUpdateFlag(SceneObjectPart obj, XmlTextReader reader) | 559 | private static void ProcessUpdateFlag(SceneObjectPart obj, XmlTextReader reader) |
@@ -563,22 +563,22 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
563 | 563 | ||
564 | private static void ProcessSitTargetOrientation(SceneObjectPart obj, XmlTextReader reader) | 564 | private static void ProcessSitTargetOrientation(SceneObjectPart obj, XmlTextReader reader) |
565 | { | 565 | { |
566 | obj.SitTargetOrientation = ReadQuaternion(reader, "SitTargetOrientation"); | 566 | obj.SitTargetOrientation = Util.ReadQuaternion(reader, "SitTargetOrientation"); |
567 | } | 567 | } |
568 | 568 | ||
569 | private static void ProcessSitTargetPosition(SceneObjectPart obj, XmlTextReader reader) | 569 | private static void ProcessSitTargetPosition(SceneObjectPart obj, XmlTextReader reader) |
570 | { | 570 | { |
571 | obj.SitTargetPosition = ReadVector(reader, "SitTargetPosition"); | 571 | obj.SitTargetPosition = Util.ReadVector(reader, "SitTargetPosition"); |
572 | } | 572 | } |
573 | 573 | ||
574 | private static void ProcessSitTargetPositionLL(SceneObjectPart obj, XmlTextReader reader) | 574 | private static void ProcessSitTargetPositionLL(SceneObjectPart obj, XmlTextReader reader) |
575 | { | 575 | { |
576 | obj.SitTargetPositionLL = ReadVector(reader, "SitTargetPositionLL"); | 576 | obj.SitTargetPositionLL = Util.ReadVector(reader, "SitTargetPositionLL"); |
577 | } | 577 | } |
578 | 578 | ||
579 | private static void ProcessSitTargetOrientationLL(SceneObjectPart obj, XmlTextReader reader) | 579 | private static void ProcessSitTargetOrientationLL(SceneObjectPart obj, XmlTextReader reader) |
580 | { | 580 | { |
581 | obj.SitTargetOrientationLL = ReadQuaternion(reader, "SitTargetOrientationLL"); | 581 | obj.SitTargetOrientationLL = Util.ReadQuaternion(reader, "SitTargetOrientationLL"); |
582 | } | 582 | } |
583 | 583 | ||
584 | private static void ProcessParentID(SceneObjectPart obj, XmlTextReader reader) | 584 | private static void ProcessParentID(SceneObjectPart obj, XmlTextReader reader) |
@@ -614,17 +614,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
614 | 614 | ||
615 | private static void ProcessGroupID(SceneObjectPart obj, XmlTextReader reader) | 615 | private static void ProcessGroupID(SceneObjectPart obj, XmlTextReader reader) |
616 | { | 616 | { |
617 | obj.GroupID = ReadUUID(reader, "GroupID"); | 617 | obj.GroupID = Util.ReadUUID(reader, "GroupID"); |
618 | } | 618 | } |
619 | 619 | ||
620 | private static void ProcessOwnerID(SceneObjectPart obj, XmlTextReader reader) | 620 | private static void ProcessOwnerID(SceneObjectPart obj, XmlTextReader reader) |
621 | { | 621 | { |
622 | obj.OwnerID = ReadUUID(reader, "OwnerID"); | 622 | obj.OwnerID = Util.ReadUUID(reader, "OwnerID"); |
623 | } | 623 | } |
624 | 624 | ||
625 | private static void ProcessLastOwnerID(SceneObjectPart obj, XmlTextReader reader) | 625 | private static void ProcessLastOwnerID(SceneObjectPart obj, XmlTextReader reader) |
626 | { | 626 | { |
627 | obj.LastOwnerID = ReadUUID(reader, "LastOwnerID"); | 627 | obj.LastOwnerID = Util.ReadUUID(reader, "LastOwnerID"); |
628 | } | 628 | } |
629 | 629 | ||
630 | private static void ProcessBaseMask(SceneObjectPart obj, XmlTextReader reader) | 630 | private static void ProcessBaseMask(SceneObjectPart obj, XmlTextReader reader) |
@@ -654,16 +654,12 @@ 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) |
665 | { | 661 | { |
666 | obj.CollisionSound = ReadUUID(reader, "CollisionSound"); | 662 | obj.CollisionSound = Util.ReadUUID(reader, "CollisionSound"); |
667 | } | 663 | } |
668 | 664 | ||
669 | private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader) | 665 | private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader) |
@@ -690,7 +686,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
690 | #region TaskInventoryXmlProcessors | 686 | #region TaskInventoryXmlProcessors |
691 | private static void ProcessTIAssetID(TaskInventoryItem item, XmlTextReader reader) | 687 | private static void ProcessTIAssetID(TaskInventoryItem item, XmlTextReader reader) |
692 | { | 688 | { |
693 | item.AssetID = ReadUUID(reader, "AssetID"); | 689 | item.AssetID = Util.ReadUUID(reader, "AssetID"); |
694 | } | 690 | } |
695 | 691 | ||
696 | private static void ProcessTIBasePermissions(TaskInventoryItem item, XmlTextReader reader) | 692 | private static void ProcessTIBasePermissions(TaskInventoryItem item, XmlTextReader reader) |
@@ -705,7 +701,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
705 | 701 | ||
706 | private static void ProcessTICreatorID(TaskInventoryItem item, XmlTextReader reader) | 702 | private static void ProcessTICreatorID(TaskInventoryItem item, XmlTextReader reader) |
707 | { | 703 | { |
708 | item.CreatorID = ReadUUID(reader, "CreatorID"); | 704 | item.CreatorID = Util.ReadUUID(reader, "CreatorID"); |
709 | } | 705 | } |
710 | 706 | ||
711 | private static void ProcessTICreatorData(TaskInventoryItem item, XmlTextReader reader) | 707 | private static void ProcessTICreatorData(TaskInventoryItem item, XmlTextReader reader) |
@@ -730,7 +726,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
730 | 726 | ||
731 | private static void ProcessTIGroupID(TaskInventoryItem item, XmlTextReader reader) | 727 | private static void ProcessTIGroupID(TaskInventoryItem item, XmlTextReader reader) |
732 | { | 728 | { |
733 | item.GroupID = ReadUUID(reader, "GroupID"); | 729 | item.GroupID = Util.ReadUUID(reader, "GroupID"); |
734 | } | 730 | } |
735 | 731 | ||
736 | private static void ProcessTIGroupPermissions(TaskInventoryItem item, XmlTextReader reader) | 732 | private static void ProcessTIGroupPermissions(TaskInventoryItem item, XmlTextReader reader) |
@@ -745,20 +741,20 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
745 | 741 | ||
746 | private static void ProcessTIItemID(TaskInventoryItem item, XmlTextReader reader) | 742 | private static void ProcessTIItemID(TaskInventoryItem item, XmlTextReader reader) |
747 | { | 743 | { |
748 | item.ItemID = ReadUUID(reader, "ItemID"); | 744 | item.ItemID = Util.ReadUUID(reader, "ItemID"); |
749 | } | 745 | } |
750 | 746 | ||
751 | private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) | 747 | private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader) |
752 | { | 748 | { |
753 | ReadUUID(reader, "OldItemID"); | 749 | Util.ReadUUID(reader, "OldItemID"); |
754 | // On deserialization, the old item id MUST BE UUID.Zero!!!!! | 750 | // On deserialization, the old item id MUST BE UUID.Zero!!!!! |
755 | // Setting this to the saved value will BREAK script persistence! | 751 | // Setting this to the saved value will BREAK script persistence! |
756 | // item.OldItemID = ReadUUID(reader, "OldItemID"); | 752 | // item.OldItemID = Util.ReadUUID(reader, "OldItemID"); |
757 | } | 753 | } |
758 | 754 | ||
759 | private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) | 755 | private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader) |
760 | { | 756 | { |
761 | item.LastOwnerID = ReadUUID(reader, "LastOwnerID"); | 757 | item.LastOwnerID = Util.ReadUUID(reader, "LastOwnerID"); |
762 | } | 758 | } |
763 | 759 | ||
764 | private static void ProcessTIName(TaskInventoryItem item, XmlTextReader reader) | 760 | private static void ProcessTIName(TaskInventoryItem item, XmlTextReader reader) |
@@ -773,7 +769,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
773 | 769 | ||
774 | private static void ProcessTIOwnerID(TaskInventoryItem item, XmlTextReader reader) | 770 | private static void ProcessTIOwnerID(TaskInventoryItem item, XmlTextReader reader) |
775 | { | 771 | { |
776 | item.OwnerID = ReadUUID(reader, "OwnerID"); | 772 | item.OwnerID = Util.ReadUUID(reader, "OwnerID"); |
777 | } | 773 | } |
778 | 774 | ||
779 | private static void ProcessTICurrentPermissions(TaskInventoryItem item, XmlTextReader reader) | 775 | private static void ProcessTICurrentPermissions(TaskInventoryItem item, XmlTextReader reader) |
@@ -783,17 +779,17 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
783 | 779 | ||
784 | private static void ProcessTIParentID(TaskInventoryItem item, XmlTextReader reader) | 780 | private static void ProcessTIParentID(TaskInventoryItem item, XmlTextReader reader) |
785 | { | 781 | { |
786 | item.ParentID = ReadUUID(reader, "ParentID"); | 782 | item.ParentID = Util.ReadUUID(reader, "ParentID"); |
787 | } | 783 | } |
788 | 784 | ||
789 | private static void ProcessTIParentPartID(TaskInventoryItem item, XmlTextReader reader) | 785 | private static void ProcessTIParentPartID(TaskInventoryItem item, XmlTextReader reader) |
790 | { | 786 | { |
791 | item.ParentPartID = ReadUUID(reader, "ParentPartID"); | 787 | item.ParentPartID = Util.ReadUUID(reader, "ParentPartID"); |
792 | } | 788 | } |
793 | 789 | ||
794 | private static void ProcessTIPermsGranter(TaskInventoryItem item, XmlTextReader reader) | 790 | private static void ProcessTIPermsGranter(TaskInventoryItem item, XmlTextReader reader) |
795 | { | 791 | { |
796 | item.PermsGranter = ReadUUID(reader, "PermsGranter"); | 792 | item.PermsGranter = Util.ReadUUID(reader, "PermsGranter"); |
797 | } | 793 | } |
798 | 794 | ||
799 | private static void ProcessTIPermsMask(TaskInventoryItem item, XmlTextReader reader) | 795 | private static void ProcessTIPermsMask(TaskInventoryItem item, 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 |
@@ -922,7 +918,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
922 | 918 | ||
923 | private static void ProcessShpScale(PrimitiveBaseShape shp, XmlTextReader reader) | 919 | private static void ProcessShpScale(PrimitiveBaseShape shp, XmlTextReader reader) |
924 | { | 920 | { |
925 | shp.Scale = ReadVector(reader, "Scale"); | 921 | shp.Scale = Util.ReadVector(reader, "Scale"); |
926 | } | 922 | } |
927 | 923 | ||
928 | private static void ProcessShpState(PrimitiveBaseShape shp, XmlTextReader reader) | 924 | private static void ProcessShpState(PrimitiveBaseShape shp, XmlTextReader reader) |
@@ -932,25 +928,17 @@ 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) |
952 | { | 940 | { |
953 | shp.SculptTexture = ReadUUID(reader, "SculptTexture"); | 941 | shp.SculptTexture = Util.ReadUUID(reader, "SculptTexture"); |
954 | } | 942 | } |
955 | 943 | ||
956 | private static void ProcessShpSculptType(PrimitiveBaseShape shp, XmlTextReader reader) | 944 | private static void ProcessShpSculptType(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) |
@@ -1459,66 +1439,6 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
1459 | return obj; | 1439 | return obj; |
1460 | } | 1440 | } |
1461 | 1441 | ||
1462 | static UUID ReadUUID(XmlTextReader reader, string name) | ||
1463 | { | ||
1464 | UUID id; | ||
1465 | string idStr; | ||
1466 | |||
1467 | reader.ReadStartElement(name); | ||
1468 | |||
1469 | if (reader.Name == "Guid") | ||
1470 | idStr = reader.ReadElementString("Guid"); | ||
1471 | else // UUID | ||
1472 | idStr = reader.ReadElementString("UUID"); | ||
1473 | |||
1474 | UUID.TryParse(idStr, out id); | ||
1475 | reader.ReadEndElement(); | ||
1476 | |||
1477 | return id; | ||
1478 | } | ||
1479 | |||
1480 | static Vector3 ReadVector(XmlTextReader reader, string name) | ||
1481 | { | ||
1482 | Vector3 vec; | ||
1483 | |||
1484 | reader.ReadStartElement(name); | ||
1485 | vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x | ||
1486 | vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y | ||
1487 | vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z | ||
1488 | reader.ReadEndElement(); | ||
1489 | |||
1490 | return vec; | ||
1491 | } | ||
1492 | |||
1493 | static Quaternion ReadQuaternion(XmlTextReader reader, string name) | ||
1494 | { | ||
1495 | Quaternion quat = new Quaternion(); | ||
1496 | |||
1497 | reader.ReadStartElement(name); | ||
1498 | while (reader.NodeType != XmlNodeType.EndElement) | ||
1499 | { | ||
1500 | switch (reader.Name.ToLower()) | ||
1501 | { | ||
1502 | case "x": | ||
1503 | quat.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1504 | break; | ||
1505 | case "y": | ||
1506 | quat.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1507 | break; | ||
1508 | case "z": | ||
1509 | quat.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1510 | break; | ||
1511 | case "w": | ||
1512 | quat.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty); | ||
1513 | break; | ||
1514 | } | ||
1515 | } | ||
1516 | |||
1517 | reader.ReadEndElement(); | ||
1518 | |||
1519 | return quat; | ||
1520 | } | ||
1521 | |||
1522 | static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name) | 1442 | static TaskInventoryDictionary ReadTaskInventory(XmlTextReader reader, string name) |
1523 | { | 1443 | { |
1524 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); | 1444 | TaskInventoryDictionary tinv = new TaskInventoryDictionary(); |
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index b6425f4..df571fa 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs | |||
@@ -53,12 +53,15 @@ namespace OpenSim.Server.Handlers.Asset | |||
53 | String.Empty); | 53 | String.Empty); |
54 | 54 | ||
55 | if (assetService == String.Empty) | 55 | if (assetService == String.Empty) |
56 | throw new Exception("No AssetService in config file"); | 56 | throw new Exception("No LocalServiceModule in config file"); |
57 | 57 | ||
58 | Object[] args = new Object[] { config }; | 58 | Object[] args = new Object[] { config }; |
59 | m_AssetService = | 59 | m_AssetService = |
60 | ServerUtils.LoadPlugin<IAssetService>(assetService, args); | 60 | ServerUtils.LoadPlugin<IAssetService>(assetService, args); |
61 | 61 | ||
62 | if (m_AssetService == null) | ||
63 | throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName)); | ||
64 | |||
62 | bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); | 65 | bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); |
63 | 66 | ||
64 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); | 67 | server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); |
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 22a718a..00f035c 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | |||
@@ -153,7 +153,7 @@ namespace OpenSim.Server.Handlers.Asset | |||
153 | } | 153 | } |
154 | catch (Exception e) | 154 | catch (Exception e) |
155 | { | 155 | { |
156 | m_log.Debug("[XINVENTORY HANDLER]: Exception {0}", e); | 156 | m_log.DebugFormat("[XINVENTORY HANDLER]: Exception {0}", e); |
157 | } | 157 | } |
158 | 158 | ||
159 | return FailureResult(); | 159 | return FailureResult(); |
@@ -604,6 +604,10 @@ namespace OpenSim.Server.Handlers.Asset | |||
604 | ret["CreatorId"] = item.CreatorId.ToString(); | 604 | ret["CreatorId"] = item.CreatorId.ToString(); |
605 | else | 605 | else |
606 | ret["CreatorId"] = String.Empty; | 606 | ret["CreatorId"] = String.Empty; |
607 | if (item.CreatorData != null) | ||
608 | ret["CreatorData"] = item.CreatorData; | ||
609 | else | ||
610 | ret["CreatorData"] = String.Empty; | ||
607 | ret["CurrentPermissions"] = item.CurrentPermissions.ToString(); | 611 | ret["CurrentPermissions"] = item.CurrentPermissions.ToString(); |
608 | ret["Description"] = item.Description.ToString(); | 612 | ret["Description"] = item.Description.ToString(); |
609 | ret["EveryOnePermissions"] = item.EveryOnePermissions.ToString(); | 613 | ret["EveryOnePermissions"] = item.EveryOnePermissions.ToString(); |
diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 470a4dd..3fd2fcf 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs | |||
@@ -43,44 +43,51 @@ namespace OpenSim.Services.AssetService | |||
43 | LogManager.GetLogger( | 43 | LogManager.GetLogger( |
44 | MethodBase.GetCurrentMethod().DeclaringType); | 44 | MethodBase.GetCurrentMethod().DeclaringType); |
45 | 45 | ||
46 | protected static AssetService m_RootInstance; | ||
47 | |||
46 | public AssetService(IConfigSource config) : base(config) | 48 | public AssetService(IConfigSource config) : base(config) |
47 | { | 49 | { |
48 | MainConsole.Instance.Commands.AddCommand("kfs", false, | 50 | if (m_RootInstance == null) |
49 | "show digest", | ||
50 | "show digest <ID>", | ||
51 | "Show asset digest", HandleShowDigest); | ||
52 | |||
53 | MainConsole.Instance.Commands.AddCommand("kfs", false, | ||
54 | "delete asset", | ||
55 | "delete asset <ID>", | ||
56 | "Delete asset from database", HandleDeleteAsset); | ||
57 | |||
58 | if (m_AssetLoader != null) | ||
59 | { | 51 | { |
60 | IConfig assetConfig = config.Configs["AssetService"]; | 52 | m_RootInstance = this; |
61 | if (assetConfig == null) | ||
62 | throw new Exception("No AssetService configuration"); | ||
63 | 53 | ||
64 | string loaderArgs = assetConfig.GetString("AssetLoaderArgs", | 54 | MainConsole.Instance.Commands.AddCommand("kfs", false, |
65 | String.Empty); | 55 | "show digest", |
56 | "show digest <ID>", | ||
57 | "Show asset digest", HandleShowDigest); | ||
66 | 58 | ||
67 | bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true); | 59 | MainConsole.Instance.Commands.AddCommand("kfs", false, |
60 | "delete asset", | ||
61 | "delete asset <ID>", | ||
62 | "Delete asset from database", HandleDeleteAsset); | ||
68 | 63 | ||
69 | if (assetLoaderEnabled) | 64 | if (m_AssetLoader != null) |
70 | { | 65 | { |
71 | m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs); | 66 | IConfig assetConfig = config.Configs["AssetService"]; |
72 | m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs, | 67 | if (assetConfig == null) |
73 | delegate(AssetBase a) | 68 | throw new Exception("No AssetService configuration"); |
74 | { | 69 | |
75 | Store(a); | 70 | string loaderArgs = assetConfig.GetString("AssetLoaderArgs", |
76 | }); | 71 | String.Empty); |
72 | |||
73 | bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true); | ||
74 | |||
75 | if (assetLoaderEnabled) | ||
76 | { | ||
77 | m_log.InfoFormat("[ASSET]: Loading default asset set from {0}", loaderArgs); | ||
78 | m_AssetLoader.ForEachDefaultXmlAsset(loaderArgs, | ||
79 | delegate(AssetBase a) | ||
80 | { | ||
81 | Store(a); | ||
82 | }); | ||
83 | } | ||
84 | |||
85 | m_log.Info("[ASSET SERVICE]: Local asset service enabled"); | ||
77 | } | 86 | } |
78 | |||
79 | m_log.Info("[ASSET SERVICE]: Local asset service enabled"); | ||
80 | } | 87 | } |
81 | } | 88 | } |
82 | 89 | ||
83 | public AssetBase Get(string id) | 90 | public virtual AssetBase Get(string id) |
84 | { | 91 | { |
85 | UUID assetID; | 92 | UUID assetID; |
86 | 93 | ||
@@ -93,12 +100,12 @@ namespace OpenSim.Services.AssetService | |||
93 | return m_Database.GetAsset(assetID); | 100 | return m_Database.GetAsset(assetID); |
94 | } | 101 | } |
95 | 102 | ||
96 | public AssetBase GetCached(string id) | 103 | public virtual AssetBase GetCached(string id) |
97 | { | 104 | { |
98 | return Get(id); | 105 | return Get(id); |
99 | } | 106 | } |
100 | 107 | ||
101 | public AssetMetadata GetMetadata(string id) | 108 | public virtual AssetMetadata GetMetadata(string id) |
102 | { | 109 | { |
103 | UUID assetID; | 110 | UUID assetID; |
104 | 111 | ||
@@ -112,7 +119,7 @@ namespace OpenSim.Services.AssetService | |||
112 | return null; | 119 | return null; |
113 | } | 120 | } |
114 | 121 | ||
115 | public byte[] GetData(string id) | 122 | public virtual byte[] GetData(string id) |
116 | { | 123 | { |
117 | UUID assetID; | 124 | UUID assetID; |
118 | 125 | ||
@@ -123,7 +130,7 @@ namespace OpenSim.Services.AssetService | |||
123 | return asset.Data; | 130 | return asset.Data; |
124 | } | 131 | } |
125 | 132 | ||
126 | public bool Get(string id, Object sender, AssetRetrieved handler) | 133 | public virtual bool Get(string id, Object sender, AssetRetrieved handler) |
127 | { | 134 | { |
128 | //m_log.DebugFormat("[AssetService]: Get asset async {0}", id); | 135 | //m_log.DebugFormat("[AssetService]: Get asset async {0}", id); |
129 | 136 | ||
@@ -141,7 +148,7 @@ namespace OpenSim.Services.AssetService | |||
141 | return true; | 148 | return true; |
142 | } | 149 | } |
143 | 150 | ||
144 | public string Store(AssetBase asset) | 151 | public virtual string Store(AssetBase asset) |
145 | { | 152 | { |
146 | //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID); | 153 | //m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID); |
147 | m_Database.StoreAsset(asset); | 154 | m_Database.StoreAsset(asset); |
@@ -154,7 +161,7 @@ namespace OpenSim.Services.AssetService | |||
154 | return false; | 161 | return false; |
155 | } | 162 | } |
156 | 163 | ||
157 | public bool Delete(string id) | 164 | public virtual bool Delete(string id) |
158 | { | 165 | { |
159 | m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id); | 166 | m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id); |
160 | UUID assetID; | 167 | UUID assetID; |
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs new file mode 100644 index 0000000..584ab6f --- /dev/null +++ b/OpenSim/Services/HypergridService/HGAssetService.cs | |||
@@ -0,0 +1,140 @@ | |||
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 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.IO; | ||
30 | using System.Reflection; | ||
31 | using System.Xml; | ||
32 | |||
33 | using Nini.Config; | ||
34 | using log4net; | ||
35 | using OpenMetaverse; | ||
36 | |||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Serialization.External; | ||
39 | using OpenSim.Server.Base; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenSim.Services.AssetService; | ||
42 | |||
43 | namespace OpenSim.Services.HypergridService | ||
44 | { | ||
45 | public class HGAssetService : OpenSim.Services.AssetService.AssetService, IAssetService | ||
46 | { | ||
47 | private static readonly ILog m_log = | ||
48 | LogManager.GetLogger( | ||
49 | MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | private string m_ProfileServiceURL; | ||
52 | private IUserAccountService m_UserAccountService; | ||
53 | |||
54 | private UserAccountCache m_Cache; | ||
55 | |||
56 | public HGAssetService(IConfigSource config) : base(config) | ||
57 | { | ||
58 | m_log.Debug("[HGAsset Service]: Starting"); | ||
59 | IConfig assetConfig = config.Configs["HGAssetService"]; | ||
60 | if (assetConfig == null) | ||
61 | throw new Exception("No HGAssetService configuration"); | ||
62 | |||
63 | string userAccountsDll = assetConfig.GetString("UserAccountsService", string.Empty); | ||
64 | if (userAccountsDll == string.Empty) | ||
65 | throw new Exception("Please specify UserAccountsService in HGAssetService configuration"); | ||
66 | |||
67 | Object[] args = new Object[] { config }; | ||
68 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args); | ||
69 | if (m_UserAccountService == null) | ||
70 | throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); | ||
71 | |||
72 | m_ProfileServiceURL = assetConfig.GetString("ProfileServerURI", string.Empty); | ||
73 | |||
74 | m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); | ||
75 | } | ||
76 | |||
77 | #region IAssetService overrides | ||
78 | public override AssetBase Get(string id) | ||
79 | { | ||
80 | AssetBase asset = base.Get(id); | ||
81 | |||
82 | if (asset == null) | ||
83 | return null; | ||
84 | |||
85 | if (asset.Metadata.Type == (sbyte)AssetType.Object) | ||
86 | asset.Data = AdjustIdentifiers(asset.Data); ; | ||
87 | |||
88 | AdjustIdentifiers(asset.Metadata); | ||
89 | |||
90 | return asset; | ||
91 | } | ||
92 | |||
93 | public override AssetMetadata GetMetadata(string id) | ||
94 | { | ||
95 | AssetMetadata meta = base.GetMetadata(id); | ||
96 | |||
97 | if (meta == null) | ||
98 | return null; | ||
99 | |||
100 | AdjustIdentifiers(meta); | ||
101 | |||
102 | return meta; | ||
103 | } | ||
104 | |||
105 | public override byte[] GetData(string id) | ||
106 | { | ||
107 | byte[] data = base.GetData(id); | ||
108 | |||
109 | if (data == null) | ||
110 | return null; | ||
111 | |||
112 | return AdjustIdentifiers(data); | ||
113 | } | ||
114 | |||
115 | //public virtual bool Get(string id, Object sender, AssetRetrieved handler) | ||
116 | |||
117 | public override bool Delete(string id) | ||
118 | { | ||
119 | // NOGO | ||
120 | return false; | ||
121 | } | ||
122 | |||
123 | #endregion | ||
124 | |||
125 | protected void AdjustIdentifiers(AssetMetadata meta) | ||
126 | { | ||
127 | UserAccount creator = m_Cache.GetUser(meta.CreatorID); | ||
128 | if (creator != null) | ||
129 | meta.CreatorID = m_ProfileServiceURL + "/" + meta.CreatorID + ";" + creator.FirstName + " " + creator.LastName; | ||
130 | } | ||
131 | |||
132 | protected byte[] AdjustIdentifiers(byte[] data) | ||
133 | { | ||
134 | string xml = Utils.BytesToString(data); | ||
135 | return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_ProfileServiceURL, m_Cache, UUID.Zero)); | ||
136 | } | ||
137 | |||
138 | } | ||
139 | |||
140 | } | ||
diff --git a/OpenSim/Services/InventoryService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs index d62c008..a04f0c4 100644 --- a/OpenSim/Services/InventoryService/HGInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGInventoryService.cs | |||
@@ -33,10 +33,12 @@ using Nini.Config; | |||
33 | using System.Reflection; | 33 | using System.Reflection; |
34 | using OpenSim.Services.Base; | 34 | using OpenSim.Services.Base; |
35 | using OpenSim.Services.Interfaces; | 35 | using OpenSim.Services.Interfaces; |
36 | using OpenSim.Services.InventoryService; | ||
36 | using OpenSim.Data; | 37 | using OpenSim.Data; |
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Server.Base; | ||
38 | 40 | ||
39 | namespace OpenSim.Services.InventoryService | 41 | namespace OpenSim.Services.HypergridService |
40 | { | 42 | { |
41 | public class HGInventoryService : XInventoryService, IInventoryService | 43 | public class HGInventoryService : XInventoryService, IInventoryService |
42 | { | 44 | { |
@@ -46,9 +48,16 @@ namespace OpenSim.Services.InventoryService | |||
46 | 48 | ||
47 | protected new IXInventoryData m_Database; | 49 | protected new IXInventoryData m_Database; |
48 | 50 | ||
51 | private string m_ProfileServiceURL; | ||
52 | private IUserAccountService m_UserAccountService; | ||
53 | |||
54 | private UserAccountCache m_Cache; | ||
55 | |||
49 | public HGInventoryService(IConfigSource config) | 56 | public HGInventoryService(IConfigSource config) |
50 | : base(config) | 57 | : base(config) |
51 | { | 58 | { |
59 | m_log.Debug("[HGInventory Service]: Starting"); | ||
60 | |||
52 | string dllName = String.Empty; | 61 | string dllName = String.Empty; |
53 | string connString = String.Empty; | 62 | string connString = String.Empty; |
54 | //string realm = "Inventory"; // OSG version doesn't use this | 63 | //string realm = "Inventory"; // OSG version doesn't use this |
@@ -68,12 +77,25 @@ namespace OpenSim.Services.InventoryService | |||
68 | // | 77 | // |
69 | // Try reading the [InventoryService] section, if it exists | 78 | // Try reading the [InventoryService] section, if it exists |
70 | // | 79 | // |
71 | IConfig authConfig = config.Configs["InventoryService"]; | 80 | IConfig invConfig = config.Configs["HGInventoryService"]; |
72 | if (authConfig != null) | 81 | if (invConfig != null) |
73 | { | 82 | { |
74 | dllName = authConfig.GetString("StorageProvider", dllName); | 83 | dllName = invConfig.GetString("StorageProvider", dllName); |
75 | connString = authConfig.GetString("ConnectionString", connString); | 84 | connString = invConfig.GetString("ConnectionString", connString); |
85 | |||
76 | // realm = authConfig.GetString("Realm", realm); | 86 | // realm = authConfig.GetString("Realm", realm); |
87 | string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty); | ||
88 | if (userAccountsDll == string.Empty) | ||
89 | throw new Exception("Please specify UserAccountsService in HGInventoryService configuration"); | ||
90 | |||
91 | Object[] args = new Object[] { config }; | ||
92 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args); | ||
93 | if (m_UserAccountService == null) | ||
94 | throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll)); | ||
95 | |||
96 | m_ProfileServiceURL = invConfig.GetString("ProfileServerURI", string.Empty); | ||
97 | |||
98 | m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); | ||
77 | } | 99 | } |
78 | 100 | ||
79 | // | 101 | // |
@@ -282,9 +304,18 @@ namespace OpenSim.Services.InventoryService | |||
282 | //{ | 304 | //{ |
283 | //} | 305 | //} |
284 | 306 | ||
285 | //public InventoryItemBase GetItem(InventoryItemBase item) | 307 | public override InventoryItemBase GetItem(InventoryItemBase item) |
286 | //{ | 308 | { |
287 | //} | 309 | InventoryItemBase it = base.GetItem(item); |
310 | |||
311 | UserAccount user = m_Cache.GetUser(it.CreatorId); | ||
312 | |||
313 | // Adjust the creator data | ||
314 | if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty)) | ||
315 | it.CreatorData = m_ProfileServiceURL + "/" + it.CreatorId + ";" + user.FirstName + " " + user.LastName; | ||
316 | |||
317 | return it; | ||
318 | } | ||
288 | 319 | ||
289 | //public InventoryFolderBase GetFolder(InventoryFolderBase folder) | 320 | //public InventoryFolderBase GetFolder(InventoryFolderBase folder) |
290 | //{ | 321 | //{ |
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Reflection; | ||
4 | |||
5 | using log4net; | ||
6 | using OpenMetaverse; | ||
7 | |||
8 | using OpenSim.Services.Interfaces; | ||
9 | |||
10 | namespace 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/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index fcfdd1d..f806af3 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs | |||
@@ -762,6 +762,7 @@ namespace OpenSim.Services.LLLoginService | |||
762 | if (account.ServiceURLs == null) | 762 | if (account.ServiceURLs == null) |
763 | return; | 763 | return; |
764 | 764 | ||
765 | // Old style: get the service keys from the DB | ||
765 | foreach (KeyValuePair<string, object> kvp in account.ServiceURLs) | 766 | foreach (KeyValuePair<string, object> kvp in account.ServiceURLs) |
766 | { | 767 | { |
767 | if (kvp.Value == null || (kvp.Value != null && kvp.Value.ToString() == string.Empty)) | 768 | if (kvp.Value == null || (kvp.Value != null && kvp.Value.ToString() == string.Empty)) |
@@ -773,6 +774,21 @@ namespace OpenSim.Services.LLLoginService | |||
773 | aCircuit.ServiceURLs[kvp.Key] = kvp.Value; | 774 | aCircuit.ServiceURLs[kvp.Key] = kvp.Value; |
774 | } | 775 | } |
775 | } | 776 | } |
777 | |||
778 | // New style: service keys start with SRV_; override the previous | ||
779 | string[] keys = m_LoginServerConfig.GetKeys(); | ||
780 | |||
781 | if (keys.Length > 0) | ||
782 | { | ||
783 | IEnumerable<string> serviceKeys = keys.Where(value => value.StartsWith("SRV_")); | ||
784 | foreach (string serviceKey in serviceKeys) | ||
785 | { | ||
786 | string keyName = serviceKey.Replace("SRV_", ""); | ||
787 | aCircuit.ServiceURLs[keyName] = m_LoginServerConfig.GetString(serviceKey, string.Empty); | ||
788 | m_log.DebugFormat("[LLLOGIN SERVICE]: found new key {0} {1}", keyName, aCircuit.ServiceURLs[keyName]); | ||
789 | } | ||
790 | } | ||
791 | |||
776 | } | 792 | } |
777 | 793 | ||
778 | private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, out string reason) | 794 | private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, out string reason) |