* Hook up archive loading to load in prim xml data

* This now has equivalent functionality to load-xml2 - no asset data is restored yet
0.6.0-stable
Justin Clarke Casey 2008-05-30 18:32:18 +00:00
parent 83f390e421
commit bc56efd1d2
4 changed files with 57 additions and 19 deletions

View File

@ -26,7 +26,9 @@
*/ */
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment.Modules.World.Serialiser;
using System; using System;
using System.IO;
using System.Reflection; using System.Reflection;
using log4net; using log4net;
@ -85,7 +87,8 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
// Reload serialized prims // Reload serialized prims
m_log.InfoFormat("[ARCHIVER]: Loading prim data"); m_log.InfoFormat("[ARCHIVER]: Loading prim data");
//m_scene.LoadPrimsFromXml2( IRegionSerialiser serialiser = m_scene.RequestModuleInterface<IRegionSerialiser>();
serialiser.LoadPrimsFromXml2(m_scene, new StringReader(serializedPrims));
} }
} }
} }

View File

@ -27,6 +27,7 @@
using libsecondlife; using libsecondlife;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules.World.Serialiser namespace OpenSim.Region.Environment.Modules.World.Serialiser
@ -39,8 +40,20 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
void SavePrimsToXml(Scene scene, string fileName); void SavePrimsToXml(Scene scene, string fileName);
/// <summary>
/// Load prims from the xml2 format
/// </summary>
/// <param name="scene"></param>
/// <param name="fileName"></param>
void LoadPrimsFromXml2(Scene scene, string fileName); void LoadPrimsFromXml2(Scene scene, string fileName);
/// <summary>
/// Load prims from the xml2 format
/// </summary>
/// <param name="scene"></param>
/// <param name="reader"></param>
void LoadPrimsFromXml2(Scene scene, TextReader reader);
void SavePrimsToXml2(Scene scene, string fileName); void SavePrimsToXml2(Scene scene, string fileName);
void LoadGroupFromXml2String(Scene scene, string xmlString); void LoadGroupFromXml2String(Scene scene, string xmlString);

View File

@ -147,27 +147,44 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
/// <summary>
/// Load prims from the xml2 format
/// </summary>
/// <param name="scene"></param>
/// <param name="fileName"></param>
public static void LoadPrimsFromXml2(Scene scene, string fileName) public static void LoadPrimsFromXml2(Scene scene, string fileName)
{ {
XmlDocument doc = new XmlDocument(); LoadPrimsFromXml2(scene, new XmlTextReader(fileName));
XmlNode rootNode; }
if (fileName.StartsWith("http:") || File.Exists(fileName))
/// <summary>
/// Load prims from the xml2 format
/// </summary>
/// <param name="scene"></param>
/// <param name="reader"></param>
public static void LoadPrimsFromXml2(Scene scene, TextReader reader)
{ {
XmlTextReader reader = new XmlTextReader(fileName); LoadPrimsFromXml2(scene, new XmlTextReader(reader));
}
/// <summary>
/// Load prims from the xml2 format. This method will close the reader
/// </summary>
/// <param name="scene"></param>
/// <param name="reader"></param>
protected static void LoadPrimsFromXml2(Scene scene, XmlTextReader reader)
{
XmlDocument doc = new XmlDocument();
reader.WhitespaceHandling = WhitespaceHandling.None; reader.WhitespaceHandling = WhitespaceHandling.None;
doc.Load(reader); doc.Load(reader);
reader.Close(); reader.Close();
rootNode = doc.FirstChild; XmlNode rootNode = doc.FirstChild;
foreach (XmlNode aPrimNode in rootNode.ChildNodes) foreach (XmlNode aPrimNode in rootNode.ChildNodes)
{ {
CreatePrimFromXml(scene, aPrimNode.OuterXml); CreatePrimFromXml(scene, aPrimNode.OuterXml);
} }
} }
else
{
throw new Exception("Could not open file " + fileName + " for reading");
}
}
public static void CreatePrimFromXml(Scene scene, string xmlData) public static void CreatePrimFromXml(Scene scene, string xmlData)
{ {

View File

@ -102,6 +102,11 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
SceneXmlLoader.LoadPrimsFromXml2(scene, fileName); SceneXmlLoader.LoadPrimsFromXml2(scene, fileName);
} }
public void LoadPrimsFromXml2(Scene scene, TextReader reader)
{
SceneXmlLoader.LoadPrimsFromXml2(scene, reader);
}
public void SavePrimsToXml2(Scene scene, string fileName) public void SavePrimsToXml2(Scene scene, string fileName)
{ {
SceneXmlLoader.SavePrimsToXml2(scene, fileName); SceneXmlLoader.SavePrimsToXml2(scene, fileName);