diff options
author | UbitUmarov | 2015-09-11 16:25:46 +0100 |
---|---|---|
committer | UbitUmarov | 2015-09-11 16:25:46 +0100 |
commit | 7841628313c4d976508cc5853da54f83b6e23512 (patch) | |
tree | 895be68db8922c7fd95d6f732036b92ffe354c05 /OpenSim/Capabilities/Handlers/FetchInventory2 | |
parent | remove diva's inventory cache since it seems to cause mantis 7720, broken it... (diff) | |
download | opensim-SC-7841628313c4d976508cc5853da54f83b6e23512.zip opensim-SC-7841628313c4d976508cc5853da54f83b6e23512.tar.gz opensim-SC-7841628313c4d976508cc5853da54f83b6e23512.tar.bz2 opensim-SC-7841628313c4d976508cc5853da54f83b6e23512.tar.xz |
change to avn fecthinventory and webfecth.. code
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2Handler.cs (renamed from OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs) | 41 | ||||
-rw-r--r-- | OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2ServerConnector.cs | 71 |
2 files changed, 83 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 |
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2ServerConnector.cs b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2ServerConnector.cs new file mode 100644 index 0000000..5bab52f --- /dev/null +++ b/OpenSim/Capabilities/Handlers/FetchInventory2/FetchInventory2ServerConnector.cs | |||
@@ -0,0 +1,71 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using Nini.Config; | ||
30 | using OpenSim.Server.Base; | ||
31 | using OpenSim.Services.Interfaces; | ||
32 | using OpenSim.Framework.Servers.HttpServer; | ||
33 | using OpenSim.Server.Handlers.Base; | ||
34 | using OpenMetaverse; | ||
35 | |||
36 | namespace OpenSim.Capabilities.Handlers | ||
37 | { | ||
38 | public class FetchInventory2ServerConnector : ServiceConnector | ||
39 | { | ||
40 | private IInventoryService m_InventoryService; | ||
41 | private string m_ConfigName = "CapsService"; | ||
42 | |||
43 | public FetchInventory2ServerConnector(IConfigSource config, IHttpServer server, string configName) | ||
44 | : base(config, server, configName) | ||
45 | { | ||
46 | if (configName != String.Empty) | ||
47 | m_ConfigName = configName; | ||
48 | |||
49 | IConfig serverConfig = config.Configs[m_ConfigName]; | ||
50 | if (serverConfig == null) | ||
51 | throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName)); | ||
52 | |||
53 | string invService = serverConfig.GetString("InventoryService", String.Empty); | ||
54 | |||
55 | if (invService == String.Empty) | ||
56 | throw new Exception("No InventoryService in config file"); | ||
57 | |||
58 | Object[] args = new Object[] { config }; | ||
59 | m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args); | ||
60 | |||
61 | if (m_InventoryService == null) | ||
62 | throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName)); | ||
63 | |||
64 | FetchInventory2Handler fiHandler = new FetchInventory2Handler(m_InventoryService); | ||
65 | IRequestHandler reqHandler | ||
66 | = new RestStreamHandler( | ||
67 | "POST", "/CAPS/FetchInventory/", fiHandler.FetchInventoryRequest, "FetchInventory", null); | ||
68 | server.AddStreamHandler(reqHandler); | ||
69 | } | ||
70 | } | ||
71 | } | ||