* Refactor RemoveItem()
parent
688940e810
commit
56827894e9
|
@ -35,7 +35,8 @@ using log4net;
|
||||||
|
|
||||||
namespace OpenSim.Framework.Communications.Cache
|
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 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);
|
||||||
|
@ -306,7 +307,10 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parentID"></param>
|
/// <param name="parentID"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
@ -399,10 +403,14 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle a client request to update the inventory folder
|
/// 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
|
/// 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,
|
/// so this will work to rename an existing folder. Needless to say, to rely on this is very confusing,
|
||||||
/// and needs to be changed.
|
/// and needs to be changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
///
|
||||||
/// <param name="folderID"></param>
|
/// <param name="folderID"></param>
|
||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
|
@ -437,7 +445,11 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handle an inventory folder move request from the client.
|
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
///
|
||||||
/// <param name="folderID"></param>
|
/// <param name="folderID"></param>
|
||||||
/// <param name="parentID"></param>
|
/// <param name="parentID"></param>
|
||||||
public bool MoveFolder(LLUUID folderID, LLUUID parentID)
|
public bool MoveFolder(LLUUID folderID, LLUUID parentID)
|
||||||
|
@ -470,7 +482,11 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method will delete all the items and folders in the given folder.
|
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
///
|
||||||
/// <param name="folderID"></param>
|
/// <param name="folderID"></param>
|
||||||
public bool PurgeFolder(LLUUID folderID)
|
public bool PurgeFolder(LLUUID folderID)
|
||||||
{
|
{
|
||||||
|
@ -540,23 +556,46 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete an item from the user's inventory
|
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userID"></param>
|
/// <param name="itemID"></param>
|
||||||
/// <param name="item"></param>
|
/// <returns>
|
||||||
/// <returns></returns>
|
/// true on a successful delete or a if the request is queued.
|
||||||
public bool DeleteItem(InventoryItemBase item)
|
/// Returns false on an immediate failure
|
||||||
|
/// </returns>
|
||||||
|
public bool DeleteItem(LLUUID itemID)
|
||||||
{
|
{
|
||||||
bool result = false;
|
|
||||||
if (HasInventory)
|
if (HasInventory)
|
||||||
{
|
{
|
||||||
result = RootFolder.DeleteItem(item.ID);
|
// XXX For historical reasons (grid comms), we need to retrieve the whole item in order to delete, even though
|
||||||
if (result)
|
// 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,6 +163,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace OpenSim.Grid.InventoryServer
|
||||||
m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID);
|
m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID);
|
||||||
|
|
||||||
// uncomment me to simulate an overloaded inventory server
|
// uncomment me to simulate an overloaded inventory server
|
||||||
//Thread.Sleep(18000);
|
Thread.Sleep(18000);
|
||||||
|
|
||||||
InventoryCollection invCollection = new InventoryCollection();
|
InventoryCollection invCollection = new InventoryCollection();
|
||||||
|
|
||||||
|
|
|
@ -467,6 +467,14 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
return asset;
|
return asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Move an item within the agent's inventory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteClient"></param>
|
||||||
|
/// <param name="folderID"></param>
|
||||||
|
/// <param name="itemID"></param>
|
||||||
|
/// <param name="length"></param>
|
||||||
|
/// <param name="newName"></param>
|
||||||
public void MoveInventoryItem(IClientAPI remoteClient, LLUUID folderID, LLUUID itemID, int length,
|
public void MoveInventoryItem(IClientAPI remoteClient, LLUUID folderID, LLUUID itemID, int length,
|
||||||
string newName)
|
string newName)
|
||||||
{
|
{
|
||||||
|
@ -474,6 +482,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
"[AGENT INVENTORY]: Moving item {0} to {1} for {2}", itemID, folderID, remoteClient.AgentId);
|
"[AGENT INVENTORY]: Moving item {0} to {1} for {2}", itemID, folderID, remoteClient.AgentId);
|
||||||
|
|
||||||
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
|
CachedUserInfo userInfo = 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.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
|
||||||
|
@ -491,7 +500,8 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
item.Name = newName;
|
item.Name = newName;
|
||||||
}
|
}
|
||||||
item.Folder = folderID;
|
item.Folder = folderID;
|
||||||
userInfo.DeleteItem(item);
|
|
||||||
|
userInfo.DeleteItem(item.ID);
|
||||||
|
|
||||||
// TODO: preserve current permissions?
|
// TODO: preserve current permissions?
|
||||||
AddInventoryItem(remoteClient, item);
|
AddInventoryItem(remoteClient, item);
|
||||||
|
@ -616,6 +626,11 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Remove an inventory item for the client's inventory
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteClient"></param>
|
||||||
|
/// <param name="itemID"></param>
|
||||||
private void RemoveInventoryItem(IClientAPI remoteClient, LLUUID itemID)
|
private void RemoveInventoryItem(IClientAPI remoteClient, LLUUID itemID)
|
||||||
{
|
{
|
||||||
CachedUserInfo userInfo
|
CachedUserInfo userInfo
|
||||||
|
@ -623,26 +638,14 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
if (userInfo == null)
|
if (userInfo == null)
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat(
|
m_log.WarnFormat(
|
||||||
"[AGENT INVENTORY]: Failed to find user {0} {1} to remove inventory item {2}",
|
"[AGENT INVENTORY]: Failed to find user {0} {1} to delete inventory item {2}",
|
||||||
remoteClient.Name, remoteClient.AgentId, itemID);
|
remoteClient.Name, remoteClient.AgentId, itemID);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// is going through the root folder really the best way?
|
userInfo.DeleteItem(itemID);
|
||||||
// this triggers a tree walk to find and remove the item. 8-(
|
|
||||||
// since this only happens in Trash (in theory) shouldn't we grab
|
|
||||||
// the trash folder directly instead of RootFolder?
|
|
||||||
if (userInfo.RootFolder != null)
|
|
||||||
{
|
|
||||||
InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
|
|
||||||
|
|
||||||
if (item != null)
|
|
||||||
{
|
|
||||||
userInfo.DeleteItem(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -658,7 +661,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
|
|
||||||
if (userInfo == null)
|
if (userInfo == null)
|
||||||
{
|
{
|
||||||
m_log.Error("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
|
m_log.Warn("[AGENT INVENTORY]: Failed to find user " + remoteClient.AgentId.ToString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue