From 1fc6872f205d76ab08ecc3e0458437d3bb0c85bd Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Mon, 20 Oct 2008 17:53:15 +0000 Subject: actually enabling SaveOAR XmlRpc ;-) --- .../RemoteController/RemoteAdminPlugin.cs | 97 +++++++++++++++++++++- 1 file changed, 93 insertions(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 5744867..fed6ecb 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -97,6 +97,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController m_httpd.AddXmlRPCHandler("admin_load_xml", XmlRpcLoadXMLMethod); m_httpd.AddXmlRPCHandler("admin_save_xml", XmlRpcSaveXMLMethod); m_httpd.AddXmlRPCHandler("admin_load_oar", XmlRpcLoadOARMethod); + m_httpd.AddXmlRPCHandler("admin_save_oar", XmlRpcSaveOARMethod); m_httpd.AddXmlRPCHandler("admin_region_query", XmlRpcRegionQueryMethod); } } @@ -901,8 +902,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController } else throw new Exception("neither region_name nor region_uuid given"); - responseData["switched"] = "true"; - new ArchiveReadRequest(scene, filename); responseData["loaded"] = "true"; @@ -914,7 +913,97 @@ namespace OpenSim.ApplicationPlugins.RemoteController m_log.DebugFormat("[RADMIN] LoadOAR: {0}", e.ToString()); responseData["loaded"] = "false"; - responseData["switched"] = "false"; + responseData["error"] = e.Message; + + response.Value = responseData; + } + + return response; + } + + /// + /// Save a region to an OAR file + /// + /// incoming XML RPC request + /// + /// XmlRpcSaveOARMethod takes the following XMLRPC + /// parameters + /// + /// parameter namedescription + /// password + /// admin password as set in OpenSim.ini + /// filename + /// file name for 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 XmlRpcSaveOARMethod(XmlRpcRequest request) + { + m_log.Info("[RADMIN]: Received Save 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")) + { + UUID region_uuid = (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"); + + scene.SavePrimsToArchive(filename); + + responseData["saved"] = "true"; + + response.Value = responseData; + } + catch (Exception e) + { + m_log.InfoFormat("[RADMIN] SaveOAR: {0}", e.Message); + m_log.DebugFormat("[RADMIN] SaveOAR: {0}", e.ToString()); + + responseData["saved"] = "false"; responseData["error"] = e.Message; response.Value = responseData; @@ -1087,7 +1176,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController public XmlRpcResponse XmlRpcRegionQueryMethod(XmlRpcRequest request) { - m_log.Info("[RADMIN]: Received Save XML Administrator Request"); + m_log.Info("[RADMIN]: Received Query XML Administrator Request"); XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); -- cgit v1.1