diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs (renamed from OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs) | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs index c0ca1e1..c904392 100644 --- a/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs +++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs | |||
@@ -25,23 +25,18 @@ | |||
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; | ||
31 | using System.Reflection; | 28 | using System.Reflection; |
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using OpenMetaverse; | 29 | using OpenMetaverse; |
35 | using OpenMetaverse.StructuredData; | 30 | using OpenMetaverse.StructuredData; |
36 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Capabilities; | 32 | using OpenSim.Framework.Capabilities; |
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Framework.Servers.HttpServer; | 33 | using OpenSim.Framework.Servers.HttpServer; |
40 | using OpenSim.Services.Interfaces; | 34 | using OpenSim.Services.Interfaces; |
41 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
42 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | 35 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; |
43 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | 36 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; |
44 | 37 | ||
38 | using log4net; | ||
39 | |||
45 | namespace OpenSim.Capabilities.Handlers | 40 | namespace OpenSim.Capabilities.Handlers |
46 | { | 41 | { |
47 | public class FetchInventory2Handler | 42 | public class FetchInventory2Handler |
@@ -49,15 +44,17 @@ namespace OpenSim.Capabilities.Handlers | |||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 45 | ||
51 | private IInventoryService m_inventoryService; | 46 | private IInventoryService m_inventoryService; |
47 | private UUID m_agentID; | ||
52 | 48 | ||
53 | public FetchInventory2Handler(IInventoryService invService) | 49 | public FetchInventory2Handler(IInventoryService invService, UUID agentId) |
54 | { | 50 | { |
55 | m_inventoryService = invService; | 51 | m_inventoryService = invService; |
52 | m_agentID = agentId; | ||
56 | } | 53 | } |
57 | 54 | ||
58 | public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) | 55 | public string FetchInventoryRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) |
59 | { | 56 | { |
60 | // m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capabilty request"); | 57 | //m_log.DebugFormat("[FETCH INVENTORY HANDLER]: Received FetchInventory capability request {0}", request); |
61 | 58 | ||
62 | OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); | 59 | OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); |
63 | OSDArray itemsRequested = (OSDArray)requestmap["items"]; | 60 | OSDArray itemsRequested = (OSDArray)requestmap["items"]; |
@@ -65,12 +62,32 @@ namespace OpenSim.Capabilities.Handlers | |||
65 | string reply; | 62 | string reply; |
66 | LLSDFetchInventory llsdReply = new LLSDFetchInventory(); | 63 | LLSDFetchInventory llsdReply = new LLSDFetchInventory(); |
67 | 64 | ||
65 | UUID[] itemIDs = new UUID[itemsRequested.Count]; | ||
66 | int i = 0; | ||
68 | foreach (OSDMap osdItemId in itemsRequested) | 67 | foreach (OSDMap osdItemId in itemsRequested) |
69 | { | 68 | { |
70 | UUID itemId = osdItemId["item_id"].AsUUID(); | 69 | itemIDs[i++] = osdItemId["item_id"].AsUUID(); |
70 | } | ||
71 | |||
72 | InventoryItemBase[] items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs); | ||
71 | 73 | ||
72 | InventoryItemBase item = m_inventoryService.GetItem(new InventoryItemBase(itemId)); | 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 | } | ||
73 | 88 | ||
89 | foreach (InventoryItemBase item in items) | ||
90 | { | ||
74 | if (item != null) | 91 | if (item != null) |
75 | { | 92 | { |
76 | // 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 |
@@ -121,4 +138,4 @@ namespace OpenSim.Capabilities.Handlers | |||
121 | return llsdItem; | 138 | return llsdItem; |
122 | } | 139 | } |
123 | } | 140 | } |
124 | } | 141 | } \ No newline at end of file |