From 0921dafddf965745fdf483f2f41ef4833a0e2caa Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Thu, 28 Aug 2008 09:34:47 +0000 Subject: adds XmlRcpLoadOAR support to RemoteAdminPlugin.cs --- .../RemoteController/RemoteAdminPlugin.cs | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) (limited to 'OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 4dc63fd..3bd80f5 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -39,6 +39,7 @@ using OpenSim.Framework; using OpenSim.Framework.Servers; using OpenSim.Region.Environment.Modules.World.Terrain; using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Modules.World.Archiver; namespace OpenSim.ApplicationPlugins.RemoteController { @@ -88,6 +89,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController m_httpd.AddXmlRPCHandler("admin_create_user", XmlRpcCreateUserMethod); m_httpd.AddXmlRPCHandler("admin_update_user", XmlRpcUpdateUserAccountMethod); m_httpd.AddXmlRPCHandler("admin_load_xml", XmlRpcLoadXMLMethod); + m_httpd.AddXmlRPCHandler("admin_load_oar", XmlRpcLoadOARMethod); } } catch (NullReferenceException) @@ -685,6 +687,99 @@ namespace OpenSim.ApplicationPlugins.RemoteController return response; } + /// + /// Load an OAR file into a region.. + /// + /// incoming XML RPC request + /// + /// XmlRpcLoadOARMethod takes the following XMLRPC + /// parameters + /// + /// parameter namedescription + /// password + /// admin password as set in OpenSim.ini + /// filename + /// file name of the OAR file + /// region_uuid + /// UUID of the region + /// region_name + /// region name + /// + /// + /// region_uuid takes precedence over + /// region_name if both are present; one of both + /// must be present. + /// + /// XmlRpcLoadOARMethod returns + /// + /// namedescription + /// success + /// true or false + /// error + /// error message if success is false + /// + /// + public XmlRpcResponse XmlRpcLoadOARMethod(XmlRpcRequest request) + { + m_log.Info("[RADMIN]: Received Load OAR Administrator Request"); + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable responseData = new Hashtable(); + + try + { + Hashtable requestData = (Hashtable) request.Params[0]; + + // check completeness + foreach (string p in new string[] { "password", "filename" }) + { + if (!requestData.Contains(p)) + throw new Exception(String.Format("missing parameter {0}", p)); + if (String.IsNullOrEmpty((string)requestData[p])) + throw new Exception(String.Format("parameter {0} is empty")); + } + + // check password + if (!String.IsNullOrEmpty(requiredPassword) && + (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + + string filename = (string)requestData["filename"]; + Scene scene = null; + if (requestData.Contains("region_uuid")) + { + LLUUID region_uuid = (string)requestData["region_uuid"]; + if (!m_app.SceneManager.TryGetScene(region_uuid, out scene)) + throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); + } + else if (requestData.Contains("region_name")) + { + string region_name = (string)requestData["region_name"]; + if (!m_app.SceneManager.TryGetScene(region_name, out scene)) + throw new Exception(String.Format("failed to switch to region {0}", region_name)); + } + else throw new Exception("neither region_name nor region_uuid given"); + + responseData["switched"] = "true"; + + new ArchiveReadRequest(scene, filename); + responseData["loaded"] = "true"; + + response.Value = responseData; + } + catch (Exception e) + { + m_log.InfoFormat("[RADMIN] LoadOAR: {0}", e.Message); + m_log.DebugFormat("[RADMIN] LoadOAR: {0}", e.ToString()); + + responseData["loaded"] = "false"; + responseData["switched"] = "false"; + responseData["error"] = e.Message; + + response.Value = responseData; + } + + return response; + } + public XmlRpcResponse XmlRpcLoadXMLMethod(XmlRpcRequest request) { m_log.Info("[RADMIN]: Received Load XML Administrator Request"); @@ -766,6 +861,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController return response; } + public void Dispose() { } -- cgit v1.1