From 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb Mon Sep 17 00:00:00 2001
From: onefang
Date: Sun, 19 May 2019 21:24:15 +1000
Subject: Dump OpenSim 0.9.0.1 into it's own branch.
---
.../Handlers/FetchInventory/FetchInvDescHandler.cs | 46 +++++++-------
.../FetchInventory/FetchInventory2Handler.cs | 33 +++++-----
.../FetchInventory2ServerConnector.cs | 71 ++++++++++++++++++++++
.../Tests/FetchInventory2HandlerTests.cs | 2 +-
.../FetchInventoryDescendents2HandlerTests.cs | 7 ++-
5 files changed, 116 insertions(+), 43 deletions(-)
create mode 100644 OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2ServerConnector.cs
(limited to 'OpenSim/Capabilities/Handlers/FetchInventory')
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs
index 7197049..53ed115 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInvDescHandler.cs
@@ -43,7 +43,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
namespace OpenSim.Capabilities.Handlers
{
- public class FetchInvDescHandler
+ public class FetchInvDescHandler
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -53,14 +53,14 @@ namespace OpenSim.Capabilities.Handlers
private IScene m_Scene;
// private object m_fetchLock = new Object();
- public FetchInvDescHandler(IInventoryService invService, ILibraryService libService, IScene s)
+ public FetchInvDescHandler(IInventoryService invService, ILibraryService libService, IScene s)
{
m_InventoryService = invService;
m_LibraryService = libService;
m_Scene = s;
}
-
+
public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
{
//m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request);
@@ -72,14 +72,14 @@ namespace OpenSim.Capabilities.Handlers
// correctly mark it as a uuid
//
request = request.Replace("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000");
-
+
// another hack 1 results in a
// System.ArgumentException: Object type System.Int32 cannot
// be converted to target type: System.Boolean
//
request = request.Replace("fetch_folders0", "fetch_folders0");
request = request.Replace("fetch_folders1", "fetch_folders1");
-
+
Hashtable hash = new Hashtable();
try
{
@@ -90,9 +90,9 @@ namespace OpenSim.Capabilities.Handlers
m_log.ErrorFormat("[WEB FETCH INV DESC HANDLER]: Fetch error: {0}{1}" + e.Message, e.StackTrace);
m_log.Error("Request: " + request);
}
-
+
ArrayList foldersrequested = (ArrayList)hash["folders"];
-
+
string response = "";
string bad_folders_response = "";
@@ -403,10 +403,7 @@ namespace OpenSim.Capabilities.Handlers
return contents;
}
contents = fetchedContents;
- InventoryFolderBase containingFolder = new InventoryFolderBase();
- containingFolder.ID = folderID;
- containingFolder.Owner = agentID;
- containingFolder = m_InventoryService.GetFolder(containingFolder);
+ InventoryFolderBase containingFolder = m_InventoryService.GetFolder(agentID, folderID);
if (containingFolder != null)
{
@@ -416,7 +413,7 @@ namespace OpenSim.Capabilities.Handlers
version = containingFolder.Version;
- if (fetchItems)
+ if (fetchItems && containingFolder.Type != (short)FolderType.Trash)
{
List itemsToReturn = contents.Items;
List originalItems = new List(itemsToReturn);
@@ -429,7 +426,7 @@ namespace OpenSim.Capabilities.Handlers
{
if (item.AssetType == (int)AssetType.Link)
{
- InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID));
+ InventoryItemBase linkedItem = m_InventoryService.GetItem(agentID, item.AssetID);
// Take care of genuinely broken links where the target doesn't exist
// HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
@@ -441,6 +438,10 @@ namespace OpenSim.Capabilities.Handlers
}
// Now scan for folder links and insert the items they target and those links at the head of the return data
+
+/* dont send contents of LinkFolders.
+from docs seems this was never a spec
+
foreach (InventoryItemBase item in originalItems)
{
if (item.AssetType == (int)AssetType.LinkFolder)
@@ -471,6 +472,7 @@ namespace OpenSim.Capabilities.Handlers
}
}
}
+*/
}
// foreach (InventoryItemBase item in contents.Items)
@@ -514,7 +516,7 @@ namespace OpenSim.Capabilities.Handlers
// }
// }
// }
-//
+//
// foreach (UUID linkedItemFolderId in linkedItemFolderIdsToSend)
// {
// m_log.DebugFormat(
@@ -654,10 +656,7 @@ namespace OpenSim.Capabilities.Handlers
// Must fetch it individually
else if (contents.FolderID == UUID.Zero)
{
- InventoryFolderBase containingFolder = new InventoryFolderBase();
- containingFolder.ID = freq.folder_id;
- containingFolder.Owner = freq.owner_id;
- containingFolder = m_InventoryService.GetFolder(containingFolder);
+ InventoryFolderBase containingFolder = m_InventoryService.GetFolder(freq.owner_id, freq.folder_id);
if (containingFolder != null)
{
@@ -723,8 +722,8 @@ namespace OpenSim.Capabilities.Handlers
if (item.AssetType == (int)AssetType.Link)
itemIDs.Add(item.AssetID);
- else if (item.AssetType == (int)AssetType.LinkFolder)
- folderIDs.Add(item.AssetID);
+// else if (item.AssetType == (int)AssetType.LinkFolder)
+// folderIDs.Add(item.AssetID);
}
//m_log.DebugFormat("[XXX]: folder {0} has {1} links and {2} linkfolders", contents.FolderID, itemIDs.Count, folderIDs.Count);
@@ -754,12 +753,9 @@ namespace OpenSim.Capabilities.Handlers
m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: GetMultipleItems failed. Falling back to fetching inventory items one by one.");
linked = new InventoryItemBase[itemIDs.Count];
int i = 0;
- InventoryItemBase item = new InventoryItemBase();
- item.Owner = freq.owner_id;
foreach (UUID id in itemIDs)
{
- item.ID = id;
- linked[i++] = m_InventoryService.GetItem(item);
+ linked[i++] = m_InventoryService.GetItem(freq.owner_id, id);
}
}
@@ -845,4 +841,4 @@ namespace OpenSim.Capabilities.Handlers
public InventoryCollection Collection;
public int Descendents;
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
index c904392..e239a90 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
@@ -64,27 +64,33 @@ namespace OpenSim.Capabilities.Handlers
UUID[] itemIDs = new UUID[itemsRequested.Count];
int i = 0;
+
foreach (OSDMap osdItemId in itemsRequested)
{
itemIDs[i++] = osdItemId["item_id"].AsUUID();
}
- InventoryItemBase[] items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);
+ InventoryItemBase[] items = null;
- if (items == null)
+ if (m_agentID != UUID.Zero)
{
- // 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];
- i = 0;
- InventoryItemBase item = new InventoryItemBase();
- item.Owner = m_agentID;
- foreach (UUID id in itemIDs)
+ items = m_inventoryService.GetMultipleItems(m_agentID, itemIDs);
+
+ if (items == null)
{
- item.ID = id;
- items[i++] = m_inventoryService.GetItem(item);
+ // 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)
{
@@ -93,7 +99,6 @@ namespace OpenSim.Capabilities.Handlers
// 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));
}
}
@@ -114,7 +119,7 @@ namespace OpenSim.Capabilities.Handlers
llsdItem.asset_id = invItem.AssetID;
llsdItem.created_at = invItem.CreationDate;
llsdItem.desc = invItem.Description;
- llsdItem.flags = (int)invItem.Flags;
+ llsdItem.flags = ((int)invItem.Flags) & 0xff;
llsdItem.item_id = invItem.ID;
llsdItem.name = invItem.Name;
llsdItem.parent_id = invItem.Folder;
@@ -138,4 +143,4 @@ namespace OpenSim.Capabilities.Handlers
return llsdItem;
}
}
-}
\ No newline at end of file
+}
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2ServerConnector.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2ServerConnector.cs
new file mode 100644
index 0000000..618f075
--- /dev/null
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2ServerConnector.cs
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using Nini.Config;
+using OpenSim.Server.Base;
+using OpenSim.Services.Interfaces;
+using OpenSim.Framework.Servers.HttpServer;
+using OpenSim.Server.Handlers.Base;
+using OpenMetaverse;
+
+namespace OpenSim.Capabilities.Handlers
+{
+ public class FetchInventory2ServerConnector : ServiceConnector
+ {
+ private IInventoryService m_InventoryService;
+ private string m_ConfigName = "CapsService";
+
+ public FetchInventory2ServerConnector(IConfigSource config, IHttpServer server, string configName)
+ : base(config, server, configName)
+ {
+ if (configName != String.Empty)
+ m_ConfigName = configName;
+
+ IConfig serverConfig = config.Configs[m_ConfigName];
+ if (serverConfig == null)
+ throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
+
+ string invService = serverConfig.GetString("InventoryService", String.Empty);
+
+ if (invService == String.Empty)
+ throw new Exception("No InventoryService in config file");
+
+ Object[] args = new Object[] { config };
+ m_InventoryService = ServerUtils.LoadPlugin(invService, args);
+
+ if (m_InventoryService == null)
+ throw new Exception(String.Format("Failed to load InventoryService from {0}; config is {1}", invService, m_ConfigName));
+
+ FetchInventory2Handler fiHandler = new FetchInventory2Handler(m_InventoryService, UUID.Zero);
+ IRequestHandler reqHandler
+ = new RestStreamHandler(
+ "POST", "/CAPS/FetchInventory/", fiHandler.FetchInventoryRequest, "FetchInventory", null);
+ server.AddStreamHandler(reqHandler);
+ }
+ }
+}
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventory2HandlerTests.cs b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventory2HandlerTests.cs
index 8af3c64..94c2c89 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventory2HandlerTests.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventory2HandlerTests.cs
@@ -120,7 +120,7 @@ namespace OpenSim.Capabilities.Handlers.FetchInventory.Tests
string request = "";
-
+
string llsdresponse = handler.FetchInventoryRequest(request, "/FETCH", string.Empty, req, resp);
Assert.That(llsdresponse != null, Is.True, "Incorrect null response");
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs
index 2d5531a..4143aa3 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/Tests/FetchInventoryDescendents2HandlerTests.cs
@@ -140,7 +140,7 @@ namespace OpenSim.Capabilities.Handlers.FetchInventory.Tests
string request = "foldersfetch_folders1fetch_items1folder_id";
request += m_rootFolderID;
request += "owner_id00000000-0000-0000-0000-000000000000sort_order1";
-
+
string llsdresponse = handler.FetchInventoryDescendentsRequest(request, "/FETCH", string.Empty, req, resp);
Assert.That(llsdresponse != null, Is.True, "Incorrect null response");
@@ -203,7 +203,7 @@ namespace OpenSim.Capabilities.Handlers.FetchInventory.Tests
// Make sure that the note card link is included
Assert.That(llsdresponse.Contains("Link to notecard"), Is.True, "Link to notecard is missing");
-
+
//Make sure the notecard item itself is included
Assert.That(llsdresponse.Contains("Test Notecard 2"), Is.True, "Notecard 2 item (the source) is missing");
@@ -215,10 +215,11 @@ namespace OpenSim.Capabilities.Handlers.FetchInventory.Tests
// Make sure the folder link is included
Assert.That(llsdresponse.Contains("Link to Objects folder"), Is.True, "Link to Objects folder is missing");
+/* contents of link folder are not supposed to be listed
// Make sure the objects inside the Objects folder are included
// Note: I'm not entirely sure this is needed, but that's what I found in the implementation
Assert.That(llsdresponse.Contains("Some Object"), Is.True, "Some Object item (contents of the source) is missing");
-
+*/
// Make sure that the source item is before the link item
pos1 = llsdresponse.IndexOf("Some Object");
pos2 = llsdresponse.IndexOf("Link to Objects folder");
--
cgit v1.1