diff options
author | Melanie Thielker | 2016-07-04 03:35:48 +0100 |
---|---|---|
committer | Melanie Thielker | 2016-07-04 03:35:48 +0100 |
commit | ea8f3c83bf96453e8223d918933d5708fa49a3cc (patch) | |
tree | 288972a5d6f112426da2b5ab109fe18ba5aedc2e /OpenSim/Services/InventoryService | |
parent | increase xmlrpc timeout in xmlrpcgroups, disable its cache until its entries ... (diff) | |
download | opensim-SC_OLD-ea8f3c83bf96453e8223d918933d5708fa49a3cc.zip opensim-SC_OLD-ea8f3c83bf96453e8223d918933d5708fa49a3cc.tar.gz opensim-SC_OLD-ea8f3c83bf96453e8223d918933d5708fa49a3cc.tar.bz2 opensim-SC_OLD-ea8f3c83bf96453e8223d918933d5708fa49a3cc.tar.xz |
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.
Diffstat (limited to 'OpenSim/Services/InventoryService')
-rw-r--r-- | OpenSim/Services/InventoryService/Tests/XInventoryServiceTests.cs | 10 | ||||
-rw-r--r-- | OpenSim/Services/InventoryService/XInventoryService.cs | 24 |
2 files changed, 13 insertions, 21 deletions
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 | |||
90 | 90 | ||
91 | Assert.That(xis.AddItem(itemToStore), Is.True); | 91 | Assert.That(xis.AddItem(itemToStore), Is.True); |
92 | 92 | ||
93 | InventoryItemBase itemRetrieved = new InventoryItemBase(itemId); | 93 | InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId); |
94 | itemRetrieved = xis.GetItem(itemRetrieved); | ||
95 | 94 | ||
96 | Assert.That(itemRetrieved, Is.Not.Null); | 95 | Assert.That(itemRetrieved, Is.Not.Null); |
97 | Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); | 96 | Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); |
@@ -139,8 +138,7 @@ namespace OpenSim.Services.InventoryService.Tests | |||
139 | 138 | ||
140 | Assert.That(xis.UpdateItem(itemToStore), Is.True); | 139 | Assert.That(xis.UpdateItem(itemToStore), Is.True); |
141 | 140 | ||
142 | InventoryItemBase itemRetrieved = new InventoryItemBase(itemId); | 141 | InventoryItemBase itemRetrieved = xis.GetItem(UUID.Zero, itemId); |
143 | itemRetrieved = xis.GetItem(itemRetrieved); | ||
144 | 142 | ||
145 | Assert.That(itemRetrieved, Is.Not.Null); | 143 | Assert.That(itemRetrieved, Is.Not.Null); |
146 | Assert.That(itemRetrieved.Name, Is.EqualTo(itemName2)); | 144 | Assert.That(itemRetrieved.Name, Is.EqualTo(itemName2)); |
@@ -162,7 +160,7 @@ namespace OpenSim.Services.InventoryService.Tests | |||
162 | 160 | ||
163 | Assert.That(xis.UpdateItem(itemToStore), Is.True); | 161 | Assert.That(xis.UpdateItem(itemToStore), Is.True); |
164 | 162 | ||
165 | itemRetrieved = xis.GetItem(itemRetrieved); | 163 | itemRetrieved = xis.GetItem(itemRetrieved.Owner, itemRetrieved.ID); |
166 | 164 | ||
167 | Assert.That(itemRetrieved, Is.Not.Null); | 165 | Assert.That(itemRetrieved, Is.Not.Null); |
168 | Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); | 166 | Assert.That(itemRetrieved.CreatorId, Is.EqualTo(creatorId)); |
@@ -174,4 +172,4 @@ namespace OpenSim.Services.InventoryService.Tests | |||
174 | Assert.That(itemRetrieved.Name, Is.EqualTo(itemName3)); | 172 | Assert.That(itemRetrieved.Name, Is.EqualTo(itemName3)); |
175 | } | 173 | } |
176 | } | 174 | } |
177 | } \ No newline at end of file | 175 | } |
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 | |||
315 | inventory.Items.Add(ConvertToOpenSim(i)); | 315 | inventory.Items.Add(ConvertToOpenSim(i)); |
316 | } | 316 | } |
317 | 317 | ||
318 | InventoryFolderBase f = new InventoryFolderBase(folderID, principalID); | 318 | InventoryFolderBase f = GetFolder(principalID, folderID); |
319 | f = GetFolder(f); | ||
320 | if (f != null) | 319 | if (f != null) |
321 | { | 320 | { |
322 | inventory.Version = f.Version; | 321 | inventory.Version = f.Version; |
@@ -359,7 +358,7 @@ namespace OpenSim.Services.InventoryService | |||
359 | { | 358 | { |
360 | // m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID); | 359 | // m_log.DebugFormat("[XINVENTORY]: Add folder {0} type {1} in parent {2}", folder.Name, folder.Type, folder.ParentID); |
361 | 360 | ||
362 | InventoryFolderBase check = GetFolder(folder); | 361 | InventoryFolderBase check = GetFolder(folder.Owner, folder.ID); |
363 | if (check != null) | 362 | if (check != null) |
364 | return false; | 363 | return false; |
365 | 364 | ||
@@ -402,7 +401,7 @@ namespace OpenSim.Services.InventoryService | |||
402 | // m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID); | 401 | // m_log.DebugFormat("[XINVENTORY]: Update folder {0} {1} ({2})", folder.Name, folder.Type, folder.ID); |
403 | 402 | ||
404 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); | 403 | XInventoryFolder xFolder = ConvertFromOpenSim(folder); |
405 | InventoryFolderBase check = GetFolder(folder); | 404 | InventoryFolderBase check = GetFolder(folder.Owner, folder.ID); |
406 | 405 | ||
407 | if (check == null) | 406 | if (check == null) |
408 | return AddFolder(folder); | 407 | return AddFolder(folder); |
@@ -512,7 +511,7 @@ namespace OpenSim.Services.InventoryService | |||
512 | // m_log.InfoFormat( | 511 | // m_log.InfoFormat( |
513 | // "[XINVENTORY SERVICE]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); | 512 | // "[XINVENTORY SERVICE]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); |
514 | 513 | ||
515 | InventoryItemBase retrievedItem = GetItem(item); | 514 | InventoryItemBase retrievedItem = GetItem(item.Owner, item.ID); |
516 | 515 | ||
517 | if (retrievedItem == null) | 516 | if (retrievedItem == null) |
518 | { | 517 | { |
@@ -598,11 +597,11 @@ namespace OpenSim.Services.InventoryService | |||
598 | return true; | 597 | return true; |
599 | } | 598 | } |
600 | 599 | ||
601 | public virtual InventoryItemBase GetItem(InventoryItemBase item) | 600 | public virtual InventoryItemBase GetItem(UUID principalID, UUID itemID) |
602 | { | 601 | { |
603 | XInventoryItem[] items = m_Database.GetItems( | 602 | XInventoryItem[] items = m_Database.GetItems( |
604 | new string[] { "inventoryID" }, | 603 | new string[] { "inventoryID" }, |
605 | new string[] { item.ID.ToString() }); | 604 | new string[] { itemID.ToString() }); |
606 | 605 | ||
607 | if (items.Length == 0) | 606 | if (items.Length == 0) |
608 | return null; | 607 | return null; |
@@ -614,22 +613,17 @@ namespace OpenSim.Services.InventoryService | |||
614 | { | 613 | { |
615 | InventoryItemBase[] items = new InventoryItemBase[ids.Length]; | 614 | InventoryItemBase[] items = new InventoryItemBase[ids.Length]; |
616 | int i = 0; | 615 | int i = 0; |
617 | InventoryItemBase item = new InventoryItemBase(); | ||
618 | item.Owner = userID; | ||
619 | foreach (UUID id in ids) | 616 | foreach (UUID id in ids) |
620 | { | 617 | items[i++] = GetItem(userID, id); |
621 | item.ID = id; | ||
622 | items[i++] = GetItem(item); | ||
623 | } | ||
624 | 618 | ||
625 | return items; | 619 | return items; |
626 | } | 620 | } |
627 | 621 | ||
628 | public virtual InventoryFolderBase GetFolder(InventoryFolderBase folder) | 622 | public virtual InventoryFolderBase GetFolder(UUID principalID, UUID folderID) |
629 | { | 623 | { |
630 | XInventoryFolder[] folders = m_Database.GetFolders( | 624 | XInventoryFolder[] folders = m_Database.GetFolders( |
631 | new string[] { "folderID"}, | 625 | new string[] { "folderID"}, |
632 | new string[] { folder.ID.ToString() }); | 626 | new string[] { folderID.ToString() }); |
633 | 627 | ||
634 | if (folders.Length == 0) | 628 | if (folders.Length == 0) |
635 | return null; | 629 | return null; |