* break out 'xml2' deserialization from sog
parent
c8d44971c4
commit
567e0d032c
|
@ -41,6 +41,7 @@ using OpenSim.Framework.Communications.Clients;
|
|||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Scenes.Hypergrid;
|
||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion
|
||||
{
|
||||
|
@ -641,7 +642,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion
|
|||
SceneObjectGroup sog = null;
|
||||
try
|
||||
{
|
||||
sog = new SceneObjectGroup(sogXmlStr);
|
||||
sog = SceneObjectSerializer.FromXml2Format(sogXmlStr);
|
||||
sog.ExtraFromXmlString(extraStr);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
@ -406,78 +406,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
SetRootPart(part);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an object using serialized data in OpenSim's xml2 format.
|
||||
/// </summary>
|
||||
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("<UUID>", "<Guid>");
|
||||
xmlData = xmlData.Replace("</UUID>", "</Guid>");
|
||||
|
||||
// Handle Nested <UUID><UUID> property
|
||||
xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>");
|
||||
xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>");
|
||||
|
||||
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<parts.Count; i++)
|
||||
{
|
||||
StringReader sr = new StringReader(parts[i].OuterXml);
|
||||
XmlTextReader reader = new XmlTextReader(sr);
|
||||
SceneObjectPart part = CreatePartFromXml(reader);
|
||||
AddPart(part);
|
||||
part.StoreUndoState();
|
||||
reader.Close();
|
||||
sr.Close();
|
||||
}
|
||||
|
||||
// Script state may, or may not, exist. Not having any, is NOT
|
||||
// ever a problem.
|
||||
|
||||
LoadScriptState(doc);
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[SCENE]: Deserialization of xml failed with {0}. xml was {1}", e, xmlData);
|
||||
}
|
||||
|
||||
//m_log.DebugFormat("[SOG]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
|
||||
}
|
||||
|
||||
protected virtual SceneObjectPart CreatePartFromXml(XmlTextReader reader)
|
||||
{
|
||||
SceneObjectPart part = SceneObjectPart.FromXml(reader);
|
||||
return part;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor. This object is added to the scene later via AttachToScene()
|
||||
/// </summary>
|
||||
|
|
|
@ -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
|
|||
/// <returns>The scene object created. null if the scene object already existed</returns>
|
||||
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;
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
/// </summary>
|
||||
/// <param name="serialization"></param>
|
||||
/// <returns></returns>
|
||||
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("<UUID>", "<Guid>");
|
||||
serialization = serialization.Replace("</UUID>", "</Guid>");
|
||||
xmlData = xmlData.Replace("<UUID>", "<Guid>");
|
||||
xmlData = xmlData.Replace("</UUID>", "</Guid>");
|
||||
|
||||
// Handle Nested <UUID><UUID> property
|
||||
serialization = serialization.Replace("<Guid><Guid>", "<UUID><Guid>");
|
||||
serialization = serialization.Replace("</Guid></Guid>", "</Guid></UUID>");
|
||||
xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>");
|
||||
xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>");
|
||||
|
||||
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);
|
||||
|
@ -130,6 +130,70 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
return sceneObject;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserialize a scene object from the 'xml2' format
|
||||
/// </summary>
|
||||
/// <param name="serialization"></param>
|
||||
/// <returns></returns>
|
||||
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("<UUID>", "<Guid>");
|
||||
xmlData = xmlData.Replace("</UUID>", "</Guid>");
|
||||
|
||||
// Handle Nested <UUID><UUID> property
|
||||
xmlData = xmlData.Replace("<Guid><Guid>", "<UUID><Guid>");
|
||||
xmlData = xmlData.Replace("</Guid></Guid>", "</Guid></UUID>");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize a scene object to the original xml format
|
||||
/// </summary>
|
||||
|
|
|
@ -25,15 +25,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#region Header
|
||||
|
||||
// CMModel.cs
|
||||
// User: bongiojp
|
||||
//
|
||||
//
|
||||
|
||||
#endregion Header
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
@ -45,6 +36,7 @@ using OpenSim;
|
|||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
|
||||
using log4net;
|
||||
|
@ -211,14 +203,15 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
|
|||
|
||||
foreach (string xml in xmllist)
|
||||
{
|
||||
try{
|
||||
temp = new SceneObjectGroup(xml);
|
||||
try
|
||||
{
|
||||
temp = SceneObjectSerializer.FromXml2Format(xml);
|
||||
temp.SetScene(scene);
|
||||
foreach (SceneObjectPart part in temp.Children.Values)
|
||||
part.RegionHandle = scene.RegionInfo.RegionHandle;
|
||||
ReplacementList.Add(temp.UUID, (EntityBase)temp);
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Info("[CMMODEL]: Error while creating replacement list for rollback: " + e);
|
||||
}
|
||||
|
|
|
@ -25,15 +25,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#region Header
|
||||
|
||||
// ContentManagementEntity.cs
|
||||
// User: bongiojp
|
||||
//
|
||||
//
|
||||
|
||||
#endregion Header
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
@ -45,6 +36,7 @@ using Nini.Config;
|
|||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
|
||||
using log4net;
|
||||
|
@ -87,7 +79,7 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
|
|||
public ContentManagementEntity(string objectXML, Scene scene, bool physics)
|
||||
: base(objectXML, scene, false)
|
||||
{
|
||||
m_UnchangedEntity = new SceneObjectGroup(objectXML);
|
||||
m_UnchangedEntity = SceneObjectSerializer.FromXml2Format(objectXML);
|
||||
}
|
||||
|
||||
#endregion Constructors
|
||||
|
|
|
@ -25,16 +25,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#region Header
|
||||
|
||||
// MetaEntity.cs
|
||||
// User: bongiojp
|
||||
//
|
||||
// TODO:
|
||||
// Create a physics manager to the meta object if there isn't one or the object knows of no scene but the user wants physics enabled.
|
||||
|
||||
#endregion Header
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
@ -46,6 +36,7 @@ using Nini.Config;
|
|||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||
using OpenSim.Region.Physics.Manager;
|
||||
|
||||
using log4net;
|
||||
|
@ -98,7 +89,7 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
|
|||
/// </summary>
|
||||
public MetaEntity(string objectXML, Scene scene, bool physics)
|
||||
{
|
||||
m_Entity = new SceneObjectGroup(objectXML);
|
||||
m_Entity = SceneObjectSerializer.FromXml2Format(objectXML);
|
||||
m_Entity.SetScene(scene);
|
||||
Initialize(physics);
|
||||
}
|
||||
|
|
|
@ -25,16 +25,6 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#region Header
|
||||
|
||||
// PointMetaEntity.cs created with MonoDevelop
|
||||
// User: bongiojp at 3:03 PM 8/6/2008
|
||||
//
|
||||
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
|
||||
//
|
||||
|
||||
#endregion Header
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
|
Loading…
Reference in New Issue