* Refactor: Renaming item and folder tree search methods to have Find*() prefixes

0.6.0-stable
Justin Clarke Casey 2008-05-03 22:39:33 +00:00
parent 87b3137928
commit 688940e810
6 changed files with 52 additions and 44 deletions

View File

@ -35,6 +35,7 @@ using log4net;
namespace OpenSim.Framework.Communications.Cache namespace OpenSim.Framework.Communications.Cache
{ {
//internal delegate void DeleteItemDelegate(
internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID); internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID);
internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID); internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID);
internal delegate void PurgeFolderDelegate(LLUUID folderID); internal delegate void PurgeFolderDelegate(LLUUID folderID);
@ -234,7 +235,7 @@ namespace OpenSim.Framework.Communications.Cache
} }
else else
{ {
InventoryFolderImpl folder = RootFolder.GetDescendentFolder(folderInfo.ParentID); InventoryFolderImpl folder = RootFolder.FindFolder(folderInfo.ParentID);
lock (folder.SubFolders) lock (folder.SubFolders)
{ {
if (folder != null) if (folder != null)
@ -275,7 +276,6 @@ namespace OpenSim.Framework.Communications.Cache
{ {
if (!RootFolder.Items.ContainsKey(itemInfo.ID)) if (!RootFolder.Items.ContainsKey(itemInfo.ID))
{ {
RootFolder.Items.Add(itemInfo.ID, itemInfo); RootFolder.Items.Add(itemInfo.ID, itemInfo);
} }
else else
@ -286,7 +286,7 @@ namespace OpenSim.Framework.Communications.Cache
} }
else else
{ {
InventoryFolderImpl folder = RootFolder.GetDescendentFolder(itemInfo.Folder); InventoryFolderImpl folder = RootFolder.FindFolder(itemInfo.Folder);
if (folder != null) if (folder != null)
{ {
lock (folder.Items) lock (folder.Items)
@ -346,7 +346,7 @@ namespace OpenSim.Framework.Communications.Cache
} }
else else
{ {
InventoryFolderImpl folder = RootFolder.GetDescendentFolder(parentID); InventoryFolderImpl folder = RootFolder.FindFolder(parentID);
if (folder != null) if (folder != null)
{ {
@ -479,7 +479,7 @@ namespace OpenSim.Framework.Communications.Cache
if (HasInventory) if (HasInventory)
{ {
InventoryFolderImpl purgedFolder = RootFolder.GetDescendentFolder(folderID); InventoryFolderImpl purgedFolder = RootFolder.FindFolder(folderID);
if (purgedFolder != null) if (purgedFolder != null)
{ {

View File

@ -104,14 +104,12 @@ namespace OpenSim.Framework.Communications.Cache
} }
/// <summary> /// <summary>
/// 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?
/// </summary> /// </summary>
/// <param name="itemID"></param> /// <param name="itemID"></param>
/// <returns></returns> /// <returns>null if the item is not found</returns>
public InventoryItemBase HasItem(LLUUID itemID) public InventoryItemBase FindItem(LLUUID itemID)
{ {
InventoryItemBase base2 = null;
lock (Items) lock (Items)
{ {
if (Items.ContainsKey(itemID)) if (Items.ContainsKey(itemID))
@ -124,15 +122,16 @@ namespace OpenSim.Framework.Communications.Cache
{ {
foreach (InventoryFolderImpl folder in SubFolders.Values) foreach (InventoryFolderImpl folder in SubFolders.Values)
{ {
base2 = folder.HasItem(itemID); InventoryItemBase item = folder.FindItem(itemID);
if (base2 != null)
if (item != null)
{ {
break; return item;
} }
} }
} }
return base2; return null;
} }
/// <summary> /// <summary>
@ -171,7 +170,7 @@ namespace OpenSim.Framework.Communications.Cache
/// Returns the folder requested if it exists as a descendent of this folder /// Returns the folder requested if it exists as a descendent of this folder
/// </summary> /// </summary>
/// <returns>The requested folder if it exists, null if it does not.</returns> /// <returns>The requested folder if it exists, null if it does not.</returns>
public InventoryFolderImpl GetDescendentFolder(LLUUID folderID) public InventoryFolderImpl FindFolder(LLUUID folderID)
{ {
InventoryFolderImpl returnFolder = null; InventoryFolderImpl returnFolder = null;
@ -185,7 +184,7 @@ namespace OpenSim.Framework.Communications.Cache
{ {
foreach (InventoryFolderImpl folder in SubFolders.Values) foreach (InventoryFolderImpl folder in SubFolders.Values)
{ {
returnFolder = folder.GetDescendentFolder(folderID); returnFolder = folder.FindFolder(folderID);
if (returnFolder != null) if (returnFolder != null)
{ {
break; break;

View File

@ -259,7 +259,7 @@ namespace OpenSim.Framework.Communications.Cache
return; return;
} }
if ((fold = libraryRoot.GetDescendentFolder(folderID)) != null) if ((fold = libraryRoot.FindFolder(folderID)) != null)
{ {
remoteClient.SendInventoryFolderDetails( remoteClient.SendInventoryFolderDetails(
libraryRoot.Owner, folderID, fold.RequestListOfItems(), libraryRoot.Owner, folderID, fold.RequestListOfItems(),
@ -308,7 +308,7 @@ namespace OpenSim.Framework.Communications.Cache
} }
else else
{ {
if ((fold = userProfile.RootFolder.GetDescendentFolder(folderID)) != null) if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null)
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[AGENT INVENTORY]: Found folder {0} for client {1}", // "[AGENT INVENTORY]: Found folder {0} for client {1}",
@ -369,7 +369,7 @@ namespace OpenSim.Framework.Communications.Cache
return libraryRoot.RequestListOfItems(); return libraryRoot.RequestListOfItems();
} }
if ((fold = libraryRoot.GetDescendentFolder(folderID)) != null) if ((fold = libraryRoot.FindFolder(folderID)) != null)
{ {
return fold.RequestListOfItems(); return fold.RequestListOfItems();
} }
@ -410,7 +410,7 @@ namespace OpenSim.Framework.Communications.Cache
} }
else else
{ {
if ((fold = userProfile.RootFolder.GetDescendentFolder(folderID)) != null) if ((fold = userProfile.RootFolder.FindFolder(folderID)) != null)
{ {
return fold.RequestListOfItems(); return fold.RequestListOfItems();
} }
@ -479,7 +479,7 @@ namespace OpenSim.Framework.Communications.Cache
{ {
if (userProfile.HasInventory) if (userProfile.HasInventory)
{ {
InventoryItemBase item = userProfile.RootFolder.HasItem(itemID); InventoryItemBase item = userProfile.RootFolder.FindItem(itemID);
if (item != null) if (item != null)
{ {
remoteClient.SendInventoryItemDetails(ownerID, item); remoteClient.SendInventoryItemDetails(ownerID, item);

View File

@ -293,7 +293,7 @@ namespace OpenSim.Region.Environment.Modules
{ {
LLUUID assetId; LLUUID assetId;
InventoryItemBase baseItem = profile.RootFolder.HasItem(wear.ItemID); InventoryItemBase baseItem = profile.RootFolder.FindItem(wear.ItemID);
if (baseItem != null) if (baseItem != null)
{ {
assetId = baseItem.assetID; assetId = baseItem.assetID;

View File

@ -127,7 +127,8 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (userInfo.RootFolder != null) if (userInfo.RootFolder != null)
{ {
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
if (item != null) if (item != null)
{ {
AssetBase asset = AssetBase asset =
@ -271,7 +272,7 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo != null && userInfo.RootFolder != null) if (userInfo != null && userInfo.RootFolder != null)
{ {
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
if (item != null) if (item != null)
{ {
@ -340,7 +341,8 @@ namespace OpenSim.Region.Environment.Scenes
if (senderUserInfo.RootFolder != null) if (senderUserInfo.RootFolder != null)
{ {
InventoryItemBase item = senderUserInfo.RootFolder.HasItem(itemId); InventoryItemBase item = senderUserInfo.RootFolder.FindItem(itemId);
if (item != null) if (item != null)
{ {
// TODO get recipient's root folder // 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}", "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(oldItemID); InventoryItemBase item = CommsManager.UserProfileCacheService.libraryRoot.FindItem(oldItemID);
if (item == null) if (item == null)
{ {
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID); CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(oldAgentID);
@ -419,7 +422,8 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo.RootFolder != null) if (userInfo.RootFolder != null)
{ {
item = userInfo.RootFolder.HasItem(oldItemID); item = userInfo.RootFolder.FindItem(oldItemID);
if (item == null) if (item == null)
{ {
m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString()); m_log.Error("[AGENT INVENTORY]: Failed to find item " + oldItemID.ToString());
@ -478,7 +482,8 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo.RootFolder != null) if (userInfo.RootFolder != null)
{ {
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
if (item != null) if (item != null)
{ {
if (newName != String.Empty) if (newName != String.Empty)
@ -615,9 +620,13 @@ namespace OpenSim.Region.Environment.Scenes
{ {
CachedUserInfo userInfo CachedUserInfo userInfo
= CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo == null) 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; return;
} }
@ -627,7 +636,8 @@ namespace OpenSim.Region.Environment.Scenes
// the trash folder directly instead of RootFolder? // the trash folder directly instead of RootFolder?
if (userInfo.RootFolder != null) if (userInfo.RootFolder != null)
{ {
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
if (item != null) if (item != null)
{ {
userInfo.DeleteItem(item); userInfo.DeleteItem(item);
@ -654,7 +664,7 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo.RootFolder != null) if (userInfo.RootFolder != null)
{ {
InventoryItemBase folder = userInfo.RootFolder.HasItem(folderID); InventoryItemBase folder = userInfo.RootFolder.FindItem(folderID);
if (folder != null) if (folder != null)
{ {
@ -833,13 +843,13 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo != null && userInfo.RootFolder != null) if (userInfo != null && userInfo.RootFolder != null)
{ {
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
// Try library // Try library
// XXX clumsy, possibly should be one call // XXX clumsy, possibly should be one call
if (null == item) if (null == item)
{ {
item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(itemID); item = CommsManager.UserProfileCacheService.libraryRoot.FindItem(itemID);
} }
if (item != null) if (item != null)
@ -884,13 +894,13 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo != null && userInfo.RootFolder != null) if (userInfo != null && userInfo.RootFolder != null)
{ {
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
// Try library // Try library
// XXX clumsy, possibly should be one call // XXX clumsy, possibly should be one call
if (null == item) if (null == item)
{ {
item = CommsManager.UserProfileCacheService.libraryRoot.HasItem(itemID); item = CommsManager.UserProfileCacheService.libraryRoot.FindItem(itemID);
} }
if (item != null) if (item != null)
@ -1203,14 +1213,11 @@ namespace OpenSim.Region.Environment.Scenes
uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags, uint EveryoneMask, uint GroupMask, uint NextOwnerMask, uint ItemFlags,
bool RezSelected, bool RemoveItem, LLUUID fromTaskID) bool RezSelected, bool RemoveItem, LLUUID fromTaskID)
{ {
SceneObjectGroup sog = RezObject(remoteClient, itemID, RayEnd, RayStart, RezObject(
RayTargetID, BypassRayCast, RayEndIsIntersection, remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
EveryoneMask, GroupMask, NextOwnerMask, ItemFlags, EveryoneMask, GroupMask, NextOwnerMask, ItemFlags, RezSelected, RemoveItem, fromTaskID, false);
RezSelected, RemoveItem, fromTaskID, false);
} }
/// <summary> /// <summary>
/// Returns SceneObjectGroup or null from asset request. /// Returns SceneObjectGroup or null from asset request.
/// </summary> /// </summary>
@ -1265,7 +1272,8 @@ namespace OpenSim.Region.Environment.Scenes
{ {
if (userInfo.RootFolder != null) if (userInfo.RootFolder != null)
{ {
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID); InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
if (item != null) if (item != null)
{ {
AssetBase rezAsset = AssetCache.GetAsset(item.AssetID, false); AssetBase rezAsset = AssetCache.GetAsset(item.AssetID, false);

View File

@ -300,7 +300,8 @@ namespace OpenSim.Region.Modules.AvatarFactory
{ {
LLUUID assetId; LLUUID assetId;
InventoryItemBase baseItem = profile.RootFolder.HasItem(wear.ItemID); InventoryItemBase baseItem = profile.RootFolder.FindItem(wear.ItemID);
if (baseItem != null) if (baseItem != null)
{ {
assetId = baseItem.AssetID; assetId = baseItem.AssetID;