From d10b5e29bcef7335d38d4cbb590b60b7b171897b Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Thu, 14 May 2009 16:33:04 +0000
Subject: * refactor: break some of xml2 serialization out of sog
---
.../Archiver/Tests/InventoryArchiverTests.cs | 3 ++-
.../Interregion/RESTInterregionComms.cs | 3 ++-
.../CoreModules/World/Archiver/Tests/ArchiverTests.cs | 3 ++-
.../CoreModules/World/Serialiser/SerialiseObjects.cs | 3 ++-
OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 13 -------------
OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs | 4 ++--
.../Scenes/Serialization/SceneObjectSerializer.cs | 19 +++++++++++++++++++
7 files changed, 29 insertions(+), 19 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index f4c5cba..34640ae 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -44,6 +44,7 @@ using OpenSim.Framework.Communications.Osp;
using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
using OpenSim.Tests.Common.Setup;
@@ -108,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
AssetBase asset1 = new AssetBase();
asset1.FullID = asset1Id;
- asset1.Data = Encoding.ASCII.GetBytes(object1.ToXmlString2());
+ asset1.Data = Encoding.ASCII.GetBytes(SceneObjectSerializer.ToXml2Format(object1));
cm.AssetCache.AddAsset(asset1);
// Create item
diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs
index 6ad3b73..606b47c 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectors/Interregion/RESTInterregionComms.cs
@@ -276,7 +276,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Interregion
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
if (regInfo != null)
{
- return m_regionClient.DoCreateObjectCall(regInfo, sog, m_aScene.m_allowScriptCrossings);
+ return m_regionClient.DoCreateObjectCall(
+ regInfo, sog, SceneObjectSerializer.ToXml2Format(sog), m_aScene.m_allowScriptCrossings);
}
//else
// m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
index c052bda..2012ea8 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs
@@ -39,6 +39,7 @@ using OpenSim.Framework.Serialization;
using OpenSim.Region.CoreModules.World.Serialiser;
using OpenSim.Region.CoreModules.World.Terrain;
using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Setup;
@@ -242,7 +243,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests
part1Name,
Math.Round(groupPosition.X), Math.Round(groupPosition.Y), Math.Round(groupPosition.Z),
part1.UUID);
- tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, object1.ToXmlString2());
+ tar.WriteFile(ArchiveConstants.OBJECTS_PATH + object1FileName, SceneObjectSerializer.ToXml2Format(object1));
tar.Close();
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs b/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs
index ed6448f..af2e350 100644
--- a/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs
+++ b/OpenSim/Region/CoreModules/World/Serialiser/SerialiseObjects.cs
@@ -31,6 +31,7 @@ using System.IO.Compression;
using System.Text;
using System.Xml;
using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Scenes.Serialization;
namespace OpenSim.Region.CoreModules.World.Serialiser
{
@@ -86,7 +87,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser
{
if (ent is SceneObjectGroup)
{
- EntityXml.Add(((SceneObjectGroup) ent).ToXmlString2());
+ EntityXml.Add(SceneObjectSerializer.ToXml2Format((SceneObjectGroup)ent));
}
}
EntityXml.Sort();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index fd2d746..5611b03 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -583,19 +583,6 @@ namespace OpenSim.Region.Framework.Scenes
#endregion
- public string ToXmlString2()
- {
- using (StringWriter sw = new StringWriter())
- {
- using (XmlTextWriter writer = new XmlTextWriter(sw))
- {
- ToXml2(writer);
- }
-
- return sw.ToString();
- }
- }
-
public void ToXml2(XmlTextWriter writer)
{
//m_log.DebugFormat("[SOG]: Starting serialization of SOG {0} to XML2", Name);
diff --git a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
index 49fe8a4..5418139 100644
--- a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
@@ -101,7 +101,7 @@ namespace OpenSim.Region.Framework.Scenes
public static string SaveGroupToXml2(SceneObjectGroup grp)
{
- return grp.ToXmlString2();
+ return SceneObjectSerializer.ToXml2Format(grp);
}
public static SceneObjectGroup DeserializeGroupFromXml2(string xmlString)
@@ -278,7 +278,7 @@ namespace OpenSim.Region.Framework.Scenes
continue;
}
- stream.WriteLine(g.ToXmlString2());
+ stream.WriteLine(SceneObjectSerializer.ToXml2Format(g));
primCount++;
}
}
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
index aa331d9..0ec1922 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -31,6 +31,7 @@ using System.Reflection;
using System.Xml;
using log4net;
using OpenMetaverse;
+using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Framework.Scenes.Serialization
@@ -246,6 +247,24 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
writer.WriteEndElement(); // SceneObjectGroup
//m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
+ }
+
+ ///
+ /// Serialize a scene object to the 'xml2' format.
+ ///
+ ///
+ ///
+ public static string ToXml2Format(ISceneObject sceneObject)
+ {
+ using (StringWriter sw = new StringWriter())
+ {
+ using (XmlTextWriter writer = new XmlTextWriter(sw))
+ {
+ sceneObject.ToXml2(writer);
+ }
+
+ return sw.ToString();
+ }
}
}
}
--
cgit v1.1