diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index 1186beefb2..339950435c 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -34,6 +34,7 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Communications.Clients;
+using OpenSim.Region.Framework.Scenes.Serialization;
//using HyperGrid.Framework;
//using OpenSim.Region.Communications.Hypergrid;
@@ -254,13 +255,12 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
if ((asset != null) && ((AssetType)asset.Type == AssetType.Object))
{
string ass_str = Utils.BytesToString(asset.Data);
- SceneObjectGroup sog = new SceneObjectGroup(ass_str, true);
+ SceneObjectGroup sog = SceneObjectSerializer.DeserializeOriginalXmlFormat(ass_str);
SniffTextureUUIDs(uuids, sog);
// We need to sniff further...
SniffTaskInventoryUUIDs(uuids, sog);
-
}
return uuids;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index bebf234817..f3d5a7c8c6 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -37,6 +37,7 @@ using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Region.Framework;
using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Region.Framework.Scenes.Serialization;
namespace OpenSim.Region.Framework.Scenes
{
@@ -2263,7 +2264,8 @@ namespace OpenSim.Region.Framework.Scenes
}
string xmlData = Utils.BytesToString(rezAsset.Data);
- SceneObjectGroup group = new SceneObjectGroup(itemId, xmlData, true);
+ SceneObjectGroup group
+ = SceneObjectSerializer.DeserializeOriginalXmlFormat(itemId, xmlData);
if (!Permissions.CanRezObject(
group.Children.Count, remoteClient.AgentId, pos)
@@ -2419,7 +2421,7 @@ namespace OpenSim.Region.Framework.Scenes
if (rezAsset != null)
{
string xmlData = Utils.BytesToString(rezAsset.Data);
- SceneObjectGroup group = new SceneObjectGroup(xmlData, true);
+ SceneObjectGroup group = SceneObjectSerializer.DeserializeOriginalXmlFormat(xmlData);
if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos))
{
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 99e6e1e58e..b0de4054f3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -406,96 +406,6 @@ namespace OpenSim.Region.Framework.Scenes
SetRootPart(part);
}
- public SceneObjectGroup(string xmlData, bool isOriginalXmlFormat)
- : this(UUID.Zero, xmlData, isOriginalXmlFormat)
- {
- }
-
- ///
- /// Create an object using serialized data in OpenSim's original xml format.
- ///
- ///
- /// If applicable, the user inventory item id from which this object was rezzed. If not applicable then this
- /// should be UUID.Zero
- ///
- ///
- ///
- /// This parameter only exists to separate the two different xml constructors. In the future, versions should
- /// be specified within the xml itself.
- ///
- public SceneObjectGroup(UUID fromUserInventoryItemID, string xmlData, bool isOriginalXmlFormat)
- {
-
- if (!isOriginalXmlFormat)
- throw new Exception("This constructor must specify the xml is in OpenSim's original format");
-
- //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
- {
-
- StringReader sr;
- XmlTextReader reader;
- XmlNodeList parts;
- XmlDocument doc;
- int linkNum;
-
- doc = new XmlDocument();
- doc.LoadXml(xmlData);
- parts = doc.GetElementsByTagName("RootPart");
-
- if (parts.Count == 0)
- {
- throw new Exception("[SCENE] Invalid Xml format - no root part");
- }
- else
- {
- sr = new StringReader(parts[0].InnerXml);
- reader = new XmlTextReader(sr);
- SetRootPart(SceneObjectPart.FromXml(fromUserInventoryItemID, reader));
- reader.Close();
- sr.Close();
- }
-
- parts = doc.GetElementsByTagName("Part");
-
- for (int i=0; i
/// Create an object using serialized data in OpenSim's xml2 format.
///
@@ -585,7 +495,7 @@ namespace OpenSim.Region.Framework.Scenes
{
}
- private void LoadScriptState(XmlDocument doc)
+ public void LoadScriptState(XmlDocument doc)
{
XmlNodeList nodes = doc.GetElementsByTagName("SavedScriptState");
if (nodes.Count > 0)
@@ -745,7 +655,6 @@ namespace OpenSim.Region.Framework.Scenes
#endregion
-
public string ToXmlString()
{
using (StringWriter sw = new StringWriter())
diff --git a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
index 7d9d247df3..1a4efe7cc1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneXmlLoader.cs
@@ -33,6 +33,7 @@ using System.Xml;
using OpenMetaverse;
using log4net;
using OpenSim.Framework;
+using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Region.Physics.Manager;
namespace OpenSim.Region.Framework.Scenes
@@ -58,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes
rootNode = doc.FirstChild;
foreach (XmlNode aPrimNode in rootNode.ChildNodes)
{
- SceneObjectGroup obj = new SceneObjectGroup(aPrimNode.OuterXml, true);
+ SceneObjectGroup obj = SceneObjectSerializer.DeserializeOriginalXmlFormat(aPrimNode.OuterXml);
if (newIDS)
{
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
new file mode 100644
index 0000000000..54e7270aea
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSim Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.IO;
+using System.Reflection;
+using System.Xml;
+using log4net;
+using OpenMetaverse;
+using OpenSim.Region.Framework.Scenes;
+
+namespace OpenSim.Region.Framework.Scenes.Serialization
+{
+ ///
+ /// Serialize and deserialize scene objects.
+ ///
+ /// This should really be in OpenSim.Framework.Serialization but this would mean circular dependency problems
+ /// right now - hopefully this isn't forever.
+ public class SceneObjectSerializer
+ {
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ ///
+ /// Deserialize a scene object from the original xml format
+ ///
+ ///
+ ///
+ public static SceneObjectGroup DeserializeOriginalXmlFormat(string serialization)
+ {
+ return DeserializeOriginalXmlFormat(UUID.Zero, serialization);
+ }
+
+ ///
+ /// Deserialize a scene object from the original xml format
+ ///
+ ///
+ ///
+ public static SceneObjectGroup DeserializeOriginalXmlFormat(UUID fromUserInventoryItemID, string serialization)
+ {
+ //m_log.DebugFormat("[SOG]: Starting deserialization of SOG");
+ //int time = System.Environment.TickCount;
+
+ SceneObjectGroup so = new SceneObjectGroup();
+
+ // libomv.types changes UUID to Guid
+ serialization = serialization.Replace("", "");
+ serialization = serialization.Replace("", "");
+
+ // Handle Nested property
+ serialization = serialization.Replace("", "");
+ serialization = serialization.Replace("", "");
+
+ try
+ {
+ StringReader sr;
+ XmlTextReader reader;
+ XmlNodeList parts;
+ XmlDocument doc;
+ int linkNum;
+
+ doc = new XmlDocument();
+ doc.LoadXml(serialization);
+ parts = doc.GetElementsByTagName("RootPart");
+
+ if (parts.Count == 0)
+ {
+ throw new Exception("Invalid Xml format - no root part");
+ }
+ else
+ {
+ sr = new StringReader(parts[0].InnerXml);
+ reader = new XmlTextReader(sr);
+ so.SetRootPart(SceneObjectPart.FromXml(fromUserInventoryItemID, reader));
+ reader.Close();
+ sr.Close();
+ }
+
+ parts = doc.GetElementsByTagName("Part");
+
+ for (int i = 0; i < parts.Count; i++)
+ {
+ sr = new StringReader(parts[i].InnerXml);
+ reader = new XmlTextReader(sr);
+ SceneObjectPart part = SceneObjectPart.FromXml(reader);
+ linkNum = part.LinkNum;
+ so.AddPart(part);
+ part.LinkNum = linkNum;
+ part.TrimPermissions();
+ part.StoreUndoState();
+ reader.Close();
+ sr.Close();
+ }
+
+ // Script state may, or may not, exist. Not having any, is NOT
+ // ever a problem.
+ so.LoadScriptState(doc);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat(
+ "[SERIALIZER]: Deserialization of xml failed with {0}. xml was {1}", e, serialization);
+ }
+
+ //m_log.DebugFormat("[SERIALIZER]: Finished deserialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time);
+
+ return so;
+ }
+ }
+}
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 07a1cc7462..a8398299bc 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -33,6 +33,7 @@ using System.Threading;
using log4net;
using OpenMetaverse;
using OpenSim.Framework;
+using OpenSim.Region.Framework.Scenes.Serialization;
namespace OpenSim.Region.Framework.Scenes
{
@@ -263,7 +264,7 @@ namespace OpenSim.Region.Framework.Scenes
if (null != objectAsset)
{
string xml = Utils.BytesToString(objectAsset.Data);
- SceneObjectGroup sog = new SceneObjectGroup(xml, true);
+ SceneObjectGroup sog = SceneObjectSerializer.DeserializeOriginalXmlFormat(xml);
GatherAssetUuids(sog, assetUuids);
}
}