aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/RestPlugin.cs81
1 files changed, 40 insertions, 41 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
index f1ca83d..c502e28 100644
--- a/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
+++ b/OpenSim/ApplicationPlugins/Rest/RestPlugin.cs
@@ -1,30 +1,29 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4 *
5* Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15* 15 *
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26 */
27*/
28 27
29using System; 28using System;
30using System.Threading; 29using System.Threading;
@@ -56,7 +55,7 @@ namespace OpenSim.ApplicationPlugins.Rest
56 { 55 {
57 #region properties 56 #region properties
58 57
59 protected static readonly log4net.ILog m_log = 58 protected static readonly log4net.ILog m_log =
60 log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 59 log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
61 60
62 private IConfig _config; // Configuration source: Rest Plugins 61 private IConfig _config; // Configuration source: Rest Plugins
@@ -106,8 +105,8 @@ namespace OpenSim.ApplicationPlugins.Rest
106 /// </summary> 105 /// </summary>
107 public bool IsEnabled 106 public bool IsEnabled
108 { 107 {
109 get 108 get
110 { 109 {
111 return (null != _pluginConfig) && _pluginConfig.GetBoolean("enabled", false); 110 return (null != _pluginConfig) && _pluginConfig.GetBoolean("enabled", false);
112 } 111 }
113 } 112 }
@@ -115,7 +114,7 @@ namespace OpenSim.ApplicationPlugins.Rest
115 /// <summary> 114 /// <summary>
116 /// OpenSimMain application 115 /// OpenSimMain application
117 /// </summary> 116 /// </summary>
118 public OpenSimMain App 117 public OpenSimMain App
119 { 118 {
120 get { return _app; } 119 get { return _app; }
121 } 120 }
@@ -123,7 +122,7 @@ namespace OpenSim.ApplicationPlugins.Rest
123 /// <summary> 122 /// <summary>
124 /// RPC server 123 /// RPC server
125 /// </summary> 124 /// </summary>
126 public BaseHttpServer HttpServer 125 public BaseHttpServer HttpServer
127 { 126 {
128 get { return _httpd; } 127 get { return _httpd; }
129 } 128 }
@@ -156,7 +155,7 @@ namespace OpenSim.ApplicationPlugins.Rest
156 155
157 public XmlTextWriter XmlWriter 156 public XmlTextWriter XmlWriter
158 { 157 {
159 get { 158 get {
160 if (null == _xw) 159 if (null == _xw)
161 { 160 {
162 _sw = new StringWriter(); 161 _sw = new StringWriter();
@@ -200,7 +199,7 @@ namespace OpenSim.ApplicationPlugins.Rest
200 return; 199 return;
201 } 200 }
202 201
203 if (!_config.GetBoolean("enabled", false)) 202 if (!_config.GetBoolean("enabled", false))
204 { 203 {
205 m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID); 204 m_log.WarnFormat("{0} Rest Plugins are disabled", MsgID);
206 return; 205 return;
@@ -211,14 +210,14 @@ namespace OpenSim.ApplicationPlugins.Rest
211 210
212 // Retrieve GOD key value, if any. 211 // Retrieve GOD key value, if any.
213 _godkey = _config.GetString("god_key", String.Empty); 212 _godkey = _config.GetString("god_key", String.Empty);
214 213
215 // Retrive prefix if any. 214 // Retrive prefix if any.
216 _prefix = _config.GetString("prefix", "/admin"); 215 _prefix = _config.GetString("prefix", "/admin");
217 216
218 // Get plugin specific config 217 // Get plugin specific config
219 _pluginConfig = openSim.ConfigSource.Configs[ConfigName]; 218 _pluginConfig = openSim.ConfigSource.Configs[ConfigName];
220 219
221 220
222 m_log.InfoFormat("{0} Rest Plugins Enabled", MsgID); 221 m_log.InfoFormat("{0} Rest Plugins Enabled", MsgID);
223 } 222 }
224 catch (Exception e) 223 catch (Exception e)
@@ -231,7 +230,7 @@ namespace OpenSim.ApplicationPlugins.Rest
231 // not possible for the openSim pointer to be null. However 230 // not possible for the openSim pointer to be null. However
232 // were the implementation to be changed, this could 231 // were the implementation to be changed, this could
233 // result in a silent initialization failure. Harmless 232 // result in a silent initialization failure. Harmless
234 // except for lack of function and lack of any 233 // except for lack of function and lack of any
235 // diagnostic indication as to why. The same is true if 234 // diagnostic indication as to why. The same is true if
236 // the HTTP server reference is bad. 235 // the HTTP server reference is bad.
237 // We should at least issue a message... 236 // We should at least issue a message...
@@ -254,7 +253,7 @@ namespace OpenSim.ApplicationPlugins.Rest
254 { 253 {
255 if (!IsEnabled) return; 254 if (!IsEnabled) return;
256 255
257 if (!path.StartsWith(_prefix)) 256 if (!path.StartsWith(_prefix))
258 { 257 {
259 path = String.Format("{0}{1}", _prefix, path); 258 path = String.Format("{0}{1}", _prefix, path);
260 } 259 }
@@ -354,7 +353,7 @@ namespace OpenSim.ApplicationPlugins.Rest
354 /// <param name="method">origin of the failure message</param> 353 /// <param name="method">origin of the failure message</param>
355 /// <param name="message">failure message</param> 354 /// <param name="message">failure message</param>
356 /// <remarks>This should probably set a return code as 355 /// <remarks>This should probably set a return code as
357 /// well. (?)</remarks> 356 /// well. (?)</remarks>
358 protected string Failure(OSHttpResponse response, OSHttpStatusCode status, 357 protected string Failure(OSHttpResponse response, OSHttpStatusCode status,
359 string method, string format, params string[] msg) 358 string method, string format, params string[] msg)
360 { 359 {
@@ -373,8 +372,8 @@ namespace OpenSim.ApplicationPlugins.Rest
373 /// <param name="method">origin of the failure message</param> 372 /// <param name="method">origin of the failure message</param>
374 /// <param name="e">exception causing the failure message</param> 373 /// <param name="e">exception causing the failure message</param>
375 /// <remarks>This should probably set a return code as 374 /// <remarks>This should probably set a return code as
376 /// well. (?)</remarks> 375 /// well. (?)</remarks>
377 public string Failure(OSHttpResponse response, OSHttpStatusCode status, 376 public string Failure(OSHttpResponse response, OSHttpStatusCode status,
378 string method, Exception e) 377 string method, Exception e)
379 { 378 {
380 string m = String.Format("exception occurred: {0}", e.Message); 379 string m = String.Format("exception occurred: {0}", e.Message);