aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs (renamed from OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs)41
1 files changed, 12 insertions, 29 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs
index 638e8bc..d1503ee 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs
@@ -25,36 +25,39 @@
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;
29using System.Collections;
30using System.Collections.Generic;
28using System.Reflection; 31using System.Reflection;
32using log4net;
33using Nini.Config;
29using OpenMetaverse; 34using OpenMetaverse;
30using OpenMetaverse.StructuredData; 35using OpenMetaverse.StructuredData;
31using OpenSim.Framework; 36using OpenSim.Framework;
32using OpenSim.Framework.Capabilities; 37using OpenSim.Framework.Capabilities;
38using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Framework.Servers.HttpServer; 39using OpenSim.Framework.Servers.HttpServer;
34using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using Caps = OpenSim.Framework.Capabilities.Caps;
35using OSDArray = OpenMetaverse.StructuredData.OSDArray; 42using OSDArray = OpenMetaverse.StructuredData.OSDArray;
36using OSDMap = OpenMetaverse.StructuredData.OSDMap; 43using OSDMap = OpenMetaverse.StructuredData.OSDMap;
37 44
38using log4net;
39
40namespace OpenSim.Capabilities.Handlers 45namespace OpenSim.Capabilities.Handlers
41{ 46{
42 public class FetchInventory2Handler 47 public class FetchInventory2Handler
43 { 48 {
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 50
46 private IInventoryService m_inventoryService; 51 private IInventoryService m_inventoryService;
47 private UUID m_agentID;
48 52
49 public FetchInventory2Handler(IInventoryService invService, UUID agentId) 53 public FetchInventory2Handler(IInventoryService invService)
50 { 54 {
51 m_inventoryService = invService; 55 m_inventoryService = invService;
52 m_agentID = agentId;
53 } 56 }
54 57
55 public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 58 public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
56 { 59 {
57 //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request); 60// m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capabilty request");
58 61
59 OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); 62 OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
60 OSDArray itemsRequested = (OSDArray)requestmap["items"]; 63 OSDArray itemsRequested = (OSDArray)requestmap["items"];
@@ -62,32 +65,12 @@ namespace OpenSim.Capabilities.Handlers
62 string reply; 65 string reply;
63 LLSDFetchInventory llsdReply = new LLSDFetchInventory(); 66 LLSDFetchInventory llsdReply = new LLSDFetchInventory();
64 67
65 UUID[] itemIDs = new UUID[itemsRequested.Count];
66 int i = 0;
67 foreach (OSDMap osdItemId in itemsRequested) 68 foreach (OSDMap osdItemId in itemsRequested)
68 { 69 {
69 itemIDs[i++] = osdItemId["item_id"].AsUUID(); 70 UUID itemId = osdItemId["item_id"].AsUUID();
70 }
71
72 InventoryItemBase[] items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);
73 71
74 if (items == null) 72 InventoryItemBase item = m_inventoryService.GetItem(new InventoryItemBase(itemId));
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 }
88 73
89 foreach (InventoryItemBase item in items)
90 {
91 if (item != null) 74 if (item != null)
92 { 75 {
93 // We don't know the agent that this request belongs to so we'll use the agent id of the item 76 // We don't know the agent that this request belongs to so we'll use the agent id of the item