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
---
.../Region/Framework/Scenes/SceneObjectGroup.cs | 72 --------------------
OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs | 6 +-
.../Scenes/Serialization/SceneObjectSerializer.cs | 78 ++++++++++++++++++++--
3 files changed, 74 insertions(+), 82 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index cceb444..fd2d746 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -407,78 +407,6 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Create an object using serialized data in OpenSim's xml2 format.
- ///
- public SceneObjectGroup(string xmlData)
- {
- SetFromXml(xmlData);
- }
-
- protected void SetFromXml(string xmlData)
- {
-
- //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
- //int time = System.Environment.TickCount;
-
- // 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);
- SetRootPart(CreatePartFromXml(reader));
- reader.Close();
- sr.Close();
- }
-
- // Then deal with the rest
- for (int i=1; i
/// Constructor. This object is added to the scene later via AttachToScene()
///
public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
diff --git a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
index 212ca72..49fe8a4 100644
--- a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
@@ -125,14 +125,14 @@ namespace OpenSim.Region.Framework.Scenes
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
{
// There is only ever one prim. This oddity should be removeable post 0.5.9
- return new SceneObjectGroup(aPrimNode.OuterXml);
+ return SceneObjectSerializer.FromXml2Format(aPrimNode.OuterXml);
}
return null;
}
else
{
- return new SceneObjectGroup(rootNode.OuterXml);
+ return SceneObjectSerializer.FromXml2Format(rootNode.OuterXml);
}
}
@@ -193,7 +193,7 @@ namespace OpenSim.Region.Framework.Scenes
/// The scene object created. null if the scene object already existed
protected static SceneObjectGroup CreatePrimFromXml2(Scene scene, string xmlData)
{
- SceneObjectGroup obj = new SceneObjectGroup(xmlData);
+ SceneObjectGroup obj = SceneObjectSerializer.FromXml2Format(xmlData);
if (scene.AddRestoredSceneObject(obj, true, false))
return obj;
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