From cdcbc48534f19afe7cbdeb6c690e6b7d9f2ff099 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 10 Aug 2009 20:31:51 -0700 Subject: Added two new methods to IIventoryService -- GetFolderForType and GetFolderContent. Some meat to it, but not completed. None of this code is called anywhere yet. --- .../Communications/Tests/LoginServiceTests.cs | 10 +++++ .../Inventory/HGInventoryBroker.cs | 26 +++++++++++++ .../Inventory/LocalInventoryServiceConnector.cs | 11 ++++++ .../Inventory/RemoteInventoryServiceConnector.cs | 38 +++++++++++++++++++ .../Inventory/HGInventoryServiceConnector.cs | 42 +++++++++++++++++++++ .../Inventory/ISessionAuthInventoryService.cs | 17 +++++++++ .../Inventory/InventoryServiceConnector.cs | 44 ++++++++++++++++++++++ .../QuickAndDirtyInventoryServiceConnector.cs | 10 +++++ OpenSim/Services/Interfaces/IInventoryService.cs | 30 +++++++++++---- .../Services/InventoryService/InventoryService.cs | 40 ++++++++++++++++++++ 10 files changed, 261 insertions(+), 7 deletions(-) diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs index 373d7cf..17a3393 100644 --- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs @@ -497,6 +497,16 @@ namespace OpenSim.Framework.Communications.Tests { } + public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) + { + return null; + } + + public InventoryCollection GetFolderContent(UUID userID, UUID folderID) + { + return null; + } + public List GetFolderItems(UUID userID, UUID folderID) { return null; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index b3c5396..f5e6824 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs @@ -201,6 +201,32 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } } + public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) + { + if (IsLocalGridUser(userID)) + return m_GridService.GetFolderForType(userID, type); + else + { + UUID sessionID = GetSessionID(userID); + string uri = GetUserInventoryURI(userID) + "/" + userID.ToString(); + // !!!!!! + return null; + //return m_HGService.GetFolderForType(uri, sessionID, type); + } + } + + public InventoryCollection GetFolderContent(UUID userID, UUID folderID) + { + if (IsLocalGridUser(userID)) + return m_GridService.GetFolderContent(userID, folderID); + else + { + UUID sessionID = GetSessionID(userID); + string uri = GetUserInventoryURI(userID) + "/" + userID.ToString(); + return m_HGService.GetFolderContent(uri, folderID, sessionID); + } + } + public List GetFolderItems(UUID userID, UUID folderID) { return new List(); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index cb20f35..bab0044 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -176,6 +176,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory m_InventoryService.GetUserInventory(userID, callback); } + public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) + { + return m_InventoryService.GetFolderForType(userID, type); + } + + public InventoryCollection GetFolderContent(UUID userID, UUID folderID) + { + return m_InventoryService.GetFolderContent(userID, folderID); + } + + public List GetFolderItems(UUID userID, UUID folderID) { return m_InventoryService.GetFolderItems(userID, folderID); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs index b544138..2064558 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs @@ -168,6 +168,44 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory } + public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) + { + //UUID sessionID = GetSessionID(userID); + //List sysFolders; + //try + //{ + // sysFolders = m_RemoteConnector.GetSystemFolders(userID.ToString(), sessionID); + //} + //catch (Exception e) + //{ + // m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}", + // e.Source, e.Message); + //} + + // PLACEHOLDER UNTIL CACHE IS DONE + return null; + + } + + public InventoryCollection GetFolderContent(UUID userID, UUID folderID) + { + UUID sessionID = GetSessionID(userID); + try + { + return m_RemoteConnector.GetFolderContent(userID.ToString(), folderID, sessionID); + } + catch (Exception e) + { + m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1}", + e.Source, e.Message); + } + InventoryCollection nullCollection = new InventoryCollection(); + nullCollection.Folders = new List(); + nullCollection.Items = new List(); + nullCollection.UserID = userID; + return nullCollection; + } + public List GetFolderItems(UUID userID, UUID folderID) { return new List(); diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs index 01e517c..b168871 100644 --- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs @@ -120,6 +120,48 @@ namespace OpenSim.Services.Connectors.Inventory } + /// + /// Gets the user folder for the given folder-type + /// + /// + /// + /// + public List GetSystemFolders(string id, UUID sessionID) + { + m_log.Debug("[HGInventory]: GetSystemFolders " + id); + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.GetSystemFolders(userID, sessionID); + } + + return new List(); + } + + /// + /// Gets everything (folders and items) inside a folder + /// + /// + /// + /// + public InventoryCollection GetFolderContent(string id, UUID folderID, UUID sessionID) + { + m_log.Debug("[HGInventory]: GetSystemFolders " + id); + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.GetFolderContent(userID, folderID, sessionID); + } + + return null; + } + public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID) { string url = string.Empty; diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs index 4fc4363..98fd680 100644 --- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs +++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; using OpenSim.Framework; using OpenSim.Services.Interfaces; using OpenMetaverse; @@ -51,6 +52,22 @@ namespace OpenSim.Services.Connectors void GetUserInventory(string userID, UUID session_id, InventoryReceiptCallback callback); /// + /// Gets the user folder for the given folder-type + /// + /// + /// + /// + List GetSystemFolders(string userID, UUID session_id); + + /// + /// Gets everything (folders and items) inside a folder + /// + /// + /// + /// + InventoryCollection GetFolderContent(string userID, UUID folderID, UUID session_id); + + /// /// Add a new folder to the user's inventory /// /// diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index ae15cfb..1a6826e 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -155,6 +155,50 @@ namespace OpenSim.Services.Connectors } } + /// + /// Gets the user folder for the given folder-type + /// + /// + /// + /// + public List GetSystemFolders(string userID, UUID sessionID) + { + try + { + return SynchronousRestSessionObjectPoster>.BeginPostObject( + "GET", m_ServerURI + "/SystemFolders/", userID, sessionID.ToString(), userID.ToString()); + } + catch (Exception e) + { + m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}", + e.Source, e.Message); + } + + return new List(); + } + + /// + /// Gets everything (folders and items) inside a folder + /// + /// + /// + /// + public InventoryCollection GetFolderContent(string userID, UUID folderID, UUID sessionID) + { + try + { + return SynchronousRestSessionObjectPoster.BeginPostObject( + "GET", m_ServerURI + "/GetFolderContents/", folderID, sessionID.ToString(), userID.ToString()); + } + catch (Exception e) + { + m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}", + e.Source, e.Message); + } + + return null; + } + public bool AddFolder(string userID, InventoryFolderBase folder, UUID sessionID) { try diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs index a804973..22289aa 100644 --- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs @@ -106,6 +106,16 @@ namespace OpenSim.Services.Connectors { } + public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) + { + return null; + } + + public InventoryCollection GetFolderContent(UUID userID, UUID folderID) + { + return null; + } + public List GetFolderItems(UUID userID, UUID folderID) { return null; diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs index 733cfd0..8058aa7 100644 --- a/OpenSim/Services/Interfaces/IInventoryService.cs +++ b/OpenSim/Services/Interfaces/IInventoryService.cs @@ -70,6 +70,29 @@ namespace OpenSim.Services.Interfaces void GetUserInventory(UUID userID, InventoryReceiptCallback callback); /// + /// Retrieve the root inventory folder for the given user. + /// + /// + /// null if no root folder was found + InventoryFolderBase GetRootFolder(UUID userID); + + /// + /// Gets the user folder for the given folder-type + /// + /// + /// + /// + InventoryFolderBase GetFolderForType(UUID userID, AssetType type); + + /// + /// Gets everything (folders and items) inside a folder + /// + /// + /// + /// + InventoryCollection GetFolderContent(UUID userID, UUID folderID); + + /// /// Gets the items inside a folder /// /// @@ -138,13 +161,6 @@ namespace OpenSim.Services.Interfaces bool HasInventoryForUser(UUID userID); /// - /// Retrieve the root inventory folder for the given user. - /// - /// - /// null if no root folder was found - InventoryFolderBase GetRootFolder(UUID userID); - - /// /// Get the active gestures of the agent. /// /// diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index 2b8ee0f..dd435c9 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs @@ -233,6 +233,46 @@ namespace OpenSim.Services.InventoryService callback.BeginInvoke(folders, items, null, null); } + public InventoryCollection GetFolderContent(UUID userID, UUID folderID) + { + m_log.Info("[INVENTORY SERVICE]: Processing request for folder " + folderID); + + // Uncomment me to simulate a slow responding inventory server + //Thread.Sleep(16000); + + InventoryCollection invCollection = new InventoryCollection(); + + List items = GetFolderItems(userID, folderID); + List folders = RequestSubFolders(folderID); + + invCollection.UserID = userID; + invCollection.Folders = folders; + invCollection.Items = items; + + m_log.DebugFormat("[INVENTORY SERVICE]: Found {0} items and {1} folders", items.Count, folders.Count); + + return invCollection; + } + + public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) + { + InventoryFolderBase root = m_Database.getUserRootFolder(userID); + if (root != null) + { + List folders = RequestSubFolders(root.ID); + + foreach (InventoryFolderBase folder in folders) + { + if (folder.Type == (short)type) + return folder; + } + } + + // we didn't find any folder of that type. Return the root folder + // hopefully the root folder is not null. If it is, too bad + return root; + } + public List GetActiveGestures(UUID userId) { List activeGestures = new List(); -- cgit v1.1