aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ApplicationPlugins')
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs302
-rw-r--r--OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs1014
2 files changed, 656 insertions, 660 deletions
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
index b70a511..4369216 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestAppearanceServices.cs
@@ -39,8 +39,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
39 39
40 public class RestAppearanceServices : IRest 40 public class RestAppearanceServices : IRest
41 { 41 {
42 42// private static readonly int PARM_USERID = 0;
43 private static readonly int PARM_USERID = 0;
44 43
45 // private static readonly int PARM_PATH = 1; 44 // private static readonly int PARM_PATH = 1;
46 45
@@ -64,6 +63,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
64 { 63 {
65 Rest.Log.InfoFormat("{0} Domain is relative, adding absolute prefix", MsgId); 64 Rest.Log.InfoFormat("{0} Domain is relative, adding absolute prefix", MsgId);
66 qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix); 65 qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix);
66 qPrefix = String.Format("{0}{1}{2}", Rest.Prefix, Rest.UrlPathSeparator, qPrefix);
67 Rest.Log.InfoFormat("{0} Domain is now <{1}>", MsgId, qPrefix); 67 Rest.Log.InfoFormat("{0} Domain is now <{1}>", MsgId, qPrefix);
68 } 68 }
69 69
@@ -294,31 +294,31 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
294 /// </summary> 294 /// </summary>
295 /// <param name=rdata>HTTP service request work area</param> 295 /// <param name=rdata>HTTP service request work area</param>
296 296
297 private void DoGet(AppearanceRequestData rdata) 297// private void DoGet(AppearanceRequestData rdata)
298 { 298// {
299 AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID); 299// AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID);
300 300//
301 if (adata == null) 301// if (adata == null)
302 { 302// {
303 rdata.Fail(Rest.HttpStatusCodeNoContent, 303// rdata.Fail(Rest.HttpStatusCodeNoContent,
304 String.Format("appearance data not found for user {0} {1}", 304// String.Format("appearance data not found for user {0} {1}",
305 rdata.userProfile.FirstName, rdata.userProfile.SurName)); 305// rdata.userProfile.FirstName, rdata.userProfile.SurName));
306 } 306// }
307 rdata.userAppearance = adata.ToAvatarAppearance(rdata.userProfile.ID); 307// rdata.userAppearance = adata.ToAvatarAppearance(rdata.userProfile.ID);
308 308//
309 rdata.initXmlWriter(); 309// rdata.initXmlWriter();
310 310//
311 FormatUserAppearance(rdata); 311// FormatUserAppearance(rdata);
312 312//
313 // Indicate a successful request 313// // Indicate a successful request
314 314//
315 rdata.Complete(); 315// rdata.Complete();
316 316//
317 // Send the response to the user. The body will be implicitly 317// // Send the response to the user. The body will be implicitly
318 // constructed from the result of the XML writer. 318// // constructed from the result of the XML writer.
319 319//
320 rdata.Respond(String.Format("Appearance {0} Normal completion", rdata.method)); 320// rdata.Respond(String.Format("Appearance {0} Normal completion", rdata.method));
321 } 321// }
322 322
323 /// <summary> 323 /// <summary>
324 /// POST adds NEW information to the user profile database. 324 /// POST adds NEW information to the user profile database.
@@ -326,112 +326,112 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
326 /// characteristics supplied in the request. 326 /// characteristics supplied in the request.
327 /// </summary> 327 /// </summary>
328 328
329 private void DoExtend(AppearanceRequestData rdata) 329// private void DoExtend(AppearanceRequestData rdata)
330 { 330// {
331 331//
332 bool created = false; 332// bool created = false;
333 bool modified = false; 333// bool modified = false;
334 string newnode = String.Empty; 334// string newnode = String.Empty;
335 335//
336 Rest.Log.DebugFormat("{0} POST ENTRY", MsgId); 336// Rest.Log.DebugFormat("{0} POST ENTRY", MsgId);
337 337//
338 //AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID); 338// //AvatarAppearance old = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
339 339//
340 rdata.userAppearance = new AvatarAppearance(); 340// rdata.userAppearance = new AvatarAppearance();
341 341//
342 // Although the following behavior is admitted by HTTP I am becoming 342// // Although the following behavior is admitted by HTTP I am becoming
343 // increasingly doubtful that it is appropriate for REST. If I attempt to 343// // increasingly doubtful that it is appropriate for REST. If I attempt to
344 // add a new record, and it already exists, then it seems to me that the 344// // add a new record, and it already exists, then it seems to me that the
345 // attempt should fail, rather than update the existing record. 345// // attempt should fail, rather than update the existing record.
346 AvatarData adata = null; 346// AvatarData adata = null;
347 if (GetUserAppearance(rdata)) 347// if (GetUserAppearance(rdata))
348 { 348// {
349 modified = rdata.userAppearance != null; 349// modified = rdata.userAppearance != null;
350 created = !modified; 350// created = !modified;
351 adata = new AvatarData(rdata.userAppearance); 351// adata = new AvatarData(rdata.userAppearance);
352 Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata); 352// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
353 // Rest.UserServices.UpdateUserProfile(rdata.userProfile); 353// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
354 } 354// }
355 else 355// else
356 { 356// {
357 created = true; 357// created = true;
358 adata = new AvatarData(rdata.userAppearance); 358// adata = new AvatarData(rdata.userAppearance);
359 Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata); 359// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
360 // Rest.UserServices.UpdateUserProfile(rdata.userProfile); 360// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
361 } 361// }
362 362//
363 if (created) 363// if (created)
364 { 364// {
365 newnode = String.Format("{0} {1}", rdata.userProfile.FirstName, 365// newnode = String.Format("{0} {1}", rdata.userProfile.FirstName,
366 rdata.userProfile.SurName); 366// rdata.userProfile.SurName);
367 // Must include a location header with a URI that identifies the new resource. 367// // Must include a location header with a URI that identifies the new resource.
368 368//
369 rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}{3}{4}", 369// rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}{3}{4}",
370 rdata.hostname,rdata.port,rdata.path,Rest.UrlPathSeparator, newnode)); 370// rdata.hostname,rdata.port,rdata.path,Rest.UrlPathSeparator, newnode));
371 rdata.Complete(Rest.HttpStatusCodeCreated); 371// rdata.Complete(Rest.HttpStatusCodeCreated);
372 372//
373 } 373// }
374 else 374// else
375 { 375// {
376 if (modified) 376// if (modified)
377 { 377// {
378 rdata.Complete(Rest.HttpStatusCodeOK); 378// rdata.Complete(Rest.HttpStatusCodeOK);
379 } 379// }
380 else 380// else
381 { 381// {
382 rdata.Complete(Rest.HttpStatusCodeNoContent); 382// rdata.Complete(Rest.HttpStatusCodeNoContent);
383 } 383// }
384 } 384// }
385 385//
386 rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method)); 386// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
387 387//
388 } 388// }
389 389
390 /// <summary> 390 /// <summary>
391 /// This updates the user's appearance. not all aspects need to be provided, 391 /// This updates the user's appearance. not all aspects need to be provided,
392 /// only those supplied will be changed. 392 /// only those supplied will be changed.
393 /// </summary> 393 /// </summary>
394 394
395 private void DoUpdate(AppearanceRequestData rdata) 395// private void DoUpdate(AppearanceRequestData rdata)
396 { 396// {
397 397//
398 // REFACTORING PROBLEM This was commented out. It doesn't work for 0.7 398// // REFACTORING PROBLEM This was commented out. It doesn't work for 0.7
399 399//
400 //bool created = false; 400// //bool created = false;
401 //bool modified = false; 401// //bool modified = false;
402 402//
403 403//
404 //rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID); 404// //rdata.userAppearance = Rest.AvatarServices.GetUserAppearance(rdata.userProfile.ID);
405 405//
406 //// If the user exists then this is considered a modification regardless 406// //// If the user exists then this is considered a modification regardless
407 //// of what may, or may not be, specified in the payload. 407// //// of what may, or may not be, specified in the payload.
408 408//
409 //if (rdata.userAppearance != null) 409// //if (rdata.userAppearance != null)
410 //{ 410// //{
411 // modified = true; 411// // modified = true;
412 // Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance); 412// // Rest.AvatarServices.UpdateUserAppearance(rdata.userProfile.ID, rdata.userAppearance);
413 // Rest.UserServices.UpdateUserProfile(rdata.userProfile); 413// // Rest.UserServices.UpdateUserProfile(rdata.userProfile);
414 //} 414// //}
415 415//
416 //if (created) 416// //if (created)
417 //{ 417// //{
418 // rdata.Complete(Rest.HttpStatusCodeCreated); 418// // rdata.Complete(Rest.HttpStatusCodeCreated);
419 //} 419// //}
420 //else 420// //else
421 //{ 421// //{
422 // if (modified) 422// // if (modified)
423 // { 423// // {
424 // rdata.Complete(Rest.HttpStatusCodeOK); 424// // rdata.Complete(Rest.HttpStatusCodeOK);
425 // } 425// // }
426 // else 426// // else
427 // { 427// // {
428 // rdata.Complete(Rest.HttpStatusCodeNoContent); 428// // rdata.Complete(Rest.HttpStatusCodeNoContent);
429 // } 429// // }
430 //} 430// //}
431 431//
432 rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method)); 432// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
433 433//
434 } 434// }
435 435
436 /// <summary> 436 /// <summary>
437 /// Delete the specified user's appearance. This actually performs a reset 437 /// Delete the specified user's appearance. This actually performs a reset
@@ -439,31 +439,29 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
439 /// Existing ownership is preserved. All prior updates are lost and can not 439 /// Existing ownership is preserved. All prior updates are lost and can not
440 /// be recovered. 440 /// be recovered.
441 /// </summary> 441 /// </summary>
442 442// private void DoDelete(AppearanceRequestData rdata)
443 private void DoDelete(AppearanceRequestData rdata) 443// {
444 { 444// AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID);
445 AvatarData adata = Rest.AvatarServices.GetAvatar(rdata.userProfile.ID); 445//
446 446// if (adata != null)
447 if (adata != null) 447// {
448 { 448// AvatarAppearance old = adata.ToAvatarAppearance(rdata.userProfile.ID);
449 AvatarAppearance old = adata.ToAvatarAppearance(rdata.userProfile.ID); 449// rdata.userAppearance = new AvatarAppearance();
450 rdata.userAppearance = new AvatarAppearance(); 450// rdata.userAppearance.Owner = old.Owner;
451 rdata.userAppearance.Owner = old.Owner; 451// adata = new AvatarData(rdata.userAppearance);
452 adata = new AvatarData(rdata.userAppearance); 452//
453 453// Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata);
454 Rest.AvatarServices.SetAvatar(rdata.userProfile.ID, adata); 454//
455 455// rdata.Complete();
456 rdata.Complete(); 456// }
457 } 457// else
458 else 458// {
459 { 459//
460 460// rdata.Complete(Rest.HttpStatusCodeNoContent);
461 rdata.Complete(Rest.HttpStatusCodeNoContent); 461// }
462 } 462//
463 463// rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method));
464 rdata.Respond(String.Format("Appearance {0} : Normal completion", rdata.method)); 464// }
465
466 }
467 465
468#endregion method-specific processing 466#endregion method-specific processing
469 467
diff --git a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
index 10f387d..a4135db 100644
--- a/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
+++ b/OpenSim/ApplicationPlugins/Rest/Inventory/RestInventoryServices.cs
@@ -45,10 +45,10 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
45{ 45{
46 public class RestInventoryServices : IRest 46 public class RestInventoryServices : IRest
47 { 47 {
48 private static readonly int PARM_USERID = 0; 48// private static readonly int PARM_USERID = 0;
49 private static readonly int PARM_PATH = 1; 49 private static readonly int PARM_PATH = 1;
50 50
51 private bool enabled = false; 51// private bool enabled = false;
52 private string qPrefix = "inventory"; 52 private string qPrefix = "inventory";
53 53
54 private static readonly string PRIVATE_ROOT_NAME = "My Inventory"; 54 private static readonly string PRIVATE_ROOT_NAME = "My Inventory";
@@ -79,7 +79,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
79 79
80 // Activate if everything went OK 80 // Activate if everything went OK
81 81
82 enabled = true; 82// enabled = true;
83 83
84 Rest.Log.InfoFormat("{0} Inventory services initialization complete", MsgId); 84 Rest.Log.InfoFormat("{0} Inventory services initialization complete", MsgId);
85 } 85 }
@@ -100,7 +100,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
100 100
101 public void Close() 101 public void Close()
102 { 102 {
103 enabled = false; 103// enabled = false;
104 Rest.Log.InfoFormat("{0} Inventory services closing down", MsgId); 104 Rest.Log.InfoFormat("{0} Inventory services closing down", MsgId);
105 } 105 }
106 106
@@ -139,7 +139,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
139 /// <param name=hdata>A consolidated HTTP request work area</param> 139 /// <param name=hdata>A consolidated HTTP request work area</param>
140 private void DoInventory(RequestData hdata) 140 private void DoInventory(RequestData hdata)
141 { 141 {
142 InventoryRequestData rdata = (InventoryRequestData) hdata; 142// InventoryRequestData rdata = (InventoryRequestData) hdata;
143 143
144 Rest.Log.DebugFormat("{0} DoInventory ENTRY", MsgId); 144 Rest.Log.DebugFormat("{0} DoInventory ENTRY", MsgId);
145 145
@@ -354,32 +354,32 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
354 /// corresponding subtree based upon node name. 354 /// corresponding subtree based upon node name.
355 /// </summary> 355 /// </summary>
356 /// <param name=rdata>HTTP service request work area</param> 356 /// <param name=rdata>HTTP service request work area</param>
357 private void DoGet(InventoryRequestData rdata) 357// private void DoGet(InventoryRequestData rdata)
358 { 358// {
359 rdata.initXmlWriter(); 359// rdata.initXmlWriter();
360 360//
361 rdata.writer.WriteStartElement(String.Empty,"Inventory",String.Empty); 361// rdata.writer.WriteStartElement(String.Empty,"Inventory",String.Empty);
362 362//
363 // If there are additional parameters, then these represent 363// // If there are additional parameters, then these represent
364 // a path relative to the root of the inventory. This path 364// // a path relative to the root of the inventory. This path
365 // must be traversed before we format the sub-tree thus 365// // must be traversed before we format the sub-tree thus
366 // identified. 366// // identified.
367 367//
368 traverse(rdata, rdata.root, PARM_PATH); 368// traverse(rdata, rdata.root, PARM_PATH);
369 369//
370 // Close all open elements 370// // Close all open elements
371 371//
372 rdata.writer.WriteFullEndElement(); 372// rdata.writer.WriteFullEndElement();
373 373//
374 // Indicate a successful request 374// // Indicate a successful request
375 375//
376 rdata.Complete(); 376// rdata.Complete();
377 377//
378 // Send the response to the user. The body will be implicitly 378// // Send the response to the user. The body will be implicitly
379 // constructed from the result of the XML writer. 379// // constructed from the result of the XML writer.
380 380//
381 rdata.Respond(String.Format("Inventory {0} Normal completion", rdata.method)); 381// rdata.Respond(String.Format("Inventory {0} Normal completion", rdata.method));
382 } 382// }
383 383
384 /// <summary> 384 /// <summary>
385 /// In the case of the inventory, and probably in general, 385 /// In the case of the inventory, and probably in general,
@@ -419,210 +419,210 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
419 /// context identified by the URI. 419 /// context identified by the URI.
420 /// </summary> 420 /// </summary>
421 /// <param name=rdata>HTTP service request work area</param> 421 /// <param name=rdata>HTTP service request work area</param>
422 private void DoExtend(InventoryRequestData rdata) 422// private void DoExtend(InventoryRequestData rdata)
423 { 423// {
424 bool created = false; 424// bool created = false;
425 bool modified = false; 425// bool modified = false;
426 string newnode = String.Empty; 426// string newnode = String.Empty;
427 427//
428 // Resolve the context node specified in the URI. Entity 428// // Resolve the context node specified in the URI. Entity
429 // data will be ADDED beneath this node. rdata already contains 429// // data will be ADDED beneath this node. rdata already contains
430 // information about the current content of the user's 430// // information about the current content of the user's
431 // inventory. 431// // inventory.
432 432//
433 Object InventoryNode = getInventoryNode(rdata, rdata.root, PARM_PATH, Rest.Fill); 433// Object InventoryNode = getInventoryNode(rdata, rdata.root, PARM_PATH, Rest.Fill);
434 434//
435 // Processing depends upon the type of inventory node 435// // Processing depends upon the type of inventory node
436 // identified in the URI. This is the CONTEXT for the 436// // identified in the URI. This is the CONTEXT for the
437 // change. We either got a context or we threw an 437// // change. We either got a context or we threw an
438 // exception. 438// // exception.
439 439//
440 // It follows that we can only add information if the URI 440// // It follows that we can only add information if the URI
441 // has identified a folder. So only a type of folder is supported 441// // has identified a folder. So only a type of folder is supported
442 // in this case. 442// // in this case.
443 443//
444 if (typeof(InventoryFolderBase) == InventoryNode.GetType() || 444// if (typeof(InventoryFolderBase) == InventoryNode.GetType() ||
445 typeof(InventoryFolderImpl) == InventoryNode.GetType()) 445// typeof(InventoryFolderImpl) == InventoryNode.GetType())
446 { 446// {
447 // Cast the context node appropriately. 447// // Cast the context node appropriately.
448 448//
449 InventoryFolderBase context = (InventoryFolderBase) InventoryNode; 449// InventoryFolderBase context = (InventoryFolderBase) InventoryNode;
450 450//
451 Rest.Log.DebugFormat("{0} {1}: Resource(s) will be added to folder {2}", 451// Rest.Log.DebugFormat("{0} {1}: Resource(s) will be added to folder {2}",
452 MsgId, rdata.method, rdata.path); 452// MsgId, rdata.method, rdata.path);
453 453//
454 // Reconstitute the inventory sub-tree from the XML supplied in the entity. 454// // Reconstitute the inventory sub-tree from the XML supplied in the entity.
455 // The result is a stand-alone inventory subtree, not yet integrated into the 455// // The result is a stand-alone inventory subtree, not yet integrated into the
456 // existing tree. An inventory collection consists of three components: 456// // existing tree. An inventory collection consists of three components:
457 // [1] A (possibly empty) set of folders. 457// // [1] A (possibly empty) set of folders.
458 // [2] A (possibly empty) set of items. 458// // [2] A (possibly empty) set of items.
459 // [3] A (possibly empty) set of assets. 459// // [3] A (possibly empty) set of assets.
460 // If all of these are empty, then the POST is a harmless no-operation. 460// // If all of these are empty, then the POST is a harmless no-operation.
461 461//
462 XmlInventoryCollection entity = ReconstituteEntity(rdata); 462// XmlInventoryCollection entity = ReconstituteEntity(rdata);
463 463//
464 // Inlined assets can be included in entity. These must be incorporated into 464// // Inlined assets can be included in entity. These must be incorporated into
465 // the asset database before we attempt to update the inventory. If anything 465// // the asset database before we attempt to update the inventory. If anything
466 // fails, return a failure to requestor. 466// // fails, return a failure to requestor.
467 467//
468 if (entity.Assets.Count > 0) 468// if (entity.Assets.Count > 0)
469 { 469// {
470 Rest.Log.DebugFormat("{0} Adding {1} assets to server", 470// Rest.Log.DebugFormat("{0} Adding {1} assets to server",
471 MsgId, entity.Assets.Count); 471// MsgId, entity.Assets.Count);
472 472//
473 foreach (AssetBase asset in entity.Assets) 473// foreach (AssetBase asset in entity.Assets)
474 { 474// {
475 Rest.Log.DebugFormat("{0} Rest asset: {1} {2} {3}", 475// Rest.Log.DebugFormat("{0} Rest asset: {1} {2} {3}",
476 MsgId, asset.ID, asset.Type, asset.Name); 476// MsgId, asset.ID, asset.Type, asset.Name);
477 Rest.AssetServices.Store(asset); 477// Rest.AssetServices.Store(asset);
478 478//
479 created = true; 479// created = true;
480 rdata.appendStatus(String.Format("<p> Created asset {0}, UUID {1} <p>", 480// rdata.appendStatus(String.Format("<p> Created asset {0}, UUID {1} <p>",
481 asset.Name, asset.ID)); 481// asset.Name, asset.ID));
482 482//
483 if (Rest.DEBUG && Rest.DumpAsset) 483// if (Rest.DEBUG && Rest.DumpAsset)
484 { 484// {
485 Rest.Dump(asset.Data); 485// Rest.Dump(asset.Data);
486 } 486// }
487 } 487// }
488 } 488// }
489 489//
490 // Modify the context using the collection of folders and items 490// // Modify the context using the collection of folders and items
491 // returned in the XmlInventoryCollection. 491// // returned in the XmlInventoryCollection.
492 492//
493 foreach (InventoryFolderBase folder in entity.Folders) 493// foreach (InventoryFolderBase folder in entity.Folders)
494 { 494// {
495 InventoryFolderBase found; 495// InventoryFolderBase found;
496 496//
497 // If the parentID is zero, then this folder is going 497// // If the parentID is zero, then this folder is going
498 // into the root folder identified by the URI. The requestor 498// // into the root folder identified by the URI. The requestor
499 // may have already set the parent ID explicitly, in which 499// // may have already set the parent ID explicitly, in which
500 // case we don't have to do it here. 500// // case we don't have to do it here.
501 501//
502 if (folder.ParentID == UUID.Zero || folder.ParentID == context.ID) 502// if (folder.ParentID == UUID.Zero || folder.ParentID == context.ID)
503 { 503// {
504 if (newnode != String.Empty) 504// if (newnode != String.Empty)
505 { 505// {
506 Rest.Log.DebugFormat("{0} Too many resources", MsgId); 506// Rest.Log.DebugFormat("{0} Too many resources", MsgId);
507 rdata.Fail(Rest.HttpStatusCodeBadRequest, "only one root entity is allowed"); 507// rdata.Fail(Rest.HttpStatusCodeBadRequest, "only one root entity is allowed");
508 } 508// }
509 folder.ParentID = context.ID; 509// folder.ParentID = context.ID;
510 newnode = folder.Name; 510// newnode = folder.Name;
511 } 511// }
512 512//
513 // Search the existing inventory for an existing entry. If 513// // Search the existing inventory for an existing entry. If
514 // we have one, we need to decide if it has really changed. 514// // we have one, we need to decide if it has really changed.
515 // It could just be present as (unnecessary) context, and we 515// // It could just be present as (unnecessary) context, and we
516 // don't want to waste time updating the database in that 516// // don't want to waste time updating the database in that
517 // case, OR, it could be being moved from another location 517// // case, OR, it could be being moved from another location
518 // in which case an update is most certainly necessary. 518// // in which case an update is most certainly necessary.
519 519//
520 found = null; 520// found = null;
521 521//
522 foreach (InventoryFolderBase xf in rdata.folders) 522// foreach (InventoryFolderBase xf in rdata.folders)
523 { 523// {
524 // Compare identifying attribute 524// // Compare identifying attribute
525 if (xf.ID == folder.ID) 525// if (xf.ID == folder.ID)
526 { 526// {
527 found = xf; 527// found = xf;
528 break; 528// break;
529 } 529// }
530 } 530// }
531 531//
532 if (found != null && FolderHasChanged(folder,found)) 532// if (found != null && FolderHasChanged(folder,found))
533 { 533// {
534 Rest.Log.DebugFormat("{0} Updating existing folder", MsgId); 534// Rest.Log.DebugFormat("{0} Updating existing folder", MsgId);
535 Rest.InventoryServices.MoveFolder(folder); 535// Rest.InventoryServices.MoveFolder(folder);
536 536//
537 modified = true; 537// modified = true;
538 rdata.appendStatus(String.Format("<p> Created folder {0}, UUID {1} <p>", 538// rdata.appendStatus(String.Format("<p> Created folder {0}, UUID {1} <p>",
539 folder.Name, folder.ID)); 539// folder.Name, folder.ID));
540 } 540// }
541 else 541// else
542 { 542// {
543 Rest.Log.DebugFormat("{0} Adding new folder", MsgId); 543// Rest.Log.DebugFormat("{0} Adding new folder", MsgId);
544 Rest.InventoryServices.AddFolder(folder); 544// Rest.InventoryServices.AddFolder(folder);
545 545//
546 created = true; 546// created = true;
547 rdata.appendStatus(String.Format("<p> Modified folder {0}, UUID {1} <p>", 547// rdata.appendStatus(String.Format("<p> Modified folder {0}, UUID {1} <p>",
548 folder.Name, folder.ID)); 548// folder.Name, folder.ID));
549 } 549// }
550 } 550// }
551 551//
552 // Now we repeat a similar process for the items included 552// // Now we repeat a similar process for the items included
553 // in the entity. 553// // in the entity.
554 554//
555 foreach (InventoryItemBase item in entity.Items) 555// foreach (InventoryItemBase item in entity.Items)
556 { 556// {
557 InventoryItemBase found = null; 557// InventoryItemBase found = null;
558 558//
559 // If the parentID is zero, then this is going 559// // If the parentID is zero, then this is going
560 // directly into the root identified by the URI. 560// // directly into the root identified by the URI.
561 561//
562 if (item.Folder == UUID.Zero) 562// if (item.Folder == UUID.Zero)
563 { 563// {
564 item.Folder = context.ID; 564// item.Folder = context.ID;
565 } 565// }
566 566//
567 // Determine whether this is a new item or a 567// // Determine whether this is a new item or a
568 // replacement definition. 568// // replacement definition.
569 569//
570 foreach (InventoryItemBase xi in rdata.items) 570// foreach (InventoryItemBase xi in rdata.items)
571 { 571// {
572 // Compare identifying attribute 572// // Compare identifying attribute
573 if (xi.ID == item.ID) 573// if (xi.ID == item.ID)
574 { 574// {
575 found = xi; 575// found = xi;
576 break; 576// break;
577 } 577// }
578 } 578// }
579 579//
580 if (found != null && ItemHasChanged(item, found)) 580// if (found != null && ItemHasChanged(item, found))
581 { 581// {
582 Rest.Log.DebugFormat("{0} Updating item {1} {2} {3} {4} {5}", 582// Rest.Log.DebugFormat("{0} Updating item {1} {2} {3} {4} {5}",
583 MsgId, item.ID, item.AssetID, item.InvType, item.AssetType, item.Name); 583// MsgId, item.ID, item.AssetID, item.InvType, item.AssetType, item.Name);
584 Rest.InventoryServices.UpdateItem(item); 584// Rest.InventoryServices.UpdateItem(item);
585 modified = true; 585// modified = true;
586 rdata.appendStatus(String.Format("<p> Modified item {0}, UUID {1} <p>", item.Name, item.ID)); 586// rdata.appendStatus(String.Format("<p> Modified item {0}, UUID {1} <p>", item.Name, item.ID));
587 } 587// }
588 else 588// else
589 { 589// {
590 Rest.Log.DebugFormat("{0} Adding item {1} {2} {3} {4} {5}", 590// Rest.Log.DebugFormat("{0} Adding item {1} {2} {3} {4} {5}",
591 MsgId, item.ID, item.AssetID, item.InvType, item.AssetType, item.Name); 591// MsgId, item.ID, item.AssetID, item.InvType, item.AssetType, item.Name);
592 Rest.InventoryServices.AddItem(item); 592// Rest.InventoryServices.AddItem(item);
593 created = true; 593// created = true;
594 rdata.appendStatus(String.Format("<p> Created item {0}, UUID {1} <p>", item.Name, item.ID)); 594// rdata.appendStatus(String.Format("<p> Created item {0}, UUID {1} <p>", item.Name, item.ID));
595 } 595// }
596 } 596// }
597 597//
598 if (created) 598// if (created)
599 { 599// {
600 // Must include a location header with a URI that identifies the new resource. 600// // Must include a location header with a URI that identifies the new resource.
601 rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}/{3}", 601// rdata.AddHeader(Rest.HttpHeaderLocation,String.Format("http://{0}{1}:{2}/{3}",
602 rdata.hostname, rdata.port,rdata.path,newnode)); 602// rdata.hostname, rdata.port,rdata.path,newnode));
603 rdata.Complete(Rest.HttpStatusCodeCreated); 603// rdata.Complete(Rest.HttpStatusCodeCreated);
604 } 604// }
605 else 605// else
606 { 606// {
607 if (modified) 607// if (modified)
608 { 608// {
609 rdata.Complete(Rest.HttpStatusCodeOK); 609// rdata.Complete(Rest.HttpStatusCodeOK);
610 } 610// }
611 else 611// else
612 { 612// {
613 rdata.Complete(Rest.HttpStatusCodeNoContent); 613// rdata.Complete(Rest.HttpStatusCodeNoContent);
614 } 614// }
615 } 615// }
616 616//
617 rdata.Respond(String.Format("Profile {0} : Normal completion", rdata.method)); 617// rdata.Respond(String.Format("Profile {0} : Normal completion", rdata.method));
618 } 618// }
619 else 619// else
620 { 620// {
621 Rest.Log.DebugFormat("{0} {1}: Resource {2} is not a valid context: {3}", 621// Rest.Log.DebugFormat("{0} {1}: Resource {2} is not a valid context: {3}",
622 MsgId, rdata.method, rdata.path, InventoryNode.GetType()); 622// MsgId, rdata.method, rdata.path, InventoryNode.GetType());
623 rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid resource context"); 623// rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid resource context");
624 } 624// }
625 } 625// }
626 626
627 /// <summary> 627 /// <summary>
628 /// PUT updates the URI-identified element in the inventory. This 628 /// PUT updates the URI-identified element in the inventory. This
@@ -646,243 +646,242 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
646 /// during the reconstitution process. 646 /// during the reconstitution process.
647 /// </summary> 647 /// </summary>
648 /// <param name=rdata>HTTP service request work area</param> 648 /// <param name=rdata>HTTP service request work area</param>
649 private void DoUpdate(InventoryRequestData rdata) 649// private void DoUpdate(InventoryRequestData rdata)
650 { 650// {
651 int count = 0; 651// int count = 0;
652 bool created = false; 652// bool created = false;
653 bool modified = false; 653// bool modified = false;
654 654//
655 // Resolve the inventory node that is to be modified. 655// // Resolve the inventory node that is to be modified.
656 // rdata already contains information about the current 656// // rdata already contains information about the current
657 // content of the user's inventory. 657// // content of the user's inventory.
658 658//
659 Object InventoryNode = getInventoryNode(rdata, rdata.root, PARM_PATH, Rest.Fill); 659// Object InventoryNode = getInventoryNode(rdata, rdata.root, PARM_PATH, Rest.Fill);
660 660//
661 // As long as we have a node, then we have something 661// // As long as we have a node, then we have something
662 // meaningful to do, unlike POST. So we reconstitute the 662// // meaningful to do, unlike POST. So we reconstitute the
663 // subtree before doing anything else. Note that we 663// // subtree before doing anything else. Note that we
664 // etiher got a valid node or we threw an exception. 664// // etiher got a valid node or we threw an exception.
665 665//
666 XmlInventoryCollection entity = ReconstituteEntity(rdata); 666// XmlInventoryCollection entity = ReconstituteEntity(rdata);
667 667//
668 // Incorporate any inlined assets first. Any failures 668// // Incorporate any inlined assets first. Any failures
669 // will terminate the request. 669// // will terminate the request.
670 670//
671 if (entity.Assets.Count > 0) 671// if (entity.Assets.Count > 0)
672 { 672// {
673 Rest.Log.DebugFormat("{0} Adding {1} assets to server", 673// Rest.Log.DebugFormat("{0} Adding {1} assets to server",
674 MsgId, entity.Assets.Count); 674// MsgId, entity.Assets.Count);
675 675//
676 foreach (AssetBase asset in entity.Assets) 676// foreach (AssetBase asset in entity.Assets)
677 { 677// {
678 Rest.Log.DebugFormat("{0} Rest asset: {1} {2} {3}", 678// Rest.Log.DebugFormat("{0} Rest asset: {1} {2} {3}",
679 MsgId, asset.ID, asset.Type, asset.Name); 679// MsgId, asset.ID, asset.Type, asset.Name);
680 680//
681 // The asset was validated during the collection process 681// // The asset was validated during the collection process
682 682//
683 Rest.AssetServices.Store(asset); 683// Rest.AssetServices.Store(asset);
684 684//
685 created = true; 685// created = true;
686 rdata.appendStatus(String.Format("<p> Created asset {0}, UUID {1} <p>", asset.Name, asset.ID)); 686// rdata.appendStatus(String.Format("<p> Created asset {0}, UUID {1} <p>", asset.Name, asset.ID));
687 687//
688 if (Rest.DEBUG && Rest.DumpAsset) 688// if (Rest.DEBUG && Rest.DumpAsset)
689 { 689// {
690 Rest.Dump(asset.Data); 690// Rest.Dump(asset.Data);
691 } 691// }
692 } 692// }
693 } 693// }
694 694//
695 // The URI specifies either a folder or an item to be updated. 695// // The URI specifies either a folder or an item to be updated.
696 // 696// //
697 // The root node in the entity will replace the node identified 697// // The root node in the entity will replace the node identified
698 // by the URI. This means the parent will remain the same, but 698// // by the URI. This means the parent will remain the same, but
699 // any or all attributes associated with the named element 699// // any or all attributes associated with the named element
700 // will change. 700// // will change.
701 // 701// //
702 // If the inventory collection contains an element with a zero 702// // If the inventory collection contains an element with a zero
703 // parent ID, then this is taken to be the replacement for the 703// // parent ID, then this is taken to be the replacement for the
704 // named node. The collection MAY also specify an explicit 704// // named node. The collection MAY also specify an explicit
705 // parent ID, in this case it MAY identify the same parent as 705// // parent ID, in this case it MAY identify the same parent as
706 // the current node, or it MAY specify a different parent, 706// // the current node, or it MAY specify a different parent,
707 // indicating that the folder is being moved in addition to any 707// // indicating that the folder is being moved in addition to any
708 // other modifications being made. 708// // other modifications being made.
709 709//
710 if (typeof(InventoryFolderBase) == InventoryNode.GetType() || 710// if (typeof(InventoryFolderBase) == InventoryNode.GetType() ||
711 typeof(InventoryFolderImpl) == InventoryNode.GetType()) 711// typeof(InventoryFolderImpl) == InventoryNode.GetType())
712 { 712// {
713 bool rfound = false; 713// bool rfound = false;
714 InventoryFolderBase uri = (InventoryFolderBase) InventoryNode; 714// InventoryFolderBase uri = (InventoryFolderBase) InventoryNode;
715 InventoryFolderBase xml = null; 715// InventoryFolderBase xml = null;
716 716//
717 // If the entity to be replaced resolved to be the root 717// // If the entity to be replaced resolved to be the root
718 // directory itself (My Inventory), then make sure that 718// // directory itself (My Inventory), then make sure that
719 // the supplied data include as appropriately typed and 719// // the supplied data include as appropriately typed and
720 // named folder. Note that we can;t rule out the possibility 720// // named folder. Note that we can;t rule out the possibility
721 // of a sub-directory being called "My Inventory", so that 721// // of a sub-directory being called "My Inventory", so that
722 // is anticipated. 722// // is anticipated.
723 723//
724 if (uri == rdata.root) 724// if (uri == rdata.root)
725 { 725// {
726 foreach (InventoryFolderBase folder in entity.Folders) 726// foreach (InventoryFolderBase folder in entity.Folders)
727 { 727// {
728 if ((rfound = (folder.Name == PRIVATE_ROOT_NAME))) 728// if ((rfound = (folder.Name == PRIVATE_ROOT_NAME)))
729 { 729// {
730 if ((rfound = (folder.ParentID == UUID.Zero))) 730// if ((rfound = (folder.ParentID == UUID.Zero)))
731 break; 731// break;
732 } 732// }
733 } 733// }
734 734//
735 if (!rfound) 735// if (!rfound)
736 { 736// {
737 Rest.Log.DebugFormat("{0} {1}: Path <{2}> will result in loss of inventory", 737// Rest.Log.DebugFormat("{0} {1}: Path <{2}> will result in loss of inventory",
738 MsgId, rdata.method, rdata.path); 738// MsgId, rdata.method, rdata.path);
739 rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid inventory structure"); 739// rdata.Fail(Rest.HttpStatusCodeBadRequest, "invalid inventory structure");
740 } 740// }
741 } 741// }
742 742//
743 // Scan the set of folders in the entity collection for an 743// // Scan the set of folders in the entity collection for an
744 // entry that matches the context folder. It is assumed that 744// // entry that matches the context folder. It is assumed that
745 // the only reliable indicator of this is a zero UUID (using 745// // the only reliable indicator of this is a zero UUID (using
746 // implicit context), or the parent's UUID matches that of the 746// // implicit context), or the parent's UUID matches that of the
747 // URI designated node (explicit context). We don't allow 747// // URI designated node (explicit context). We don't allow
748 // ambiguity in this case because this is POST and we are 748// // ambiguity in this case because this is POST and we are
749 // supposed to be modifying a specific node. 749// // supposed to be modifying a specific node.
750 // We assign any element IDs required as an economy; we don't 750// // We assign any element IDs required as an economy; we don't
751 // want to iterate over the fodler set again if it can be 751// // want to iterate over the fodler set again if it can be
752 // helped. 752// // helped.
753 753//
754 foreach (InventoryFolderBase folder in entity.Folders) 754// foreach (InventoryFolderBase folder in entity.Folders)
755 { 755// {
756 if (folder.ParentID == uri.ParentID || 756// if (folder.ParentID == uri.ParentID ||
757 folder.ParentID == UUID.Zero) 757// folder.ParentID == UUID.Zero)
758 { 758// {
759 folder.ParentID = uri.ParentID; 759// folder.ParentID = uri.ParentID;
760 xml = folder; 760// xml = folder;
761 count++; 761// count++;
762 } 762// }
763 } 763// }
764 764//
765 // More than one entry is ambiguous. Other folders should be 765// // More than one entry is ambiguous. Other folders should be
766 // added using the POST verb. 766// // added using the POST verb.
767 767//
768 if (count > 1) 768// if (count > 1)
769 { 769// {
770 Rest.Log.DebugFormat("{0} {1}: Request for <{2}> is ambiguous", 770// Rest.Log.DebugFormat("{0} {1}: Request for <{2}> is ambiguous",
771 MsgId, rdata.method, rdata.path); 771// MsgId, rdata.method, rdata.path);
772 rdata.Fail(Rest.HttpStatusCodeConflict, "context is ambiguous"); 772// rdata.Fail(Rest.HttpStatusCodeConflict, "context is ambiguous");
773 } 773// }
774 774//
775 // Exactly one entry means we ARE replacing the node 775// // Exactly one entry means we ARE replacing the node
776 // identified by the URI. So we delete the old folder 776// // identified by the URI. So we delete the old folder
777 // by moving it to the trash and then purging it. 777// // by moving it to the trash and then purging it.
778 // We then add all of the folders and items we 778// // We then add all of the folders and items we
779 // included in the entity. The subtree has been 779// // included in the entity. The subtree has been
780 // modified. 780// // modified.
781 781//
782 if (count == 1) 782// if (count == 1)
783 { 783// {
784 InventoryFolderBase TrashCan = GetTrashCan(rdata); 784// InventoryFolderBase TrashCan = GetTrashCan(rdata);
785 785//
786 // All went well, so we generate a UUID is one is 786// // All went well, so we generate a UUID is one is
787 // needed. 787// // needed.
788 788//
789 if (xml.ID == UUID.Zero) 789// if (xml.ID == UUID.Zero)
790 { 790// {
791 xml.ID = UUID.Random(); 791// xml.ID = UUID.Random();
792 } 792// }
793 793//
794 uri.ParentID = TrashCan.ID; 794// uri.ParentID = TrashCan.ID;
795 Rest.InventoryServices.MoveFolder(uri); 795// Rest.InventoryServices.MoveFolder(uri);
796 Rest.InventoryServices.PurgeFolder(TrashCan); 796// Rest.InventoryServices.PurgeFolder(TrashCan);
797 modified = true; 797// modified = true;
798 } 798// }
799 799//
800 // Now, regardelss of what they represent, we 800// // Now, regardelss of what they represent, we
801 // integrate all of the elements in the entity. 801// // integrate all of the elements in the entity.
802 802//
803 foreach (InventoryFolderBase f in entity.Folders) 803// foreach (InventoryFolderBase f in entity.Folders)
804 { 804// {
805 rdata.appendStatus(String.Format("<p>Moving folder {0} UUID {1} <p>", f.Name, f.ID)); 805// rdata.appendStatus(String.Format("<p>Moving folder {0} UUID {1} <p>", f.Name, f.ID));
806 Rest.InventoryServices.MoveFolder(f); 806// Rest.InventoryServices.MoveFolder(f);
807 } 807// }
808 808//
809 foreach (InventoryItemBase it in entity.Items) 809// foreach (InventoryItemBase it in entity.Items)
810 { 810// {
811 rdata.appendStatus(String.Format("<p>Storing item {0} UUID {1} <p>", it.Name, it.ID)); 811// rdata.appendStatus(String.Format("<p>Storing item {0} UUID {1} <p>", it.Name, it.ID));
812 Rest.InventoryServices.AddItem(it); 812// Rest.InventoryServices.AddItem(it);
813 } 813// }
814 } 814// }
815 815//
816 /// <summary> 816// /// <summary>
817 /// URI specifies an item to be updated 817// /// URI specifies an item to be updated
818 /// </summary> 818// /// </summary>
819 /// <remarks> 819// /// <remarks>
820 /// The entity must contain a single item node to be 820// /// The entity must contain a single item node to be
821 /// updated. ID and Folder ID must be correct. 821// /// updated. ID and Folder ID must be correct.
822 /// </remarks> 822// /// </remarks>
823 823//
824 else 824// else
825 { 825// {
826 InventoryItemBase uri = (InventoryItemBase) InventoryNode; 826// InventoryItemBase uri = (InventoryItemBase) InventoryNode;
827 InventoryItemBase xml = null; 827// InventoryItemBase xml = null;
828 828//
829 if (entity.Folders.Count != 0) 829// if (entity.Folders.Count != 0)
830 { 830// {
831 Rest.Log.DebugFormat("{0} {1}: Request should not contain any folders <{2}>", 831// Rest.Log.DebugFormat("{0} {1}: Request should not contain any folders <{2}>",
832 MsgId, rdata.method, rdata.path); 832// MsgId, rdata.method, rdata.path);
833 rdata.Fail(Rest.HttpStatusCodeBadRequest, "folder is not allowed"); 833// rdata.Fail(Rest.HttpStatusCodeBadRequest, "folder is not allowed");
834 } 834// }
835 835//
836 if (entity.Items.Count > 1) 836// if (entity.Items.Count > 1)
837 { 837// {
838 Rest.Log.DebugFormat("{0} {1}: Entity contains too many items <{2}>", 838// Rest.Log.DebugFormat("{0} {1}: Entity contains too many items <{2}>",
839 MsgId, rdata.method, rdata.path); 839// MsgId, rdata.method, rdata.path);
840 rdata.Fail(Rest.HttpStatusCodeBadRequest, "too may items"); 840// rdata.Fail(Rest.HttpStatusCodeBadRequest, "too may items");
841 } 841// }
842 842//
843 xml = entity.Items[0]; 843// xml = entity.Items[0];
844 844//
845 if (xml.ID == UUID.Zero) 845// if (xml.ID == UUID.Zero)
846 { 846// {
847 xml.ID = UUID.Random(); 847// xml.ID = UUID.Random();
848 } 848// }
849 849//
850 // If the folder reference has changed, then this item is 850// // If the folder reference has changed, then this item is
851 // being moved. Otherwise we'll just delete the old, and 851// // being moved. Otherwise we'll just delete the old, and
852 // add in the new. 852// // add in the new.
853 853//
854 // Delete the old item 854// // Delete the old item
855 855//
856 List<UUID> uuids = new List<UUID>(); 856// List<UUID> uuids = new List<UUID>();
857 uuids.Add(uri.ID); 857// uuids.Add(uri.ID);
858 Rest.InventoryServices.DeleteItems(uri.Owner, uuids); 858// Rest.InventoryServices.DeleteItems(uri.Owner, uuids);
859 859//
860 // Add the new item to the inventory 860// // Add the new item to the inventory
861 861//
862 Rest.InventoryServices.AddItem(xml); 862// Rest.InventoryServices.AddItem(xml);
863 863//
864 rdata.appendStatus(String.Format("<p>Storing item {0} UUID {1} <p>", xml.Name, xml.ID)); 864// rdata.appendStatus(String.Format("<p>Storing item {0} UUID {1} <p>", xml.Name, xml.ID));
865 } 865// }
866 866//
867 if (created) 867// if (created)
868 { 868// {
869 rdata.Complete(Rest.HttpStatusCodeCreated); 869// rdata.Complete(Rest.HttpStatusCodeCreated);
870 } 870// }
871 else 871// else
872 { 872// {
873 if (modified) 873// if (modified)
874 { 874// {
875 rdata.Complete(Rest.HttpStatusCodeOK); 875// rdata.Complete(Rest.HttpStatusCodeOK);
876 } 876// }
877 else 877// else
878 { 878// {
879 rdata.Complete(Rest.HttpStatusCodeNoContent); 879// rdata.Complete(Rest.HttpStatusCodeNoContent);
880 } 880// }
881 } 881// }
882 882//
883 rdata.Respond(String.Format("Profile {0} : Normal completion", rdata.method)); 883// rdata.Respond(String.Format("Profile {0} : Normal completion", rdata.method));
884 884// }
885 }
886 885
887 /// <summary> 886 /// <summary>
888 /// Arguably the most damaging REST interface. It deletes the inventory 887 /// Arguably the most damaging REST interface. It deletes the inventory
@@ -904,42 +903,41 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
904 /// elements. 903 /// elements.
905 /// </summary> 904 /// </summary>
906 /// <param name=rdata>HTTP service request work area</param> 905 /// <param name=rdata>HTTP service request work area</param>
907 906// private void DoDelete(InventoryRequestData rdata)
908 private void DoDelete(InventoryRequestData rdata) 907// {
909 { 908// Object InventoryNode = getInventoryNode(rdata, rdata.root, PARM_PATH, false);
910 Object InventoryNode = getInventoryNode(rdata, rdata.root, PARM_PATH, false); 909//
911 910// if (typeof(InventoryFolderBase) == InventoryNode.GetType() ||
912 if (typeof(InventoryFolderBase) == InventoryNode.GetType() || 911// typeof(InventoryFolderImpl) == InventoryNode.GetType())
913 typeof(InventoryFolderImpl) == InventoryNode.GetType()) 912// {
914 { 913// InventoryFolderBase TrashCan = GetTrashCan(rdata);
915 InventoryFolderBase TrashCan = GetTrashCan(rdata); 914//
916 915// InventoryFolderBase folder = (InventoryFolderBase) InventoryNode;
917 InventoryFolderBase folder = (InventoryFolderBase) InventoryNode; 916// Rest.Log.DebugFormat("{0} {1}: Folder {2} will be deleted",
918 Rest.Log.DebugFormat("{0} {1}: Folder {2} will be deleted", 917// MsgId, rdata.method, rdata.path);
919 MsgId, rdata.method, rdata.path); 918// folder.ParentID = TrashCan.ID;
920 folder.ParentID = TrashCan.ID; 919// Rest.InventoryServices.MoveFolder(folder);
921 Rest.InventoryServices.MoveFolder(folder); 920// Rest.InventoryServices.PurgeFolder(TrashCan);
922 Rest.InventoryServices.PurgeFolder(TrashCan); 921//
923 922// rdata.appendStatus(String.Format("<p>Deleted folder {0} UUID {1} <p>", folder.Name, folder.ID));
924 rdata.appendStatus(String.Format("<p>Deleted folder {0} UUID {1} <p>", folder.Name, folder.ID)); 923// }
925 } 924//
926 925// // Deleting items is much more straight forward.
927 // Deleting items is much more straight forward. 926//
928 927// else
929 else 928// {
930 { 929// InventoryItemBase item = (InventoryItemBase) InventoryNode;
931 InventoryItemBase item = (InventoryItemBase) InventoryNode; 930// Rest.Log.DebugFormat("{0} {1}: Item {2} will be deleted",
932 Rest.Log.DebugFormat("{0} {1}: Item {2} will be deleted", 931// MsgId, rdata.method, rdata.path);
933 MsgId, rdata.method, rdata.path); 932// List<UUID> uuids = new List<UUID>();
934 List<UUID> uuids = new List<UUID>(); 933// uuids.Add(item.ID);
935 uuids.Add(item.ID); 934// Rest.InventoryServices.DeleteItems(item.Owner, uuids);
936 Rest.InventoryServices.DeleteItems(item.Owner, uuids); 935// rdata.appendStatus(String.Format("<p>Deleted item {0} UUID {1} <p>", item.Name, item.ID));
937 rdata.appendStatus(String.Format("<p>Deleted item {0} UUID {1} <p>", item.Name, item.ID)); 936// }
938 } 937//
939 938// rdata.Complete();
940 rdata.Complete(); 939// rdata.Respond(String.Format("Profile {0} : Normal completion", rdata.method));
941 rdata.Respond(String.Format("Profile {0} : Normal completion", rdata.method)); 940// }
942 }
943 941
944#endregion method-specific processing 942#endregion method-specific processing
945 943