diff options
author | Diva Canto | 2010-11-29 08:43:33 -0800 |
---|---|---|
committer | Diva Canto | 2010-11-29 08:43:33 -0800 |
commit | f86c438653fc3c8356a8f0c43a055b1928183f02 (patch) | |
tree | b8ad05db04efde6385eeaed48dcbe4e896133ad5 /OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs | |
parent | Changed the parser for InventoryItem deserialization. Moved some utility func... (diff) | |
download | opensim-SC-f86c438653fc3c8356a8f0c43a055b1928183f02.zip opensim-SC-f86c438653fc3c8356a8f0c43a055b1928183f02.tar.gz opensim-SC-f86c438653fc3c8356a8f0c43a055b1928183f02.tar.bz2 opensim-SC-f86c438653fc3c8356a8f0c43a055b1928183f02.tar.xz |
Preservation of creator information now also working in IARs. Cleaned up usage help. Moved Osp around, deleted unnecessary OspInventoryWrapperPlugin, added manipulation of SOP's xml representation in a generic ExternalRepresentationUtils function.
Diffstat (limited to 'OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs')
-rw-r--r-- | OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs index df9af32..d5e84c7 100644 --- a/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs +++ b/OpenSim/Framework/Serialization/External/UserInventoryItemSerializer.cs | |||
@@ -35,6 +35,7 @@ using System.Xml; | |||
35 | using log4net; | 35 | using log4net; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Services.Interfaces; | ||
38 | 39 | ||
39 | namespace OpenSim.Framework.Serialization.External | 40 | namespace OpenSim.Framework.Serialization.External |
40 | { | 41 | { |
@@ -56,6 +57,8 @@ namespace OpenSim.Framework.Serialization.External | |||
56 | m_InventoryItemXmlProcessors.Add("ID", ProcessID); | 57 | m_InventoryItemXmlProcessors.Add("ID", ProcessID); |
57 | m_InventoryItemXmlProcessors.Add("InvType", ProcessInvType); | 58 | m_InventoryItemXmlProcessors.Add("InvType", ProcessInvType); |
58 | m_InventoryItemXmlProcessors.Add("CreatorUUID", ProcessCreatorUUID); | 59 | m_InventoryItemXmlProcessors.Add("CreatorUUID", ProcessCreatorUUID); |
60 | m_InventoryItemXmlProcessors.Add("CreatorID", ProcessCreatorID); | ||
61 | m_InventoryItemXmlProcessors.Add("CreatorData", ProcessCreatorData); | ||
59 | m_InventoryItemXmlProcessors.Add("CreationDate", ProcessCreationDate); | 62 | m_InventoryItemXmlProcessors.Add("CreationDate", ProcessCreationDate); |
60 | m_InventoryItemXmlProcessors.Add("Owner", ProcessOwner); | 63 | m_InventoryItemXmlProcessors.Add("Owner", ProcessOwner); |
61 | m_InventoryItemXmlProcessors.Add("Description", ProcessDescription); | 64 | m_InventoryItemXmlProcessors.Add("Description", ProcessDescription); |
@@ -94,6 +97,12 @@ namespace OpenSim.Framework.Serialization.External | |||
94 | item.CreatorId = reader.ReadElementContentAsString("CreatorUUID", String.Empty); | 97 | item.CreatorId = reader.ReadElementContentAsString("CreatorUUID", String.Empty); |
95 | } | 98 | } |
96 | 99 | ||
100 | private static void ProcessCreatorID(InventoryItemBase item, XmlTextReader reader) | ||
101 | { | ||
102 | // when it exists, this overrides the previous | ||
103 | item.CreatorId = reader.ReadElementContentAsString("CreatorID", String.Empty); | ||
104 | } | ||
105 | |||
97 | private static void ProcessCreationDate(InventoryItemBase item, XmlTextReader reader) | 106 | private static void ProcessCreationDate(InventoryItemBase item, XmlTextReader reader) |
98 | { | 107 | { |
99 | item.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty); | 108 | item.CreationDate = reader.ReadElementContentAsInt("CreationDate", String.Empty); |
@@ -161,12 +170,12 @@ namespace OpenSim.Framework.Serialization.External | |||
161 | 170 | ||
162 | private static void ProcessGroupOwned(InventoryItemBase item, XmlTextReader reader) | 171 | private static void ProcessGroupOwned(InventoryItemBase item, XmlTextReader reader) |
163 | { | 172 | { |
164 | //item.GroupOwned = reader.ReadElementContentAsBoolean("GroupOwned", String.Empty); | 173 | item.GroupOwned = Util.ReadBoolean(reader); |
165 | // We don't do that, because ReadElementContentAsBoolean assumes lower case strings, | 174 | } |
166 | // and they may not be lower case | 175 | |
167 | reader.ReadStartElement(); // GroupOwned | 176 | private static void ProcessCreatorData(InventoryItemBase item, XmlTextReader reader) |
168 | item.GroupOwned = Boolean.Parse(reader.ReadContentAsString().ToLower()); | 177 | { |
169 | reader.ReadEndElement(); | 178 | item.CreatorData = reader.ReadElementContentAsString("CreatorData", String.Empty); |
170 | } | 179 | } |
171 | 180 | ||
172 | #endregion | 181 | #endregion |
@@ -231,7 +240,7 @@ namespace OpenSim.Framework.Serialization.External | |||
231 | 240 | ||
232 | } | 241 | } |
233 | 242 | ||
234 | public static string Serialize(InventoryItemBase inventoryItem) | 243 | public static string Serialize(InventoryItemBase inventoryItem, Dictionary<string, object> options, IUserAccountService userAccountService) |
235 | { | 244 | { |
236 | StringWriter sw = new StringWriter(); | 245 | StringWriter sw = new StringWriter(); |
237 | XmlTextWriter writer = new XmlTextWriter(sw); | 246 | XmlTextWriter writer = new XmlTextWriter(sw); |
@@ -250,7 +259,7 @@ namespace OpenSim.Framework.Serialization.External | |||
250 | writer.WriteString(inventoryItem.InvType.ToString()); | 259 | writer.WriteString(inventoryItem.InvType.ToString()); |
251 | writer.WriteEndElement(); | 260 | writer.WriteEndElement(); |
252 | writer.WriteStartElement("CreatorUUID"); | 261 | writer.WriteStartElement("CreatorUUID"); |
253 | writer.WriteString(inventoryItem.CreatorId); | 262 | writer.WriteString(OspResolver.MakeOspa(inventoryItem.CreatorIdAsUuid, userAccountService)); |
254 | writer.WriteEndElement(); | 263 | writer.WriteEndElement(); |
255 | writer.WriteStartElement("CreationDate"); | 264 | writer.WriteStartElement("CreationDate"); |
256 | writer.WriteString(inventoryItem.CreationDate.ToString()); | 265 | writer.WriteString(inventoryItem.CreationDate.ToString()); |
@@ -294,6 +303,20 @@ namespace OpenSim.Framework.Serialization.External | |||
294 | writer.WriteStartElement("GroupOwned"); | 303 | writer.WriteStartElement("GroupOwned"); |
295 | writer.WriteString(inventoryItem.GroupOwned.ToString()); | 304 | writer.WriteString(inventoryItem.GroupOwned.ToString()); |
296 | writer.WriteEndElement(); | 305 | writer.WriteEndElement(); |
306 | if (inventoryItem.CreatorData != null && inventoryItem.CreatorData != string.Empty) | ||
307 | writer.WriteElementString("CreatorData", inventoryItem.CreatorData); | ||
308 | else if (options.ContainsKey("profile")) | ||
309 | { | ||
310 | if (userAccountService != null) | ||
311 | { | ||
312 | UserAccount account = userAccountService.GetUserAccount(UUID.Zero, inventoryItem.CreatorIdAsUuid); | ||
313 | if (account != null) | ||
314 | { | ||
315 | writer.WriteElementString("CreatorData", (string)options["profile"] + "/" + inventoryItem.CreatorIdAsUuid + ";" + account.FirstName + " " + account.LastName); | ||
316 | } | ||
317 | writer.WriteElementString("CreatorID", inventoryItem.CreatorId); | ||
318 | } | ||
319 | } | ||
297 | 320 | ||
298 | writer.WriteEndElement(); | 321 | writer.WriteEndElement(); |
299 | 322 | ||