* Refactor: move UpdateFolder into CachedUserInfo

0.6.0-stable
Justin Clarke Casey 2008-05-03 19:27:34 +00:00
parent 45a71bb045
commit 45430a5403
3 changed files with 49 additions and 25 deletions

View File

@ -37,6 +37,8 @@ namespace OpenSim.Framework.Communications.Cache
{
internal delegate void CreateInventoryFolderDelegate(
string folderName, LLUUID folderID, ushort folderType, LLUUID parentID);
internal delegate void UpdateInventoryFolderDelegate(
string name, LLUUID folderID, ushort type, LLUUID parentID);
/// <summary>
/// Stores user profile and inventory data received from backend services for a particular user.
@ -336,7 +338,7 @@ namespace OpenSim.Framework.Communications.Cache
else
{
m_log.WarnFormat(
"[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists",
"[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists",
folderName, folderID);
return false;
@ -367,7 +369,7 @@ namespace OpenSim.Framework.Communications.Cache
else
{
m_log.WarnFormat(
"[INVENTORY CACHE]: Tried to create folder {0} {1} but the folder already exists",
"[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists",
folderName, folderID);
return false;
@ -376,7 +378,7 @@ namespace OpenSim.Framework.Communications.Cache
else
{
m_log.WarnFormat(
"[INVENTORY CACHE]: Could not find parent folder with id {0} in order to create folder {1} {2}",
"[AGENT INVENTORY]: Could not find parent folder with id {0} in order to create folder {1} {2}",
parentID, folderName, folderID);
return false;
@ -392,9 +394,46 @@ namespace OpenSim.Framework.Communications.Cache
return true;
}
return false;
}
/// <summary>
/// Handle a client request to update the inventory folder
///
/// 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.
/// </summary>
/// <param name="folderID"></param>
/// <param name="type"></param>
/// <param name="name"></param>
/// <param name="parentID"></param>
public bool UpdateFolder(string name, LLUUID folderID, ushort type, LLUUID parentID)
{
// m_log.DebugFormat(
// "[AGENT INVENTORY]: Updating inventory folder {0} {1} for {2} {3}", folderID, name, remoteClient.Name, remoteClient.AgentId);
if (HasInventory)
{
InventoryFolderBase baseFolder = new InventoryFolderBase();
baseFolder.Owner = m_userProfile.ID;
baseFolder.ID = folderID;
baseFolder.Name = name;
baseFolder.ParentID = parentID;
baseFolder.Type = (short) type;
baseFolder.Version = RootFolder.Version;
m_commsManager.InventoryService.AddFolder(baseFolder);
}
else
{
AddRequest(
new InventoryRequest(
Delegate.CreateDelegate(typeof(UpdateInventoryFolderDelegate), this, "UpdateFolder"),
new object[] { name, folderID, type, parentID }));
}
return true;
}
/// <summary>
/// Add an item to the user's inventory

View File

@ -36,8 +36,6 @@ namespace OpenSim.Framework.Communications.Cache
{
internal delegate void MoveInventoryFolderDelegate(IClientAPI remoteClient, LLUUID folderID, LLUUID parentID);
internal delegate void PurgeInventoryDescendentsDelegate(IClientAPI remoteClient, LLUUID folderID);
internal delegate void UpdateInventoryFolderDelegate(
IClientAPI remoteClient, LLUUID folderID, ushort type, string name, LLUUID parentID);
/// <summary>
/// Holds user profile information and retrieves it from backend services.
@ -198,24 +196,11 @@ namespace OpenSim.Framework.Communications.Cache
if (m_userProfiles.TryGetValue(remoteClient.AgentId, out userProfile))
{
if (userProfile.HasInventory)
if (!userProfile.UpdateFolder(name, folderID, type, parentID))
{
InventoryFolderBase baseFolder = new InventoryFolderBase();
baseFolder.Owner = remoteClient.AgentId;
baseFolder.ID = folderID;
baseFolder.Name = name;
baseFolder.ParentID = parentID;
baseFolder.Type = (short) type;
baseFolder.Version = userProfile.RootFolder.Version;
m_commsManager.InventoryService.AddFolder(baseFolder);
}
else
{
userProfile.AddRequest(
new InventoryRequest(
Delegate.CreateDelegate(typeof(UpdateInventoryFolderDelegate), this, "HandleUpdateInventoryFolder"),
new object[] { remoteClient, folderID, type, name, parentID }));
m_log.ErrorFormat(
"[AGENT INVENTORY]: Failed to create folder for user {0} {1}",
remoteClient.Name, remoteClient.AgentId);
}
}
else

View File

@ -62,7 +62,7 @@ namespace OpenSim.Grid.InventoryServer
m_log.InfoFormat("[GRID AGENT INVENTORY]: Processing request for inventory of {0}", userID);
// uncomment me to simulate an overloaded inventory server
//Thread.Sleep(20000);
//Thread.Sleep(18000);
InventoryCollection invCollection = new InventoryCollection();