From 56827894e9fca8d15b84a1f897b24e88c8ab9c29 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Sat, 3 May 2008 23:23:46 +0000
Subject: * Refactor RemoveItem()
---
.../Communications/Cache/CachedUserInfo.cs | 61 ++++++++++++++++++----
.../Communications/Cache/InventoryFolderImpl.cs | 1 +
2 files changed, 51 insertions(+), 11 deletions(-)
(limited to 'OpenSim/Framework/Communications')
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs
index 6a7b6b7..84e42a3 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 DeleteItemDelegate(
+ internal delegate void DeleteItemDelegate(LLUUID itemID);
+
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);
@@ -306,7 +307,10 @@ namespace OpenSim.Framework.Communications.Cache
}
///
- /// Create a folder in this agent's inventory
+ /// Create a folder in this agent's inventory.
+ ///
+ /// If the inventory service has not yet delievered the inventory
+ /// for this user then the request will be queued.
///
///
///
@@ -399,10 +403,14 @@ namespace OpenSim.Framework.Communications.Cache
///
/// Handle a client request to update the inventory folder
///
+ /// If the inventory service has not yet delievered the inventory
+ /// for this user then the request will be queued.
+ ///
/// FIXME: We call add new inventory folder because in the data layer, we happen to use an SQL REPLACE
/// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing,
/// and needs to be changed.
///
+ ///
///
///
///
@@ -437,7 +445,11 @@ namespace OpenSim.Framework.Communications.Cache
///
/// Handle an inventory folder move request from the client.
+ ///
+ /// If the inventory service has not yet delievered the inventory
+ /// for this user then the request will be queued.
///
+ ///
///
///
public bool MoveFolder(LLUUID folderID, LLUUID parentID)
@@ -470,7 +482,11 @@ namespace OpenSim.Framework.Communications.Cache
///
/// This method will delete all the items and folders in the given folder.
+ ///
+ /// If the inventory service has not yet delievered the inventory
+ /// for this user then the request will be queued.
///
+ ///
///
public bool PurgeFolder(LLUUID folderID)
{
@@ -540,23 +556,46 @@ namespace OpenSim.Framework.Communications.Cache
///
/// Delete an item from the user's inventory
+ ///
+ /// If the inventory service has not yet delievered the inventory
+ /// for this user then the request will be queued.
///
- ///
- ///
- ///
- public bool DeleteItem(InventoryItemBase item)
+ ///
+ ///
+ /// true on a successful delete or a if the request is queued.
+ /// Returns false on an immediate failure
+ ///
+ public bool DeleteItem(LLUUID itemID)
{
- bool result = false;
if (HasInventory)
{
- result = RootFolder.DeleteItem(item.ID);
- if (result)
+ // XXX For historical reasons (grid comms), we need to retrieve the whole item in order to delete, even though
+ // really only the item id is required.
+ InventoryItemBase item = RootFolder.FindItem(itemID);
+
+ if (null == item)
{
- m_commsManager.InventoryService.DeleteItem(item);
+ m_log.WarnFormat("[AGENT INVENTORY]: Tried to delete item {0} which does not exist", itemID);
+
+ return false;
+ }
+
+ if (RootFolder.DeleteItem(item.ID))
+ {
+ return m_commsManager.InventoryService.DeleteItem(item);
}
}
+ else
+ {
+ AddRequest(
+ new InventoryRequest(
+ Delegate.CreateDelegate(typeof(DeleteItemDelegate), this, "DeleteItem"),
+ new object[] { itemID }));
+
+ return true;
+ }
- return result;
+ return false;
}
}
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
index 39296eb..af05af3 100644
--- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
+++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs
@@ -163,6 +163,7 @@ namespace OpenSim.Framework.Communications.Cache
}
}
}
+
return found;
}
--
cgit v1.1