* Refactor: Renaming item and folder tree search methods to have Find*() prefixes
parent
87b3137928
commit
688940e810
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -104,14 +104,12 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
}
|
||||
|
||||
/// <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>
|
||||
/// <param name="itemID"></param>
|
||||
/// <returns></returns>
|
||||
public InventoryItemBase HasItem(LLUUID itemID)
|
||||
/// <returns>null if the item is not found</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -171,7 +170,7 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
/// Returns the folder requested if it exists as a descendent of this folder
|
||||
/// </summary>
|
||||
/// <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;
|
||||
|
||||
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns SceneObjectGroup or null from asset request.
|
||||
/// </summary>
|
||||
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue