diff options
3 files changed, 53 insertions, 14 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs index 47e34dc..dc665c1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | |||
@@ -181,25 +181,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
181 | 181 | ||
182 | /// <summary> | 182 | /// <summary> |
183 | /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. | 183 | /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. |
184 | /// | 184 | /// </summary> |
185 | /// This method does not handle paths that contain multiple delimitors | 185 | /// <remarks> |
186 | /// This method does not handle paths that contain multiple delimiters | ||
186 | /// | 187 | /// |
187 | /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some | 188 | /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some |
188 | /// XPath like expression | 189 | /// XPath like expression |
189 | /// | 190 | /// |
190 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. | 191 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. |
191 | /// </summary> | 192 | /// </remarks> |
192 | /// | 193 | /// |
193 | /// <param name="inventoryService"> | 194 | /// <param name="inventoryService">Inventory service to query</param> |
194 | /// Inventory service to query | 195 | /// <param name="startFolder">The folder from which the path starts</param> |
195 | /// </param> | 196 | /// <param name="path">The path to the required item.</param> |
196 | /// <param name="startFolder"> | ||
197 | /// The folder from which the path starts | ||
198 | /// </param> | ||
199 | /// <param name="path"> | ||
200 | /// <param name="path"> | ||
201 | /// The path to the required item. | ||
202 | /// </param> | ||
203 | /// <returns>null if the item is not found</returns> | 197 | /// <returns>null if the item is not found</returns> |
204 | public static InventoryItemBase FindItemByPath( | 198 | public static InventoryItemBase FindItemByPath( |
205 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) | 199 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs index c6bd296..bacf7c1 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs | |||
@@ -53,6 +53,25 @@ namespace OpenSim.Region.Framework.Tests | |||
53 | public class UserInventoryTests | 53 | public class UserInventoryTests |
54 | { | 54 | { |
55 | [Test] | 55 | [Test] |
56 | public void TestGiveInventoryItem() | ||
57 | { | ||
58 | TestHelper.InMethod(); | ||
59 | // log4net.Config.XmlConfigurator.Configure(); | ||
60 | |||
61 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | ||
63 | UserAccount user2 = UserAccountHelpers.CreateUserWithInventory(scene); | ||
64 | InventoryItemBase item1 = UserInventoryHelpers.CreateInventoryItem(scene, "item1", user1.PrincipalID); | ||
65 | |||
66 | scene.GiveInventoryItem(user2.PrincipalID, user1.PrincipalID, item1.ID); | ||
67 | |||
68 | InventoryItemBase retrievedItem1 | ||
69 | = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Objects/item1"); | ||
70 | |||
71 | Assert.That(retrievedItem1, Is.Not.Null); | ||
72 | } | ||
73 | |||
74 | [Test] | ||
56 | public void TestGiveInventoryFolder() | 75 | public void TestGiveInventoryFolder() |
57 | { | 76 | { |
58 | TestHelper.InMethod(); | 77 | TestHelper.InMethod(); |
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs index 03215f2..93b655a 100644 --- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs | |||
@@ -43,7 +43,20 @@ namespace OpenSim.Tests.Common | |||
43 | public static readonly string PATH_DELIMITER = "/"; | 43 | public static readonly string PATH_DELIMITER = "/"; |
44 | 44 | ||
45 | /// <summary> | 45 | /// <summary> |
46 | /// Creates a notecard in the objects folder. | 46 | /// Creates a notecard in the objects folder and specify an item id. |
47 | /// </summary> | ||
48 | /// <param name="scene"></param> | ||
49 | /// <param name="itemName"></param> | ||
50 | /// <param name="itemId"></param> | ||
51 | /// <param name="userId"></param> | ||
52 | /// <returns></returns> | ||
53 | public static InventoryItemBase CreateInventoryItem(Scene scene, string itemName, UUID userId) | ||
54 | { | ||
55 | return CreateInventoryItem(scene, itemName, UUID.Random(), userId); | ||
56 | } | ||
57 | |||
58 | /// <summary> | ||
59 | /// Creates a notecard in the objects folder and specify an item id. | ||
47 | /// </summary> | 60 | /// </summary> |
48 | /// <param name="scene"></param> | 61 | /// <param name="scene"></param> |
49 | /// <param name="itemName"></param> | 62 | /// <param name="itemName"></param> |
@@ -139,5 +152,18 @@ namespace OpenSim.Tests.Common | |||
139 | else | 152 | else |
140 | return null; | 153 | return null; |
141 | } | 154 | } |
155 | |||
156 | /// <summary> | ||
157 | /// Get the inventory item that matches the path name. If there are multiple items then only the first | ||
158 | /// is returned. | ||
159 | /// </summary> | ||
160 | /// <param name="inventoryService"></param> | ||
161 | /// <param name="userId"></param> | ||
162 | /// <param name="path"></param> | ||
163 | /// <returns>null if no item matching the path was found</returns> | ||
164 | public static InventoryItemBase GetInventoryItem(IInventoryService inventoryService, UUID userId, string path) | ||
165 | { | ||
166 | return InventoryArchiveUtils.FindItemByPath(inventoryService, userId, path); | ||
167 | } | ||
142 | } | 168 | } |
143 | } \ No newline at end of file | 169 | } \ No newline at end of file |