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.
---
.../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 ++++++++++++++++++++
6 files changed, 176 insertions(+), 7 deletions(-)
(limited to 'OpenSim/Services')
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