From 5ad4c79a4e5e2d6c9ba26034e5b325007f0b6f7a Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Thu, 10 Apr 2008 16:04:19 +0000
Subject: * Refactor GetUsersInventory()
---
.../Framework/Communications/IInventoryServices.cs | 4 +--
.../Communications/InventoryServiceBase.cs | 2 +-
.../Grid/InventoryServer/GridInventoryService.cs | 42 +++++++++++++++++-----
3 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs
index 966ab75..ecc6c71 100644
--- a/OpenSim/Framework/Communications/IInventoryServices.cs
+++ b/OpenSim/Framework/Communications/IInventoryServices.cs
@@ -85,8 +85,8 @@ namespace OpenSim.Framework.Communications
/// Returns a list of all the folders in a given user's inventory.
///
///
- /// A flat list of the user's inventory folder tree.
- /// Null if there is no inventory for this user
+ /// A flat list of the user's inventory folder tree,
+ /// null if there is no inventory for this user
List GetInventorySkeleton(LLUUID userId);
}
}
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs
index f9a47b1..e50e19e 100644
--- a/OpenSim/Framework/Communications/InventoryServiceBase.cs
+++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs
@@ -141,7 +141,7 @@ namespace OpenSim.Framework.Communications
if (null != existingRootFolder)
{
- m_log.ErrorFormat(
+ m_log.WarnFormat(
"[AGENT INVENTORY]: Did not create a new inventory for user {0} since they already have "
+ "a root inventory folder with id {1}",
user, existingRootFolder.ID);
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
index ffff89f..e30c31e 100644
--- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs
+++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs
@@ -43,7 +43,14 @@ namespace OpenSim.Grid.InventoryServer
{
}
- private bool TryGetUsersInventory(LLUUID userID, out List folderList,
+ ///
+ /// Get a user's inventory.
+ ///
+ ///
+ ///
+ ///
+ /// true if the inventory was retrieved, false otherwise
+ private bool GetUsersInventory(LLUUID userID, out List folderList,
out List itemsList)
{
List allFolders = GetInventorySkeleton(userID);
@@ -93,22 +100,39 @@ namespace OpenSim.Grid.InventoryServer
/// Return a user's entire inventory
///
///
- ///
+ /// The user's inventory. If an inventory cannot be found then an empty collection is returned.
public InventoryCollection GetUserInventory(Guid rawUserID)
{
LLUUID userID = new LLUUID(rawUserID);
- m_log.Info("[AGENT INVENTORY]: Processing request for inventory of " + userID.ToString());
+ m_log.InfoFormat("[AGENT INVENTORY]: Processing request for inventory of {0}", userID);
InventoryCollection invCollection = new InventoryCollection();
- List folders;
- List allItems;
- if (TryGetUsersInventory(userID, out folders, out allItems))
+
+ List allFolders = GetInventorySkeleton(userID);
+
+ if (null == allFolders)
+ {
+ m_log.WarnFormat("[AGENT INVENTORY]: No inventory found for user {0}", rawUserID);
+
+ return invCollection;
+ }
+
+ List allItems = new List();
+
+ foreach (InventoryFolderBase folder in allFolders)
{
- invCollection.AllItems = allItems;
- invCollection.Folders = folders;
- invCollection.UserID = userID;
+ List items = RequestFolderItems(folder.ID);
+
+ if (items != null)
+ {
+ allItems.InsertRange(0, items);
+ }
}
+
+ invCollection.AllItems = allItems;
+ invCollection.Folders = allFolders;
+ invCollection.UserID = userID;
// foreach (InventoryFolderBase folder in folders)
// {
--
cgit v1.1