aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs109
1 files changed, 56 insertions, 53 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 463ef22..4caa9cb 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -62,8 +62,20 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
62 { 62 {
63 String fixedData = ExternalRepresentationUtils.SanitizeXml(xmlData); 63 String fixedData = ExternalRepresentationUtils.SanitizeXml(xmlData);
64 using (XmlTextReader wrappedReader = new XmlTextReader(fixedData, XmlNodeType.Element, null)) 64 using (XmlTextReader wrappedReader = new XmlTextReader(fixedData, XmlNodeType.Element, null))
65 {
65 using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment })) 66 using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment }))
66 return FromOriginalXmlFormat(reader); 67 {
68 try {
69 return FromOriginalXmlFormat(reader);
70 }
71 catch (Exception e)
72 {
73 m_log.Error("[SERIALIZER]: Deserialization of xml failed ", e);
74 Util.LogFailedXML("[SERIALIZER]:", fixedData);
75 return null;
76 }
77 }
78 }
67 } 79 }
68 80
69 /// <summary> 81 /// <summary>
@@ -76,43 +88,33 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
76 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG"); 88 //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
77 //int time = System.Environment.TickCount; 89 //int time = System.Environment.TickCount;
78 90
79 SceneObjectGroup sceneObject = null; 91 int linkNum;
80 92
81 try 93 reader.ReadToFollowing("RootPart");
82 { 94 reader.ReadToFollowing("SceneObjectPart");
83 int linkNum; 95 SceneObjectGroup sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader));
96 reader.ReadToFollowing("OtherParts");
84 97
85 reader.ReadToFollowing("RootPart"); 98 if (reader.ReadToDescendant("Part"))
86 reader.ReadToFollowing("SceneObjectPart"); 99 {
87 sceneObject = new SceneObjectGroup(SceneObjectPart.FromXml(reader)); 100 do
88 reader.ReadToFollowing("OtherParts");
89
90 if (reader.ReadToDescendant("Part"))
91 { 101 {
92 do 102 if (reader.ReadToDescendant("SceneObjectPart"))
93 { 103 {
94 if (reader.ReadToDescendant("SceneObjectPart")) 104 SceneObjectPart part = SceneObjectPart.FromXml(reader);
95 { 105 linkNum = part.LinkNum;
96 SceneObjectPart part = SceneObjectPart.FromXml(reader); 106 sceneObject.AddPart(part);
97 linkNum = part.LinkNum; 107 part.LinkNum = linkNum;
98 sceneObject.AddPart(part); 108 part.TrimPermissions();
99 part.LinkNum = linkNum; 109 }
100 part.TrimPermissions(); 110 }
101 } 111 while (reader.ReadToNextSibling("Part"));
102 }
103 while (reader.ReadToNextSibling("Part"));
104 }
105
106 // Script state may, or may not, exist. Not having any, is NOT
107 // ever a problem.
108 sceneObject.LoadScriptState(reader);
109 }
110 catch (Exception e)
111 {
112 m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed. Exception {0}", e);
113 return null;
114 } 112 }
115 113
114 // Script state may, or may not, exist. Not having any, is NOT
115 // ever a problem.
116 sceneObject.LoadScriptState(reader);
117
116 return sceneObject; 118 return sceneObject;
117 } 119 }
118 120
@@ -236,7 +238,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
236 238
237 if (parts.Count == 0) 239 if (parts.Count == 0)
238 { 240 {
239 m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed: No SceneObjectPart nodes. xml was " + xmlData); 241 m_log.Error("[SERIALIZER]: Deserialization of xml failed: No SceneObjectPart nodes");
242 Util.LogFailedXML("[SERIALIZER]:", xmlData);
240 return null; 243 return null;
241 } 244 }
242 245
@@ -280,7 +283,8 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
280 } 283 }
281 catch (Exception e) 284 catch (Exception e)
282 { 285 {
283 m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData); 286 m_log.Error("[SERIALIZER]: Deserialization of xml failed ", e);
287 Util.LogFailedXML("[SERIALIZER]:", xmlData);
284 return null; 288 return null;
285 } 289 }
286 } 290 }
@@ -708,7 +712,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
708 private static void ProcessShape(SceneObjectPart obj, XmlReader reader) 712 private static void ProcessShape(SceneObjectPart obj, XmlReader reader)
709 { 713 {
710 List<string> errorNodeNames; 714 List<string> errorNodeNames;
711 obj.Shape = ReadShape(reader, "Shape", out errorNodeNames); 715 obj.Shape = ReadShape(reader, "Shape", out errorNodeNames, obj);
712 716
713 if (errorNodeNames != null) 717 if (errorNodeNames != null)
714 { 718 {
@@ -1599,18 +1603,21 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1599 1603
1600 reader.ReadStartElement("SceneObjectPart"); 1604 reader.ReadStartElement("SceneObjectPart");
1601 1605
1602 ExternalRepresentationUtils.ExecuteReadProcessors( 1606 bool errors = ExternalRepresentationUtils.ExecuteReadProcessors(
1603 obj, 1607 obj,
1604 m_SOPXmlProcessors, 1608 m_SOPXmlProcessors,
1605 reader, 1609 reader,
1606 (o, nodeName, e) 1610 (o, nodeName, e) => {
1607 => m_log.DebugFormat( 1611 m_log.Debug(string.Format("[SceneObjectSerializer]: Error while parsing element {0} in object {1} {2} ",
1608 "[SceneObjectSerializer]: Exception while parsing {0} in object {1} {2}: {3}{4}", 1612 nodeName, ((SceneObjectPart)o).Name, ((SceneObjectPart)o).UUID), e);
1609 ((SceneObjectPart)o).Name, ((SceneObjectPart)o).UUID, nodeName, e.Message, e.StackTrace)); 1613 });
1614
1615 if (errors)
1616 throw new XmlException(string.Format("Error parsing object {0} {1}", obj.Name, obj.UUID));
1610 1617
1611 reader.ReadEndElement(); // SceneObjectPart 1618 reader.ReadEndElement(); // SceneObjectPart
1612 1619
1613 //m_log.DebugFormat("[XXX]: parsed SOP {0} - {1}", obj.Name, obj.UUID); 1620 // m_log.DebugFormat("[SceneObjectSerializer]: parsed SOP {0} {1}", obj.Name, obj.UUID);
1614 return obj; 1621 return obj;
1615 } 1622 }
1616 1623
@@ -1655,7 +1662,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1655 /// <param name="name">The name of the xml element containing the shape</param> 1662 /// <param name="name">The name of the xml element containing the shape</param>
1656 /// <param name="errors">a list containing the failing node names. If no failures then null.</param> 1663 /// <param name="errors">a list containing the failing node names. If no failures then null.</param>
1657 /// <returns>The shape parsed</returns> 1664 /// <returns>The shape parsed</returns>
1658 public static PrimitiveBaseShape ReadShape(XmlReader reader, string name, out List<string> errorNodeNames) 1665 public static PrimitiveBaseShape ReadShape(XmlReader reader, string name, out List<string> errorNodeNames, SceneObjectPart obj)
1659 { 1666 {
1660 List<string> internalErrorNodeNames = null; 1667 List<string> internalErrorNodeNames = null;
1661 1668
@@ -1674,18 +1681,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
1674 shape, 1681 shape,
1675 m_ShapeXmlProcessors, 1682 m_ShapeXmlProcessors,
1676 reader, 1683 reader,
1677 (o, nodeName, e) 1684 (o, nodeName, e) => {
1678 => 1685 m_log.Debug(string.Format("[SceneObjectSerializer]: Error while parsing element {0} in Shape property of object {1} {2} ",
1679 { 1686 nodeName, obj.Name, obj.UUID), e);
1680// m_log.DebugFormat(
1681// "[SceneObjectSerializer]: Exception while parsing Shape property {0}: {1}{2}",
1682// nodeName, e.Message, e.StackTrace);
1683 if (internalErrorNodeNames == null)
1684 internalErrorNodeNames = new List<string>();
1685 1687
1686 internalErrorNodeNames.Add(nodeName); 1688 if (internalErrorNodeNames == null)
1687 } 1689 internalErrorNodeNames = new List<string>();
1688 ); 1690 internalErrorNodeNames.Add(nodeName);
1691 });
1689 1692
1690 reader.ReadEndElement(); // Shape 1693 reader.ReadEndElement(); // Shape
1691 1694