diff options
6 files changed, 226 insertions, 182 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index e7fb43a..0d90a15 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | |||
@@ -206,7 +206,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
206 | else | 206 | else |
207 | return null; | 207 | return null; |
208 | } | 208 | } |
209 | 209 | ||
210 | public static List<InventoryItemBase> FindItemsByPath( | ||
211 | IInventoryService inventoryService, UUID userId, string path) | ||
212 | { | ||
213 | InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); | ||
214 | |||
215 | if (null == rootFolder) | ||
216 | return new List<InventoryItemBase>(); | ||
217 | |||
218 | return FindItemsByPath(inventoryService, rootFolder, path); | ||
219 | } | ||
220 | |||
210 | /// <summary> | 221 | /// <summary> |
211 | /// Find items that match a given PATH_DELIMITOR delimited path starting from this folder. | 222 | /// Find items that match a given PATH_DELIMITOR delimited path starting from this folder. |
212 | /// </summary> | 223 | /// </summary> |
@@ -239,11 +250,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
239 | if (components.Length == 1) | 250 | if (components.Length == 1) |
240 | { | 251 | { |
241 | // m_log.DebugFormat( | 252 | // m_log.DebugFormat( |
242 | // "FOUND SINGLE COMPONENT [{0}]. Looking for this in [{1}] {2}", | 253 | // "FOUND SINGLE COMPONENT [{0}]. Looking for this in [{1}] {2}", |
243 | // components[0], startFolder.Name, startFolder.ID); | 254 | // components[0], startFolder.Name, startFolder.ID); |
244 | 255 | ||
245 | List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID); | 256 | List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID); |
246 | 257 | ||
247 | // m_log.DebugFormat("[INVENTORY ARCHIVE UTILS]: Found {0} items in FindItemByPath()", items.Count); | 258 | // m_log.DebugFormat("[INVENTORY ARCHIVE UTILS]: Found {0} items in FindItemByPath()", items.Count); |
248 | 259 | ||
249 | foreach (InventoryItemBase item in items) | 260 | foreach (InventoryItemBase item in items) |
@@ -257,7 +268,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
257 | else | 268 | else |
258 | { | 269 | { |
259 | // m_log.DebugFormat("FOUND COMPONENTS [{0}] and [{1}]", components[0], components[1]); | 270 | // m_log.DebugFormat("FOUND COMPONENTS [{0}] and [{1}]", components[0], components[1]); |
260 | 271 | ||
261 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); | 272 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); |
262 | 273 | ||
263 | foreach (InventoryFolderBase folder in contents.Folders) | 274 | foreach (InventoryFolderBase folder in contents.Folders) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index b70e1c3..f37f94a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -425,192 +425,198 @@ namespace OpenSim.Region.Framework.Scenes | |||
425 | InventoryItemBase item = new InventoryItemBase(itemId, senderId); | 425 | InventoryItemBase item = new InventoryItemBase(itemId, senderId); |
426 | item = InventoryService.GetItem(item); | 426 | item = InventoryService.GetItem(item); |
427 | 427 | ||
428 | if ((item != null) && (item.Owner == senderId)) | 428 | if (item == null) |
429 | { | 429 | { |
430 | IUserManagement uman = RequestModuleInterface<IUserManagement>(); | 430 | m_log.WarnFormat( |
431 | if (uman != null) | 431 | "[AGENT INVENTORY]: Failed to find item {0} sent by {1} to {2}", itemId, senderId, recipient); |
432 | uman.AddUser(item.CreatorIdAsUuid, item.CreatorData); | 432 | return null; |
433 | } | ||
433 | 434 | ||
434 | if (!Permissions.BypassPermissions()) | 435 | if (item.Owner != senderId) |
435 | { | 436 | { |
436 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | 437 | m_log.WarnFormat( |
437 | return null; | 438 | "[AGENT INVENTORY]: Attempt to send item {0} {1} to {2} failed because sender {3} did not match item owner {4}", |
438 | } | 439 | item.Name, item.ID, recipient, senderId, item.Owner); |
440 | return null; | ||
441 | } | ||
442 | |||
443 | IUserManagement uman = RequestModuleInterface<IUserManagement>(); | ||
444 | if (uman != null) | ||
445 | uman.AddUser(item.CreatorIdAsUuid, item.CreatorData); | ||
446 | |||
447 | if (!Permissions.BypassPermissions()) | ||
448 | { | ||
449 | if ((item.CurrentPermissions & (uint)PermissionMask.Transfer) == 0) | ||
450 | return null; | ||
451 | } | ||
439 | 452 | ||
440 | // Insert a copy of the item into the recipient | 453 | // Insert a copy of the item into the recipient |
441 | InventoryItemBase itemCopy = new InventoryItemBase(); | 454 | InventoryItemBase itemCopy = new InventoryItemBase(); |
442 | itemCopy.Owner = recipient; | 455 | itemCopy.Owner = recipient; |
443 | itemCopy.CreatorId = item.CreatorId; | 456 | itemCopy.CreatorId = item.CreatorId; |
444 | itemCopy.CreatorData = item.CreatorData; | 457 | itemCopy.CreatorData = item.CreatorData; |
445 | itemCopy.ID = UUID.Random(); | 458 | itemCopy.ID = UUID.Random(); |
446 | itemCopy.AssetID = item.AssetID; | 459 | itemCopy.AssetID = item.AssetID; |
447 | itemCopy.Description = item.Description; | 460 | itemCopy.Description = item.Description; |
448 | itemCopy.Name = item.Name; | 461 | itemCopy.Name = item.Name; |
449 | itemCopy.AssetType = item.AssetType; | 462 | itemCopy.AssetType = item.AssetType; |
450 | itemCopy.InvType = item.InvType; | 463 | itemCopy.InvType = item.InvType; |
451 | itemCopy.Folder = recipientFolderId; | 464 | itemCopy.Folder = recipientFolderId; |
452 | 465 | ||
453 | if (Permissions.PropagatePermissions() && recipient != senderId) | 466 | if (Permissions.PropagatePermissions() && recipient != senderId) |
467 | { | ||
468 | // Trying to do this right this time. This is evil. If | ||
469 | // you believe in Good, go elsewhere. Vampires and other | ||
470 | // evil creatores only beyond this point. You have been | ||
471 | // warned. | ||
472 | |||
473 | // We're going to mask a lot of things by the next perms | ||
474 | // Tweak the next perms to be nicer to our data | ||
475 | // | ||
476 | // In this mask, all the bits we do NOT want to mess | ||
477 | // with are set. These are: | ||
478 | // | ||
479 | // Transfer | ||
480 | // Copy | ||
481 | // Modufy | ||
482 | uint permsMask = ~ ((uint)PermissionMask.Copy | | ||
483 | (uint)PermissionMask.Transfer | | ||
484 | (uint)PermissionMask.Modify); | ||
485 | |||
486 | // Now, reduce the next perms to the mask bits | ||
487 | // relevant to the operation | ||
488 | uint nextPerms = permsMask | (item.NextPermissions & | ||
489 | ((uint)PermissionMask.Copy | | ||
490 | (uint)PermissionMask.Transfer | | ||
491 | (uint)PermissionMask.Modify)); | ||
492 | |||
493 | // nextPerms now has all bits set, except for the actual | ||
494 | // next permission bits. | ||
495 | |||
496 | // This checks for no mod, no copy, no trans. | ||
497 | // This indicates an error or messed up item. Do it like | ||
498 | // SL and assume trans | ||
499 | if (nextPerms == permsMask) | ||
500 | nextPerms |= (uint)PermissionMask.Transfer; | ||
501 | |||
502 | // Inventory owner perms are the logical AND of the | ||
503 | // folded perms and the root prim perms, however, if | ||
504 | // the root prim is mod, the inventory perms will be | ||
505 | // mod. This happens on "take" and is of little concern | ||
506 | // here, save for preventing escalation | ||
507 | |||
508 | // This hack ensures that items previously permalocked | ||
509 | // get unlocked when they're passed or rezzed | ||
510 | uint basePerms = item.BasePermissions | | ||
511 | (uint)PermissionMask.Move; | ||
512 | uint ownerPerms = item.CurrentPermissions; | ||
513 | |||
514 | // If this is an object, root prim perms may be more | ||
515 | // permissive than folded perms. Use folded perms as | ||
516 | // a mask | ||
517 | if (item.InvType == (int)InventoryType.Object) | ||
454 | { | 518 | { |
455 | // Trying to do this right this time. This is evil. If | 519 | // Create a safe mask for the current perms |
456 | // you believe in Good, go elsewhere. Vampires and other | 520 | uint foldedPerms = (item.CurrentPermissions & 7) << 13; |
457 | // evil creatores only beyond this point. You have been | 521 | foldedPerms |= permsMask; |
458 | // warned. | 522 | |
459 | 523 | bool isRootMod = (item.CurrentPermissions & | |
460 | // We're going to mask a lot of things by the next perms | 524 | (uint)PermissionMask.Modify) != 0 ? |
461 | // Tweak the next perms to be nicer to our data | 525 | true : false; |
462 | // | 526 | |
463 | // In this mask, all the bits we do NOT want to mess | 527 | // Mask the owner perms to the folded perms |
464 | // with are set. These are: | 528 | ownerPerms &= foldedPerms; |
465 | // | 529 | basePerms &= foldedPerms; |
466 | // Transfer | 530 | |
467 | // Copy | 531 | // If the root was mod, let the mask reflect that |
468 | // Modufy | 532 | // We also need to adjust the base here, because |
469 | uint permsMask = ~ ((uint)PermissionMask.Copy | | 533 | // we should be able to edit in-inventory perms |
470 | (uint)PermissionMask.Transfer | | 534 | // for the root prim, if it's mod. |
471 | (uint)PermissionMask.Modify); | 535 | if (isRootMod) |
472 | |||
473 | // Now, reduce the next perms to the mask bits | ||
474 | // relevant to the operation | ||
475 | uint nextPerms = permsMask | (item.NextPermissions & | ||
476 | ((uint)PermissionMask.Copy | | ||
477 | (uint)PermissionMask.Transfer | | ||
478 | (uint)PermissionMask.Modify)); | ||
479 | |||
480 | // nextPerms now has all bits set, except for the actual | ||
481 | // next permission bits. | ||
482 | |||
483 | // This checks for no mod, no copy, no trans. | ||
484 | // This indicates an error or messed up item. Do it like | ||
485 | // SL and assume trans | ||
486 | if (nextPerms == permsMask) | ||
487 | nextPerms |= (uint)PermissionMask.Transfer; | ||
488 | |||
489 | // Inventory owner perms are the logical AND of the | ||
490 | // folded perms and the root prim perms, however, if | ||
491 | // the root prim is mod, the inventory perms will be | ||
492 | // mod. This happens on "take" and is of little concern | ||
493 | // here, save for preventing escalation | ||
494 | |||
495 | // This hack ensures that items previously permalocked | ||
496 | // get unlocked when they're passed or rezzed | ||
497 | uint basePerms = item.BasePermissions | | ||
498 | (uint)PermissionMask.Move; | ||
499 | uint ownerPerms = item.CurrentPermissions; | ||
500 | |||
501 | // If this is an object, root prim perms may be more | ||
502 | // permissive than folded perms. Use folded perms as | ||
503 | // a mask | ||
504 | if (item.InvType == (int)InventoryType.Object) | ||
505 | { | 536 | { |
506 | // Create a safe mask for the current perms | 537 | ownerPerms |= (uint)PermissionMask.Modify; |
507 | uint foldedPerms = (item.CurrentPermissions & 7) << 13; | 538 | basePerms |= (uint)PermissionMask.Modify; |
508 | foldedPerms |= permsMask; | ||
509 | |||
510 | bool isRootMod = (item.CurrentPermissions & | ||
511 | (uint)PermissionMask.Modify) != 0 ? | ||
512 | true : false; | ||
513 | |||
514 | // Mask the owner perms to the folded perms | ||
515 | ownerPerms &= foldedPerms; | ||
516 | basePerms &= foldedPerms; | ||
517 | |||
518 | // If the root was mod, let the mask reflect that | ||
519 | // We also need to adjust the base here, because | ||
520 | // we should be able to edit in-inventory perms | ||
521 | // for the root prim, if it's mod. | ||
522 | if (isRootMod) | ||
523 | { | ||
524 | ownerPerms |= (uint)PermissionMask.Modify; | ||
525 | basePerms |= (uint)PermissionMask.Modify; | ||
526 | } | ||
527 | } | 539 | } |
540 | } | ||
528 | 541 | ||
529 | // These will be applied to the root prim at next rez. | 542 | // These will be applied to the root prim at next rez. |
530 | // The slam bit (bit 3) and folded permission (bits 0-2) | 543 | // The slam bit (bit 3) and folded permission (bits 0-2) |
531 | // are preserved due to the above mangling | 544 | // are preserved due to the above mangling |
532 | ownerPerms &= nextPerms; | 545 | ownerPerms &= nextPerms; |
533 | 546 | ||
534 | // Mask the base permissions. This is a conservative | 547 | // Mask the base permissions. This is a conservative |
535 | // approach altering only the three main perms | 548 | // approach altering only the three main perms |
536 | basePerms &= nextPerms; | 549 | basePerms &= nextPerms; |
537 | 550 | ||
538 | // Assign to the actual item. Make sure the slam bit is | 551 | // Assign to the actual item. Make sure the slam bit is |
539 | // set, if it wasn't set before. | 552 | // set, if it wasn't set before. |
540 | itemCopy.BasePermissions = basePerms; | 553 | itemCopy.BasePermissions = basePerms; |
541 | itemCopy.CurrentPermissions = ownerPerms; | 554 | itemCopy.CurrentPermissions = ownerPerms; |
542 | itemCopy.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; | 555 | itemCopy.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; |
543 | 556 | ||
544 | itemCopy.NextPermissions = item.NextPermissions; | 557 | itemCopy.NextPermissions = item.NextPermissions; |
545 | 558 | ||
546 | // This preserves "everyone can move" | 559 | // This preserves "everyone can move" |
547 | itemCopy.EveryOnePermissions = item.EveryOnePermissions & | 560 | itemCopy.EveryOnePermissions = item.EveryOnePermissions & |
548 | nextPerms; | 561 | nextPerms; |
549 | 562 | ||
550 | // Intentionally killing "share with group" here, as | 563 | // Intentionally killing "share with group" here, as |
551 | // the recipient will not have the group this is | 564 | // the recipient will not have the group this is |
552 | // set to | 565 | // set to |
553 | itemCopy.GroupPermissions = 0; | 566 | itemCopy.GroupPermissions = 0; |
554 | } | 567 | } |
555 | else | 568 | else |
569 | { | ||
570 | itemCopy.CurrentPermissions = item.CurrentPermissions; | ||
571 | itemCopy.NextPermissions = item.NextPermissions; | ||
572 | itemCopy.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions; | ||
573 | itemCopy.GroupPermissions = item.GroupPermissions & item.NextPermissions; | ||
574 | itemCopy.BasePermissions = item.BasePermissions; | ||
575 | } | ||
576 | |||
577 | if (itemCopy.Folder == UUID.Zero) | ||
578 | { | ||
579 | InventoryFolderBase folder = InventoryService.GetFolderForType(recipient, (AssetType)itemCopy.AssetType); | ||
580 | |||
581 | if (folder != null) | ||
556 | { | 582 | { |
557 | itemCopy.CurrentPermissions = item.CurrentPermissions; | 583 | itemCopy.Folder = folder.ID; |
558 | itemCopy.NextPermissions = item.NextPermissions; | ||
559 | itemCopy.EveryOnePermissions = item.EveryOnePermissions & item.NextPermissions; | ||
560 | itemCopy.GroupPermissions = item.GroupPermissions & item.NextPermissions; | ||
561 | itemCopy.BasePermissions = item.BasePermissions; | ||
562 | } | 584 | } |
563 | 585 | else | |
564 | if (itemCopy.Folder == UUID.Zero) | ||
565 | { | 586 | { |
566 | InventoryFolderBase folder = InventoryService.GetFolderForType(recipient, (AssetType)itemCopy.AssetType); | 587 | InventoryFolderBase root = InventoryService.GetRootFolder(recipient); |
567 | 588 | ||
568 | if (folder != null) | 589 | if (root != null) |
569 | { | 590 | itemCopy.Folder = root.ID; |
570 | itemCopy.Folder = folder.ID; | ||
571 | } | ||
572 | else | 591 | else |
573 | { | 592 | return null; // No destination |
574 | InventoryFolderBase root = InventoryService.GetRootFolder(recipient); | ||
575 | |||
576 | if (root != null) | ||
577 | itemCopy.Folder = root.ID; | ||
578 | else | ||
579 | return null; // No destination | ||
580 | } | ||
581 | } | 593 | } |
594 | } | ||
582 | 595 | ||
583 | itemCopy.GroupID = UUID.Zero; | 596 | itemCopy.GroupID = UUID.Zero; |
584 | itemCopy.GroupOwned = false; | 597 | itemCopy.GroupOwned = false; |
585 | itemCopy.Flags = item.Flags; | 598 | itemCopy.Flags = item.Flags; |
586 | itemCopy.SalePrice = item.SalePrice; | 599 | itemCopy.SalePrice = item.SalePrice; |
587 | itemCopy.SaleType = item.SaleType; | 600 | itemCopy.SaleType = item.SaleType; |
588 | 601 | ||
589 | if (AddInventoryItem(itemCopy)) | 602 | if (AddInventoryItem(itemCopy)) |
590 | { | 603 | { |
591 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); | 604 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); |
592 | if (invAccess != null) | 605 | if (invAccess != null) |
593 | invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); | 606 | invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); |
594 | } | 607 | } |
595 | 608 | ||
596 | if (!Permissions.BypassPermissions()) | 609 | if (!Permissions.BypassPermissions()) |
610 | { | ||
611 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
597 | { | 612 | { |
598 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | 613 | List<UUID> items = new List<UUID>(); |
599 | { | 614 | items.Add(itemId); |
600 | List<UUID> items = new List<UUID>(); | 615 | InventoryService.DeleteItems(senderId, items); |
601 | items.Add(itemId); | ||
602 | InventoryService.DeleteItems(senderId, items); | ||
603 | } | ||
604 | } | 616 | } |
605 | |||
606 | return itemCopy; | ||
607 | } | ||
608 | else | ||
609 | { | ||
610 | m_log.WarnFormat("[AGENT INVENTORY]: Failed to find item {0} or item does not belong to giver ", itemId); | ||
611 | return null; | ||
612 | } | 617 | } |
613 | 618 | ||
619 | return itemCopy; | ||
614 | } | 620 | } |
615 | 621 | ||
616 | /// <summary> | 622 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs index 83f0686..10c275e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs | |||
@@ -59,19 +59,24 @@ namespace OpenSim.Region.Framework.Tests | |||
59 | // log4net.Config.XmlConfigurator.Configure(); | 59 | // log4net.Config.XmlConfigurator.Configure(); |
60 | 60 | ||
61 | Scene scene = SceneSetupHelpers.SetupScene(); | 61 | Scene scene = SceneSetupHelpers.SetupScene(); |
62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, 1001); |
63 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene); | 63 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, 1002); |
64 | InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); | 64 | InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); |
65 | 65 | ||
66 | scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID); | 66 | scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID); |
67 | 67 | ||
68 | InventoryItemBase retrievedItem1 | 68 | InventoryItemBase retrievedItem1 |
69 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Objects/item1"); | 69 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Notecards/item1"); |
70 | 70 | ||
71 | Assert.That(retrievedItem1, Is.Not.Null); | 71 | Assert.That(retrievedItem1, Is.Not.Null); |
72 | 72 | ||
73 | // Try giving back the freshly received item | 73 | // Try giving back the freshly received item |
74 | //scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID); | 74 | scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID); |
75 | |||
76 | List<InventoryItemBase> reretrievedItems | ||
77 | = UserInventoryHelpers.GetInventoryItems(scene.InventoryService, user1.PrincipalID, "Notecards/item1"); | ||
78 | |||
79 | Assert.That(reretrievedItems.Count, Is.EqualTo(2)); | ||
75 | } | 80 | } |
76 | 81 | ||
77 | [Test] | 82 | [Test] |
@@ -81,8 +86,8 @@ namespace OpenSim.Region.Framework.Tests | |||
81 | // log4net.Config.XmlConfigurator.Configure(); | 86 | // log4net.Config.XmlConfigurator.Configure(); |
82 | 87 | ||
83 | Scene scene = SceneSetupHelpers.SetupScene(); | 88 | Scene scene = SceneSetupHelpers.SetupScene(); |
84 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | 89 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene, 1001); |
85 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene); | 90 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene, 1002); |
86 | InventoryFolderBase folder1 | 91 | InventoryFolderBase folder1 |
87 | = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1"); | 92 | = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, user1.PrincipalID, "folder1"); |
88 | 93 | ||
diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index e543337..73dd06a 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs | |||
@@ -340,6 +340,9 @@ namespace OpenSim.Services.InventoryService | |||
340 | List<InventoryItemBase> itemsList = new List<InventoryItemBase>(); | 340 | List<InventoryItemBase> itemsList = new List<InventoryItemBase>(); |
341 | 341 | ||
342 | itemsList.AddRange(m_Database.getInventoryInFolder(folderID)); | 342 | itemsList.AddRange(m_Database.getInventoryInFolder(folderID)); |
343 | |||
344 | // m_log.DebugFormat( | ||
345 | // "[INVENTORY SERVICE]: Found {0} items in folder {1} for {2}", itemsList.Count, folderID, userID); | ||
343 | 346 | ||
344 | return itemsList; | 347 | return itemsList; |
345 | } | 348 | } |
@@ -385,8 +388,9 @@ namespace OpenSim.Services.InventoryService | |||
385 | // See IInventoryServices | 388 | // See IInventoryServices |
386 | public virtual bool AddItem(InventoryItemBase item) | 389 | public virtual bool AddItem(InventoryItemBase item) |
387 | { | 390 | { |
388 | m_log.DebugFormat( | 391 | // m_log.DebugFormat( |
389 | "[INVENTORY SERVICE]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); | 392 | // "[INVENTORY SERVICE]: Adding item {0} {1} to folder {2} for {3}", |
393 | // item.Name, item.ID, item.Folder, item.Owner); | ||
390 | 394 | ||
391 | m_Database.addInventoryItem(item); | 395 | m_Database.addInventoryItem(item); |
392 | 396 | ||
diff --git a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs index 8cfad79..d924ecd 100644 --- a/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/UserAccountHelpers.cs | |||
@@ -118,16 +118,19 @@ namespace OpenSim.Tests.Common | |||
118 | 118 | ||
119 | public static UserAccount CreateUserWithInventory(Scene scene) | 119 | public static UserAccount CreateUserWithInventory(Scene scene) |
120 | { | 120 | { |
121 | return CreateUserWithInventory(scene, 99); | ||
122 | } | ||
123 | |||
124 | public static UserAccount CreateUserWithInventory(Scene scene, int uuidTail) | ||
125 | { | ||
121 | return CreateUserWithInventory( | 126 | return CreateUserWithInventory( |
122 | scene, "Bill", "Bailey", UUID.Parse("00000000-0000-0000-0000-000000000099"), "troll"); | 127 | scene, "Bill", "Bailey", new UUID(string.Format("00000000-0000-0000-0000-{0:X12}", uuidTail)), "troll"); |
123 | } | 128 | } |
124 | 129 | ||
125 | public static UserAccount CreateUserWithInventory( | 130 | public static UserAccount CreateUserWithInventory( |
126 | Scene scene, string firstName, string lastName, UUID userId, string pw) | 131 | Scene scene, string firstName, string lastName, UUID userId, string pw) |
127 | { | 132 | { |
128 | UserAccount ua | 133 | UserAccount ua = new UserAccount(userId) { FirstName = firstName, LastName = lastName }; |
129 | = new UserAccount(userId) | ||
130 | { FirstName = firstName, LastName = lastName }; | ||
131 | CreateUserWithInventory(scene, ua, pw); | 134 | CreateUserWithInventory(scene, ua, pw); |
132 | return ua; | 135 | return ua; |
133 | } | 136 | } |
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs index 93b655a..875bf4a 100644 --- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs | |||
@@ -65,15 +65,18 @@ namespace OpenSim.Tests.Common | |||
65 | /// <returns></returns> | 65 | /// <returns></returns> |
66 | public static InventoryItemBase CreateInventoryItem(Scene scene, string itemName, UUID itemId, UUID userId) | 66 | public static InventoryItemBase CreateInventoryItem(Scene scene, string itemName, UUID itemId, UUID userId) |
67 | { | 67 | { |
68 | AssetBase asset = AssetHelpers.CreateAsset(scene, userId); | ||
68 | InventoryItemBase item = new InventoryItemBase(); | 69 | InventoryItemBase item = new InventoryItemBase(); |
69 | item.Name = itemName; | 70 | item.Name = itemName; |
70 | item.AssetID = AssetHelpers.CreateAsset(scene, userId).FullID; | 71 | item.AssetID = asset.FullID; |
71 | item.ID = itemId; | 72 | item.ID = itemId; |
73 | item.Owner = userId; | ||
74 | item.AssetType = asset.Type; | ||
75 | item.InvType = (int)InventoryType.Notecard; | ||
76 | |||
77 | InventoryFolderBase folder = scene.InventoryService.GetFolderForType(userId, AssetType.Notecard); | ||
72 | 78 | ||
73 | // Really quite bad since the objs folder could be moved in the future and confuse the tests | 79 | item.Folder = folder.ID; |
74 | InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); | ||
75 | |||
76 | item.Folder = objsFolder.ID; | ||
77 | scene.AddInventoryItem(item); | 80 | scene.AddInventoryItem(item); |
78 | 81 | ||
79 | return item; | 82 | return item; |
@@ -165,5 +168,17 @@ namespace OpenSim.Tests.Common | |||
165 | { | 168 | { |
166 | return InventoryArchiveUtils.FindItemByPath(inventoryService, userId, path); | 169 | return InventoryArchiveUtils.FindItemByPath(inventoryService, userId, path); |
167 | } | 170 | } |
171 | |||
172 | /// <summary> | ||
173 | /// Get the inventory items that match the path name. | ||
174 | /// </summary> | ||
175 | /// <param name="inventoryService"></param> | ||
176 | /// <param name="userId"></param> | ||
177 | /// <param name="path"></param> | ||
178 | /// <returns>An empty list if no matching items were found.</returns> | ||
179 | public static List<InventoryItemBase> GetInventoryItems(IInventoryService inventoryService, UUID userId, string path) | ||
180 | { | ||
181 | return InventoryArchiveUtils.FindItemsByPath(inventoryService, userId, path); | ||
182 | } | ||
168 | } | 183 | } |
169 | } \ No newline at end of file | 184 | } \ No newline at end of file |