diff options
author | Diva Canto | 2015-05-08 20:53:28 -0700 |
---|---|---|
committer | Diva Canto | 2015-05-08 20:53:28 -0700 |
commit | 0bf1209f908bb9a384ddb3a4255a75bf2317c478 (patch) | |
tree | 3ebc80806ecfe884352f6628132421d2edcdab04 /OpenSim | |
parent | Restore handling of bad folders. I'm not entirely sure this is part of the pr... (diff) | |
download | opensim-SC-0bf1209f908bb9a384ddb3a4255a75bf2317c478.zip opensim-SC-0bf1209f908bb9a384ddb3a4255a75bf2317c478.tar.gz opensim-SC-0bf1209f908bb9a384ddb3a4255a75bf2317c478.tar.bz2 opensim-SC-0bf1209f908bb9a384ddb3a4255a75bf2317c478.tar.xz |
Another major overhaul of inventory downloading, this time pertaining to inventory links. Added yet another function to IInventoryService to get multiple items at once, so that fetching collections of linked items is done once per folder instead of once per item.
Diffstat (limited to 'OpenSim')
10 files changed, 297 insertions, 103 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventoryDescendents/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventoryDescendents/FetchInvDescHandler.cs index b7f332d..8dd6235 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventoryDescendents/FetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventoryDescendents/FetchInvDescHandler.cs | |||
@@ -603,136 +603,174 @@ namespace OpenSim.Capabilities.Handlers | |||
603 | // Do some post-processing. May need to fetch more from inv server for links | 603 | // Do some post-processing. May need to fetch more from inv server for links |
604 | foreach (InventoryCollection contents in fetchedContents) | 604 | foreach (InventoryCollection contents in fetchedContents) |
605 | { | 605 | { |
606 | // Find the original request | ||
607 | LLSDFetchInventoryDescendents freq = fetchFolders[i++]; | ||
608 | |||
606 | InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents(); | 609 | InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents(); |
607 | coll.Collection = contents; | 610 | coll.Collection = contents; |
608 | 611 | ||
609 | if (contents == null) | 612 | if (BadFolder(freq, contents, bad_folders)) |
610 | { | ||
611 | bad_folders.Add(fids[i++]); | ||
612 | continue; | 613 | continue; |
614 | |||
615 | // Next: link management | ||
616 | ProcessLinks(freq, coll); | ||
617 | |||
618 | result.Add(coll); | ||
619 | } | ||
620 | } | ||
621 | |||
622 | return result; | ||
623 | } | ||
624 | |||
625 | private bool BadFolder(LLSDFetchInventoryDescendents freq, InventoryCollection contents, List<UUID> bad_folders) | ||
626 | { | ||
627 | bool bad = false; | ||
628 | if (contents == null) | ||
629 | { | ||
630 | bad_folders.Add(freq.folder_id); | ||
631 | bad = true; | ||
632 | } | ||
633 | |||
634 | // The inventory server isn't sending FolderID in the collection... | ||
635 | // Must fetch it individually | ||
636 | if (contents.FolderID == UUID.Zero) | ||
637 | { | ||
638 | InventoryFolderBase containingFolder = new InventoryFolderBase(); | ||
639 | containingFolder.ID = freq.folder_id; | ||
640 | containingFolder.Owner = freq.owner_id; | ||
641 | containingFolder = m_InventoryService.GetFolder(containingFolder); | ||
642 | |||
643 | if (containingFolder != null) | ||
644 | { | ||
645 | contents.FolderID = containingFolder.ID; | ||
646 | contents.OwnerID = containingFolder.Owner; | ||
647 | contents.Version = containingFolder.Version; | ||
648 | } | ||
649 | else | ||
650 | { | ||
651 | // Was it really a request for folder Zero? | ||
652 | // This is an overkill, but Firestorm really asks for folder Zero. | ||
653 | // I'm leaving the code here for the time being, but commented. | ||
654 | if (freq.folder_id == UUID.Zero) | ||
655 | { | ||
656 | //coll.Collection.OwnerID = freq.owner_id; | ||
657 | //coll.Collection.FolderID = contents.FolderID; | ||
658 | //containingFolder = m_InventoryService.GetRootFolder(freq.owner_id); | ||
659 | //if (containingFolder != null) | ||
660 | //{ | ||
661 | // m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Request for parent of folder {0}", containingFolder.ID); | ||
662 | // coll.Collection.Folders.Clear(); | ||
663 | // coll.Collection.Folders.Add(containingFolder); | ||
664 | // if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null) | ||
665 | // { | ||
666 | // InventoryFolderBase lib = new InventoryFolderBase(m_LibraryService.LibraryRootFolder.ID, m_LibraryService.LibraryRootFolder.Owner); | ||
667 | // lib.Name = m_LibraryService.LibraryRootFolder.Name; | ||
668 | // lib.Type = m_LibraryService.LibraryRootFolder.Type; | ||
669 | // lib.Version = m_LibraryService.LibraryRootFolder.Version; | ||
670 | // coll.Collection.Folders.Add(lib); | ||
671 | // } | ||
672 | // coll.Collection.Items.Clear(); | ||
673 | //} | ||
674 | } | ||
675 | else | ||
676 | { | ||
677 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Unable to fetch folder {0}", freq.folder_id); | ||
678 | bad_folders.Add(freq.folder_id); | ||
679 | bad = true; | ||
613 | } | 680 | } |
681 | } | ||
682 | } | ||
614 | 683 | ||
684 | return bad; | ||
685 | } | ||
615 | 686 | ||
616 | // Find the original request | 687 | private void ProcessLinks(LLSDFetchInventoryDescendents freq, InventoryCollectionWithDescendents coll) |
617 | LLSDFetchInventoryDescendents freq = fetchFolders[i++]; | 688 | { |
689 | InventoryCollection contents = coll.Collection; | ||
690 | |||
691 | if (freq.fetch_items && contents.Items != null) | ||
692 | { | ||
693 | List<InventoryItemBase> itemsToReturn = contents.Items; | ||
694 | |||
695 | // descendents must only include the links, not the linked items we add | ||
696 | coll.Descendents = itemsToReturn.Count; | ||
618 | 697 | ||
619 | // The inventory server isn't sending FolderID in the collection... | 698 | // Add target items for links in this folder before the links themselves. |
620 | // Must fetch it individually | 699 | List<UUID> itemIDs = new List<UUID>(); |
621 | if (contents.FolderID == UUID.Zero) | 700 | List<UUID> folderIDs = new List<UUID>(); |
701 | foreach (InventoryItemBase item in itemsToReturn) | ||
702 | { | ||
703 | //m_log.DebugFormat("[XXX]: {0} {1}", item.Name, item.AssetType); | ||
704 | if (item.AssetType == (int)AssetType.Link) | ||
705 | itemIDs.Add(item.AssetID); | ||
706 | |||
707 | else if (item.AssetType == (int)AssetType.LinkFolder) | ||
708 | folderIDs.Add(item.AssetID); | ||
709 | } | ||
710 | |||
711 | //m_log.DebugFormat("[XXX]: folder {0} has {1} links and {2} linkfolders", contents.FolderID, itemIDs.Count, folderIDs.Count); | ||
712 | |||
713 | // Scan for folder links and insert the items they target and those links at the head of the return data | ||
714 | if (folderIDs.Count > 0) | ||
715 | { | ||
716 | InventoryCollection[] linkedFolders = m_InventoryService.GetMultipleFoldersContent(coll.Collection.OwnerID, folderIDs.ToArray()); | ||
717 | foreach (InventoryCollection linkedFolderContents in linkedFolders) | ||
622 | { | 718 | { |
623 | InventoryFolderBase containingFolder = new InventoryFolderBase(); | 719 | List<InventoryItemBase> links = linkedFolderContents.Items; |
624 | containingFolder.ID = freq.folder_id; | ||
625 | containingFolder.Owner = freq.owner_id; | ||
626 | containingFolder = m_InventoryService.GetFolder(containingFolder); | ||
627 | 720 | ||
628 | if (containingFolder != null) | 721 | itemsToReturn.InsertRange(0, links); |
629 | { | 722 | |
630 | contents.FolderID = containingFolder.ID; | 723 | foreach (InventoryItemBase link in linkedFolderContents.Items) |
631 | contents.OwnerID = containingFolder.Owner; | ||
632 | contents.Version = containingFolder.Version; | ||
633 | } | ||
634 | else | ||
635 | { | 724 | { |
636 | // Was it really a request for folder Zero? | 725 | // Take care of genuinely broken links where the target doesn't exist |
637 | // This is an overkill, but Firestorm really asks for folder Zero. | 726 | // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, |
638 | // I'm leaving the code here for the time being, but commented. | 727 | // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles |
639 | if (fetchFolders[i - 1].folder_id == UUID.Zero) | 728 | // rather than having to keep track of every folder requested in the recursion. |
640 | { | 729 | if (link != null) |
641 | //coll.Collection.OwnerID = freq.owner_id; | ||
642 | //coll.Collection.FolderID = contents.FolderID; | ||
643 | //containingFolder = m_InventoryService.GetRootFolder(freq.owner_id); | ||
644 | //if (containingFolder != null) | ||
645 | //{ | ||
646 | // m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Request for parent of folder {0}", containingFolder.ID); | ||
647 | // coll.Collection.Folders.Clear(); | ||
648 | // coll.Collection.Folders.Add(containingFolder); | ||
649 | // if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null) | ||
650 | // { | ||
651 | // InventoryFolderBase lib = new InventoryFolderBase(m_LibraryService.LibraryRootFolder.ID, m_LibraryService.LibraryRootFolder.Owner); | ||
652 | // lib.Name = m_LibraryService.LibraryRootFolder.Name; | ||
653 | // lib.Type = m_LibraryService.LibraryRootFolder.Type; | ||
654 | // lib.Version = m_LibraryService.LibraryRootFolder.Version; | ||
655 | // coll.Collection.Folders.Add(lib); | ||
656 | // } | ||
657 | // coll.Collection.Items.Clear(); | ||
658 | //} | ||
659 | } | ||
660 | else | ||
661 | { | 730 | { |
662 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Unable to fetch folder {0}", freq.folder_id); | 731 | //m_log.DebugFormat( |
663 | bad_folders.Add(freq.folder_id); | 732 | // "[WEB FETCH INV DESC HANDLER]: Adding item {0} {1} from folder {2} linked from {3} ({4} {5})", |
664 | continue; | 733 | // link.Name, (AssetType)link.AssetType, linkedFolderContents.FolderID, contents.FolderID, link.ID, link.AssetID); |
734 | itemIDs.Add(link.ID); | ||
665 | } | 735 | } |
666 | } | 736 | } |
667 | } | 737 | } |
738 | } | ||
668 | 739 | ||
669 | if (freq.fetch_items && contents.Items != null) | 740 | if (itemIDs.Count > 0) |
741 | { | ||
742 | InventoryItemBase[] linked = m_InventoryService.GetMultipleItems(freq.owner_id, itemIDs.ToArray()); | ||
743 | if (linked == null) | ||
670 | { | 744 | { |
671 | List<InventoryItemBase> itemsToReturn = contents.Items; | 745 | // OMG!!! One by one!!! This is fallback code, in case the backend isn't updated |
672 | List<InventoryItemBase> originalItems = new List<InventoryItemBase>(itemsToReturn); | 746 | m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: GetMultipleItems failed. Falling back to fetching inventory items one by one."); |
673 | 747 | linked = new InventoryItemBase[itemIDs.Count]; | |
674 | // descendents must only include the links, not the linked items we add | 748 | int i = 0; |
675 | coll.Descendents = originalItems.Count; | 749 | InventoryItemBase item = new InventoryItemBase(); |
676 | 750 | item.Owner = freq.owner_id; | |
677 | // Add target items for links in this folder before the links themselves. | 751 | foreach (UUID id in itemIDs) |
678 | foreach (InventoryItemBase item in originalItems) | ||
679 | { | 752 | { |
680 | if (item.AssetType == (int)AssetType.Link) | 753 | item.ID = id; |
681 | { | 754 | linked[i++] = m_InventoryService.GetItem(item); |
682 | InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID)); | ||
683 | |||
684 | // Take care of genuinely broken links where the target doesn't exist | ||
685 | // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, | ||
686 | // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles | ||
687 | // rather than having to keep track of every folder requested in the recursion. | ||
688 | if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link) | ||
689 | { | ||
690 | itemsToReturn.Insert(0, linkedItem); | ||
691 | } | ||
692 | } | ||
693 | } | 755 | } |
756 | } | ||
694 | 757 | ||
695 | // Now scan for folder links and insert the items they target and those links at the head of the return data | 758 | foreach (InventoryItemBase linkedItem in linked) |
696 | foreach (InventoryItemBase item in originalItems) | 759 | { |
760 | // Take care of genuinely broken links where the target doesn't exist | ||
761 | // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, | ||
762 | // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles | ||
763 | // rather than having to keep track of every folder requested in the recursion. | ||
764 | if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link) | ||
697 | { | 765 | { |
698 | if (item.AssetType == (int)AssetType.LinkFolder) | 766 | itemsToReturn.Insert(0, linkedItem); |
699 | { | ||
700 | InventoryCollection linkedFolderContents = m_InventoryService.GetFolderContent(coll.Collection.OwnerID, item.AssetID); | ||
701 | List<InventoryItemBase> links = linkedFolderContents.Items; | ||
702 | |||
703 | itemsToReturn.InsertRange(0, links); | ||
704 | |||
705 | foreach (InventoryItemBase link in linkedFolderContents.Items) | ||
706 | { | ||
707 | // Take care of genuinely broken links where the target doesn't exist | ||
708 | // HACK: Also, don't follow up links that just point to other links. In theory this is legitimate, | ||
709 | // but no viewer has been observed to set these up and this is the lazy way of avoiding cycles | ||
710 | // rather than having to keep track of every folder requested in the recursion. | ||
711 | if (link != null) | ||
712 | { | ||
713 | //m_log.DebugFormat( | ||
714 | // "[WEB FETCH INV DESC HANDLER]: Adding item {0} {1} from folder {2} linked from {3}", | ||
715 | // link.Name, (AssetType)link.AssetType, item.AssetID, contents.FolderID); | ||
716 | |||
717 | InventoryItemBase linkedItem | ||
718 | = m_InventoryService.GetItem(new InventoryItemBase(link.AssetID)); | ||
719 | |||
720 | if (linkedItem != null) | ||
721 | itemsToReturn.Insert(0, linkedItem); | ||
722 | } | ||
723 | } | ||
724 | } | ||
725 | } | 767 | } |
726 | } | 768 | } |
727 | |||
728 | result.Add(coll); | ||
729 | } | 769 | } |
730 | } | 770 | } |
731 | 771 | ||
732 | return result; | ||
733 | } | 772 | } |
734 | 773 | ||
735 | |||
736 | /// <summary> | 774 | /// <summary> |
737 | /// Convert an internal inventory folder object into an LLSD object. | 775 | /// Convert an internal inventory folder object into an LLSD object. |
738 | /// </summary> | 776 | /// </summary> |
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs index eb7d3a9..e657f53 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LocalInventoryService.cs | |||
@@ -99,6 +99,22 @@ namespace OpenSim.Region.CoreModules.Framework.Library | |||
99 | return invColl; | 99 | return invColl; |
100 | } | 100 | } |
101 | 101 | ||
102 | public virtual InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs) | ||
103 | { | ||
104 | InventoryItemBase[] itemColl = new InventoryItemBase[itemIDs.Length]; | ||
105 | int i = 0; | ||
106 | InventoryItemBase item = new InventoryItemBase(); | ||
107 | item.Owner = principalID; | ||
108 | foreach (UUID fid in itemIDs) | ||
109 | { | ||
110 | item.ID = fid; | ||
111 | itemColl[i++] = GetItem(item); | ||
112 | } | ||
113 | |||
114 | return itemColl; | ||
115 | } | ||
116 | |||
117 | |||
102 | /// <summary> | 118 | /// <summary> |
103 | /// Add a new folder to the user's inventory | 119 | /// Add a new folder to the user's inventory |
104 | /// </summary> | 120 | /// </summary> |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index 232cfdf..6a83b42 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs | |||
@@ -615,6 +615,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
615 | return connector.GetItem(item); | 615 | return connector.GetItem(item); |
616 | } | 616 | } |
617 | 617 | ||
618 | public InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] itemIDs) | ||
619 | { | ||
620 | if (itemIDs == null) | ||
621 | return new InventoryItemBase[0]; | ||
622 | //m_log.Debug("[HG INVENTORY CONNECTOR]: GetItem " + item.ID); | ||
623 | |||
624 | string invURL = GetInventoryServiceURL(userID); | ||
625 | |||
626 | if (invURL == null) // not there, forward to local inventory connector to resolve | ||
627 | lock (m_Lock) | ||
628 | return m_LocalGridInventoryService.GetMultipleItems(userID, itemIDs); | ||
629 | |||
630 | IInventoryService connector = GetConnector(invURL); | ||
631 | |||
632 | return connector.GetMultipleItems(userID, itemIDs); | ||
633 | } | ||
634 | |||
618 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) | 635 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) |
619 | { | 636 | { |
620 | if (folder == null) | 637 | if (folder == null) |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 75dd200..2f29a7c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | |||
@@ -307,6 +307,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
307 | return item; | 307 | return item; |
308 | } | 308 | } |
309 | 309 | ||
310 | public InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] itemIDs) | ||
311 | { | ||
312 | return m_InventoryService.GetMultipleItems(userID, itemIDs); | ||
313 | } | ||
314 | |||
310 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) | 315 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) |
311 | { | 316 | { |
312 | return m_InventoryService.GetFolder(folder); | 317 | return m_InventoryService.GetFolder(folder); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs index 9beb382..e0cc1e8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs | |||
@@ -303,6 +303,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | |||
303 | return m_RemoteConnector.GetItem(item); | 303 | return m_RemoteConnector.GetItem(item); |
304 | } | 304 | } |
305 | 305 | ||
306 | public InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] itemIDs) | ||
307 | { | ||
308 | if (itemIDs == null) | ||
309 | return new InventoryItemBase[0]; | ||
310 | |||
311 | return m_RemoteConnector.GetMultipleItems(userID, itemIDs); | ||
312 | } | ||
313 | |||
306 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) | 314 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) |
307 | { | 315 | { |
308 | //m_log.DebugFormat("[XINVENTORY CONNECTOR]: GetFolder {0}", folder.ID); | 316 | //m_log.DebugFormat("[XINVENTORY CONNECTOR]: GetFolder {0}", folder.ID); |
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs index 4f01e36..cf0762b 100644 --- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs +++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs | |||
@@ -149,6 +149,8 @@ namespace OpenSim.Server.Handlers.Inventory | |||
149 | return HandleDeleteItems(request); | 149 | return HandleDeleteItems(request); |
150 | case "GETITEM": | 150 | case "GETITEM": |
151 | return HandleGetItem(request); | 151 | return HandleGetItem(request); |
152 | case "GETMULTIPLEITEMS": | ||
153 | return HandleGetMultipleItems(request); | ||
152 | case "GETFOLDER": | 154 | case "GETFOLDER": |
153 | return HandleGetFolder(request); | 155 | return HandleGetFolder(request); |
154 | case "GETACTIVEGESTURES": | 156 | case "GETACTIVEGESTURES": |
@@ -576,6 +578,40 @@ namespace OpenSim.Server.Handlers.Inventory | |||
576 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | 578 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); |
577 | } | 579 | } |
578 | 580 | ||
581 | byte[] HandleGetMultipleItems(Dictionary<string, object> request) | ||
582 | { | ||
583 | Dictionary<string, object> resultSet = new Dictionary<string, object>(); | ||
584 | UUID principal = UUID.Zero; | ||
585 | UUID.TryParse(request["PRINCIPAL"].ToString(), out principal); | ||
586 | string itemIDstr = request["ITEMS"].ToString(); | ||
587 | int count = 0; | ||
588 | Int32.TryParse(request["COUNT"].ToString(), out count); | ||
589 | |||
590 | UUID[] fids = new UUID[count]; | ||
591 | string[] uuids = itemIDstr.Split(','); | ||
592 | int i = 0; | ||
593 | foreach (string id in uuids) | ||
594 | { | ||
595 | UUID fid = UUID.Zero; | ||
596 | if (UUID.TryParse(id, out fid)) | ||
597 | fids[i] = fid; | ||
598 | i += 1; | ||
599 | } | ||
600 | |||
601 | InventoryItemBase[] itemsList = m_InventoryService.GetMultipleItems(principal, fids); | ||
602 | if (itemsList != null && itemsList.Length > 0) | ||
603 | { | ||
604 | count = 0; | ||
605 | foreach (InventoryItemBase item in itemsList) | ||
606 | resultSet["item_" + count++] = (item == null) ? (object)"NULL" : EncodeItem(item); | ||
607 | } | ||
608 | |||
609 | string xmlString = ServerUtils.BuildXmlResponse(resultSet); | ||
610 | |||
611 | //m_log.DebugFormat("[XXX]: resp string: {0}", xmlString); | ||
612 | return Util.UTF8NoBomEncoding.GetBytes(xmlString); | ||
613 | } | ||
614 | |||
579 | byte[] HandleGetFolder(Dictionary<string,object> request) | 615 | byte[] HandleGetFolder(Dictionary<string,object> request) |
580 | { | 616 | { |
581 | Dictionary<string, object> result = new Dictionary<string, object>(); | 617 | Dictionary<string, object> result = new Dictionary<string, object>(); |
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs index 56dece3..0cea4a1 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs | |||
@@ -316,6 +316,7 @@ namespace OpenSim.Services.Connectors | |||
316 | 316 | ||
317 | return inventoryArr; | 317 | return inventoryArr; |
318 | } | 318 | } |
319 | |||
319 | public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) | 320 | public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) |
320 | { | 321 | { |
321 | Dictionary<string,object> ret = MakeRequest("GETFOLDERITEMS", | 322 | Dictionary<string,object> ret = MakeRequest("GETFOLDERITEMS", |
@@ -526,6 +527,42 @@ namespace OpenSim.Services.Connectors | |||
526 | return null; | 527 | return null; |
527 | } | 528 | } |
528 | 529 | ||
530 | public virtual InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs) | ||
531 | { | ||
532 | InventoryItemBase[] itemArr = new InventoryItemBase[itemIDs.Length]; | ||
533 | try | ||
534 | { | ||
535 | Dictionary<string, object> resultSet = MakeRequest("GETMULTIPLEITEMS", | ||
536 | new Dictionary<string, object> { | ||
537 | { "PRINCIPAL", principalID.ToString() }, | ||
538 | { "ITEMS", String.Join(",", itemIDs) }, | ||
539 | { "COUNT", itemIDs.Length.ToString() } | ||
540 | }); | ||
541 | |||
542 | if (!CheckReturn(resultSet)) | ||
543 | return null; | ||
544 | |||
545 | int i = 0; | ||
546 | foreach (KeyValuePair<string, object> kvp in resultSet) | ||
547 | { | ||
548 | InventoryCollection inventory = new InventoryCollection(); | ||
549 | if (kvp.Key.StartsWith("item_")) | ||
550 | { | ||
551 | if (kvp.Value is Dictionary<string, object>) | ||
552 | itemArr[i++] = BuildItem((Dictionary<string, object>)kvp.Value); | ||
553 | else | ||
554 | itemArr[i++] = null; | ||
555 | } | ||
556 | } | ||
557 | } | ||
558 | catch (Exception e) | ||
559 | { | ||
560 | m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Exception in GetMultipleItems: {0}", e.Message); | ||
561 | } | ||
562 | |||
563 | return itemArr; | ||
564 | } | ||
565 | |||
529 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) | 566 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) |
530 | { | 567 | { |
531 | try | 568 | try |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs index 0331c66..fdeea18 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs | |||
@@ -301,6 +301,21 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
301 | return null; | 301 | return null; |
302 | } | 302 | } |
303 | 303 | ||
304 | public InventoryItemBase[] GetMultipleItems(UUID principalID, UUID[] itemIDs) | ||
305 | { | ||
306 | InventoryItemBase[] result = new InventoryItemBase[itemIDs.Length]; | ||
307 | int i = 0; | ||
308 | InventoryItemBase item = new InventoryItemBase(); | ||
309 | item.Owner = principalID; | ||
310 | foreach (UUID id in itemIDs) | ||
311 | { | ||
312 | item.ID = id; | ||
313 | result[i++] = GetItem(item); | ||
314 | } | ||
315 | |||
316 | return result; | ||
317 | } | ||
318 | |||
304 | /// <summary> | 319 | /// <summary> |
305 | /// Get a folder, given by its UUID | 320 | /// Get a folder, given by its UUID |
306 | /// </summary> | 321 | /// </summary> |
diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs index 829f169..1e8652c 100644 --- a/OpenSim/Services/Interfaces/IInventoryService.cs +++ b/OpenSim/Services/Interfaces/IInventoryService.cs | |||
@@ -82,7 +82,7 @@ namespace OpenSim.Services.Interfaces | |||
82 | /// </summary> | 82 | /// </summary> |
83 | /// <param name="userId"></param> | 83 | /// <param name="userId"></param> |
84 | /// <param name="folderIDs"></param> | 84 | /// <param name="folderIDs"></param> |
85 | /// <returns>Inventory content. null if the request failed.</returns> | 85 | /// <returns>Inventory content.</returns> |
86 | InventoryCollection[] GetMultipleFoldersContent(UUID userID, UUID[] folderIDs); | 86 | InventoryCollection[] GetMultipleFoldersContent(UUID userID, UUID[] folderIDs); |
87 | 87 | ||
88 | /// <summary> | 88 | /// <summary> |
@@ -164,6 +164,13 @@ namespace OpenSim.Services.Interfaces | |||
164 | InventoryItemBase GetItem(InventoryItemBase item); | 164 | InventoryItemBase GetItem(InventoryItemBase item); |
165 | 165 | ||
166 | /// <summary> | 166 | /// <summary> |
167 | /// Get multiple items, given by their UUIDs | ||
168 | /// </summary> | ||
169 | /// <param name="item"></param> | ||
170 | /// <returns>null if no item was found, otherwise the found item</returns> | ||
171 | InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] ids); | ||
172 | |||
173 | /// <summary> | ||
167 | /// Get a folder, given by its UUID | 174 | /// Get a folder, given by its UUID |
168 | /// </summary> | 175 | /// </summary> |
169 | /// <param name="folder"></param> | 176 | /// <param name="folder"></param> |
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 6582b75..50cadab 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs | |||
@@ -610,6 +610,21 @@ namespace OpenSim.Services.InventoryService | |||
610 | return ConvertToOpenSim(items[0]); | 610 | return ConvertToOpenSim(items[0]); |
611 | } | 611 | } |
612 | 612 | ||
613 | public virtual InventoryItemBase[] GetMultipleItems(UUID userID, UUID[] ids) | ||
614 | { | ||
615 | InventoryItemBase[] items = new InventoryItemBase[ids.Length]; | ||
616 | int i = 0; | ||
617 | InventoryItemBase item = new InventoryItemBase(); | ||
618 | item.Owner = userID; | ||
619 | foreach (UUID id in ids) | ||
620 | { | ||
621 | item.ID = id; | ||
622 | items[i++] = GetItem(item); | ||
623 | } | ||
624 | |||
625 | return items; | ||
626 | } | ||
627 | |||
613 | public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder) | 628 | public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder) |
614 | { | 629 | { |
615 | XInventoryFolder[] folders = m_Database.GetFolders( | 630 | XInventoryFolder[] folders = m_Database.GetFolders( |