aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs29
1 files changed, 26 insertions, 3 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
index b67b326..0832b02 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Reflection;
28using OpenMetaverse; 29using OpenMetaverse;
29using OpenMetaverse.StructuredData; 30using OpenMetaverse.StructuredData;
30using OpenSim.Framework; 31using OpenSim.Framework;
@@ -34,11 +35,13 @@ using OpenSim.Services.Interfaces;
34using OSDArray = OpenMetaverse.StructuredData.OSDArray; 35using OSDArray = OpenMetaverse.StructuredData.OSDArray;
35using OSDMap = OpenMetaverse.StructuredData.OSDMap; 36using OSDMap = OpenMetaverse.StructuredData.OSDMap;
36 37
38using log4net;
39
37namespace OpenSim.Capabilities.Handlers 40namespace OpenSim.Capabilities.Handlers
38{ 41{
39 public class FetchInventory2Handler 42 public class FetchInventory2Handler
40 { 43 {
41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 45
43 private IInventoryService m_inventoryService; 46 private IInventoryService m_inventoryService;
44 private UUID m_agentID; 47 private UUID m_agentID;
@@ -59,12 +62,32 @@ namespace OpenSim.Capabilities.Handlers
59 string reply; 62 string reply;
60 LLSDFetchInventory llsdReply = new LLSDFetchInventory(); 63 LLSDFetchInventory llsdReply = new LLSDFetchInventory();
61 64
65 UUID[] itemIDs = new UUID[itemsRequested.Count];
66 int i = 0;
62 foreach (OSDMap osdItemId in itemsRequested) 67 foreach (OSDMap osdItemId in itemsRequested)
63 { 68 {
64 UUID itemId = osdItemId["item_id"].AsUUID(); 69 itemIDs[i++] = osdItemId["item_id"].AsUUID();
70 }
65 71
66 InventoryItemBase item = m_inventoryService.GetItem(new InventoryItemBase(itemId, m_agentID)); 72 InventoryItemBase[] items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);
73
74 if (items == null)
75 {
76 // OMG!!! One by one!!! This is fallback code, in case the backend isn't updated
77 m_log.WarnFormat("[FETCH INVENTORY HANDLER]: GetMultipleItems failed. Falling back to fetching inventory items one by one.");
78 items = new InventoryItemBase[itemsRequested.Count];
79 i = 0;
80 InventoryItemBase item = new InventoryItemBase();
81 item.Owner = m_agentID;
82 foreach (UUID id in itemIDs)
83 {
84 item.ID = id;
85 items[i++] = m_inventoryService.GetItem(item);
86 }
87 }
67 88
89 foreach (InventoryItemBase item in items)
90 {
68 if (item != null) 91 if (item != null)
69 { 92 {
70 // We don't know the agent that this request belongs to so we'll use the agent id of the item 93 // We don't know the agent that this request belongs to so we'll use the agent id of the item