aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDiva Canto2015-05-05 20:59:09 -0700
committerDiva Canto2015-05-05 20:59:09 -0700
commit1abbad71b4603245e5481c11e3ce55f57b64935f (patch)
tree694b750495216edbb16a2822a546e7617eff2c66 /OpenSim
parentRevert "Patch llCastRay fully-simplified to V2." for further review. (diff)
downloadopensim-SC-1abbad71b4603245e5481c11e3ce55f57b64935f.zip
opensim-SC-1abbad71b4603245e5481c11e3ce55f57b64935f.tar.gz
opensim-SC-1abbad71b4603245e5481c11e3ce55f57b64935f.tar.bz2
opensim-SC-1abbad71b4603245e5481c11e3ce55f57b64935f.tar.xz
Refactored some code that is used in two different dlls related to SOP rewriting. Also added some unit tests that relate to mantis #7514
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs184
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs209
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectSerializationTests.cs136
-rw-r--r--OpenSim/Services/HypergridService/HGAssetService.cs2
5 files changed, 323 insertions, 210 deletions
diff --git a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
index 6debf65..64de18b 100644
--- a/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
+++ b/OpenSim/Framework/Serialization/External/ExternalRepresentationUtils.cs
@@ -125,7 +125,8 @@ namespace OpenSim.Framework.Serialization.External
125 /// <param name="userService">The service for retrieving user account information</param> 125 /// <param name="userService">The service for retrieving user account information</param>
126 /// <param name="scopeID">The scope of the user account information (Grid ID)</param> 126 /// <param name="scopeID">The scope of the user account information (Grid ID)</param>
127 /// <returns>The SceneObjectPart represented in XML2</returns> 127 /// <returns>The SceneObjectPart represented in XML2</returns>
128 public static string RewriteSOP(string xml, string homeURL, IUserAccountService userService, UUID scopeID) 128 [Obsolete("This method is deprecated. Use RewriteSOP instead.")]
129 public static string RewriteSOP_Old(string xml, string homeURL, IUserAccountService userService, UUID scopeID)
129 { 130 {
130 if (xml == string.Empty || homeURL == string.Empty || userService == null) 131 if (xml == string.Empty || homeURL == string.Empty || userService == null)
131 return xml; 132 return xml;
@@ -173,6 +174,187 @@ namespace OpenSim.Framework.Serialization.External
173 } 174 }
174 } 175 }
175 176
177 /// <summary>
178 /// Takes a XML representation of a SceneObjectPart and returns another XML representation
179 /// with creator data added to it.
180 /// </summary>
181 /// <param name="xml">The SceneObjectPart represented in XML2</param>
182 /// <param name="sceneName">An identifier for the component that's calling this function</param>
183 /// <param name="homeURL">The URL of the user agents service (home) for the creator</param>
184 /// <param name="userService">The service for retrieving user account information</param>
185 /// <param name="scopeID">The scope of the user account information (Grid ID)</param>
186 /// <returns>The SceneObjectPart represented in XML2</returns>
187 public static string RewriteSOP(string xmlData, string sceneName, string homeURL, IUserAccountService userService, UUID scopeID)
188 {
189 // Console.WriteLine("Input XML [{0}]", xmlData);
190 if (xmlData == string.Empty || homeURL == string.Empty || userService == null)
191 return xmlData;
192
193 using (StringWriter sw = new StringWriter())
194 using (XmlTextWriter writer = new XmlTextWriter(sw))
195 using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null))
196 using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment }))
197 {
198 TransformXml(reader, writer, sceneName, homeURL, userService, scopeID);
199
200 // Console.WriteLine("Output: [{0}]", sw.ToString());
201
202 return sw.ToString();
203 }
204 }
205
206 protected static void TransformXml(XmlReader reader, XmlWriter writer, string sceneName, string homeURI, IUserAccountService userAccountService, UUID scopeID)
207 {
208 // m_log.DebugFormat("[HG ASSET MAPPER]: Transforming XML");
209
210 int sopDepth = -1;
211 UserAccount creator = null;
212 bool hasCreatorData = false;
213
214 while (reader.Read())
215 {
216 // Console.WriteLine("Depth: {0}, name {1}", reader.Depth, reader.Name);
217
218 switch (reader.NodeType)
219 {
220 case XmlNodeType.Attribute:
221 // Console.WriteLine("FOUND ATTRIBUTE {0}", reader.Name);
222 writer.WriteAttributeString(reader.Name, reader.Value);
223 break;
224
225 case XmlNodeType.CDATA:
226 writer.WriteCData(reader.Value);
227 break;
228
229 case XmlNodeType.Comment:
230 writer.WriteComment(reader.Value);
231 break;
232
233 case XmlNodeType.DocumentType:
234 writer.WriteDocType(reader.Name, reader.Value, null, null);
235 break;
236
237 case XmlNodeType.Element:
238 // m_log.DebugFormat("Depth {0} at element {1}", reader.Depth, reader.Name);
239
240 writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
241
242 if (reader.HasAttributes)
243 {
244 while (reader.MoveToNextAttribute())
245 writer.WriteAttributeString(reader.Name, reader.Value);
246
247 reader.MoveToElement();
248 }
249
250 if (reader.LocalName == "SceneObjectPart")
251 {
252 if (sopDepth < 0)
253 {
254 sopDepth = reader.Depth;
255 // m_log.DebugFormat("[HG ASSET MAPPER]: Set sopDepth to {0}", sopDepth);
256 }
257 }
258 else
259 {
260 if (sopDepth >= 0 && reader.Depth == sopDepth + 1)
261 {
262 if (reader.Name == "CreatorID")
263 {
264 reader.Read();
265 if (reader.NodeType == XmlNodeType.Element && reader.Name == "Guid" || reader.Name == "UUID")
266 {
267 reader.Read();
268
269 if (reader.NodeType == XmlNodeType.Text)
270 {
271 UUID uuid = UUID.Zero;
272 UUID.TryParse(reader.Value, out uuid);
273 creator = userAccountService.GetUserAccount(scopeID, uuid);
274 writer.WriteElementString("UUID", reader.Value);
275 reader.Read();
276 }
277 else
278 {
279 // If we unexpected run across mixed content in this node, still carry on
280 // transforming the subtree (this replicates earlier behaviour).
281 TransformXml(reader, writer, sceneName, homeURI, userAccountService, scopeID);
282 }
283 }
284 else
285 {
286 // If we unexpected run across mixed content in this node, still carry on
287 // transforming the subtree (this replicates earlier behaviour).
288 TransformXml(reader, writer, sceneName, homeURI, userAccountService, scopeID);
289 }
290 }
291 else if (reader.Name == "CreatorData")
292 {
293 reader.Read();
294 if (reader.NodeType == XmlNodeType.Text)
295 {
296 hasCreatorData = true;
297 writer.WriteString(reader.Value);
298 }
299 else
300 {
301 // If we unexpected run across mixed content in this node, still carry on
302 // transforming the subtree (this replicates earlier behaviour).
303 TransformXml(reader, writer, sceneName, homeURI, userAccountService, scopeID);
304 }
305 }
306 }
307 }
308
309 if (reader.IsEmptyElement)
310 {
311 // m_log.DebugFormat("[HG ASSET MAPPER]: Writing end for empty element {0}", reader.Name);
312 writer.WriteEndElement();
313 }
314
315 break;
316
317 case XmlNodeType.EndElement:
318 // m_log.DebugFormat("Depth {0} at EndElement", reader.Depth);
319 if (sopDepth == reader.Depth)
320 {
321 if (!hasCreatorData && creator != null)
322 writer.WriteElementString(reader.Prefix, "CreatorData", reader.NamespaceURI, string.Format("{0};{1} {2}", homeURI, creator.FirstName, creator.LastName));
323
324 // m_log.DebugFormat("[HG ASSET MAPPER]: Reset sopDepth");
325 sopDepth = -1;
326 creator = null;
327 hasCreatorData = false;
328 }
329 writer.WriteEndElement();
330 break;
331
332 case XmlNodeType.EntityReference:
333 writer.WriteEntityRef(reader.Name);
334 break;
335
336 case XmlNodeType.ProcessingInstruction:
337 writer.WriteProcessingInstruction(reader.Name, reader.Value);
338 break;
339
340 case XmlNodeType.Text:
341 writer.WriteString(reader.Value);
342 break;
343
344 case XmlNodeType.XmlDeclaration:
345 // For various reasons, not all serializations have xml declarations (or consistent ones)
346 // and as it's embedded inside a byte stream we don't need it anyway, so ignore.
347 break;
348
349 default:
350 m_log.WarnFormat(
351 "[HG ASSET MAPPER]: Unrecognized node {0} in asset XML transform in {1}",
352 reader.NodeType, sceneName);
353 break;
354 }
355 }
356 }
357
176 public static string CalcCreatorData(string homeURL, string name) 358 public static string CalcCreatorData(string homeURL, string name)
177 { 359 {
178 return homeURL + ";" + name; 360 return homeURL + ";" + name;
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
index c2010b1..f54298c 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs
@@ -35,6 +35,7 @@ using System.Xml;
35using log4net; 35using log4net;
36using OpenMetaverse; 36using OpenMetaverse;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Serialization.External;
38 39
39using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
40using OpenSim.Region.Framework.Scenes.Serialization; 41using OpenSim.Region.Framework.Scenes.Serialization;
@@ -189,217 +190,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
189 return Utils.StringToBytes(RewriteSOP(xml)); 190 return Utils.StringToBytes(RewriteSOP(xml));
190 } 191 }
191 192
192 protected void TransformXml(XmlReader reader, XmlWriter writer)
193 {
194// m_log.DebugFormat("[HG ASSET MAPPER]: Transforming XML");
195
196 int sopDepth = -1;
197 UserAccount creator = null;
198 bool hasCreatorData = false;
199
200 while (reader.Read())
201 {
202// Console.WriteLine("Depth: {0}, name {1}", reader.Depth, reader.Name);
203
204 switch (reader.NodeType)
205 {
206 case XmlNodeType.Attribute:
207// Console.WriteLine("FOUND ATTRIBUTE {0}", reader.Name);
208 writer.WriteAttributeString(reader.Name, reader.Value);
209 break;
210
211 case XmlNodeType.CDATA:
212 writer.WriteCData(reader.Value);
213 break;
214
215 case XmlNodeType.Comment:
216 writer.WriteComment(reader.Value);
217 break;
218
219 case XmlNodeType.DocumentType:
220 writer.WriteDocType(reader.Name, reader.Value, null, null);
221 break;
222
223 case XmlNodeType.Element:
224// m_log.DebugFormat("Depth {0} at element {1}", reader.Depth, reader.Name);
225
226 writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
227
228 if (reader.HasAttributes)
229 {
230 while (reader.MoveToNextAttribute())
231 writer.WriteAttributeString(reader.Name, reader.Value);
232
233 reader.MoveToElement();
234 }
235
236 if (reader.LocalName == "SceneObjectPart")
237 {
238 if (sopDepth < 0)
239 {
240 sopDepth = reader.Depth;
241// m_log.DebugFormat("[HG ASSET MAPPER]: Set sopDepth to {0}", sopDepth);
242 }
243 }
244 else
245 {
246 if (sopDepth >= 0 && reader.Depth == sopDepth + 1)
247 {
248 if (reader.Name == "CreatorID")
249 {
250 reader.Read();
251 if (reader.NodeType == XmlNodeType.Element && reader.Name == "Guid" || reader.Name == "UUID")
252 {
253 reader.Read();
254
255 if (reader.NodeType == XmlNodeType.Text)
256 {
257 UUID uuid = UUID.Zero;
258 UUID.TryParse(reader.Value, out uuid);
259 creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
260 writer.WriteElementString("UUID", reader.Value);
261 reader.Read();
262 }
263 else
264 {
265 // If we unexpected run across mixed content in this node, still carry on
266 // transforming the subtree (this replicates earlier behaviour).
267 TransformXml(reader, writer);
268 }
269 }
270 else
271 {
272 // If we unexpected run across mixed content in this node, still carry on
273 // transforming the subtree (this replicates earlier behaviour).
274 TransformXml(reader, writer);
275 }
276 }
277 else if (reader.Name == "CreatorData")
278 {
279 reader.Read();
280 if (reader.NodeType == XmlNodeType.Text)
281 {
282 hasCreatorData = true;
283 writer.WriteString(reader.Value);
284 }
285 else
286 {
287 // If we unexpected run across mixed content in this node, still carry on
288 // transforming the subtree (this replicates earlier behaviour).
289 TransformXml(reader, writer);
290 }
291 }
292 }
293 }
294
295 if (reader.IsEmptyElement)
296 {
297// m_log.DebugFormat("[HG ASSET MAPPER]: Writing end for empty element {0}", reader.Name);
298 writer.WriteEndElement();
299 }
300
301 break;
302
303 case XmlNodeType.EndElement:
304// m_log.DebugFormat("Depth {0} at EndElement", reader.Depth);
305 if (sopDepth == reader.Depth)
306 {
307 if (!hasCreatorData && creator != null)
308 writer.WriteElementString(reader.Prefix, "CreatorData", reader.NamespaceURI, string.Format("{0};{1} {2}", m_HomeURI, creator.FirstName, creator.LastName));
309
310// m_log.DebugFormat("[HG ASSET MAPPER]: Reset sopDepth");
311 sopDepth = -1;
312 creator = null;
313 hasCreatorData = false;
314 }
315 writer.WriteEndElement();
316 break;
317
318 case XmlNodeType.EntityReference:
319 writer.WriteEntityRef(reader.Name);
320 break;
321
322 case XmlNodeType.ProcessingInstruction:
323 writer.WriteProcessingInstruction(reader.Name, reader.Value);
324 break;
325
326 case XmlNodeType.Text:
327 writer.WriteString(reader.Value);
328 break;
329
330 case XmlNodeType.XmlDeclaration:
331 // For various reasons, not all serializations have xml declarations (or consistent ones)
332 // and as it's embedded inside a byte stream we don't need it anyway, so ignore.
333 break;
334
335 default:
336 m_log.WarnFormat(
337 "[HG ASSET MAPPER]: Unrecognized node {0} in asset XML transform in {1}",
338 reader.NodeType, m_scene.Name);
339 break;
340 }
341 }
342 }
343
344 protected string RewriteSOP(string xmlData) 193 protected string RewriteSOP(string xmlData)
345 { 194 {
346// Console.WriteLine("Input XML [{0}]", xmlData); 195// Console.WriteLine("Input XML [{0}]", xmlData);
196 return ExternalRepresentationUtils.RewriteSOP(xmlData, m_scene.Name, m_HomeURI, m_scene.UserAccountService, m_scene.RegionInfo.ScopeID);
347 197
348 using (StringWriter sw = new StringWriter())
349 using (XmlTextWriter writer = new XmlTextWriter(sw))
350 using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null))
351 using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment }))
352 {
353 TransformXml(reader, writer);
354
355// Console.WriteLine("Output: [{0}]", sw.ToString());
356
357 return sw.ToString();
358 }
359
360 // We are now taking the more complex streaming approach above because some assets can be very large
361 // and can trigger higher CPU use or possibly memory problems.
362// XmlDocument doc = new XmlDocument();
363// doc.LoadXml(xml);
364// XmlNodeList sops = doc.GetElementsByTagName("SceneObjectPart");
365//
366// foreach (XmlNode sop in sops)
367// {
368// UserAccount creator = null;
369// bool hasCreatorData = false;
370// XmlNodeList nodes = sop.ChildNodes;
371// foreach (XmlNode node in nodes)
372// {
373// if (node.Name == "CreatorID")
374// {
375// UUID uuid = UUID.Zero;
376// UUID.TryParse(node.InnerText, out uuid);
377// creator = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, uuid);
378// }
379// if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
380// hasCreatorData = true;
381//
382// //if (node.Name == "OwnerID")
383// //{
384// // UserAccount owner = GetUser(node.InnerText);
385// // if (owner != null)
386// // node.InnerText = m_ProfileServiceURL + "/" + node.InnerText + "/" + owner.FirstName + " " + owner.LastName;
387// //}
388// }
389//
390// if (!hasCreatorData && creator != null)
391// {
392// XmlElement creatorData = doc.CreateElement("CreatorData");
393// creatorData.InnerText = m_HomeURI + ";" + creator.FirstName + " " + creator.LastName;
394// sop.AppendChild(creatorData);
395// }
396// }
397//
398// using (StringWriter wr = new StringWriter())
399// {
400// doc.Save(wr);
401// return wr.ToString();
402// }
403 } 198 }
404 199
405 // TODO: unused 200 // TODO: unused
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
index 4d99a6e..db66c83 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs
@@ -335,7 +335,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
335 if (asset.Type == (sbyte)AssetType.Object && asset.Data != null && m_options.ContainsKey("home")) 335 if (asset.Type == (sbyte)AssetType.Object && asset.Data != null && m_options.ContainsKey("home"))
336 { 336 {
337 //m_log.DebugFormat("[ARCHIVER]: Rewriting object data for {0}", asset.ID); 337 //m_log.DebugFormat("[ARCHIVER]: Rewriting object data for {0}", asset.ID);
338 string xml = ExternalRepresentationUtils.RewriteSOP(Utils.BytesToString(asset.Data), m_options["home"].ToString(), m_userAccountService, m_scopeID); 338 string xml = ExternalRepresentationUtils.RewriteSOP(Utils.BytesToString(asset.Data), string.Empty, m_options["home"].ToString(), m_userAccountService, m_scopeID);
339 asset.Data = Utils.StringToBytes(xml); 339 asset.Data = Utils.StringToBytes(xml);
340 } 340 }
341 return asset; 341 return asset;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSerializationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSerializationTests.cs
new file mode 100644
index 0000000..927d8e8
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSerializationTests.cs
@@ -0,0 +1,136 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using System.Xml;
33using System.Linq;
34using Nini.Config;
35using NUnit.Framework;
36using OpenMetaverse;
37using OpenSim.Framework;
38using OpenSim.Framework.Serialization.External;
39using OpenSim.Framework.Communications;
40using OpenSim.Region.Framework.Scenes;
41using OpenSim.Region.Framework.Scenes.Serialization;
42using OpenSim.Services.Interfaces;
43using OpenSim.Tests.Common;
44
45namespace OpenSim.Region.Framework.Scenes.Tests
46{
47 /// <summary>
48 /// Basic scene object serialization tests.
49 /// </summary>
50 [TestFixture]
51 public class SceneObjectSerializationTests : OpenSimTestCase
52 {
53
54 /// <summary>
55 /// Serialize and deserialize.
56 /// </summary>
57 [Test]
58 public void TestSerialDeserial()
59 {
60 TestHelpers.InMethod();
61
62 Scene scene = new SceneHelpers().SetupScene();
63 int partsToTestCount = 3;
64
65 SceneObjectGroup so
66 = SceneHelpers.CreateSceneObject(partsToTestCount, TestHelpers.ParseTail(0x1), "obj1", 0x10);
67 SceneObjectPart[] parts = so.Parts;
68 so.Name = "obj1";
69 so.Description = "xpto";
70
71 string xml = SceneObjectSerializer.ToXml2Format(so);
72 Assert.That(!string.IsNullOrEmpty(xml), "SOG serialization resulted in empty or null string");
73
74 XmlDocument doc = new XmlDocument();
75 doc.LoadXml(xml);
76 XmlNodeList nodes = doc.GetElementsByTagName("SceneObjectPart");
77 Assert.That(nodes.Count, Is.EqualTo(3), "SOG serialization resulted in wrong number of SOPs");
78
79 SceneObjectGroup so2 = SceneObjectSerializer.FromXml2Format(xml);
80 Assert.IsNotNull(so2, "SOG deserialization resulted in null object");
81 Assert.That(so2.Name == so.Name, "Name of deserialized object does not match original name");
82 Assert.That(so2.Description == so.Description, "Description of deserialized object does not match original name");
83 }
84
85 /// <summary>
86 /// This checks for a bug reported in mantis #7514
87 /// </summary>
88 [Test]
89 public void TestNamespaceAttribute()
90 {
91 TestHelpers.InMethod();
92
93 Scene scene = new SceneHelpers().SetupScene();
94 UserAccount account = new UserAccount(UUID.Zero, UUID.Random(), "Test", "User", string.Empty);
95 scene.UserAccountService.StoreUserAccount(account);
96 int partsToTestCount = 1;
97
98 SceneObjectGroup so
99 = SceneHelpers.CreateSceneObject(partsToTestCount, TestHelpers.ParseTail(0x1), "obj1", 0x10);
100 SceneObjectPart[] parts = so.Parts;
101 so.Name = "obj1";
102 so.Description = "xpto";
103 so.OwnerID = account.PrincipalID;
104 so.RootPart.CreatorID = so.OwnerID;
105
106 string xml = SceneObjectSerializer.ToXml2Format(so);
107 Assert.That(!string.IsNullOrEmpty(xml), "SOG serialization resulted in empty or null string");
108
109 xml = ExternalRepresentationUtils.RewriteSOP(xml, "Test Scene", "http://localhost", scene.UserAccountService, UUID.Zero);
110 //Console.WriteLine(xml);
111
112 XmlDocument doc = new XmlDocument();
113 doc.LoadXml(xml);
114
115 XmlNodeList nodes = doc.GetElementsByTagName("SceneObjectPart");
116 Assert.That(nodes.Count, Is.GreaterThan(0), "SOG serialization resulted in no SOPs");
117 foreach (XmlAttribute a in nodes[0].Attributes)
118 {
119 int count = a.Name.Count(c => c == ':');
120 Assert.That(count, Is.EqualTo(1), "Cannot have multiple ':' in attribute name in SOP");
121 }
122 nodes = doc.GetElementsByTagName("CreatorData");
123 Assert.That(nodes.Count, Is.GreaterThan(0), "SOG serialization resulted in no CreatorData");
124 foreach (XmlAttribute a in nodes[0].Attributes)
125 {
126 int count = a.Name.Count(c => c == ':');
127 Assert.That(count, Is.EqualTo(1), "Cannot have multiple ':' in attribute name in CreatorData");
128 }
129
130 SceneObjectGroup so2 = SceneObjectSerializer.FromXml2Format(xml);
131 Assert.IsNotNull(so2, "SOG deserialization resulted in null object");
132 Assert.AreNotEqual(so.RootPart.CreatorIdentification, so2.RootPart.CreatorIdentification, "RewriteSOP failed to transform CreatorData.");
133 Assert.That(so2.RootPart.CreatorIdentification.Contains("http://"), "RewriteSOP failed to add the homeURL to CreatorData");
134 }
135 }
136} \ No newline at end of file
diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs
index b57f8d8..a829932 100644
--- a/OpenSim/Services/HypergridService/HGAssetService.cs
+++ b/OpenSim/Services/HypergridService/HGAssetService.cs
@@ -163,7 +163,7 @@ namespace OpenSim.Services.HypergridService
163 protected byte[] AdjustIdentifiers(byte[] data) 163 protected byte[] AdjustIdentifiers(byte[] data)
164 { 164 {
165 string xml = Utils.BytesToString(data); 165 string xml = Utils.BytesToString(data);
166 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, m_HomeURL, m_Cache, UUID.Zero)); 166 return Utils.StringToBytes(ExternalRepresentationUtils.RewriteSOP(xml, "HGAssetService", m_HomeURL, m_Cache, UUID.Zero));
167 } 167 }
168 168
169 } 169 }