diff options
Diffstat (limited to '')
5 files changed, 62 insertions, 32 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs index 19bf381..21fcf92 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/Rest.cs | |||
@@ -58,6 +58,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
58 | internal static CommunicationsManager Comms = null; | 58 | internal static CommunicationsManager Comms = null; |
59 | internal static IInventoryServices InventoryServices = null; | 59 | internal static IInventoryServices InventoryServices = null; |
60 | internal static IUserService UserServices = null; | 60 | internal static IUserService UserServices = null; |
61 | internal static IAvatarService AvatarServices = null; | ||
61 | internal static AssetCache AssetServices = null; | 62 | internal static AssetCache AssetServices = null; |
62 | internal static string Prefix = null; | 63 | internal static string Prefix = null; |
63 | internal static IConfig Config = null; | 64 | internal static IConfig Config = null; |
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs index 9d34b4e..5fd8015 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAssetServices.cs | |||
@@ -57,7 +57,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
57 | 57 | ||
58 | if (!qPrefix.StartsWith(Rest.UrlPathSeparator)) | 58 | if (!qPrefix.StartsWith(Rest.UrlPathSeparator)) |
59 | { | 59 | { |
60 | qPrefix = Rest.Prefix + Rest.UrlPathSeparator + qPrefix; | 60 | Rest.Log.InfoFormat("{0} Prefixing domain name ({1})", MsgId, qPrefix); |
61 | qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix); | ||
62 | Rest.Log.InfoFormat("{0} Fully qualified domain name is <{1}>", MsgId, qPrefix); | ||
61 | } | 63 | } |
62 | 64 | ||
63 | // Register interface using the fully-qualified prefix | 65 | // Register interface using the fully-qualified prefix |
@@ -85,7 +87,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
85 | public void Close() | 87 | public void Close() |
86 | { | 88 | { |
87 | enabled = false; | 89 | enabled = false; |
88 | Rest.Log.InfoFormat("{0} Asset services closing down", MsgId); | 90 | Rest.Log.InfoFormat("{0} Asset services ({1}) closing down", MsgId, qPrefix); |
89 | } | 91 | } |
90 | 92 | ||
91 | // Properties | 93 | // Properties |
@@ -110,7 +112,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
110 | 112 | ||
111 | AssetRequestData rdata = (AssetRequestData) rparm; | 113 | AssetRequestData rdata = (AssetRequestData) rparm; |
112 | 114 | ||
113 | Rest.Log.DebugFormat("{0} REST Asset handler ENTRY", MsgId); | 115 | Rest.Log.DebugFormat("{0} REST Asset handler ({1}) ENTRY", MsgId, qPrefix); |
114 | 116 | ||
115 | // Now that we know this is a serious attempt to | 117 | // Now that we know this is a serious attempt to |
116 | // access inventory data, we should find out who | 118 | // access inventory data, we should find out who |
@@ -184,15 +186,17 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
184 | 186 | ||
185 | #endregion Interface | 187 | #endregion Interface |
186 | 188 | ||
189 | /// <summary> | ||
190 | /// The only parameter we recognize is a UUID.If an asset with this identification is | ||
191 | /// found, it's content, base-64 encoded, is returned to the client. | ||
192 | /// </summary> | ||
193 | |||
187 | private void DoGet(AssetRequestData rdata) | 194 | private void DoGet(AssetRequestData rdata) |
188 | { | 195 | { |
189 | bool istexture = false; | 196 | bool istexture = false; |
190 | 197 | ||
191 | Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method); | 198 | Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method); |
192 | 199 | ||
193 | // The only parameter we accept is an UUID for | ||
194 | // the asset | ||
195 | |||
196 | if (rdata.Parameters.Length == 1) | 200 | if (rdata.Parameters.Length == 1) |
197 | { | 201 | { |
198 | UUID uuid = new UUID(rdata.Parameters[0]); | 202 | UUID uuid = new UUID(rdata.Parameters[0]); |
@@ -226,15 +230,19 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
226 | } | 230 | } |
227 | 231 | ||
228 | rdata.Complete(); | 232 | rdata.Complete(); |
229 | rdata.Respond("Asset " + rdata.method + ": Normal completion"); | 233 | rdata.Respond(String.Format("Asset <{0}> : Normal completion", rdata.method)); |
234 | |||
230 | } | 235 | } |
231 | 236 | ||
237 | /// <summary> | ||
238 | /// The only parameter we recognize is a UUID. The enclosed asset data (base-64 encoded) | ||
239 | /// is decoded and stored in the database, identified by the supplied UUID. | ||
240 | /// </summary> | ||
241 | |||
232 | private void DoPut(AssetRequestData rdata) | 242 | private void DoPut(AssetRequestData rdata) |
233 | { | 243 | { |
234 | Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method); | ||
235 | 244 | ||
236 | // The only parameter we accept is an UUID for | 245 | Rest.Log.DebugFormat("{0} REST Asset handler, Method = <{1}> ENTRY", MsgId, rdata.method); |
237 | // the asset | ||
238 | 246 | ||
239 | if (rdata.Parameters.Length == 1) | 247 | if (rdata.Parameters.Length == 1) |
240 | { | 248 | { |
@@ -265,9 +273,14 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
265 | } | 273 | } |
266 | 274 | ||
267 | rdata.Complete(); | 275 | rdata.Complete(); |
268 | rdata.Respond("Asset " + rdata.method + ": Normal completion"); | 276 | rdata.Respond(String.Format("Asset <{0}>: Normal completion", rdata.method)); |
277 | |||
269 | } | 278 | } |
270 | 279 | ||
280 | /// <summary> | ||
281 | /// Asset processing has no special data area requirements. | ||
282 | /// </summary> | ||
283 | |||
271 | internal class AssetRequestData : RequestData | 284 | internal class AssetRequestData : RequestData |
272 | { | 285 | { |
273 | internal AssetRequestData(OSHttpRequest request, OSHttpResponse response, string prefix) | 286 | internal AssetRequestData(OSHttpRequest request, OSHttpResponse response, string prefix) |
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs index ab6128f..126b757 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestHandler.cs | |||
@@ -123,7 +123,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
123 | /// construction, or during initialization. | 123 | /// construction, or during initialization. |
124 | /// | 124 | /// |
125 | /// I was not able to make this code work within a constructor | 125 | /// I was not able to make this code work within a constructor |
126 | /// so it is islated within this method. | 126 | /// so it is isolated within this method. |
127 | /// </summary> | 127 | /// </summary> |
128 | 128 | ||
129 | private void LoadHandlers() | 129 | private void LoadHandlers() |
@@ -222,7 +222,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
222 | return; | 222 | return; |
223 | } | 223 | } |
224 | 224 | ||
225 | Rest.Log.InfoFormat("{0} Plugin will be enabled", MsgId); | 225 | Rest.Log.InfoFormat("{0} Rest <{1}> plugin will be enabled", MsgId, Name); |
226 | Rest.Log.InfoFormat("{0} Configuration parameters read from <{1}>", MsgId, ConfigName); | ||
226 | 227 | ||
227 | // These are stored in static variables to make | 228 | // These are stored in static variables to make |
228 | // them easy to reach from anywhere in the assembly. | 229 | // them easy to reach from anywhere in the assembly. |
@@ -233,6 +234,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
233 | Rest.UserServices = Rest.Comms.UserService; | 234 | Rest.UserServices = Rest.Comms.UserService; |
234 | Rest.InventoryServices = Rest.Comms.InventoryService; | 235 | Rest.InventoryServices = Rest.Comms.InventoryService; |
235 | Rest.AssetServices = Rest.Comms.AssetCache; | 236 | Rest.AssetServices = Rest.Comms.AssetCache; |
237 | Rest.AvatarServices = Rest.Comms.AvatarService; | ||
236 | Rest.Config = Config; | 238 | Rest.Config = Config; |
237 | Rest.Prefix = Prefix; | 239 | Rest.Prefix = Prefix; |
238 | Rest.GodKey = GodKey; | 240 | Rest.GodKey = GodKey; |
@@ -261,15 +263,18 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
261 | // The supplied prefix MUST be absolute | 263 | // The supplied prefix MUST be absolute |
262 | 264 | ||
263 | if (Rest.Prefix.Substring(0,1) != Rest.UrlPathSeparator) | 265 | if (Rest.Prefix.Substring(0,1) != Rest.UrlPathSeparator) |
264 | Rest.Prefix = Rest.UrlPathSeparator+Rest.Prefix; | 266 | { |
267 | Rest.Log.WarnFormat("{0} Prefix <{1}> is not absolute and must be", MsgId, Rest.Prefix); | ||
268 | Rest.Log.InfoFormat("{0} Prefix changed to </{1}>", MsgId, Rest.Prefix); | ||
269 | Rest.Prefix = String.Format("{0}{1}", Rest.UrlPathSeparator, Rest.Prefix); | ||
270 | } | ||
265 | 271 | ||
266 | // If data dumping is requested, report on the chosen line | 272 | // If data dumping is requested, report on the chosen line |
267 | // length. | 273 | // length. |
268 | 274 | ||
269 | if (Rest.DumpAsset) | 275 | if (Rest.DumpAsset) |
270 | { | 276 | { |
271 | Rest.Log.InfoFormat("{0} Dump {1} bytes per line", MsgId, | 277 | Rest.Log.InfoFormat("{0} Dump {1} bytes per line", MsgId, Rest.DumpLineSize); |
272 | Rest.DumpLineSize); | ||
273 | } | 278 | } |
274 | 279 | ||
275 | // Load all of the handlers present in the | 280 | // Load all of the handlers present in the |
@@ -361,11 +366,13 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
361 | /// underlying handlers and looks for the best match. It returns | 366 | /// underlying handlers and looks for the best match. It returns |
362 | /// true if a match is found. | 367 | /// true if a match is found. |
363 | /// The matching process could be made arbitrarily complex. | 368 | /// The matching process could be made arbitrarily complex. |
369 | /// Note: The match is case-insensitive. | ||
364 | /// </summary> | 370 | /// </summary> |
365 | 371 | ||
366 | public bool Match(OSHttpRequest request, OSHttpResponse response) | 372 | public bool Match(OSHttpRequest request, OSHttpResponse response) |
367 | { | 373 | { |
368 | string path = request.RawUrl; | 374 | |
375 | string path = request.RawUrl.ToLower(); | ||
369 | 376 | ||
370 | Rest.Log.DebugFormat("{0} Match ENTRY", MsgId); | 377 | Rest.Log.DebugFormat("{0} Match ENTRY", MsgId); |
371 | 378 | ||
@@ -483,6 +490,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
483 | /// If there is a stream handler registered that can handle the | 490 | /// If there is a stream handler registered that can handle the |
484 | /// request, then fine. If the request is not matched, do | 491 | /// request, then fine. If the request is not matched, do |
485 | /// nothing. | 492 | /// nothing. |
493 | /// Note: The selection is case-insensitive | ||
486 | /// </summary> | 494 | /// </summary> |
487 | 495 | ||
488 | private bool FindStreamHandler(OSHttpRequest request, OSHttpResponse response) | 496 | private bool FindStreamHandler(OSHttpRequest request, OSHttpResponse response) |
@@ -490,7 +498,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
490 | RequestData rdata = new RequestData(request, response, String.Empty); | 498 | RequestData rdata = new RequestData(request, response, String.Empty); |
491 | 499 | ||
492 | string bestMatch = null; | 500 | string bestMatch = null; |
493 | string path = String.Format("{0}:{1}", rdata.method, rdata.path); | 501 | string path = String.Format("{0}:{1}", rdata.method, rdata.path).ToLower(); |
494 | 502 | ||
495 | Rest.Log.DebugFormat("{0} Checking for stream handler for <{1}>", MsgId, path); | 503 | Rest.Log.DebugFormat("{0} Checking for stream handler for <{1}>", MsgId, path); |
496 | 504 | ||
@@ -567,6 +575,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
567 | /// handler was located. The boolean indicates whether or not the request has been | 575 | /// handler was located. The boolean indicates whether or not the request has been |
568 | /// handled, not whether or not the request was successful - that information is in | 576 | /// handled, not whether or not the request was successful - that information is in |
569 | /// the response. | 577 | /// the response. |
578 | /// Note: The selection process is case-insensitive | ||
570 | /// </summary> | 579 | /// </summary> |
571 | 580 | ||
572 | internal bool FindPathHandler(OSHttpRequest request, OSHttpResponse response) | 581 | internal bool FindPathHandler(OSHttpRequest request, OSHttpResponse response) |
@@ -585,7 +594,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
585 | 594 | ||
586 | foreach (string pattern in pathHandlers.Keys) | 595 | foreach (string pattern in pathHandlers.Keys) |
587 | { | 596 | { |
588 | if (request.RawUrl.StartsWith(pattern)) | 597 | if (request.RawUrl.ToLower().StartsWith(pattern)) |
589 | { | 598 | { |
590 | if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) | 599 | if (String.IsNullOrEmpty(bestMatch) || pattern.Length > bestMatch.Length) |
591 | { | 600 | { |
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs index d352655..6791cba 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs | |||
@@ -66,7 +66,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
66 | 66 | ||
67 | if (!qPrefix.StartsWith(Rest.UrlPathSeparator)) | 67 | if (!qPrefix.StartsWith(Rest.UrlPathSeparator)) |
68 | { | 68 | { |
69 | qPrefix = Rest.Prefix + Rest.UrlPathSeparator + qPrefix; | 69 | Rest.Log.InfoFormat("{0} Domain is relative, adding absolute prefix", MsgId); |
70 | qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix); | ||
71 | Rest.Log.InfoFormat("{0} Domain is now <{1}>", MsgId, qPrefix); | ||
70 | } | 72 | } |
71 | 73 | ||
72 | // Register interface using the absolute URI. | 74 | // Register interface using the absolute URI. |
@@ -262,7 +264,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
262 | // TODO | 264 | // TODO |
263 | // If something went wrong in inventory processing the thread could stall here | 265 | // If something went wrong in inventory processing the thread could stall here |
264 | // indefinitely. There should be a watchdog timer to fail the request if the | 266 | // indefinitely. There should be a watchdog timer to fail the request if the |
265 | // response is not recieved in a timely fashion. | 267 | // response is not received in a timely fashion. |
266 | 268 | ||
267 | rdata.uuid = rdata.userProfile.ID; | 269 | rdata.uuid = rdata.userProfile.ID; |
268 | 270 | ||
@@ -330,7 +332,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
330 | default : | 332 | default : |
331 | Rest.Log.WarnFormat("{0} Method {1} not supported for {2}", | 333 | Rest.Log.WarnFormat("{0} Method {1} not supported for {2}", |
332 | MsgId, rdata.method, rdata.path); | 334 | MsgId, rdata.method, rdata.path); |
333 | rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed, rdata.method+" not supported"); | 335 | rdata.Fail(Rest.HttpStatusCodeMethodNotAllowed, |
336 | String.Format("{0} not supported", rdata.method)); | ||
334 | break; | 337 | break; |
335 | } | 338 | } |
336 | } | 339 | } |
@@ -591,8 +594,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
591 | if (created) | 594 | if (created) |
592 | { | 595 | { |
593 | // Must include a location header with a URI that identifies the new resource. | 596 | // Must include a location header with a URI that identifies the new resource. |
594 | rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}/{2}", | 597 | rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}/{3}", |
595 | rdata.hostname+":"+rdata.port,rdata.path,newnode)); | 598 | rdata.hostname, rdata.port,rdata.path,newnode)); |
596 | rdata.Complete(Rest.HttpStatusCodeCreated); | 599 | rdata.Complete(Rest.HttpStatusCodeCreated); |
597 | } | 600 | } |
598 | else | 601 | else |
@@ -607,7 +610,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
607 | } | 610 | } |
608 | } | 611 | } |
609 | 612 | ||
610 | rdata.Respond("Inventory " + rdata.method + ": Normal completion"); | 613 | rdata.Respond(String.Format("Profile {0} : Normal completion", rdata.method)); |
611 | } | 614 | } |
612 | else | 615 | else |
613 | { | 616 | { |
@@ -872,7 +875,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
872 | } | 875 | } |
873 | } | 876 | } |
874 | 877 | ||
875 | rdata.Respond("Inventory " + rdata.method + ": Normal completion"); | 878 | rdata.Respond(String.Format("Profile {0} : Normal completion", rdata.method)); |
879 | |||
876 | } | 880 | } |
877 | 881 | ||
878 | /// <summary> | 882 | /// <summary> |
@@ -927,7 +931,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
927 | } | 931 | } |
928 | 932 | ||
929 | rdata.Complete(); | 933 | rdata.Complete(); |
930 | rdata.Respond("Inventory " + rdata.method + ": Normal completion"); | 934 | rdata.Respond(String.Format("Profile {0} : Normal completion", rdata.method)); |
931 | } | 935 | } |
932 | 936 | ||
933 | #endregion method-specific processing | 937 | #endregion method-specific processing |
@@ -1061,7 +1065,8 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1061 | 1065 | ||
1062 | Rest.Log.DebugFormat("{0} {1}: Resource {2} not found", | 1066 | Rest.Log.DebugFormat("{0} {1}: Resource {2} not found", |
1063 | MsgId, rdata.method, rdata.path); | 1067 | MsgId, rdata.method, rdata.path); |
1064 | rdata.Fail(Rest.HttpStatusCodeNotFound, "resource "+rdata.path+" not found"); | 1068 | rdata.Fail(Rest.HttpStatusCodeNotFound, |
1069 | String.Format("resource {0}:{1} not found", rdata.method, rdata.path)); | ||
1065 | 1070 | ||
1066 | return null; /* Never reached */ | 1071 | return null; /* Never reached */ |
1067 | } | 1072 | } |
@@ -1189,9 +1194,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
1189 | { | 1194 | { |
1190 | // Fetching an Item has a special significance. In this | 1195 | // Fetching an Item has a special significance. In this |
1191 | // case we also want to fetch the associated asset. | 1196 | // case we also want to fetch the associated asset. |
1192 | // To make it interesting, we'll d this via redirection. | 1197 | // To make it interesting, we'll do this via redirection. |
1193 | string asseturl = "http://" + rdata.hostname + ":" + rdata.port + | 1198 | string asseturl = String.Format("http://{0}:{1}/{2}{3}{4}", rdata.hostname, rdata.port, |
1194 | "/admin/assets" + Rest.UrlPathSeparator + ifound.AssetID.ToString(); | 1199 | "admin/assets",Rest.UrlPathSeparator,ifound.AssetID.ToString()); |
1195 | rdata.Redirect(asseturl,Rest.PERMANENT); | 1200 | rdata.Redirect(asseturl,Rest.PERMANENT); |
1196 | Rest.Log.DebugFormat("{0} Never Reached", MsgId); | 1201 | Rest.Log.DebugFormat("{0} Never Reached", MsgId); |
1197 | } | 1202 | } |
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestTestServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestTestServices.cs index aba7357..8d28dd6 100644 --- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestTestServices.cs +++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestTestServices.cs | |||
@@ -58,7 +58,9 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory | |||
58 | 58 | ||
59 | if (!qPrefix.StartsWith(Rest.UrlPathSeparator)) | 59 | if (!qPrefix.StartsWith(Rest.UrlPathSeparator)) |
60 | { | 60 | { |
61 | qPrefix = Rest.Prefix + Rest.UrlPathSeparator + qPrefix; | 61 | Rest.Log.InfoFormat("{0} Domain is relative, adding absolute prefix", MsgId); |
62 | qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix); | ||
63 | Rest.Log.InfoFormat("{0} Domain is now <{1}>", MsgId, qPrefix); | ||
62 | } | 64 | } |
63 | 65 | ||
64 | // Load test cases | 66 | // Load test cases |