aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/RestPlugin.cs59
1 files changed, 33 insertions, 26 deletions
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