From ea8f3c83bf96453e8223d918933d5708fa49a3cc Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 4 Jul 2016 03:35:48 +0100 Subject: Finally remove the requirement for an InventoryItem/FolderBase object to be passed into inventory queries. This makes the API more homogenous and also will more clearly show coding errors related to HG inventory where the .Owner field has a meaning for a query but wasn't always set. --- .../Tests/XInventoryServiceTests.cs | 10 ++++----- .../Services/InventoryService/XInventoryService.cs | 24 ++++++++-------------- 2 files changed, 13 insertions(+), 21 deletions(-) (limited to 'OpenSim/Services/InventoryService') diff --git a/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs b/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs index 9e3fa69..3cfd125 100644 --- a/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs +++ b/OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs @@ -90,8 +90,7 @@ namespace OpenSim.Services.InventoryService.Tests Assert.That(xis.AddItem(itemToStore), Is.True); - InventoryItemBase itemRetrieved = new InventoryItemBase(itemId); - itemRetrieved = xis.GetItem(itemRetrieved); + InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId); Assert.That(itemRetrieved, Is.Not.Null); Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); @@ -139,8 +138,7 @@ namespace OpenSim.Services.InventoryService.Tests Assert.That(xis.UpdateItem(itemToStore), Is.True); - InventoryItemBase itemRetrieved = new InventoryItemBase(itemId); - itemRetrieved = xis.GetItem(itemRetrieved); + InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId); Assert.That(itemRetrieved, Is.Not.Null); Assert.That(itemRetrieved.Name, Is.EqualTo(itemName2)); @@ -162,7 +160,7 @@ namespace OpenSim.Services.InventoryService.Tests Assert.That(xis.UpdateItem(itemToStore), Is.True); - itemRetrieved = xis.GetItem(itemRetrieved); + itemRetrieved = xis.GetItem(itemRetrieved.Owner, itemRetrieved.ID); Assert.That(itemRetrieved, Is.Not.Null); Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); @@ -174,4 +172,4 @@ namespace OpenSim.Services.InventoryService.Tests Assert.That(itemRetrieved.Name, Is.EqualTo(itemName3)); } } -} \ No newline at end of file +} diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index b75193f..004c4bf 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -315,8 +315,7 @@ namespace OpenSim.Services.InventoryService inventory.Items.Add(ConvertToOpenSim(i)); } - InventoryFolderBase f = new InventoryFolderBase(folderID, principalID); - f = GetFolder(f); + InventoryFolderBase f = GetFolder(principalID, folderID); if (f != null) { inventory.Version = f.Version; @@ -359,7 +358,7 @@ namespace OpenSim.Services.InventoryService { // m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID); - InventoryFolderBase check = GetFolder(folder); + InventoryFolderBase check = GetFolder(folder.Owner, folder.ID); if (check != null) return false; @@ -402,7 +401,7 @@ namespace OpenSim.Services.InventoryService // m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID); XInventoryFolder xFolder = ConvertFromOpenSim(folder); - InventoryFolderBase check = GetFolder(folder); + InventoryFolderBase check = GetFolder(folder.Owner, folder.ID); if (check == null) return AddFolder(folder); @@ -512,7 +511,7 @@ namespace OpenSim.Services.InventoryService // m_log.InfoFormat( // "[XINVENTORY SERVICE]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); - InventoryItemBase retrievedItem = GetItem(item); + InventoryItemBase retrievedItem = GetItem(item.Owner, item.ID); if (retrievedItem == null) { @@ -598,11 +597,11 @@ namespace OpenSim.Services.InventoryService return true; } - public virtual InventoryItemBase GetItem(InventoryItemBase item) + public virtual InventoryItemBase GetItem(UUID principalID, UUID itemID) { XInventoryItem[] items = m_Database.GetItems( new string[] { "inventoryID" }, - new string[] { item.ID.ToString() }); + new string[] { itemID.ToString() }); if (items.Length == 0) return null; @@ -614,22 +613,17 @@ namespace OpenSim.Services.InventoryService { InventoryItemBase[] items = new InventoryItemBase[ids.Length]; int i = 0; - InventoryItemBase item = new InventoryItemBase(); - item.Owner = userID; foreach (UUID id in ids) - { - item.ID = id; - items[i++] = GetItem(item); - } + items[i++] = GetItem(userID, id); return items; } - public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder) + public virtual InventoryFolderBase GetFolder(UUID principalID, UUID folderID) { XInventoryFolder[] folders = m_Database.GetFolders( new string[] { "folderID"}, - new string[] { folder.ID.ToString() }); + new string[] { folderID.ToString() }); if (folders.Length == 0) return null; -- cgit v1.1