diff options
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 | ||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
28 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | ||
33 | using Nini.Config; | ||
29 | using OpenMetaverse; | 34 | using OpenMetaverse; |
30 | using OpenMetaverse.StructuredData; | 35 | using OpenMetaverse.StructuredData; |
31 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
32 | using OpenSim.Framework.Capabilities; | 37 | using OpenSim.Framework.Capabilities; |
38 | using OpenSim.Region.Framework.Interfaces; | ||
33 | using OpenSim.Framework.Servers.HttpServer; | 39 | using OpenSim.Framework.Servers.HttpServer; |
34 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
35 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | 42 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; |
36 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | 43 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; |
37 | 44 | ||
38 | using log4net; | ||
39 | |||
40 | namespace OpenSim.Capabilities.Handlers | 45 | namespace 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 |