Added MoveItems, which is most useful upon viewer-delete inventory operation. Moving a batch of items is a 1-time operation. Made it async anyway, so that the viewer doesn't wait in case the DB layer is dumb (which is the case currently).
parent
4382f28efc
commit
d519f1885f
|
@ -547,6 +547,11 @@ namespace OpenSim.Framework.Communications.Tests
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool MoveItems(UUID owner, List<InventoryItemBase> items)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool DeleteItems(UUID owner, List<UUID> items)
|
public bool DeleteItems(UUID owner, List<UUID> items)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -254,7 +254,7 @@ namespace OpenSim.Framework
|
||||||
string newName);
|
string newName);
|
||||||
|
|
||||||
public delegate void MoveInventoryItem(
|
public delegate void MoveInventoryItem(
|
||||||
IClientAPI remoteClient, UUID folderID, UUID itemID, int length, string newName);
|
IClientAPI remoteClient, List<InventoryItemBase> items);
|
||||||
|
|
||||||
public delegate void RemoveInventoryItem(
|
public delegate void RemoveInventoryItem(
|
||||||
IClientAPI remoteClient, List<UUID> itemIDs);
|
IClientAPI remoteClient, List<UUID> itemIDs);
|
||||||
|
|
|
@ -7027,14 +7027,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
if (OnMoveInventoryItem != null)
|
if (OnMoveInventoryItem != null)
|
||||||
{
|
{
|
||||||
handlerMoveInventoryItem = null;
|
handlerMoveInventoryItem = null;
|
||||||
|
InventoryItemBase itm = null;
|
||||||
|
List<InventoryItemBase> items = new List<InventoryItemBase>();
|
||||||
foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
|
foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
|
||||||
{
|
{
|
||||||
handlerMoveInventoryItem = OnMoveInventoryItem;
|
itm = new InventoryItemBase(datablock.ItemID, AgentId);
|
||||||
if (handlerMoveInventoryItem != null)
|
itm.Folder = datablock.FolderID;
|
||||||
{
|
itm.Name = Util.FieldToString(datablock.NewName);
|
||||||
handlerMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length,
|
// weird, comes out as empty string
|
||||||
Util.FieldToString(datablock.NewName));
|
//m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
|
||||||
}
|
items.Add(itm);
|
||||||
|
}
|
||||||
|
handlerMoveInventoryItem = OnMoveInventoryItem;
|
||||||
|
if (handlerMoveInventoryItem != null)
|
||||||
|
{
|
||||||
|
handlerMoveInventoryItem(this, items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -181,6 +181,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
/// <returns>true if the item was successfully updated</returns>
|
/// <returns>true if the item was successfully updated</returns>
|
||||||
public abstract bool UpdateItem(InventoryItemBase item);
|
public abstract bool UpdateItem(InventoryItemBase item);
|
||||||
|
|
||||||
|
public abstract bool MoveItems(UUID ownerID, List<InventoryItemBase> items);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete an item from the user's inventory
|
/// Delete an item from the user's inventory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -393,6 +393,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
|
||||||
|
{
|
||||||
|
if (items == null)
|
||||||
|
return false;
|
||||||
|
if (items.Count == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (IsLocalGridUser(ownerID))
|
||||||
|
return m_GridService.MoveItems(ownerID, items);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UUID sessionID = GetSessionID(ownerID);
|
||||||
|
string uri = GetUserInventoryURI(ownerID) + "/" + ownerID.ToString();
|
||||||
|
return m_HGService.MoveItems(uri, items, sessionID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
|
public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Delete {0} items for user {1}", itemIDs.Count, ownerID);
|
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Delete {0} items for user {1}", itemIDs.Count, ownerID);
|
||||||
|
|
|
@ -289,6 +289,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
return m_InventoryService.UpdateItem(item);
|
return m_InventoryService.UpdateItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
|
||||||
|
{
|
||||||
|
return m_InventoryService.MoveItems(ownerID, items);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete an item from the user's inventory
|
/// Delete an item from the user's inventory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -273,6 +273,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID);
|
return m_RemoteConnector.UpdateItem(item.Owner.ToString(), item, sessionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
|
||||||
|
{
|
||||||
|
if (items == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
UUID sessionID = GetSessionID(ownerID);
|
||||||
|
return m_RemoteConnector.MoveItems(ownerID.ToString(), items, sessionID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
|
public override bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
|
||||||
{
|
{
|
||||||
if (itemIDs == null)
|
if (itemIDs == null)
|
||||||
|
|
|
@ -638,36 +638,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="itemID"></param>
|
/// <param name="itemID"></param>
|
||||||
/// <param name="length"></param>
|
/// <param name="length"></param>
|
||||||
/// <param name="newName"></param>
|
/// <param name="newName"></param>
|
||||||
public void MoveInventoryItem(IClientAPI remoteClient, UUID folderID, UUID itemID, int length,
|
public void MoveInventoryItem(IClientAPI remoteClient, List<InventoryItemBase> items)
|
||||||
string newName)
|
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[AGENT INVENTORY]: Moving item {0} to {1} for {2}", itemID, folderID, remoteClient.AgentId);
|
"[AGENT INVENTORY]: Moving {0} items for user {1}", items.Count, remoteClient.AgentId);
|
||||||
|
|
||||||
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
if (!InventoryService.MoveItems(remoteClient.AgentId, items))
|
||||||
item = InventoryService.GetItem(item);
|
m_log.Warn("[AGENT INVENTORY]: Failed to move items for user " + remoteClient.AgentId);
|
||||||
|
|
||||||
if (item != null)
|
|
||||||
{
|
|
||||||
if (newName != String.Empty)
|
|
||||||
{
|
|
||||||
item.Name = newName;
|
|
||||||
}
|
|
||||||
item.Folder = folderID;
|
|
||||||
|
|
||||||
// Diva comment: can't we just update?
|
|
||||||
List<UUID> uuids = new List<UUID>();
|
|
||||||
uuids.Add(item.ID);
|
|
||||||
InventoryService.DeleteItems(item.Owner, uuids);
|
|
||||||
|
|
||||||
AddInventoryItem(remoteClient, item);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.Warn("[AGENT INVENTORY]: Failed to find item " + itemID.ToString());
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -125,8 +125,8 @@ namespace OpenSim.Server.Handlers.Inventory
|
||||||
"POST", "/NewFolder/", m_InventoryService.AddFolder, CheckAuthSession));
|
"POST", "/NewFolder/", m_InventoryService.AddFolder, CheckAuthSession));
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
m_httpServer.AddStreamHandler(
|
||||||
new RestDeserialiseTrustedHandler<InventoryFolderBase, bool>(
|
new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
|
||||||
"POST", "/CreateFolder/", m_InventoryService.AddFolder, CheckTrustSource));
|
"POST", "/CreateFolder/", m_InventoryService.AddFolder, CheckAuthSession));
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
m_httpServer.AddStreamHandler(
|
||||||
new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
|
new RestDeserialiseSecureHandler<InventoryItemBase, bool>(
|
||||||
|
@ -137,9 +137,13 @@ namespace OpenSim.Server.Handlers.Inventory
|
||||||
"POST", "/AddNewItem/", m_InventoryService.AddItem, CheckTrustSource));
|
"POST", "/AddNewItem/", m_InventoryService.AddItem, CheckTrustSource));
|
||||||
|
|
||||||
m_httpServer.AddStreamHandler(
|
m_httpServer.AddStreamHandler(
|
||||||
new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>(
|
new RestDeserialiseSecureHandler<Guid, List<InventoryItemBase>>(
|
||||||
"POST", "/GetItems/", GetFolderItems, CheckTrustSource));
|
"POST", "/GetItems/", GetFolderItems, CheckAuthSession));
|
||||||
|
|
||||||
|
m_httpServer.AddStreamHandler(
|
||||||
|
new RestDeserialiseSecureHandler<List<InventoryItemBase>, bool>(
|
||||||
|
"POST", "/MoveItems/", MoveItems, CheckAuthSession));
|
||||||
|
|
||||||
// for persistent active gestures
|
// for persistent active gestures
|
||||||
m_httpServer.AddStreamHandler(
|
m_httpServer.AddStreamHandler(
|
||||||
new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>
|
new RestDeserialiseTrustedHandler<Guid, List<InventoryItemBase>>
|
||||||
|
@ -256,6 +260,15 @@ namespace OpenSim.Server.Handlers.Inventory
|
||||||
return m_InventoryService.DeleteItems(UUID.Zero, uuids);
|
return m_InventoryService.DeleteItems(UUID.Zero, uuids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool MoveItems(List<InventoryItemBase> items)
|
||||||
|
{
|
||||||
|
// oops we lost the user info here. Bad bad handlers
|
||||||
|
// let's peek at one item
|
||||||
|
UUID ownerID = UUID.Zero;
|
||||||
|
if (items.Count > 0)
|
||||||
|
ownerID = items[0].Owner;
|
||||||
|
return m_InventoryService.MoveItems(ownerID, items);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -253,6 +253,19 @@ namespace OpenSim.Services.Connectors.Inventory
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool MoveItems(string id, List<InventoryItemBase> items, UUID sessionID)
|
||||||
|
{
|
||||||
|
string url = string.Empty;
|
||||||
|
string userID = string.Empty;
|
||||||
|
|
||||||
|
if (StringToUrlAndUserID(id, out url, out userID))
|
||||||
|
{
|
||||||
|
ISessionAuthInventoryService connector = GetConnector(url);
|
||||||
|
return connector.MoveItems(userID, items, sessionID);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool DeleteItems(string id, List<UUID> itemIDs, UUID sessionID)
|
public bool DeleteItems(string id, List<UUID> itemIDs, UUID sessionID)
|
||||||
{
|
{
|
||||||
string url = string.Empty;
|
string url = string.Empty;
|
||||||
|
|
|
@ -116,6 +116,8 @@ namespace OpenSim.Services.Connectors
|
||||||
/// <returns>true if the item was successfully updated</returns>
|
/// <returns>true if the item was successfully updated</returns>
|
||||||
bool UpdateItem(string userID, InventoryItemBase item, UUID session_id);
|
bool UpdateItem(string userID, InventoryItemBase item, UUID session_id);
|
||||||
|
|
||||||
|
bool MoveItems(string userID, List<InventoryItemBase> items, UUID session_id);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete an item from the user's inventory
|
/// Delete an item from the user's inventory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -383,6 +383,48 @@ namespace OpenSim.Services.Connectors
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MoveItems Async group
|
||||||
|
*/
|
||||||
|
|
||||||
|
delegate void MoveItemsDelegate(string userID, List<InventoryItemBase> items, UUID sessionID);
|
||||||
|
|
||||||
|
private void MoveItemsAsync(string userID, List<InventoryItemBase> items, UUID sessionID)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SynchronousRestSessionObjectPoster<List<InventoryItemBase>, bool>.BeginPostObject(
|
||||||
|
"POST", m_ServerURI + "/MoveItems/", items, sessionID.ToString(), userID.ToString());
|
||||||
|
|
||||||
|
// Success
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[INVENTORY CONNECTOR]: Move inventory items operation failed, {0} {1} (old server?). Trying slow way.",
|
||||||
|
e.Source, e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (InventoryItemBase item in items)
|
||||||
|
{
|
||||||
|
InventoryItemBase itm = this.QueryItem(userID, item, sessionID);
|
||||||
|
itm.Name = item.Name;
|
||||||
|
itm.Folder = item.Folder;
|
||||||
|
this.UpdateItem(userID, itm, sessionID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MoveItemsCompleted(IAsyncResult iar)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool MoveItems(string userID, List<InventoryItemBase> items, UUID sessionID)
|
||||||
|
{
|
||||||
|
MoveItemsDelegate d = MoveItemsAsync;
|
||||||
|
d.BeginInvoke(userID, items, sessionID, MoveItemsCompleted, d);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public bool DeleteItems(string userID, List<UUID> items, UUID sessionID)
|
public bool DeleteItems(string userID, List<UUID> items, UUID sessionID)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -151,6 +151,11 @@ namespace OpenSim.Services.Connectors
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool DeleteItems(UUID owner, List<UUID> itemIDs)
|
public bool DeleteItems(UUID owner, List<UUID> itemIDs)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -142,6 +142,8 @@ namespace OpenSim.Services.Interfaces
|
||||||
/// <returns>true if the item was successfully updated</returns>
|
/// <returns>true if the item was successfully updated</returns>
|
||||||
bool UpdateItem(InventoryItemBase item);
|
bool UpdateItem(InventoryItemBase item);
|
||||||
|
|
||||||
|
bool MoveItems(UUID ownerID, List<InventoryItemBase> items);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete an item from the user's inventory
|
/// Delete an item from the user's inventory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -386,6 +386,24 @@ namespace OpenSim.Services.InventoryService
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
|
||||||
|
{
|
||||||
|
m_log.InfoFormat(
|
||||||
|
"[INVENTORY SERVICE]: Moving {0} items from user {1}", items.Count, ownerID);
|
||||||
|
|
||||||
|
InventoryItemBase itm = null;
|
||||||
|
foreach (InventoryItemBase item in items)
|
||||||
|
{
|
||||||
|
itm = GetInventoryItem(item.ID);
|
||||||
|
itm.Folder = item.Folder;
|
||||||
|
if ((item.Name != null) && !item.Name.Equals(string.Empty))
|
||||||
|
itm.Name = item.Name;
|
||||||
|
m_Database.updateInventoryItem(itm);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// See IInventoryServices
|
// See IInventoryServices
|
||||||
public virtual bool DeleteItems(UUID owner, List<UUID> itemIDs)
|
public virtual bool DeleteItems(UUID owner, List<UUID> itemIDs)
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,6 +143,11 @@ namespace OpenSim.Tests.Common.Mock
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool MoveItems(UUID ownerID, List<InventoryItemBase> items)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
|
public bool DeleteItems(UUID ownerID, List<UUID> itemIDs)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue