From 567e0d032c56b2d1498216416fa6874ec77dd55b Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Fri, 8 May 2009 19:18:37 +0000
Subject: * break out 'xml2' deserialization from sog
---
.../Scenes/Serialization/SceneObjectSerializer.cs | 78 ++++++++++++++++++++--
1 file changed, 71 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs')
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index 9eac3be..aa331d9 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
///
///
///
- public static SceneObjectGroup FromOriginalXmlFormat(UUID fromUserInventoryItemID, string serialization)
+ public static SceneObjectGroup FromOriginalXmlFormat(UUID fromUserInventoryItemID, string xmlData)
{
//m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
//int time = System.Environment.TickCount;
@@ -67,12 +67,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
SceneObjectGroup sceneObject = new SceneObjectGroup();
// libomv.types changes UUID to Guid
- serialization = serialization.Replace("", "");
- serialization = serialization.Replace("", "");
+ xmlData = xmlData.Replace("", "");
+ xmlData = xmlData.Replace("", "");
// Handle Nested property
- serialization = serialization.Replace("", "");
- serialization = serialization.Replace("", "");
+ xmlData = xmlData.Replace("", "");
+ xmlData = xmlData.Replace("", "");
try
{
@@ -83,7 +83,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
int linkNum;
doc = new XmlDocument();
- doc.LoadXml(serialization);
+ doc.LoadXml(xmlData);
parts = doc.GetElementsByTagName("RootPart");
if (parts.Count == 0)
@@ -122,7 +122,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
catch (Exception e)
{
m_log.ErrorFormat(
- "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, serialization);
+ "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData);
}
//m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
@@ -131,6 +131,70 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
}
///
+ /// Deserialize a scene object from the 'xml2' format
+ ///
+ ///
+ ///
+ public static SceneObjectGroup FromXml2Format(string xmlData)
+ {
+ //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
+ //int time = System.Environment.TickCount;
+
+ SceneObjectGroup sceneObject = new SceneObjectGroup();
+
+ // libomv.types changes UUID to Guid
+ xmlData = xmlData.Replace("", "");
+ xmlData = xmlData.Replace("", "");
+
+ // Handle Nested property
+ xmlData = xmlData.Replace("", "");
+ xmlData = xmlData.Replace("", "");
+
+ try
+ {
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml(xmlData);
+
+ XmlNodeList parts = doc.GetElementsByTagName("SceneObjectPart");
+
+ // Process the root part first
+ if (parts.Count > 0)
+ {
+ StringReader sr = new StringReader(parts[0].OuterXml);
+ XmlTextReader reader = new XmlTextReader(sr);
+ sceneObject.SetRootPart(SceneObjectPart.FromXml(reader));
+ reader.Close();
+ sr.Close();
+ }
+
+ // Then deal with the rest
+ for (int i = 1; i < parts.Count; i++)
+ {
+ StringReader sr = new StringReader(parts[i].OuterXml);
+ XmlTextReader reader = new XmlTextReader(sr);
+ SceneObjectPart part = SceneObjectPart.FromXml(reader);
+ sceneObject.AddPart(part);
+ part.StoreUndoState();
+ reader.Close();
+ sr.Close();
+ }
+
+ // Script state may, or may not, exist. Not having any, is NOT
+ // ever a problem.
+
+ sceneObject.LoadScriptState(doc);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData);
+ }
+
+ //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
+
+ return sceneObject;
+ }
+
+ ///
/// Serialize a scene object to the original xml format
///
///
--
cgit v1.1