diff --git a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs index 6ad11ee13c..d3f0cbc6de 100644 --- a/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/Environment/Modules/World/Archiver/ArchiveReadRequest.cs @@ -26,7 +26,9 @@ */ using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Modules.World.Serialiser; using System; +using System.IO; using System.Reflection; using log4net; @@ -85,7 +87,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver // Reload serialized prims m_log.InfoFormat("[ARCHIVER]: Loading prim data"); - //m_scene.LoadPrimsFromXml2( + IRegionSerialiser serialiser = m_scene.RequestModuleInterface(); + serialiser.LoadPrimsFromXml2(m_scene, new StringReader(serializedPrims)); } } } diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs index 752b5b6df8..b7ed9f9f99 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/IRegionSerialiser.cs @@ -27,6 +27,7 @@ using libsecondlife; using System.Collections.Generic; +using System.IO; using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Modules.World.Serialiser @@ -38,9 +39,21 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser void LoadPrimsFromXml(Scene scene, string fileName, bool newIDS, LLVector3 loadOffset); void SavePrimsToXml(Scene scene, string fileName); - + + /// + /// Load prims from the xml2 format + /// + /// + /// void LoadPrimsFromXml2(Scene scene, string fileName); + /// + /// Load prims from the xml2 format + /// + /// + /// + void LoadPrimsFromXml2(Scene scene, TextReader reader); + void SavePrimsToXml2(Scene scene, string fileName); void LoadGroupFromXml2String(Scene scene, string xmlString); diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs index 7f51b58b54..2ac07547ea 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SceneXmlLoader.cs @@ -147,26 +147,43 @@ namespace OpenSim.Region.Environment.Scenes } } + /// + /// Load prims from the xml2 format + /// + /// + /// public static void LoadPrimsFromXml2(Scene scene, string fileName) { - XmlDocument doc = new XmlDocument(); - XmlNode rootNode; - if (fileName.StartsWith("http:") || File.Exists(fileName)) + LoadPrimsFromXml2(scene, new XmlTextReader(fileName)); + } + + /// + /// Load prims from the xml2 format + /// + /// + /// + public static void LoadPrimsFromXml2(Scene scene, TextReader reader) + { + LoadPrimsFromXml2(scene, new XmlTextReader(reader)); + } + + /// + /// Load prims from the xml2 format. This method will close the reader + /// + /// + /// + protected static void LoadPrimsFromXml2(Scene scene, XmlTextReader reader) + { + XmlDocument doc = new XmlDocument(); + reader.WhitespaceHandling = WhitespaceHandling.None; + doc.Load(reader); + reader.Close(); + XmlNode rootNode = doc.FirstChild; + + foreach (XmlNode aPrimNode in rootNode.ChildNodes) { - XmlTextReader reader = new XmlTextReader(fileName); - reader.WhitespaceHandling = WhitespaceHandling.None; - doc.Load(reader); - reader.Close(); - rootNode = doc.FirstChild; - foreach (XmlNode aPrimNode in rootNode.ChildNodes) - { - CreatePrimFromXml(scene, aPrimNode.OuterXml); - } - } - else - { - throw new Exception("Could not open file " + fileName + " for reading"); - } + CreatePrimFromXml(scene, aPrimNode.OuterXml); + } } public static void CreatePrimFromXml(Scene scene, string xmlData) diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs index bfa0a43169..b181fe8c3f 100644 --- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiserModule.cs @@ -101,6 +101,11 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser { SceneXmlLoader.LoadPrimsFromXml2(scene, fileName); } + + public void LoadPrimsFromXml2(Scene scene, TextReader reader) + { + SceneXmlLoader.LoadPrimsFromXml2(scene, reader); + } public void SavePrimsToXml2(Scene scene, string fileName) {