From e5f33e75055a8f83cf4e11a6120774cb90dbc3be Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 18 Aug 2009 22:36:03 -0700 Subject: GetFolderItems implemented. It's not being called, but it might. --- .../Connectors/Inventory/HGInventoryServiceConnector.cs | 13 +++++++++++++ .../Inventory/ISessionAuthInventoryService.cs | 7 +++++++ .../Connectors/Inventory/InventoryServiceConnector.cs | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs index 94b4ad9..75fa516 100644 --- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs @@ -214,6 +214,19 @@ namespace OpenSim.Services.Connectors.Inventory return false; } + public List GetFolderItems(string id, UUID folderID, UUID sessionID) + { + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.GetFolderItems(userID, folderID, sessionID); + } + return new List(); + } + public bool AddItem(string id, InventoryItemBase item, UUID sessionID) { string url = string.Empty; diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs index f50bcf5..7f051f3 100644 --- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs +++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs @@ -96,6 +96,13 @@ namespace OpenSim.Services.Connectors bool PurgeFolder(string userID, InventoryFolderBase folder, UUID session_id); /// + /// Get items from a folder. + /// + /// + /// true if the folder was successfully purged + List GetFolderItems(string userID, UUID folderID, UUID session_id); + + /// /// Add a new item to the user's inventory /// /// diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 5d94eac..5aa4b30 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -334,6 +334,23 @@ namespace OpenSim.Services.Connectors return false; } + public List GetFolderItems(string userID, UUID folderID, UUID sessionID) + { + try + { + InventoryFolderBase folder = new InventoryFolderBase(folderID, new UUID(userID)); + return SynchronousRestSessionObjectPoster>.BeginPostObject( + "POST", m_ServerURI + "/GetItems/", folder, sessionID.ToString(), userID); + } + catch (Exception e) + { + m_log.ErrorFormat("[INVENTORY CONNECTOR]: Get folder items operation failed, {0} {1}", + e.Source, e.Message); + } + + return null; + } + public bool AddItem(string userID, InventoryItemBase item, UUID sessionID) { try -- cgit v1.1 From c5af39239f7f2a1725d9c08bea80522de8835e0f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 19 Aug 2009 00:13:51 -0700 Subject: A better purge of trash folder. --- .../Connectors/Inventory/HGInventoryServiceConnector.cs | 4 ++-- .../Connectors/Inventory/ISessionAuthInventoryService.cs | 2 +- .../Connectors/Inventory/InventoryServiceConnector.cs | 9 ++++++--- .../Inventory/QuickAndDirtyInventoryServiceConnector.cs | 2 +- OpenSim/Services/Interfaces/IInventoryService.cs | 3 ++- OpenSim/Services/InventoryService/InventoryService.cs | 12 ++++++++---- 6 files changed, 20 insertions(+), 12 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs index 75fa516..00b74b5 100644 --- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs @@ -253,7 +253,7 @@ namespace OpenSim.Services.Connectors.Inventory return false; } - public bool DeleteItem(string id, InventoryItemBase item, UUID sessionID) + public bool DeleteItems(string id, List itemIDs, UUID sessionID) { string url = string.Empty; string userID = string.Empty; @@ -261,7 +261,7 @@ namespace OpenSim.Services.Connectors.Inventory if (StringToUrlAndUserID(id, out url, out userID)) { ISessionAuthInventoryService connector = GetConnector(url); - return connector.UpdateItem(userID, item, sessionID); + return connector.DeleteItems(userID, itemIDs, sessionID); } return false; } diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs index 7f051f3..e4e713c 100644 --- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs +++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs @@ -121,7 +121,7 @@ namespace OpenSim.Services.Connectors /// /// /// true if the item was successfully deleted - bool DeleteItem(string userID, InventoryItemBase item, UUID session_id); + bool DeleteItems(string userID, List itemIDs, UUID session_id); InventoryItemBase QueryItem(string userID, InventoryItemBase item, UUID session_id); diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 5aa4b30..9b2e331 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -383,12 +383,15 @@ namespace OpenSim.Services.Connectors return false; } - public bool DeleteItem(string userID, InventoryItemBase item, UUID sessionID) + public bool DeleteItems(string userID, List items, UUID sessionID) { try { - return SynchronousRestSessionObjectPoster.BeginPostObject( - "POST", m_ServerURI + "/DeleteItem/", item, sessionID.ToString(), item.Owner.ToString()); + List guids = new List(); + foreach (UUID u in items) + guids.Add(u.Guid); + return SynchronousRestSessionObjectPoster, bool>.BeginPostObject( + "POST", m_ServerURI + "/DeleteItem/", guids, sessionID.ToString(), userID); } catch (Exception e) { diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs index 5cbd307..3bbf129 100644 --- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs @@ -151,7 +151,7 @@ namespace OpenSim.Services.Connectors return false; } - public bool DeleteItem(InventoryItemBase item) + public bool DeleteItems(UUID owner, List itemIDs) { return false; } diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs index a89a238..6409b57 100644 --- a/OpenSim/Services/Interfaces/IInventoryService.cs +++ b/OpenSim/Services/Interfaces/IInventoryService.cs @@ -147,7 +147,8 @@ namespace OpenSim.Services.Interfaces /// /// /// true if the item was successfully deleted - bool DeleteItem(InventoryItemBase item); + //bool DeleteItem(InventoryItemBase item); + bool DeleteItems(UUID userID, List itemIDs); /// /// Get an item, given by its UUID diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index 65c2d96..69b1b28 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs @@ -387,12 +387,14 @@ namespace OpenSim.Services.InventoryService } // See IInventoryServices - public virtual bool DeleteItem(InventoryItemBase item) + public virtual bool DeleteItems(UUID owner, List itemIDs) { m_log.InfoFormat( - "[INVENTORY SERVICE]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); + "[INVENTORY SERVICE]: Deleting {0} items from user {1}", itemIDs.Count, owner); - m_Database.deleteInventoryItem(item.ID); + // uhh..... + foreach (UUID uuid in itemIDs) + m_Database.deleteInventoryItem(uuid); // FIXME: Should return false on failure return true; @@ -439,10 +441,12 @@ namespace OpenSim.Services.InventoryService List items = GetFolderItems(folder.Owner, folder.ID); + List uuids = new List(); foreach (InventoryItemBase item in items) { - DeleteItem(item); + uuids.Add(item.ID); } + DeleteItems(folder.Owner, uuids); // FIXME: Should return false on failure return true; -- cgit v1.1 From d519f1885f587409592cf92bc0f4ba8533a1866f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 19 Aug 2009 10:56:08 -0700 Subject: 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). --- .../Inventory/HGInventoryServiceConnector.cs | 13 +++++++ .../Inventory/ISessionAuthInventoryService.cs | 2 ++ .../Inventory/InventoryServiceConnector.cs | 42 ++++++++++++++++++++++ .../QuickAndDirtyInventoryServiceConnector.cs | 5 +++ OpenSim/Services/Interfaces/IInventoryService.cs | 2 ++ .../Services/InventoryService/InventoryService.cs | 18 ++++++++++ 6 files changed, 82 insertions(+) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs index 00b74b5..45e921a 100644 --- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs @@ -253,6 +253,19 @@ namespace OpenSim.Services.Connectors.Inventory return false; } + public bool MoveItems(string id, List 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 itemIDs, UUID sessionID) { string url = string.Empty; diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs index e4e713c..c89c9b7 100644 --- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs +++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs @@ -116,6 +116,8 @@ namespace OpenSim.Services.Connectors /// true if the item was successfully updated bool UpdateItem(string userID, InventoryItemBase item, UUID session_id); + bool MoveItems(string userID, List items, UUID session_id); + /// /// Delete an item from the user's inventory /// diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 9b2e331..bcf9d87 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -383,6 +383,48 @@ namespace OpenSim.Services.Connectors return false; } + /** + * MoveItems Async group + */ + + delegate void MoveItemsDelegate(string userID, List items, UUID sessionID); + + private void MoveItemsAsync(string userID, List items, UUID sessionID) + { + try + { + SynchronousRestSessionObjectPoster, 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 items, UUID sessionID) + { + MoveItemsDelegate d = MoveItemsAsync; + d.BeginInvoke(userID, items, sessionID, MoveItemsCompleted, d); + return true; + } + public bool DeleteItems(string userID, List items, UUID sessionID) { try diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs index 3bbf129..cd283ff 100644 --- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs @@ -151,6 +151,11 @@ namespace OpenSim.Services.Connectors return false; } + public bool MoveItems(UUID ownerID, List items) + { + return false; + } + public bool DeleteItems(UUID owner, List itemIDs) { return false; diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs index 6409b57..ebdb09a 100644 --- a/OpenSim/Services/Interfaces/IInventoryService.cs +++ b/OpenSim/Services/Interfaces/IInventoryService.cs @@ -142,6 +142,8 @@ namespace OpenSim.Services.Interfaces /// true if the item was successfully updated bool UpdateItem(InventoryItemBase item); + bool MoveItems(UUID ownerID, List items); + /// /// Delete an item from the user's inventory /// diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index 69b1b28..e0217f6 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs @@ -386,6 +386,24 @@ namespace OpenSim.Services.InventoryService return true; } + public virtual bool MoveItems(UUID ownerID, List 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 public virtual bool DeleteItems(UUID owner, List itemIDs) { -- cgit v1.1