From 688940e8103f2b1f55bb48ebe2566d32f872b8f5 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Sat, 3 May 2008 22:39:33 +0000
Subject: * Refactor: Renaming item and folder tree search methods to have
Find*() prefixes
---
.../Communications/Cache/CachedUserInfo.cs | 12 +++---
.../Communications/Cache/InventoryFolderImpl.cs | 21 +++++-----
.../Cache/UserProfileCacheService.cs | 10 ++---
.../Avatar/AvatarFactory/AvatarFactoryModule.cs | 2 +-
.../Region/Environment/Scenes/Scene.Inventory.cs | 48 +++++++++++++---------
.../Modules/AvatarFactory/AvatarFactoryModule.cs | 3 +-
6 files changed, 52 insertions(+), 44 deletions(-)
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index ceca1a4..6a7b6b7 100644
--- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
+++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
@@ -35,7 +35,8 @@ using log4net;
namespace OpenSim.Framework.Communications.Cache
{
- internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID);
+ //internal delegate void DeleteItemDelegate(
+ internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID);
internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID);
internal delegate void PurgeFolderDelegate(LLUUID folderID);
internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID);
@@ -234,7 +235,7 @@ namespace OpenSim.Framework.Communications.Cache
}
else
{
- InventoryFolderImpl folder = RootFolder.GetDescendentFolder(folderInfo.ParentID);
+ InventoryFolderImpl folder = RootFolder.FindFolder(folderInfo.ParentID);
lock (folder.SubFolders)
{
if (folder != null)
@@ -275,7 +276,6 @@ namespace OpenSim.Framework.Communications.Cache
{
if (!RootFolder.Items.ContainsKey(itemInfo.ID))
{
-
RootFolder.Items.Add(itemInfo.ID, itemInfo);
}
else
@@ -286,7 +286,7 @@ namespace OpenSim.Framework.Communications.Cache
}
else
{
- InventoryFolderImpl folder = RootFolder.GetDescendentFolder(itemInfo.Folder);
+ InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder);
if (folder != null)
{
lock (folder.Items)
@@ -346,7 +346,7 @@ namespace OpenSim.Framework.Communications.Cache
}
else
{
- InventoryFolderImpl folder = RootFolder.GetDescendentFolder(parentID);
+ InventoryFolderImpl folder = RootFolder.FindFolder(parentID);
if (folder != null)
{
@@ -479,7 +479,7 @@ namespace OpenSim.Framework.Communications.Cache
if (HasInventory)
{
- InventoryFolderImpl purgedFolder = RootFolder.GetDescendentFolder(folderID);
+ InventoryFolderImpl purgedFolder = RootFolder.FindFolder(folderID);
if (purgedFolder != null)
{
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index f6accf6..39296eb 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -104,14 +104,12 @@ namespace OpenSim.Framework.Communications.Cache
}
///
- /// Does this folder or any of its subfolders contain the given item?
+ /// Returns the item if it exists in this folder or any of this folder's subfolders?
///
///
- ///
- public InventoryItemBase HasItem(LLUUID itemID)
+ /// null if the item is not found
+ public InventoryItemBase FindItem(LLUUID itemID)
{
- InventoryItemBase base2 = null;
-
lock (Items)
{
if (Items.ContainsKey(itemID))
@@ -124,15 +122,16 @@ namespace OpenSim.Framework.Communications.Cache
{
foreach (InventoryFolderImpl folder in SubFolders.Values)
{
- base2 = folder.HasItem(itemID);
- if (base2 != null)
+ InventoryItemBase item = folder.FindItem(itemID);
+
+ if (item != null)
{
- break;
+ return item;
}
}
}
- return base2;
+ return null;
}
///
@@ -171,7 +170,7 @@ namespace OpenSim.Framework.Communications.Cache
/// Returns the folder requested if it exists as a descendent of this folder
///
/// The requested folder if it exists, null if it does not.
- public InventoryFolderImpl GetDescendentFolder(LLUUID folderID)
+ public InventoryFolderImpl FindFolder(LLUUID folderID)
{
InventoryFolderImpl returnFolder = null;
@@ -185,7 +184,7 @@ namespace OpenSim.Framework.Communications.Cache
{
foreach (InventoryFolderImpl folder in SubFolders.Values)
{
- returnFolder = folder.GetDescendentFolder(folderID);
+ returnFolder = folder.FindFolder(folderID);
if (returnFolder != null)
{
break;
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index 0404477..92b08e5 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -259,7 +259,7 @@ namespace OpenSim.Framework.Communications.Cache
return;
}
- if ((fold = libraryRoot.GetDescendentFolder(folderID)) != null)
+ if ((fold = libraryRoot.FindFolder(folderID)) != null)
{
remoteClient.SendInventoryFolderDetails(
libraryRoot.Owner, folderID, fold.RequestListOfItems(),
@@ -308,7 +308,7 @@ namespace OpenSim.Framework.Communications.Cache
}
else
{
- if ((fold = userProfile.RootFolder.GetDescendentFolder(folderID)) != null)
+ if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null)
{
// m_log.DebugFormat(
// "[AGENT INVENTORY]: Found folder {0} for client {1}",
@@ -369,7 +369,7 @@ namespace OpenSim.Framework.Communications.Cache
return libraryRoot.RequestListOfItems();
}
- if ((fold = libraryRoot.GetDescendentFolder(folderID)) != null)
+ if ((fold = libraryRoot.FindFolder(folderID)) != null)
{
return fold.RequestListOfItems();
}
@@ -410,7 +410,7 @@ namespace OpenSim.Framework.Communications.Cache
}
else
{
- if ((fold = userProfile.RootFolder.GetDescendentFolder(folderID)) != null)
+ if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null)
{
return fold.RequestListOfItems();
}
@@ -479,7 +479,7 @@ namespace OpenSim.Framework.Communications.Cache
{
if (userProfile.HasInventory)
{
- InventoryItemBase item = userProfile.RootFolder.HasItem(itemID);
+ InventoryItemBase item = userProfile.RootFolder.FindItem(itemID);
if (item != null)
{
remoteClient.SendInventoryItemDetails(ownerID, item);
diff --git a/OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index cb94021..5df3f52 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -293,7 +293,7 @@ namespace OpenSim.Region.Environment.Modules
{
LLUUID assetId;
- InventoryItemBase baseItem = profile.RootFolder.HasItem(wear.ItemID);
+ InventoryItemBase baseItem = profile.RootFolder.FindItem(wear.ItemID);
if (baseItem != null)
{
assetId = baseItem.assetID;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 0715b64..7cce216 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -127,7 +127,8 @@ namespace OpenSim.Region.Environment.Scenes
{
if (userInfo.RootFolder != null)
{
- InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
+ InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
+
if (item != null)
{
AssetBase asset =
@@ -271,7 +272,7 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo != null && userInfo.RootFolder != null)
{
- InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
+ InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
if (item != null)
{
@@ -340,7 +341,8 @@ namespace OpenSim.Region.Environment.Scenes
if (senderUserInfo.RootFolder != null)
{
- InventoryItemBase item = senderUserInfo.RootFolder.HasItem(itemId);
+ InventoryItemBase item = senderUserInfo.RootFolder.FindItem(itemId);
+
if (item != null)
{
// TODO get recipient's root folder
@@ -407,7 +409,8 @@ namespace OpenSim.Region.Environment.Scenes
"[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
- InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID);
+ InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.FindItem(oldItemID);
+
if (item == null)
{
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID);
@@ -419,7 +422,8 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo.RootFolder != null)
{
- item = userInfo.RootFolder.HasItem(oldItemID);
+ item = userInfo.RootFolder.FindItem(oldItemID);
+
if (item == null)
{
m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString());
@@ -478,7 +482,8 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo.RootFolder != null)
{
- InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
+ InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
+
if (item != null)
{
if (newName != String.Empty)
@@ -615,9 +620,13 @@ namespace OpenSim.Region.Environment.Scenes
{
CachedUserInfo userInfo
= CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
+
if (userInfo == null)
{
- m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
+ m_log.ErrorFormat(
+ "[AGENT INVENTORY]: Failed to find user {0} {1} to remove inventory item {2}",
+ remoteClient.Name, remoteClient.AgentId, itemID);
+
return;
}
@@ -627,7 +636,8 @@ namespace OpenSim.Region.Environment.Scenes
// the trash folder directly instead of RootFolder?
if (userInfo.RootFolder != null)
{
- InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
+ InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
+
if (item != null)
{
userInfo.DeleteItem(item);
@@ -654,7 +664,7 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo.RootFolder != null)
{
- InventoryItemBase folder = userInfo.RootFolder.HasItem(folderID);
+ InventoryItemBase folder = userInfo.RootFolder.FindItem(folderID);
if (folder != null)
{
@@ -833,13 +843,13 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo != null && userInfo.RootFolder != null)
{
- InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
+ InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
// Try library
// XXX clumsy, possibly should be one call
if (null == item)
{
- item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(itemID);
+ item = CommsManager.UserProfileCacheService.libraryRoot.FindItem(itemID);
}
if (item != null)
@@ -884,13 +894,13 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo != null && userInfo.RootFolder != null)
{
- InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
+ InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
// Try library
// XXX clumsy, possibly should be one call
if (null == item)
{
- item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(itemID);
+ item = CommsManager.UserProfileCacheService.libraryRoot.FindItem(itemID);
}
if (item != null)
@@ -1203,14 +1213,11 @@ namespace OpenSim.Region.Environment.Scenes
uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags,
bool RezSelected, bool RemoveItem, LLUUID fromTaskID)
{
- SceneObjectGroup sog = RezObject(remoteClient, itemID, RayEnd, RayStart,
- RayTargetID, BypassRayCast, RayEndIsIntersection,
- EveryoneMask, GroupMask, NextOwnerMask, ItemFlags,
- RezSelected, RemoveItem, fromTaskID, false);
+ RezObject(
+ remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
+ EveryoneMask, GroupMask, NextOwnerMask, ItemFlags, RezSelected, RemoveItem, fromTaskID, false);
}
-
-
///
/// Returns SceneObjectGroup or null from asset request.
///
@@ -1265,7 +1272,8 @@ namespace OpenSim.Region.Environment.Scenes
{
if (userInfo.RootFolder != null)
{
- InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
+ InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
+
if (item != null)
{
AssetBase rezAsset = AssetCache.GetAsset(item.AssetID, false);
diff --git a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
index 0ee8848..7b1211f 100644
--- a/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/Modules/AvatarFactory/AvatarFactoryModule.cs
@@ -300,7 +300,8 @@ namespace OpenSim.Region.Modules.AvatarFactory
{
LLUUID assetId;
- InventoryItemBase baseItem = profile.RootFolder.HasItem(wear.ItemID);
+ InventoryItemBase baseItem = profile.RootFolder.FindItem(wear.ItemID);
+
if (baseItem != null)
{
assetId = baseItem.AssetID;
--
cgit v1.1