* Refactor: Remove the unused userID parameter that was being passed into almost every inventory method

* This allows lots of redundant inventory methods with only slightly different names to be eliminated.
0.6.0-stable
Justin Clarke Casey 2008-05-01 20:47:33 +00:00
parent e41232bac5
commit 1de6cffa28
9 changed files with 155 additions and 316 deletions

View File

@ -333,61 +333,12 @@ namespace OpenSim.Data.MySQL
item.Creator = new LLUUID((string) reader["creatorID"]);
item.BasePermissions = (uint) reader["inventoryBasePermissions"];
item.EveryOnePermissions = (uint) reader["inventoryEveryOnePermissions"];
try
{
item.SalePrice = (int) reader["salePrice"];
}
catch (InvalidCastException)
{
m_log.WarnFormat("Could not cast salePrice {0} to {1}", reader["salePrice"], "int");
}
try
{
item.SaleType = Convert.ToByte(reader["saleType"]);
}
catch (InvalidCastException)
{
m_log.WarnFormat("Could not convert saleType {0} to {1}", reader["saleType"], "byte");
}
try
{
item.CreationDate = (int) reader["creationDate"];
}
catch (InvalidCastException)
{
m_log.WarnFormat("Could not cast creationDate {0} to {1}", reader["creationDate"], "int");
}
try
{
item.GroupID = new LLUUID(reader["groupID"].ToString());
}
catch (Exception)
{
item.GroupID = LLUUID.Zero;
m_log.WarnFormat("Could not convert groupID {0} to {1}", reader["groupID"], "LLUUID");
}
try
{
item.GroupOwned = Convert.ToBoolean(reader["groupOwned"]);
}
catch (InvalidCastException)
{
m_log.WarnFormat("Could not cast groupOwned {0} to {1}", reader["groupOwned"], "boolean");
}
try
{
item.Flags = (uint) reader["flags"];
}
catch (InvalidCastException)
{
m_log.WarnFormat("Could not cast flags {0} to {1}", reader["flags"], "uint");
}
return item;
}

View File

@ -166,12 +166,12 @@ namespace OpenSim.Framework.Communications.Cache
{
foreach (InventoryFolderImpl folder in folders)
{
FolderReceive(userID, folder);
FolderReceive(folder);
}
foreach (InventoryItemBase item in items)
{
ItemReceive(userID, item);
ItemReceive(item);
}
}
catch (Exception e)
@ -198,14 +198,12 @@ namespace OpenSim.Framework.Communications.Cache
/// </summary>
/// <param name="userID"></param>
/// <param name="folderInfo"></param>
private void FolderReceive(LLUUID userID, InventoryFolderImpl folderInfo)
private void FolderReceive(InventoryFolderImpl folderInfo)
{
// m_log.DebugFormat(
// "[INVENTORY CACHE]: Received folder {0} {1} for user {2}",
// folderInfo.Name, folderInfo.ID, userID);
if (userID == UserProfile.ID)
{
if (RootFolder == null)
{
if (folderInfo.ParentID == LLUUID.Zero)
@ -248,7 +246,6 @@ namespace OpenSim.Framework.Communications.Cache
ResolvePendingFolders(folderInfo);
}
}
/// <summary>
/// Callback invoked when an item is received from an async request to the inventory service.
@ -256,15 +253,14 @@ namespace OpenSim.Framework.Communications.Cache
/// We're assuming here that items are always received after all the folders have been
/// received.
/// </summary>
/// <param name="userID"></param>
/// <param name="folderInfo"></param>
private void ItemReceive(LLUUID userID, InventoryItemBase itemInfo)
private void ItemReceive(InventoryItemBase itemInfo)
{
// m_log.DebugFormat(
// "[INVENTORY CACHE]: Received item {0} {1} for user {2}",
// itemInfo.Name, itemInfo.ID, userID);
if ((userID == UserProfile.ID) && (RootFolder != null))
if (RootFolder != null)
{
if (itemInfo.Folder == RootFolder.ID)
{
@ -305,14 +301,13 @@ namespace OpenSim.Framework.Communications.Cache
/// <summary>
/// Add an item to the user's inventory
/// </summary>
/// <param name="userID"></param>
/// <param name="itemInfo"></param>
public void AddItem(LLUUID userID, InventoryItemBase itemInfo)
{
if ((userID == UserProfile.ID) && HasInventory)
if (HasInventory)
{
ItemReceive(userID, itemInfo);
m_commsManager.InventoryService.AddNewInventoryItem(userID, itemInfo);
ItemReceive(itemInfo);
m_commsManager.InventoryService.AddItem(itemInfo);
}
}
@ -325,7 +320,7 @@ namespace OpenSim.Framework.Communications.Cache
{
if ((userID == UserProfile.ID) && HasInventory)
{
m_commsManager.InventoryService.UpdateInventoryItem(userID, itemInfo);
m_commsManager.InventoryService.UpdateItem(itemInfo);
}
}
@ -343,7 +338,7 @@ namespace OpenSim.Framework.Communications.Cache
result = RootFolder.DeleteItem(item.ID);
if (result)
{
m_commsManager.InventoryService.DeleteInventoryItem(userID, item);
m_commsManager.InventoryService.DeleteItem(item);
}
}

View File

@ -181,7 +181,8 @@ namespace OpenSim.Framework.Communications.Cache
createdBaseFolder.ParentID = createdFolder.ParentID;
createdBaseFolder.Type = createdFolder.Type;
createdBaseFolder.Version = createdFolder.Version;
m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder);
m_commsManager.InventoryService.AddFolder(createdBaseFolder);
}
else
{
@ -207,7 +208,7 @@ namespace OpenSim.Framework.Communications.Cache
createdBaseFolder.Type = createdFolder.Type;
createdBaseFolder.Version = createdFolder.Version;
m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, createdBaseFolder);
m_commsManager.InventoryService.AddFolder(createdBaseFolder);
}
else
{
@ -265,7 +266,8 @@ namespace OpenSim.Framework.Communications.Cache
baseFolder.ParentID = parentID;
baseFolder.Type = (short) type;
baseFolder.Version = userProfile.RootFolder.Version;
m_commsManager.InventoryService.AddNewInventoryFolder(remoteClient.AgentId, baseFolder);
m_commsManager.InventoryService.AddFolder(baseFolder);
}
else
{
@ -299,7 +301,8 @@ namespace OpenSim.Framework.Communications.Cache
baseFolder.Owner = remoteClient.AgentId;
baseFolder.ID = folderID;
baseFolder.ParentID = parentID;
m_commsManager.InventoryService.MoveInventoryFolder(remoteClient.AgentId, baseFolder);
m_commsManager.InventoryService.MoveFolder(baseFolder);
}
else
{
@ -544,7 +547,7 @@ namespace OpenSim.Framework.Communications.Cache
purgedBaseFolder.Type = purgedFolder.Type;
purgedBaseFolder.Version = purgedFolder.Version;
m_commsManager.InventoryService.PurgeInventoryFolder(remoteClient.AgentId, purgedBaseFolder);
m_commsManager.InventoryService.PurgeFolder(purgedBaseFolder);
purgedFolder.Purge();
}

View File

@ -50,46 +50,46 @@ namespace OpenSim.Framework.Communications
void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback);
/// <summary>
/// Add a new folder to the given user's inventory
/// Add a new folder to the user's inventory
/// </summary>
/// <param name="userID"></param>
/// <param name="folder"></param>
void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
/// <returns>true if the folder was successfully added</returns>
bool AddFolder(InventoryFolderBase folder);
/// <summary>
/// Move an inventory folder to a new location
/// </summary>
/// <param name="userID"></param>
/// <param name="folder">A folder containing the details of the new location</param>
void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder);
/// <returns>true if the folder was successfully moved</returns>
bool MoveFolder(InventoryFolderBase folder);
/// <summary>
/// Purge an inventory folder of all its items and subfolders.
/// </summary>
/// <param name="userID"></param>
/// <param name="folder"></param>
void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder);
/// <returns>true if the folder was successfully purged</returns>
bool PurgeFolder(InventoryFolderBase folder);
/// <summary>
/// Add a new item to the given user's inventory
/// Add a new item to the user's inventory
/// </summary>
/// <param name="userID"></param>
/// <param name="item"></param>
void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
/// <returns>true if the item was successfully added</returns>
bool AddItem(InventoryItemBase item);
/// <summary>
/// Update an item in the given user's inventory
/// Update an item in the user's inventory
/// </summary>
/// <param name="userID"></param>
/// <param name="item"></param>
void UpdateInventoryItem(LLUUID userID, InventoryItemBase item);
/// <returns>true if the item was successfully updated</returns>
bool UpdateItem(InventoryItemBase item);
/// <summary>
/// Delete an item from the given user's inventory
/// Delete an item from the user's inventory
/// </summary>
/// <param name="userID"></param>
/// <param name="item"></param>
void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
/// <returns>true if the item was successfully deleted</returns>
bool DeleteItem(InventoryItemBase item);
/// <summary>
/// Create a new inventory for the given user.

View File

@ -107,16 +107,6 @@ namespace OpenSim.Framework.Communications
return userFolders;
}
// See IInventoryServices
public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{
// FIXME: Probably doesn't do what was originally intended - only ever queries the first plugin
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.moveInventoryFolder(folder);
}
}
// See IInventoryServices
public virtual bool HasInventoryForUser(LLUUID userID)
{
@ -161,24 +151,6 @@ namespace OpenSim.Framework.Communications
// See IInventoryServices
public abstract void RequestInventoryForUser(LLUUID userID, InventoryReceiptCallback callback);
// See IInventoryServices
public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
// See IInventoryServices
public abstract void MoveExistingInventoryFolder(InventoryFolderBase folder);
// See IInventoryServices
public abstract void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder);
// See IInventoryServices
public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
// See IInventoryServices
public abstract void UpdateInventoryItem(LLUUID userID, InventoryItemBase item);
// See IInventoryServices
public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
#endregion
#region Methods used by GridInventoryService
@ -206,47 +178,74 @@ namespace OpenSim.Framework.Communications
#endregion
protected void AddFolder(InventoryFolderBase folder)
public bool AddFolder(InventoryFolderBase folder)
{
m_log.DebugFormat(
"[INVENTORY SERVICE BASE]: Adding folder {0}, {1} to {2}", folder.Name, folder.ID, folder.ParentID);
"[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.addInventoryFolder(folder);
}
// FIXME: Should return false on failure
return true;
}
protected void MoveFolder(InventoryFolderBase folder)
public bool MoveFolder(InventoryFolderBase folder)
{
m_log.DebugFormat(
"[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.moveInventoryFolder(folder);
}
// FIXME: Should return false on failure
return true;
}
protected void AddItem(InventoryItemBase item)
public bool AddItem(InventoryItemBase item)
{
m_log.DebugFormat(
"[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.addInventoryItem(item);
}
// FIXME: Should return false on failure
return true;
}
protected void UpdateItem(InventoryItemBase item)
public bool UpdateItem(InventoryItemBase item)
{
m_log.InfoFormat(
"[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.updateInventoryItem(item);
}
// FIXME: Should return false on failure
return true;
}
protected void DeleteItem(InventoryItemBase item)
public bool DeleteItem(InventoryItemBase item)
{
m_log.InfoFormat(
"[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder);
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{
plugin.Value.deleteInventoryItem(item.ID);
}
// FIXME: Should return false on failure
return true;
}
/// <summary>
@ -256,8 +255,11 @@ namespace OpenSim.Framework.Communications
/// already know... Needs heavy refactoring.
/// </summary>
/// <param name="folder"></param>
protected void PurgeFolder(InventoryFolderBase folder)
public bool PurgeFolder(InventoryFolderBase folder)
{
m_log.DebugFormat(
"[AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID);
List<InventoryFolderBase> subFolders = RequestSubFolders(folder.ID);
foreach (InventoryFolderBase subFolder in subFolders)
@ -276,6 +278,9 @@ namespace OpenSim.Framework.Communications
{
DeleteItem(item);
}
// FIXME: Should return false on failure
return true;
}
private void AddNewInventorySet(UsersInventory inventory)

View File

@ -182,89 +182,7 @@ namespace OpenSim.Grid.InventoryServer
m_log.InfoFormat("[GRID AGENT INVENTORY]: Creating new set of inventory folders for user {0}", userID);
CreateNewUserInventory(userID);
return true;
}
public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{
AddFolder(folder);
}
public override void MoveExistingInventoryFolder(InventoryFolderBase folder)
{
MoveFolder(folder);
}
public override void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{
PurgeFolder(folder);
}
public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
{
AddItem(item);
}
public override void UpdateInventoryItem(LLUUID userID, InventoryItemBase item)
{
UpdateItem(item);
}
public bool AddInventoryFolder(InventoryFolderBase folder)
{
// Right now, this actions act more like an update/insert combination than a simple create.
m_log.InfoFormat(
"[GRID AGENT INVENTORY]: Creating folder {0} {1} in folder {2}", folder.Name, folder.ID, folder.ParentID);
AddNewInventoryFolder(folder.Owner, folder);
return true;
}
public bool MoveInventoryFolder(InventoryFolderBase folder)
{
m_log.InfoFormat(
"[GRID AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID);
MoveExistingInventoryFolder(folder);
return true;
}
public bool PurgeInventoryFolder(InventoryFolderBase folder)
{
m_log.InfoFormat(
"[GRID AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID);
PurgeInventoryFolder(folder.Owner, folder);
return true;
}
public bool AddInventoryItem(InventoryItemBase item)
{
// Right now, this actions act more like an update/insert combination than a simple create.
m_log.InfoFormat("[GRID AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder);
AddNewInventoryItem(item.Owner, item);
return true;
}
public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
{
m_log.InfoFormat("[GRID AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder);
DeleteItem(item);
}
/// <summary>
/// FIXME: Get DeleteInventoryItem to return a bool
/// </summary>
/// <param name="item"></param>
/// <returns></returns>
public bool DeleteInvItem(InventoryItemBase item)
{
DeleteInventoryItem(item.Owner, item);
return true;
return CreateNewUserInventory(userID);
}
}
}

View File

@ -95,23 +95,23 @@ namespace OpenSim.Grid.InventoryServer
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryFolderBase, bool>(
"POST", "/NewFolder/", m_inventoryService.AddInventoryFolder));
"POST", "/NewFolder/", m_inventoryService.AddFolder));
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryFolderBase, bool>(
"POST", "/MoveFolder/", m_inventoryService.MoveInventoryFolder));
"POST", "/MoveFolder/", m_inventoryService.MoveFolder));
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryFolderBase, bool>(
"POST", "/PurgeFolder/", m_inventoryService.PurgeInventoryFolder));
"POST", "/PurgeFolder/", m_inventoryService.PurgeFolder));
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryItemBase, bool>(
"POST", "/NewItem/", m_inventoryService.AddInventoryItem));
"POST", "/NewItem/", m_inventoryService.AddItem));
m_httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryItemBase, bool>(
"POST", "/DeleteItem/", m_inventoryService.DeleteInvItem));
"POST", "/DeleteItem/", m_inventoryService.DeleteItem));
// WARNING: Root folders no longer just delivers the root and immediate child folders (e.g
// system folders such as Objects, Textures), but it now returns the entire inventory skeleton.

View File

@ -80,41 +80,6 @@ namespace OpenSim.Region.Communications.Local
callback(userID, folders, items);
}
public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{
AddFolder(folder);
}
public override void MoveExistingInventoryFolder(InventoryFolderBase folder)
{
MoveFolder(folder);
}
public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
{
AddItem(item);
}
public override void UpdateInventoryItem(LLUUID userID, InventoryItemBase item)
{
UpdateItem(item);
}
public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
{
DeleteItem(item);
}
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
/// </summary>
/// <param name="userID"></param>
/// <param name="folder"></param>
public override void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{
PurgeFolder(folder);
}
public override bool HasInventoryForUser(LLUUID userID)
{
InventoryFolderBase root = RequestRootFolder(userID);

View File

@ -155,13 +155,11 @@ namespace OpenSim.Region.Communications.OGS1
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
/// </summary>
/// <param name="userID"></param>
/// <param name="folder"></param>
public void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
public bool AddFolder(InventoryFolderBase folder)
{
try
{
SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, bool>(
return SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, bool>(
"POST", _inventoryServerUrl + "/NewFolder/", folder);
}
catch (WebException e)
@ -169,18 +167,19 @@ namespace OpenSim.Region.Communications.OGS1
m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Add new inventory folder operation failed, {0} {1}",
e.Source, e.Message);
}
return false;
}
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
/// </summary>
/// <param name="userID"></param>
/// <param name="folder"></param>
public void MoveInventoryFolder(LLUUID userID, InventoryFolderBase folder)
public bool MoveFolder(InventoryFolderBase folder)
{
try
{
SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, bool>(
return SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, bool>(
"POST", _inventoryServerUrl + "/MoveFolder/", folder);
}
catch (WebException e)
@ -188,19 +187,18 @@ namespace OpenSim.Region.Communications.OGS1
m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Move inventory folder operation failed, {0} {1}",
e.Source, e.Message);
}
return false;
}
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
/// </summary>
/// <param name="userID"></param>
/// <param name="folder"></param>
/// <returns></returns>
public void PurgeInventoryFolder(LLUUID userID, InventoryFolderBase folder)
public bool PurgeFolder(InventoryFolderBase folder)
{
try
{
SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, bool>(
return SynchronousRestObjectPoster.BeginPostObject<InventoryFolderBase, bool>(
"POST", _inventoryServerUrl + "/PurgeFolder/", folder);
}
catch (WebException e)
@ -208,18 +206,18 @@ namespace OpenSim.Region.Communications.OGS1
m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Move inventory folder operation failed, {0} {1}",
e.Source, e.Message);
}
return false;
}
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
/// </summary>
/// <param name="userID"></param>
/// <param name="folder"></param>
public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
public bool AddItem(InventoryItemBase item)
{
try
{
SynchronousRestObjectPoster.BeginPostObject<InventoryItemBase, bool>(
return SynchronousRestObjectPoster.BeginPostObject<InventoryItemBase, bool>(
"POST", _inventoryServerUrl + "/NewItem/", item);
}
catch (WebException e)
@ -227,14 +225,16 @@ namespace OpenSim.Region.Communications.OGS1
m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Add new inventory item operation failed, {0} {1}",
e.Source, e.Message);
}
return false;
}
// TODO: this is a temporary workaround, the UpdateInventoryItem method need to be implemented
public void UpdateInventoryItem(LLUUID userID, InventoryItemBase item)
public bool UpdateItem(InventoryItemBase item)
{
try
{
SynchronousRestObjectPoster.BeginPostObject<InventoryItemBase, bool>(
return SynchronousRestObjectPoster.BeginPostObject<InventoryItemBase, bool>(
"POST", _inventoryServerUrl + "/NewItem/", item);
}
catch (WebException e)
@ -242,18 +242,18 @@ namespace OpenSim.Region.Communications.OGS1
m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Update new inventory item operation failed, {0} {1}",
e.Source, e.Message);
}
return false;
}
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInventoryServices"></see>
/// </summary>
/// <param name="userID"></param>
/// <param name="folder"></param>
public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
public bool DeleteItem(InventoryItemBase item)
{
try
{
SynchronousRestObjectPoster.BeginPostObject<InventoryItemBase, bool>(
return SynchronousRestObjectPoster.BeginPostObject<InventoryItemBase, bool>(
"POST", _inventoryServerUrl + "/DeleteItem/", item);
}
catch (WebException e)
@ -261,6 +261,8 @@ namespace OpenSim.Region.Communications.OGS1
m_log.ErrorFormat("[OGS1 INVENTORY SERVICE]: Delete inventory item operation failed, {0} {1}",
e.Source, e.Message);
}
return false;
}
public bool HasInventoryForUser(LLUUID userID)