aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs45
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs3
3 files changed, 40 insertions, 11 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
index dc665c1..e7fb43a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
@@ -149,14 +149,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
149 149
150 /// <summary> 150 /// <summary>
151 /// Find an item given a PATH_DELIMITOR delimited path starting from the user's root folder. 151 /// Find an item given a PATH_DELIMITOR delimited path starting from the user's root folder.
152 /// 152 /// </summary>
153 /// <remarks>
153 /// This method does not handle paths that contain multiple delimitors 154 /// This method does not handle paths that contain multiple delimitors
154 /// 155 ///
155 /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some 156 /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some
156 /// XPath like expression 157 /// XPath like expression
157 /// 158 ///
158 /// FIXME: Delimitors which occur in names themselves are not currently escapable. 159 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
159 /// </summary> 160 /// </remarks>
160 /// 161 ///
161 /// <param name="inventoryService"> 162 /// <param name="inventoryService">
162 /// Inventory service to query 163 /// Inventory service to query
@@ -178,7 +179,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
178 179
179 return FindItemByPath(inventoryService, rootFolder, path); 180 return FindItemByPath(inventoryService, rootFolder, path);
180 } 181 }
181 182
182 /// <summary> 183 /// <summary>
183 /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. 184 /// Find an item given a PATH_DELIMITOR delimited path starting from this folder.
184 /// </summary> 185 /// </summary>
@@ -190,7 +191,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
190 /// 191 ///
191 /// FIXME: Delimitors which occur in names themselves are not currently escapable. 192 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
192 /// </remarks> 193 /// </remarks>
193 /// 194 ///
194 /// <param name="inventoryService">Inventory service to query</param> 195 /// <param name="inventoryService">Inventory service to query</param>
195 /// <param name="startFolder">The folder from which the path starts</param> 196 /// <param name="startFolder">The folder from which the path starts</param>
196 /// <param name="path">The path to the required item.</param> 197 /// <param name="path">The path to the required item.</param>
@@ -198,6 +199,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
198 public static InventoryItemBase FindItemByPath( 199 public static InventoryItemBase FindItemByPath(
199 IInventoryService inventoryService, InventoryFolderBase startFolder, string path) 200 IInventoryService inventoryService, InventoryFolderBase startFolder, string path)
200 { 201 {
202 List<InventoryItemBase> foundItems = FindItemsByPath(inventoryService, startFolder, path);
203
204 if (foundItems.Count != 0)
205 return foundItems[0];
206 else
207 return null;
208 }
209
210 /// <summary>
211 /// Find items that match a given PATH_DELIMITOR delimited path starting from this folder.
212 /// </summary>
213 /// <remarks>
214 /// This method does not handle paths that contain multiple delimiters
215 ///
216 /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some
217 /// XPath like expression
218 ///
219 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
220 /// </remarks>
221 ///
222 /// <param name="inventoryService">Inventory service to query</param>
223 /// <param name="startFolder">The folder from which the path starts</param>
224 /// <param name="path">The path to the required item.</param>
225 /// <returns>The items that were found with this path. An empty list if no items were found.</returns>
226 public static List<InventoryItemBase> FindItemsByPath(
227 IInventoryService inventoryService, InventoryFolderBase startFolder, string path)
228 {
229 List<InventoryItemBase> foundItems = new List<InventoryItemBase>();
230
201 // If the path isn't just / then trim any starting extraneous slashes 231 // If the path isn't just / then trim any starting extraneous slashes
202 path = path.TrimStart(new char[] { PATH_DELIMITER }); 232 path = path.TrimStart(new char[] { PATH_DELIMITER });
203 233
@@ -221,7 +251,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
221// m_log.DebugFormat("[INVENTORY ARCHIVE UTILS]: Inspecting item {0} {1}", item.Name, item.ID); 251// m_log.DebugFormat("[INVENTORY ARCHIVE UTILS]: Inspecting item {0} {1}", item.Name, item.ID);
222 252
223 if (item.Name == components[0]) 253 if (item.Name == components[0])
224 return item; 254 foundItems.Add(item);
225 } 255 }
226 } 256 }
227 else 257 else
@@ -233,12 +263,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
233 foreach (InventoryFolderBase folder in contents.Folders) 263 foreach (InventoryFolderBase folder in contents.Folders)
234 { 264 {
235 if (folder.Name == components[0]) 265 if (folder.Name == components[0])
236 return FindItemByPath(inventoryService, folder, components[1]); 266 foundItems.AddRange(FindItemsByPath(inventoryService, folder, components[1]));
237 } 267 }
238 } 268 }
239 269
240 // We didn't find an item or intermediate folder with the given name 270 return foundItems;
241 return null;
242 } 271 }
243 272
244 /// <summary> 273 /// <summary>
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
index c34a0ec..c2ad079 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs
@@ -255,10 +255,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
255 255
256 // The path may point to an item instead 256 // The path may point to an item instead
257 if (inventoryFolder == null) 257 if (inventoryFolder == null)
258 {
259 inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath); 258 inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath);
260 //inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath);
261 }
262 259
263 if (null == inventoryFolder && null == inventoryItem) 260 if (null == inventoryFolder && null == inventoryItem)
264 { 261 {
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
index bacf7c1..83f0686 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UserInventoryTests.cs
@@ -69,6 +69,9 @@ namespace OpenSim.Region.Framework.Tests
69 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Objects/item1"); 69 = UserInventoryHelpers.GetInventoryItem(scene.InventoryService, user2.PrincipalID, "Objects/item1");
70 70
71 Assert.That(retrievedItem1, Is.Not.Null); 71 Assert.That(retrievedItem1, Is.Not.Null);
72
73 // Try giving back the freshly received item
74 //scene.GiveInventoryItem(user1.PrincipalID, user2.PrincipalID, retrievedItem1.ID);
72 } 75 }
73 76
74 [Test] 77 [Test]