* Cleanup and CCC (Code Convention Conformance)
parent
91a096dca6
commit
1c70790a8f
|
@ -34,10 +34,10 @@ using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.ApplicationPlugins.Rest.Regions
|
namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||||
{
|
{
|
||||||
|
|
||||||
public partial class RestRegionPlugin : RestPlugin
|
public partial class RestRegionPlugin : RestPlugin
|
||||||
{
|
{
|
||||||
#region POST methods
|
#region POST methods
|
||||||
|
|
||||||
public string PostHandler(string request, string path, string param,
|
public string PostHandler(string request, string path, string param,
|
||||||
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
|
@ -59,24 +59,26 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
|
||||||
if (String.IsNullOrEmpty(param)) return CreateRegion(httpRequest, httpResponse);
|
if (String.IsNullOrEmpty(param)) return CreateRegion(httpRequest, httpResponse);
|
||||||
|
|
||||||
// Parse region ID and other parameters
|
// Parse region ID and other parameters
|
||||||
param = param.TrimEnd(new char[]{'/'});
|
param = param.TrimEnd(new char[] {'/'});
|
||||||
string[] comps = param.Split('/');
|
string[] comps = param.Split('/');
|
||||||
UUID regionID = (UUID)comps[0];
|
UUID regionID = (UUID) comps[0];
|
||||||
|
|
||||||
m_log.DebugFormat("{0} POST region UUID {1}", MsgID, regionID.ToString());
|
m_log.DebugFormat("{0} POST region UUID {1}", MsgID, regionID.ToString());
|
||||||
if (UUID.Zero == regionID) throw new Exception("missing region ID");
|
if (UUID.Zero == regionID) throw new Exception("missing region ID");
|
||||||
|
|
||||||
Scene scene = null;
|
Scene scene = null;
|
||||||
App.SceneManager.TryGetScene(regionID, out scene);
|
App.SceneManager.TryGetScene(regionID, out scene);
|
||||||
if (null == scene) return Failure(httpResponse, OSHttpStatusCode.ClientErrorNotFound,
|
if (null == scene)
|
||||||
"POST", "cannot find region {0}", regionID.ToString());
|
return Failure(httpResponse, OSHttpStatusCode.ClientErrorNotFound,
|
||||||
|
"POST", "cannot find region {0}", regionID.ToString());
|
||||||
|
|
||||||
if (2 == comps.Length) {
|
if (2 == comps.Length)
|
||||||
|
{
|
||||||
// check for {prims}
|
// check for {prims}
|
||||||
switch (comps[1].ToLower())
|
switch (comps[1].ToLower())
|
||||||
{
|
{
|
||||||
case "prims":
|
case "prims":
|
||||||
return LoadPrims(request, httpRequest, httpResponse, scene);
|
return LoadPrims(request, httpRequest, httpResponse, scene);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,18 +45,18 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||||
protected static readonly ILog m_log =
|
protected static readonly ILog m_log =
|
||||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private IConfig _config; // Configuration source: Rest Plugins
|
private IConfig _config; // Configuration source: Rest Plugins
|
||||||
private IConfig _pluginConfig; // Configuration source: Plugin specific
|
private IConfig _pluginConfig; // Configuration source: Plugin specific
|
||||||
private OpenSimBase _app; // The 'server'
|
private OpenSimBase _app; // The 'server'
|
||||||
private BaseHttpServer _httpd; // The server's RPC interface
|
private BaseHttpServer _httpd; // The server's RPC interface
|
||||||
private string _prefix; // URL prefix below
|
private string _prefix; // URL prefix below
|
||||||
// which all REST URLs
|
// which all REST URLs
|
||||||
// are living
|
// are living
|
||||||
private StringWriter _sw = null;
|
private StringWriter _sw = null;
|
||||||
private RestXmlWriter _xw = null;
|
private RestXmlWriter _xw = null;
|
||||||
|
|
||||||
private string _godkey;
|
private string _godkey;
|
||||||
private int _reqk;
|
private int _reqk;
|
||||||
|
|
||||||
[ThreadStatic]
|
[ThreadStatic]
|
||||||
private static string _threadRequestID = String.Empty;
|
private static string _threadRequestID = String.Empty;
|
||||||
|
@ -150,14 +150,16 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||||
|
|
||||||
public XmlTextWriter XmlWriter
|
public XmlTextWriter XmlWriter
|
||||||
{
|
{
|
||||||
get {
|
get
|
||||||
|
{
|
||||||
if (null == _xw)
|
if (null == _xw)
|
||||||
{
|
{
|
||||||
_sw = new StringWriter();
|
_sw = new StringWriter();
|
||||||
_xw = new RestXmlWriter(_sw);
|
_xw = new RestXmlWriter(_sw);
|
||||||
_xw.Formatting = Formatting.Indented;
|
_xw.Formatting = Formatting.Indented;
|
||||||
}
|
}
|
||||||
return _xw; }
|
return _xw;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string XmlWriterResult
|
public string XmlWriterResult
|
||||||
|
@ -171,19 +173,23 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||||
return _sw.ToString();
|
return _sw.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion properties
|
#endregion properties
|
||||||
|
|
||||||
|
|
||||||
#region methods
|
#region methods
|
||||||
// TODO: required by IPlugin, but likely not at all right
|
|
||||||
string m_version = "0.0";
|
|
||||||
|
|
||||||
public string Version { get { return m_version; } }
|
// TODO: required by IPlugin, but likely not at all right
|
||||||
|
private string m_version = "0.0";
|
||||||
|
|
||||||
|
public string Version
|
||||||
|
{
|
||||||
|
get { return m_version; }
|
||||||
|
}
|
||||||
|
|
||||||
public void Initialise()
|
public void Initialise()
|
||||||
{
|
{
|
||||||
m_log.Info("[RESTPLUGIN]: " + Name + " cannot be default-initialized!");
|
m_log.Info("[RESTPLUGIN]: " + Name + " cannot be default-initialized!");
|
||||||
throw new PluginNotInitialisedException (Name);
|
throw new PluginNotInitialisedException(Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -250,8 +256,8 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<RestStreamHandler> _handlers = new List<RestStreamHandler>();
|
private List<RestStreamHandler> _handlers = new List<RestStreamHandler>();
|
||||||
private Dictionary<string, IHttpAgentHandler> _agents = new Dictionary<string, IHttpAgentHandler>();
|
private Dictionary<string, IHttpAgentHandler> _agents = new Dictionary<string, IHttpAgentHandler>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add a REST stream handler to the underlying HTTP server.
|
/// Add a REST stream handler to the underlying HTTP server.
|
||||||
|
@ -327,7 +333,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||||
if (null == keys) return false;
|
if (null == keys) return false;
|
||||||
|
|
||||||
// we take the last key supplied
|
// we take the last key supplied
|
||||||
return keys[keys.Length-1] == _godkey;
|
return keys[keys.Length - 1] == _godkey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -351,11 +357,11 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||||
_httpd.RemoveStreamHandler(h.HttpMethod, h.Path);
|
_httpd.RemoveStreamHandler(h.HttpMethod, h.Path);
|
||||||
}
|
}
|
||||||
_handlers = null;
|
_handlers = null;
|
||||||
foreach (KeyValuePair<string,IHttpAgentHandler> h in _agents)
|
foreach (KeyValuePair<string, IHttpAgentHandler> h in _agents)
|
||||||
{
|
{
|
||||||
_httpd.RemoveAgentHandler(h.Key,h.Value);
|
_httpd.RemoveAgentHandler(h.Key, h.Value);
|
||||||
}
|
}
|
||||||
_agents = null;
|
_agents = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Dispose()
|
public virtual void Dispose()
|
||||||
|
@ -375,7 +381,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||||
{
|
{
|
||||||
string m = String.Format(format, msg);
|
string m = String.Format(format, msg);
|
||||||
|
|
||||||
response.StatusCode = (int)status;
|
response.StatusCode = (int) status;
|
||||||
response.StatusDescription = m;
|
response.StatusDescription = m;
|
||||||
|
|
||||||
m_log.ErrorFormat("{0} {1} failed: {2}", MsgID, method, m);
|
m_log.ErrorFormat("{0} {1} failed: {2}", MsgID, method, m);
|
||||||
|
@ -394,7 +400,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||||
{
|
{
|
||||||
string m = String.Format("exception occurred: {0}", e.Message);
|
string m = String.Format("exception occurred: {0}", e.Message);
|
||||||
|
|
||||||
response.StatusCode = (int)status;
|
response.StatusCode = (int) status;
|
||||||
response.StatusDescription = m;
|
response.StatusDescription = m;
|
||||||
|
|
||||||
m_log.DebugFormat("{0} {1} failed: {2}", MsgID, method, e.ToString());
|
m_log.DebugFormat("{0} {1} failed: {2}", MsgID, method, e.ToString());
|
||||||
|
@ -402,6 +408,7 @@ namespace OpenSim.ApplicationPlugins.Rest
|
||||||
|
|
||||||
return String.Format("<error>{0}</error>", e.Message);
|
return String.Format("<error>{0}</error>", e.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion methods
|
#endregion methods
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue