* Refactor: Move MoveFolder() and PurgeFolder() into CachedUserInfo (which arguably should be split)
parent
9485b52f97
commit
068163b14b
|
@ -35,10 +35,10 @@ using log4net;
|
||||||
|
|
||||||
namespace OpenSim.Framework.Communications.Cache
|
namespace OpenSim.Framework.Communications.Cache
|
||||||
{
|
{
|
||||||
internal delegate void CreateInventoryFolderDelegate(
|
internal delegate void CreateFolderDelegate(string folderName, LLUUID folderID, ushort folderType, LLUUID parentID);
|
||||||
string folderName, LLUUID folderID, ushort folderType, LLUUID parentID);
|
internal delegate void MoveFolderDelegate(LLUUID folderID, LLUUID parentID);
|
||||||
internal delegate void UpdateInventoryFolderDelegate(
|
internal delegate void PurgeFolderDelegate(LLUUID folderID);
|
||||||
string name, LLUUID folderID, ushort type, LLUUID parentID);
|
internal delegate void UpdateFolderDelegate(string name, LLUUID folderID, ushort type, LLUUID parentID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stores user profile and inventory data received from backend services for a particular user.
|
/// Stores user profile and inventory data received from backend services for a particular user.
|
||||||
|
@ -54,7 +54,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
private readonly CommunicationsManager m_commsManager;
|
private readonly CommunicationsManager m_commsManager;
|
||||||
|
|
||||||
public UserProfileData UserProfile { get { return m_userProfile; } }
|
public UserProfileData UserProfile { get { return m_userProfile; } }
|
||||||
private UserProfileData m_userProfile;
|
private readonly UserProfileData m_userProfile;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Has we received the user's inventory from the inventory service?
|
/// Has we received the user's inventory from the inventory service?
|
||||||
|
@ -389,7 +389,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
{
|
{
|
||||||
AddRequest(
|
AddRequest(
|
||||||
new InventoryRequest(
|
new InventoryRequest(
|
||||||
Delegate.CreateDelegate(typeof(CreateInventoryFolderDelegate), this, "CreateFolder"),
|
Delegate.CreateDelegate(typeof(CreateFolderDelegate), this, "CreateFolder"),
|
||||||
new object[] { folderName, folderID, folderType, parentID }));
|
new object[] { folderName, folderID, folderType, parentID }));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -428,11 +428,88 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
{
|
{
|
||||||
AddRequest(
|
AddRequest(
|
||||||
new InventoryRequest(
|
new InventoryRequest(
|
||||||
Delegate.CreateDelegate(typeof(UpdateInventoryFolderDelegate), this, "UpdateFolder"),
|
Delegate.CreateDelegate(typeof(UpdateFolderDelegate), this, "UpdateFolder"),
|
||||||
new object[] { name, folderID, type, parentID }));
|
new object[] { name, folderID, type, parentID }));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle an inventory folder move request from the client.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderID"></param>
|
||||||
|
/// <param name="parentID"></param>
|
||||||
|
public bool MoveFolder(LLUUID folderID, LLUUID parentID)
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}",
|
||||||
|
// parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId);
|
||||||
|
|
||||||
|
if (HasInventory)
|
||||||
|
{
|
||||||
|
InventoryFolderBase baseFolder = new InventoryFolderBase();
|
||||||
|
baseFolder.Owner = m_userProfile.ID;
|
||||||
|
baseFolder.ID = folderID;
|
||||||
|
baseFolder.ParentID = parentID;
|
||||||
|
|
||||||
|
m_commsManager.InventoryService.MoveFolder(baseFolder);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddRequest(
|
||||||
|
new InventoryRequest(
|
||||||
|
Delegate.CreateDelegate(typeof(MoveFolderDelegate), this, "MoveFolder"),
|
||||||
|
new object[] { folderID, parentID }));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This method will delete all the items and folders in the given folder.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderID"></param>
|
||||||
|
public bool PurgeFolder(LLUUID folderID)
|
||||||
|
{
|
||||||
|
// m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}",
|
||||||
|
// folderID, remoteClient.Name, remoteClient.AgentId);
|
||||||
|
|
||||||
|
if (HasInventory)
|
||||||
|
{
|
||||||
|
InventoryFolderImpl purgedFolder = RootFolder.GetDescendentFolder(folderID);
|
||||||
|
|
||||||
|
if (purgedFolder != null)
|
||||||
|
{
|
||||||
|
// XXX Nasty - have to create a new object to hold details we already have
|
||||||
|
InventoryFolderBase purgedBaseFolder = new InventoryFolderBase();
|
||||||
|
purgedBaseFolder.Owner = purgedFolder.Owner;
|
||||||
|
purgedBaseFolder.ID = purgedFolder.ID;
|
||||||
|
purgedBaseFolder.Name = purgedFolder.Name;
|
||||||
|
purgedBaseFolder.ParentID = purgedFolder.ParentID;
|
||||||
|
purgedBaseFolder.Type = purgedFolder.Type;
|
||||||
|
purgedBaseFolder.Version = purgedFolder.Version;
|
||||||
|
|
||||||
|
m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder);
|
||||||
|
|
||||||
|
purgedFolder.Purge();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AddRequest(
|
||||||
|
new InventoryRequest(
|
||||||
|
Delegate.CreateDelegate(typeof(PurgeFolderDelegate), this, "PurgeFolder"),
|
||||||
|
new object[] { folderID }));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -499,18 +576,18 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class InventoryRequest : IInventoryRequest
|
class InventoryRequest : IInventoryRequest
|
||||||
{
|
{
|
||||||
private Delegate m_delegat;
|
private Delegate m_delegate;
|
||||||
private Object[] m_args;
|
private Object[] m_args;
|
||||||
|
|
||||||
internal InventoryRequest(Delegate delegat, Object[] args)
|
internal InventoryRequest(Delegate delegat, Object[] args)
|
||||||
{
|
{
|
||||||
m_delegat = delegat;
|
m_delegate = delegat;
|
||||||
m_args = args;
|
m_args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute()
|
public void Execute()
|
||||||
{
|
{
|
||||||
m_delegat.DynamicInvoke(m_args);
|
m_delegate.DynamicInvoke(m_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,7 @@ using libsecondlife;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
namespace OpenSim.Framework.Communications.Cache
|
namespace OpenSim.Framework.Communications.Cache
|
||||||
{
|
{
|
||||||
internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID);
|
|
||||||
internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Holds user profile information and retrieves it from backend services.
|
/// Holds user profile information and retrieves it from backend services.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -199,7 +196,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
if (!userProfile.UpdateFolder(name, folderID, type, parentID))
|
if (!userProfile.UpdateFolder(name, folderID, type, parentID))
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[AGENT INVENTORY]: Failed to create folder for user {0} {1}",
|
"[AGENT INVENTORY]: Failed to update folder for user {0} {1}",
|
||||||
remoteClient.Name, remoteClient.AgentId);
|
remoteClient.Name, remoteClient.AgentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,29 +216,15 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
/// <param name="parentID"></param>
|
/// <param name="parentID"></param>
|
||||||
public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID)
|
public void HandleMoveInventoryFolder(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID)
|
||||||
{
|
{
|
||||||
// m_log.DebugFormat(
|
|
||||||
// "[AGENT INVENTORY]: Moving inventory folder {0} into folder {1} for {2} {3}",
|
|
||||||
// parentID, remoteClient.Name, remoteClient.Name, remoteClient.AgentId);
|
|
||||||
|
|
||||||
CachedUserInfo userProfile;
|
CachedUserInfo userProfile;
|
||||||
|
|
||||||
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
|
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
|
||||||
{
|
{
|
||||||
if (userProfile.HasInventory)
|
if (!userProfile.MoveFolder(folderID, parentID))
|
||||||
{
|
{
|
||||||
InventoryFolderBase baseFolder = new InventoryFolderBase();
|
m_log.ErrorFormat(
|
||||||
baseFolder.Owner = remoteClient.AgentId;
|
"[AGENT INVENTORY]: Failed to move folder for user {0} {1}",
|
||||||
baseFolder.ID = folderID;
|
remoteClient.Name, remoteClient.AgentId);
|
||||||
baseFolder.ParentID = parentID;
|
|
||||||
|
|
||||||
m_commsManager.InventoryService.MoveFolder(baseFolder);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
userProfile.AddRequest(
|
|
||||||
new InventoryRequest(
|
|
||||||
Delegate.CreateDelegate(typeof(MoveInventoryFolderDelegate), this, "HandleMoveInventoryFolder"),
|
|
||||||
new object[] { remoteClient, folderID, parentID }));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -249,7 +232,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[AGENT INVENTORY]: Could not find user profile for {0} {1}",
|
"[AGENT INVENTORY]: Could not find user profile for {0} {1}",
|
||||||
remoteClient.Name, remoteClient.AgentId);
|
remoteClient.Name, remoteClient.AgentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -463,37 +446,15 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
/// <param name="folderID"></param>
|
/// <param name="folderID"></param>
|
||||||
public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID)
|
public void HandlePurgeInventoryDescendents(IClientAPI remoteClient, LLUUID folderID)
|
||||||
{
|
{
|
||||||
// m_log.InfoFormat("[AGENT INVENTORY]: Purging folder {0} for {1} uuid {2}",
|
|
||||||
// folderID, remoteClient.Name, remoteClient.AgentId);
|
|
||||||
|
|
||||||
CachedUserInfo userProfile;
|
CachedUserInfo userProfile;
|
||||||
|
|
||||||
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
|
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
|
||||||
{
|
{
|
||||||
if (userProfile.HasInventory)
|
if (!userProfile.PurgeFolder(folderID))
|
||||||
{
|
{
|
||||||
InventoryFolderImpl purgedFolder = userProfile.RootFolder.GetDescendentFolder(folderID);
|
m_log.ErrorFormat(
|
||||||
if (purgedFolder != null)
|
"[AGENT INVENTORY]: Failed to purge folder for user {0} {1}",
|
||||||
{
|
remoteClient.Name, remoteClient.AgentId);
|
||||||
// XXX Nasty - have to create a new object to hold details we already have
|
|
||||||
InventoryFolderBase purgedBaseFolder = new InventoryFolderBase();
|
|
||||||
purgedBaseFolder.Owner = purgedFolder.Owner;
|
|
||||||
purgedBaseFolder.ID = purgedFolder.ID;
|
|
||||||
purgedBaseFolder.Name = purgedFolder.Name;
|
|
||||||
purgedBaseFolder.ParentID = purgedFolder.ParentID;
|
|
||||||
purgedBaseFolder.Type = purgedFolder.Type;
|
|
||||||
purgedBaseFolder.Version = purgedFolder.Version;
|
|
||||||
|
|
||||||
m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder);
|
|
||||||
|
|
||||||
purgedFolder.Purge();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
userProfile.AddRequest(
|
|
||||||
new InventoryRequest(
|
|
||||||
Delegate.CreateDelegate(typeof(PurgeInventoryDescendentsDelegate), this, "HandlePurgeInventoryDescendents"),
|
|
||||||
new object[] { remoteClient, folderID }));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -501,7 +462,7 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[AGENT INVENTORY]: Could not find user profile for {0} {1}",
|
"[AGENT INVENTORY]: Could not find user profile for {0} {1}",
|
||||||
remoteClient.Name, remoteClient.AgentId);
|
remoteClient.Name, remoteClient.AgentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID)
|
public void HandleFetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID)
|
||||||
|
|
Loading…
Reference in New Issue