public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { // m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capabilty request"); OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); OSDArray itemsRequested = (OSDArray)requestmap["items"]; string reply; LLSDFetchInventory llsdReply = new LLSDFetchInventory(); foreach (OSDMap osdItemId in itemsRequested) { UUID itemId = osdItemId["item_id"].AsUUID(); InventoryItemBase item = m_inventoryService.GetItem(new InventoryItemBase(itemId, m_agentID)); if (item != null) { // We don't know the agent that this request belongs to so we'll use the agent id of the item // which will be the same for all items. llsdReply.agent_id = item.Owner; llsdReply.items.Array.Add(ConvertInventoryItem(item)); } } reply = LLSDHelpers.SerialiseLLSDReply(llsdReply); return reply; }
public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) { //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request); OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); OSDArray itemsRequested = (OSDArray)requestmap["items"]; string reply; LLSDFetchInventory llsdReply = new LLSDFetchInventory(); UUID[] itemIDs = new UUID[itemsRequested.Count]; int i = 0; foreach (OSDMap osdItemId in itemsRequested) { itemIDs[i++] = osdItemId["item_id"].AsUUID(); } InventoryItemBase[] items = null; if (m_agentID != UUID.Zero) { items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs); if (items == null) { // OMG!!! One by one!!! This is fallback code, in case the backend isn't updated m_log.WarnFormat("[FETCH INVENTORY HANDLER]: GetMultipleItems failed. Falling back to fetching inventory items one by one."); items = new InventoryItemBase[itemsRequested.Count]; foreach (UUID id in itemIDs) items[i++] = m_inventoryService.GetItem(m_agentID, id); } } else { items = new InventoryItemBase[itemsRequested.Count]; foreach (UUID id in itemIDs) items[i++] = m_inventoryService.GetItem(UUID.Zero, id); } foreach (InventoryItemBase item in items) { if (item != null) { // We don't know the agent that this request belongs to so we'll use the agent id of the item // which will be the same for all items. llsdReply.agent_id = item.Owner; llsdReply.items.Array.Add(ConvertInventoryItem(item)); } } reply = LLSDHelpers.SerialiseLLSDReply(llsdReply); return reply; }
public Hashtable FetchLibInventoryItemsRequest(Hashtable mDhttpMethod, UUID AgentID) { m_log.DebugFormat("[AGENT INVENTORY]: Received CAPS library inventory items request for {0}", AgentID); // nasty temporary hack here, the linden client falsely // identifies the uuid 00000000-0000-0000-0000-000000000000 // as a string which breaks us // // correctly mark it as a uuid // string request = (string)mDhttpMethod["requestbody"]; request = request.Replace("<string>00000000-0000-0000-0000-000000000000</string>", "<uuid>00000000-0000-0000-0000-000000000000</uuid>"); Hashtable hash = new Hashtable(); try { hash = (Hashtable)LLSD.LLSDDeserialize(OpenMetaverse.Utils.StringToBytes(request)); } catch (LLSD.LLSDParseException pe) { m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); m_log.Error("Request: " + request.ToString()); } ArrayList foldersrequested = (ArrayList)hash["items"]; string response = ""; lock (m_fetchLock) { for (int i = 0; i < foldersrequested.Count; i++) { string inventoryitemstr = ""; Hashtable inventoryhash = (Hashtable)foldersrequested[i]; LLSDFetchInventory llsdRequest = new LLSDFetchInventory(); try { LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest); } catch (Exception e) { m_log.Debug("[CAPS]: caught exception doing OSD deserialize" + e); } InventoryItemBase item = null; if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null) { item = m_LibraryService.LibraryRootFolder.FindItem(llsdRequest.item_id); } if(item == null) //Try normal inventory them item = m_InventoryService.GetItem(new InventoryItemBase(llsdRequest.item_id, llsdRequest.owner_id)); if (item != null) { LLSDInventoryItem reply = ConvertInventoryItem(item, llsdRequest.owner_id); inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply); response += inventoryitemstr; } } if (response.Length == 0) { // Ter-guess: If requests fail a lot, the client seems to stop requesting descendants. // Therefore, I'm concluding that the client only has so many threads available to do requests // and when a thread stalls.. is stays stalled. // Therefore we need to return something valid response = "<llsd><map><key>folders</key><array /></map></llsd>"; } else { response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>"; } //m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml"); //m_log.Debug("[CAPS] "+response); } Hashtable cancelresponsedata = new Hashtable(); cancelresponsedata["int_response_code"] = 200; //501; //410; //404; cancelresponsedata["content_type"] = "text/plain"; cancelresponsedata["keepalive"] = false; cancelresponsedata["str_response_string"] = response; return cancelresponsedata; }