aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs66
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs8
2 files changed, 69 insertions, 5 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
index 6d598d1..2eeb637 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenMetaverse;
30using OpenSim.Framework; 31using OpenSim.Framework;
31using OpenSim.Services.Interfaces; 32using OpenSim.Services.Interfaces;
32 33
@@ -38,6 +39,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
38 public static class InventoryArchiveUtils 39 public static class InventoryArchiveUtils
39 { 40 {
40 public static readonly string PATH_DELIMITER = "/"; 41 public static readonly string PATH_DELIMITER = "/";
42
43 /// <summary>
44 /// Find a folder given a PATH_DELIMITER delimited path starting from a user's root folder
45 /// </summary>
46 ///
47 /// This method does not handle paths that contain multiple delimitors
48 ///
49 /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some
50 /// XPath like expression
51 ///
52 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
53 ///
54 /// <param name="inventoryService">
55 /// Inventory service to query
56 /// </param>
57 /// <param name="userId">
58 /// User id to search
59 /// </param>
60 /// <param name="path">
61 /// The path to the required folder.
62 /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned.
63 /// </param>
64 /// <returns>null if the folder is not found</returns>
65 public static InventoryFolderBase FindFolderByPath(
66 IInventoryService inventoryService, UUID userId, string path)
67 {
68 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
69
70 if (null == rootFolder)
71 return null;
72
73 return FindFolderByPath(inventoryService, rootFolder, path);
74 }
41 75
42 /// <summary> 76 /// <summary>
43 /// Find a folder given a PATH_DELIMITER delimited path starting from this folder 77 /// Find a folder given a PATH_DELIMITER delimited path starting from this folder
@@ -91,6 +125,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
91 // We didn't find a folder with the right name 125 // We didn't find a folder with the right name
92 return null; 126 return null;
93 } 127 }
128
129 /// <summary>
130 /// Find an item given a PATH_DELIMITOR delimited path starting from the user's root folder.
131 ///
132 /// This method does not handle paths that contain multiple delimitors
133 ///
134 /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some
135 /// XPath like expression
136 ///
137 /// FIXME: Delimitors which occur in names themselves are not currently escapable.
138 /// </summary>
139 ///
140 /// <param name="inventoryService">
141 /// Inventory service to query
142 /// </param>
143 /// <param name="userId">
144 /// The user to search
145 /// </param>
146 /// <param name="path">
147 /// The path to the required item.
148 /// </param>
149 /// <returns>null if the item is not found</returns>
150 public static InventoryItemBase FindItemByPath(
151 IInventoryService inventoryService, UUID userId, string path)
152 {
153 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
154
155 if (null == rootFolder)
156 return null;
157
158 return FindItemByPath(inventoryService, rootFolder, path);
159 }
94 160
95 /// <summary> 161 /// <summary>
96 /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. 162 /// Find an item given a PATH_DELIMITOR delimited path starting from this folder.
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
index bdc2802..50fd2b0 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs
@@ -136,8 +136,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
136 item1.AssetID = asset1.FullID; 136 item1.AssetID = asset1.FullID;
137 item1.ID = item1Id; 137 item1.ID = item1Id;
138 InventoryFolderBase objsFolder 138 InventoryFolderBase objsFolder
139 = InventoryArchiveUtils.FindFolderByPath( 139 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects");
140 scene.InventoryService, scene.InventoryService.GetRootFolder(userId), "Objects");
141 item1.Folder = objsFolder.ID; 140 item1.Folder = objsFolder.ID;
142 scene.AddInventoryItem(userId, item1); 141 scene.AddInventoryItem(userId, item1);
143 142
@@ -267,10 +266,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
267 CachedUserInfo userInfo 266 CachedUserInfo userInfo
268 = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); 267 = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
269 268
270 //InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
271 InventoryItemBase foundItem 269 InventoryItemBase foundItem
272 = InventoryArchiveUtils.FindItemByPath( 270 = InventoryArchiveUtils.FindItemByPath( scene.InventoryService, userInfo.UserProfile.ID, itemName);
273 scene.InventoryService, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), itemName); 271
274 Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); 272 Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item");
275 Assert.That( 273 Assert.That(
276 foundItem.CreatorId, Is.EqualTo(item1.CreatorId), 274 foundItem.CreatorId, Is.EqualTo(item1.CreatorId),