diff options
author | Jeff Ames | 2008-08-18 00:39:10 +0000 |
---|---|---|
committer | Jeff Ames | 2008-08-18 00:39:10 +0000 |
commit | 6ef9d4da901a346c232458317cca6268da888e2e (patch) | |
tree | dd1d935b10f34f261839da9f9879c02322e8ede7 /OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs | |
parent | Update svn properties, minor formatting cleanup. (diff) | |
download | opensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.zip opensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.tar.gz opensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.tar.bz2 opensim-SC-6ef9d4da901a346c232458317cca6268da888e2e.tar.xz |
Formatting cleanup.
Diffstat (limited to 'OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs')
-rw-r--r-- | OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs index b4eb7db..95b0ee3 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs | |||
@@ -23,7 +23,6 @@ | |||
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 | * | ||
27 | */ | 26 | */ |
28 | 27 | ||
29 | using libsecondlife; | 28 | using libsecondlife; |
@@ -40,10 +39,8 @@ using OpenSim.Framework.Communications.Cache; | |||
40 | 39 | ||
41 | namespace OpenSim.ApplicationPlugins.Rest.Inventory | 40 | namespace OpenSim.ApplicationPlugins.Rest.Inventory |
42 | { | 41 | { |
43 | |||
44 | public class RestAssetServices : IRest | 42 | public class RestAssetServices : IRest |
45 | { | 43 | { |
46 | |||
47 | private bool enabled = false; | 44 | private bool enabled = false; |
48 | private string qPrefix = "assets"; | 45 | private string qPrefix = "assets"; |
49 | 46 | ||
@@ -52,7 +49,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
52 | 49 | ||
53 | public RestAssetServices() | 50 | public RestAssetServices() |
54 | { | 51 | { |
55 | |||
56 | Rest.Log.InfoFormat("{0} Asset services initializing", MsgId); | 52 | Rest.Log.InfoFormat("{0} Asset services initializing", MsgId); |
57 | Rest.Log.InfoFormat("{0} Using REST Implementation Version {1}", MsgId, Rest.Version); | 53 | Rest.Log.InfoFormat("{0} Using REST Implementation Version {1}", MsgId, Rest.Version); |
58 | 54 | ||
@@ -73,7 +69,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
73 | enabled = true; | 69 | enabled = true; |
74 | 70 | ||
75 | Rest.Log.InfoFormat("{0} Asset services initialization complete", MsgId); | 71 | Rest.Log.InfoFormat("{0} Asset services initialization complete", MsgId); |
76 | |||
77 | } | 72 | } |
78 | 73 | ||
79 | // Post-construction, pre-enabled initialization opportunity | 74 | // Post-construction, pre-enabled initialization opportunity |
@@ -84,7 +79,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
84 | } | 79 | } |
85 | 80 | ||
86 | // Called by the plug-in to halt REST processing. Local processing is | 81 | // Called by the plug-in to halt REST processing. Local processing is |
87 | // disabled, and control blocks until all current processing has | 82 | // disabled, and control blocks until all current processing has |
88 | // completed. No new processing will be started | 83 | // completed. No new processing will be started |
89 | 84 | ||
90 | public void Close() | 85 | public void Close() |
@@ -111,14 +106,14 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
111 | 106 | ||
112 | private void DoAsset(RequestData rparm) | 107 | private void DoAsset(RequestData rparm) |
113 | { | 108 | { |
114 | 109 | if (!enabled) | |
115 | if (!enabled) return; | 110 | return; |
116 | 111 | ||
117 | AssetRequestData rdata = (AssetRequestData) rparm; | 112 | AssetRequestData rdata = (AssetRequestData) rparm; |
118 | 113 | ||
119 | Rest.Log.DebugFormat("{0} REST Asset handler ENTRY", MsgId); | 114 | Rest.Log.DebugFormat("{0} REST Asset handler ENTRY", MsgId); |
120 | 115 | ||
121 | // Now that we know this is a serious attempt to | 116 | // Now that we know this is a serious attempt to |
122 | // access inventory data, we should find out who | 117 | // access inventory data, we should find out who |
123 | // is asking, and make sure they are authorized | 118 | // is asking, and make sure they are authorized |
124 | // to do so. We need to validate the caller's | 119 | // to do so. We need to validate the caller's |
@@ -129,9 +124,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
129 | // With the present HTTP server we can't use the | 124 | // With the present HTTP server we can't use the |
130 | // builtin authentication mechanisms because they | 125 | // builtin authentication mechanisms because they |
131 | // would be enforced for all in-bound requests. | 126 | // would be enforced for all in-bound requests. |
132 | // Instead we look at the headers ourselves and | 127 | // Instead we look at the headers ourselves and |
133 | // handle authentication directly. | 128 | // handle authentication directly. |
134 | 129 | ||
135 | try | 130 | try |
136 | { | 131 | { |
137 | if (!rdata.IsAuthenticated) | 132 | if (!rdata.IsAuthenticated) |
@@ -144,13 +139,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
144 | if (e.statusCode == Rest.HttpStatusCodeNotAuthorized) | 139 | if (e.statusCode == Rest.HttpStatusCodeNotAuthorized) |
145 | { | 140 | { |
146 | Rest.Log.WarnFormat("{0} User not authenticated", MsgId); | 141 | Rest.Log.WarnFormat("{0} User not authenticated", MsgId); |
147 | Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, | 142 | Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, |
148 | rdata.request.Headers.Get("Authorization")); | 143 | rdata.request.Headers.Get("Authorization")); |
149 | } | 144 | } |
150 | else | 145 | else |
151 | { | 146 | { |
152 | Rest.Log.ErrorFormat("{0} User authentication failed", MsgId); | 147 | Rest.Log.ErrorFormat("{0} User authentication failed", MsgId); |
153 | Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, | 148 | Rest.Log.DebugFormat("{0} Authorization header: {1}", MsgId, |
154 | rdata.request.Headers.Get("Authorization")); | 149 | rdata.request.Headers.Get("Authorization")); |
155 | } | 150 | } |
156 | throw (e); | 151 | throw (e); |
@@ -173,7 +168,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
173 | case "post" : | 168 | case "post" : |
174 | case "delete" : | 169 | case "delete" : |
175 | default : | 170 | default : |
176 | Rest.Log.WarnFormat("{0} Asset: Method not supported: {1}", | 171 | Rest.Log.WarnFormat("{0} Asset: Method not supported: {1}", |
177 | MsgId, rdata.method); | 172 | MsgId, rdata.method); |
178 | rdata.Fail(Rest.HttpStatusCodeBadRequest, | 173 | rdata.Fail(Rest.HttpStatusCodeBadRequest, |
179 | Rest.HttpStatusDescBadRequest); | 174 | Rest.HttpStatusDescBadRequest); |
@@ -194,7 +189,6 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
194 | 189 | ||
195 | private void DoGet(AssetRequestData rdata) | 190 | private void DoGet(AssetRequestData rdata) |
196 | { | 191 | { |
197 | |||
198 | bool istexture = false; | 192 | bool istexture = false; |
199 | 193 | ||
200 | Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method); | 194 | Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method); |
@@ -204,13 +198,11 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
204 | 198 | ||
205 | if (rdata.parameters.Length == 1) | 199 | if (rdata.parameters.Length == 1) |
206 | { | 200 | { |
207 | |||
208 | LLUUID uuid = new LLUUID(rdata.parameters[0]); | 201 | LLUUID uuid = new LLUUID(rdata.parameters[0]); |
209 | AssetBase asset = Rest.AssetServices.GetAsset(uuid, istexture); | 202 | AssetBase asset = Rest.AssetServices.GetAsset(uuid, istexture); |
210 | 203 | ||
211 | if (asset != null) | 204 | if (asset != null) |
212 | { | 205 | { |
213 | |||
214 | Rest.Log.DebugFormat("{0} Asset located <{1}>", MsgId, rdata.parameters[0]); | 206 | Rest.Log.DebugFormat("{0} Asset located <{1}>", MsgId, rdata.parameters[0]); |
215 | 207 | ||
216 | rdata.initXmlWriter(); | 208 | rdata.initXmlWriter(); |
@@ -227,19 +219,17 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
227 | rdata.writer.WriteBase64(asset.Data,0,asset.Data.Length); | 219 | rdata.writer.WriteBase64(asset.Data,0,asset.Data.Length); |
228 | 220 | ||
229 | rdata.writer.WriteFullEndElement(); | 221 | rdata.writer.WriteFullEndElement(); |
230 | |||
231 | } | 222 | } |
232 | else | 223 | else |
233 | { | 224 | { |
234 | Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path); | 225 | Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path); |
235 | rdata.Fail(Rest.HttpStatusCodeNotFound, | 226 | rdata.Fail(Rest.HttpStatusCodeNotFound, |
236 | Rest.HttpStatusDescNotFound); | 227 | Rest.HttpStatusDescNotFound); |
237 | } | 228 | } |
238 | } | 229 | } |
239 | 230 | ||
240 | rdata.Complete(); | 231 | rdata.Complete(); |
241 | rdata.Respond("Asset " + rdata.method + ": Normal completion"); | 232 | rdata.Respond("Asset " + rdata.method + ": Normal completion"); |
242 | |||
243 | } | 233 | } |
244 | 234 | ||
245 | private void DoPut(AssetRequestData rdata) | 235 | private void DoPut(AssetRequestData rdata) |
@@ -257,7 +247,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
257 | if (!xml.ReadToFollowing("Asset")) | 247 | if (!xml.ReadToFollowing("Asset")) |
258 | { | 248 | { |
259 | Rest.Log.DebugFormat("{0} Invalid request data: <{1}>", MsgId, rdata.path); | 249 | Rest.Log.DebugFormat("{0} Invalid request data: <{1}>", MsgId, rdata.path); |
260 | rdata.Fail(Rest.HttpStatusCodeBadRequest, | 250 | rdata.Fail(Rest.HttpStatusCodeBadRequest, |
261 | Rest.HttpStatusDescBadRequest); | 251 | Rest.HttpStatusDescBadRequest); |
262 | } | 252 | } |
263 | 253 | ||
@@ -275,13 +265,12 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
275 | else | 265 | else |
276 | { | 266 | { |
277 | Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path); | 267 | Rest.Log.DebugFormat("{0} Invalid parameters: <{1}>", MsgId, rdata.path); |
278 | rdata.Fail(Rest.HttpStatusCodeNotFound, | 268 | rdata.Fail(Rest.HttpStatusCodeNotFound, |
279 | Rest.HttpStatusDescNotFound); | 269 | Rest.HttpStatusDescNotFound); |
280 | } | 270 | } |
281 | 271 | ||
282 | rdata.Complete(); | 272 | rdata.Complete(); |
283 | rdata.Respond("Asset " + rdata.method + ": Normal completion"); | 273 | rdata.Respond("Asset " + rdata.method + ": Normal completion"); |
284 | |||
285 | } | 274 | } |
286 | 275 | ||
287 | internal class AssetRequestData : RequestData | 276 | internal class AssetRequestData : RequestData |
@@ -291,6 +280,5 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
291 | { | 280 | { |
292 | } | 281 | } |
293 | } | 282 | } |
294 | |||
295 | } | 283 | } |
296 | } | 284 | } |