aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs24
-rw-r--r--OpenSim/ApplicationPlugins/Rest/RestPlugin.cs59
2 files changed, 46 insertions, 37 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs b/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs
index aa93f28..c689daa 100644
--- a/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Regions/POSTHandler.cs
@@ -34,10 +34,10 @@ using OpenSim.Region.Framework.Scenes;
34 34
35namespace OpenSim.ApplicationPlugins.Rest.Regions 35namespace OpenSim.ApplicationPlugins.Rest.Regions
36{ 36{
37
38 public partial class RestRegionPlugin : RestPlugin 37 public partial class RestRegionPlugin : RestPlugin
39 { 38 {
40 #region POST methods 39 #region POST methods
40
41 public string PostHandler(string request, string path, string param, 41 public string PostHandler(string request, string path, string param,
42 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 42 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
43 { 43 {
@@ -59,24 +59,26 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
59 if (String.IsNullOrEmpty(param)) return CreateRegion(httpRequest, httpResponse); 59 if (String.IsNullOrEmpty(param)) return CreateRegion(httpRequest, httpResponse);
60 60
61 // Parse region ID and other parameters 61 // Parse region ID and other parameters
62 param = param.TrimEnd(new char[]{'/'}); 62 param = param.TrimEnd(new char[] {'/'});
63 string[] comps = param.Split('/'); 63 string[] comps = param.Split('/');
64 UUID regionID = (UUID)comps[0]; 64 UUID regionID = (UUID) comps[0];
65 65
66 m_log.DebugFormat("{0} POST region UUID {1}", MsgID, regionID.ToString()); 66 m_log.DebugFormat("{0} POST region UUID {1}", MsgID, regionID.ToString());
67 if (UUID.Zero == regionID) throw new Exception("missing region ID"); 67 if (UUID.Zero == regionID) throw new Exception("missing region ID");
68 68
69 Scene scene = null; 69 Scene scene = null;
70 App.SceneManager.TryGetScene(regionID, out scene); 70 App.SceneManager.TryGetScene(regionID, out scene);
71 if (null == scene) return Failure(httpResponse, OSHttpStatusCode.ClientErrorNotFound, 71 if (null == scene)
72 "POST", "cannot find region {0}", regionID.ToString()); 72 return Failure(httpResponse, OSHttpStatusCode.ClientErrorNotFound,
73 "POST", "cannot find region {0}", regionID.ToString());
73 74
74 if (2 == comps.Length) { 75 if (2 == comps.Length)
76 {
75 // check for {prims} 77 // check for {prims}
76 switch (comps[1].ToLower()) 78 switch (comps[1].ToLower())
77 { 79 {
78 case "prims": 80 case "prims":
79 return LoadPrims(request, httpRequest, httpResponse, scene); 81 return LoadPrims(request, httpRequest, httpResponse, scene);
80 } 82 }
81 } 83 }
82 84
@@ -106,12 +108,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Regions
106 public string LoadPrims(string requestBody, OSHttpRequest request, OSHttpResponse response, Scene scene) 108 public string LoadPrims(string requestBody, OSHttpRequest request, OSHttpResponse response, Scene scene)
107 { 109 {
108 IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>(); 110 IRegionSerialiserModule serialiser = scene.RequestModuleInterface<IRegionSerialiserModule>();
109 if (serialiser != null) 111 if (serialiser != null)
110 serialiser.LoadPrimsFromXml2(scene, new StringReader(requestBody), true); 112 serialiser.LoadPrimsFromXml2(scene, new StringReader(requestBody), true);
111 113
112 return ""; 114 return "";
113 } 115 }
114 116
115 #endregion POST methods 117 #endregion POST methods
116 } 118 }
117} 119} \ No newline at end of file
diff --git a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
index a0d4209..f3c3016 100644
--- a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
+++ b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
@@ -45,18 +45,18 @@ namespace OpenSim.ApplicationPlugins.Rest
45 protected static readonly ILog m_log = 45 protected static readonly ILog m_log =
46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 private IConfig _config; // Configuration source: Rest Plugins 48 private IConfig _config; // Configuration source: Rest Plugins
49 private IConfig _pluginConfig; // Configuration source: Plugin specific 49 private IConfig _pluginConfig; // Configuration source: Plugin specific
50 private OpenSimBase _app; // The 'server' 50 private OpenSimBase _app; // The 'server'
51 private BaseHttpServer _httpd; // The server's RPC interface 51 private BaseHttpServer _httpd; // The server's RPC interface
52 private string _prefix; // URL prefix below 52 private string _prefix; // URL prefix below
53 // which all REST URLs 53 // which all REST URLs
54 // are living 54 // are living
55 private StringWriter _sw = null; 55 private StringWriter _sw = null;
56 private RestXmlWriter _xw = null; 56 private RestXmlWriter _xw = null;
57 57
58 private string _godkey; 58 private string _godkey;
59 private int _reqk; 59 private int _reqk;
60 60
61 [ThreadStatic] 61 [ThreadStatic]
62 private static string _threadRequestID = String.Empty; 62 private static string _threadRequestID = String.Empty;
@@ -150,14 +150,16 @@ namespace OpenSim.ApplicationPlugins.Rest
150 150
151 public XmlTextWriter XmlWriter 151 public XmlTextWriter XmlWriter
152 { 152 {
153 get { 153 get
154 {
154 if (null == _xw) 155 if (null == _xw)
155 { 156 {
156 _sw = new StringWriter(); 157 _sw = new StringWriter();
157 _xw = new RestXmlWriter(_sw); 158 _xw = new RestXmlWriter(_sw);
158 _xw.Formatting = Formatting.Indented; 159 _xw.Formatting = Formatting.Indented;
159 } 160 }
160 return _xw; } 161 return _xw;
162 }
161 } 163 }
162 164
163 public string XmlWriterResult 165 public string XmlWriterResult
@@ -171,19 +173,23 @@ namespace OpenSim.ApplicationPlugins.Rest
171 return _sw.ToString(); 173 return _sw.ToString();
172 } 174 }
173 } 175 }
174 #endregion properties
175 176
177 #endregion properties
176 178
177 #region methods 179 #region methods
180
178 // TODO: required by IPlugin, but likely not at all right 181 // TODO: required by IPlugin, but likely not at all right
179 string m_version = "0.0"; 182 private string m_version = "0.0";
180 183
181 public string Version { get { return m_version; } } 184 public string Version
185 {
186 get { return m_version; }
187 }
182 188
183 public void Initialise() 189 public void Initialise()
184 { 190 {
185 m_log.Info("[RESTPLUGIN]: " + Name + " cannot be default-initialized!"); 191 m_log.Info("[RESTPLUGIN]: " + Name + " cannot be default-initialized!");
186 throw new PluginNotInitialisedException (Name); 192 throw new PluginNotInitialisedException(Name);
187 } 193 }
188 194
189 /// <summary> 195 /// <summary>
@@ -250,8 +256,8 @@ namespace OpenSim.ApplicationPlugins.Rest
250 { 256 {
251 } 257 }
252 258
253 private List<RestStreamHandler> _handlers = new List<RestStreamHandler>(); 259 private List<RestStreamHandler> _handlers = new List<RestStreamHandler>();
254 private Dictionary<string, IHttpAgentHandler> _agents = new Dictionary<string, IHttpAgentHandler>(); 260 private Dictionary<string, IHttpAgentHandler> _agents = new Dictionary<string, IHttpAgentHandler>();
255 261
256 /// <summary> 262 /// <summary>
257 /// Add a REST stream handler to the underlying HTTP server. 263 /// Add a REST stream handler to the underlying HTTP server.
@@ -327,7 +333,7 @@ namespace OpenSim.ApplicationPlugins.Rest
327 if (null == keys) return false; 333 if (null == keys) return false;
328 334
329 // we take the last key supplied 335 // we take the last key supplied
330 return keys[keys.Length-1] == _godkey; 336 return keys[keys.Length - 1] == _godkey;
331 } 337 }
332 338
333 /// <summary> 339 /// <summary>
@@ -351,11 +357,11 @@ namespace OpenSim.ApplicationPlugins.Rest
351 _httpd.RemoveStreamHandler(h.HttpMethod, h.Path); 357 _httpd.RemoveStreamHandler(h.HttpMethod, h.Path);
352 } 358 }
353 _handlers = null; 359 _handlers = null;
354 foreach (KeyValuePair<string,IHttpAgentHandler> h in _agents) 360 foreach (KeyValuePair<string, IHttpAgentHandler> h in _agents)
355 { 361 {
356 _httpd.RemoveAgentHandler(h.Key,h.Value); 362 _httpd.RemoveAgentHandler(h.Key, h.Value);
357 } 363 }
358 _agents = null; 364 _agents = null;
359 } 365 }
360 366
361 public virtual void Dispose() 367 public virtual void Dispose()
@@ -375,7 +381,7 @@ namespace OpenSim.ApplicationPlugins.Rest
375 { 381 {
376 string m = String.Format(format, msg); 382 string m = String.Format(format, msg);
377 383
378 response.StatusCode = (int)status; 384 response.StatusCode = (int) status;
379 response.StatusDescription = m; 385 response.StatusDescription = m;
380 386
381 m_log.ErrorFormat("{0} {1} failed: {2}", MsgID, method, m); 387 m_log.ErrorFormat("{0} {1} failed: {2}", MsgID, method, m);
@@ -394,7 +400,7 @@ namespace OpenSim.ApplicationPlugins.Rest
394 { 400 {
395 string m = String.Format("exception occurred: {0}", e.Message); 401 string m = String.Format("exception occurred: {0}", e.Message);
396 402
397 response.StatusCode = (int)status; 403 response.StatusCode = (int) status;
398 response.StatusDescription = m; 404 response.StatusDescription = m;
399 405
400 m_log.DebugFormat("{0} {1} failed: {2}", MsgID, method, e.ToString()); 406 m_log.DebugFormat("{0} {1} failed: {2}", MsgID, method, e.ToString());
@@ -402,6 +408,7 @@ namespace OpenSim.ApplicationPlugins.Rest
402 408
403 return String.Format("<error>{0}</error>", e.Message); 409 return String.Format("<error>{0}</error>", e.Message);
404 } 410 }
411
405 #endregion methods 412 #endregion methods
406 } 413 }
407} 414} \ No newline at end of file