diff options
Diffstat (limited to 'OpenSim')
9 files changed, 356 insertions, 102 deletions
diff --git a/OpenSim/Data/Tests/BasicEstateTest.cs b/OpenSim/Data/Tests/BasicEstateTest.cs index 284d066..7a63c67 100644 --- a/OpenSim/Data/Tests/BasicEstateTest.cs +++ b/OpenSim/Data/Tests/BasicEstateTest.cs | |||
@@ -155,9 +155,8 @@ namespace OpenSim.Data.Tests | |||
155 | } | 155 | } |
156 | 156 | ||
157 | [Test] | 157 | [Test] |
158 | private void T012_EstateSettingsRandomStorage() | 158 | public void T012_EstateSettingsRandomStorage() |
159 | { | 159 | { |
160 | |||
161 | // Letting estate store generate rows to database for us | 160 | // Letting estate store generate rows to database for us |
162 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); | 161 | EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID); |
163 | new PropertyScrambler<EstateSettings>().Scramble(originalSettings); | 162 | new PropertyScrambler<EstateSettings>().Scramble(originalSettings); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 38bd149..ff583e5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -42,6 +42,7 @@ using OpenSim.Framework.Communications.Osp; | |||
42 | using OpenSim.Framework.Serialization; | 42 | using OpenSim.Framework.Serialization; |
43 | using OpenSim.Framework.Serialization.External; | 43 | using OpenSim.Framework.Serialization.External; |
44 | using OpenSim.Region.CoreModules.World.Archiver; | 44 | using OpenSim.Region.CoreModules.World.Archiver; |
45 | using OpenSim.Region.Framework.Scenes; | ||
45 | using OpenSim.Services.Interfaces; | 46 | using OpenSim.Services.Interfaces; |
46 | 47 | ||
47 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | 48 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver |
@@ -56,31 +57,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
56 | private string m_invPath; | 57 | private string m_invPath; |
57 | 58 | ||
58 | /// <value> | 59 | /// <value> |
60 | /// We only use this to request modules | ||
61 | /// </value> | ||
62 | protected Scene m_scene; | ||
63 | |||
64 | /// <value> | ||
59 | /// The stream from which the inventory archive will be loaded. | 65 | /// The stream from which the inventory archive will be loaded. |
60 | /// </value> | 66 | /// </value> |
61 | private Stream m_loadStream; | 67 | private Stream m_loadStream; |
62 | 68 | ||
63 | protected CommunicationsManager m_commsManager; | ||
64 | protected IAssetService m_assetService; | ||
65 | |||
66 | public InventoryArchiveReadRequest( | 69 | public InventoryArchiveReadRequest( |
67 | CachedUserInfo userInfo, string invPath, string loadPath, CommunicationsManager commsManager, IAssetService assetService) | 70 | Scene scene, CachedUserInfo userInfo, string invPath, string loadPath) |
68 | : this( | 71 | : this( |
72 | scene, | ||
69 | userInfo, | 73 | userInfo, |
70 | invPath, | 74 | invPath, |
71 | new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress), | 75 | new GZipStream(new FileStream(loadPath, FileMode.Open), CompressionMode.Decompress)) |
72 | commsManager, assetService) | ||
73 | { | 76 | { |
74 | } | 77 | } |
75 | 78 | ||
76 | public InventoryArchiveReadRequest( | 79 | public InventoryArchiveReadRequest( |
77 | CachedUserInfo userInfo, string invPath, Stream loadStream, CommunicationsManager commsManager, IAssetService assetService) | 80 | Scene scene, CachedUserInfo userInfo, string invPath, Stream loadStream) |
78 | { | 81 | { |
82 | m_scene = scene; | ||
79 | m_userInfo = userInfo; | 83 | m_userInfo = userInfo; |
80 | m_invPath = invPath; | 84 | m_invPath = invPath; |
81 | m_loadStream = loadStream; | 85 | m_loadStream = loadStream; |
82 | m_commsManager = commsManager; | ||
83 | m_assetService = assetService; | ||
84 | } | 86 | } |
85 | 87 | ||
86 | /// <summary> | 88 | /// <summary> |
@@ -98,6 +100,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
98 | int successfulItemRestores = 0; | 100 | int successfulItemRestores = 0; |
99 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); | 101 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); |
100 | 102 | ||
103 | /* | ||
101 | if (!m_userInfo.HasReceivedInventory) | 104 | if (!m_userInfo.HasReceivedInventory) |
102 | { | 105 | { |
103 | // If the region server has access to the user admin service (by which users are created), | 106 | // If the region server has access to the user admin service (by which users are created), |
@@ -106,7 +109,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
106 | // | 109 | // |
107 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might | 110 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might |
108 | // use a remote inventory service, though this is vanishingly rare at the moment. | 111 | // use a remote inventory service, though this is vanishingly rare at the moment. |
109 | if (null == m_commsManager.UserAdminService) | 112 | if (null == m_scene.CommsManager.UserAdminService) |
110 | { | 113 | { |
111 | m_log.ErrorFormat( | 114 | m_log.ErrorFormat( |
112 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", | 115 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", |
@@ -125,8 +128,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
125 | } | 128 | } |
126 | } | 129 | } |
127 | } | 130 | } |
128 | 131 | */ | |
129 | InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); | 132 | |
133 | //InventoryFolderImpl rootDestinationFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); | ||
134 | InventoryFolderBase rootDestinationFolder | ||
135 | = InventoryArchiveUtils.FindFolderByPath( | ||
136 | m_scene.InventoryService, m_userInfo.UserProfile.ID, m_invPath); | ||
130 | 137 | ||
131 | if (null == rootDestinationFolder) | 138 | if (null == rootDestinationFolder) |
132 | { | 139 | { |
@@ -140,7 +147,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
140 | 147 | ||
141 | // In order to load identically named folders, we need to keep track of the folders that we have already | 148 | // In order to load identically named folders, we need to keep track of the folders that we have already |
142 | // created | 149 | // created |
143 | Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>(); | 150 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); |
144 | 151 | ||
145 | byte[] data; | 152 | byte[] data; |
146 | TarArchiveReader.TarEntryType entryType; | 153 | TarArchiveReader.TarEntryType entryType; |
@@ -155,7 +162,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
155 | } | 162 | } |
156 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) | 163 | else if (filePath.StartsWith(ArchiveConstants.INVENTORY_PATH)) |
157 | { | 164 | { |
158 | InventoryFolderImpl foundFolder | 165 | InventoryFolderBase foundFolder |
159 | = ReplicateArchivePathToUserInventory( | 166 | = ReplicateArchivePathToUserInventory( |
160 | filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, | 167 | filePath, TarArchiveReader.TarEntryType.TYPE_DIRECTORY == entryType, |
161 | rootDestinationFolder, foldersCreated, nodesLoaded); | 168 | rootDestinationFolder, foldersCreated, nodesLoaded); |
@@ -167,7 +174,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
167 | // Don't use the item ID that's in the file | 174 | // Don't use the item ID that's in the file |
168 | item.ID = UUID.Random(); | 175 | item.ID = UUID.Random(); |
169 | 176 | ||
170 | UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_commsManager); | 177 | UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager); |
171 | if (UUID.Zero != ospResolvedId) | 178 | if (UUID.Zero != ospResolvedId) |
172 | item.CreatorIdAsUuid = ospResolvedId; | 179 | item.CreatorIdAsUuid = ospResolvedId; |
173 | 180 | ||
@@ -176,7 +183,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
176 | // Reset folder ID to the one in which we want to load it | 183 | // Reset folder ID to the one in which we want to load it |
177 | item.Folder = foundFolder.ID; | 184 | item.Folder = foundFolder.ID; |
178 | 185 | ||
179 | m_userInfo.AddItem(item); | 186 | //m_userInfo.AddItem(item); |
187 | m_scene.InventoryService.AddItem(item); | ||
180 | successfulItemRestores++; | 188 | successfulItemRestores++; |
181 | 189 | ||
182 | // If we're loading an item directly into the given destination folder then we need to record | 190 | // If we're loading an item directly into the given destination folder then we need to record |
@@ -209,11 +217,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
209 | /// chain, only the root node needs to be recorded | 217 | /// chain, only the root node needs to be recorded |
210 | /// </param> | 218 | /// </param> |
211 | /// <returns>The last user inventory folder created or found for the archive path</returns> | 219 | /// <returns>The last user inventory folder created or found for the archive path</returns> |
212 | public InventoryFolderImpl ReplicateArchivePathToUserInventory( | 220 | public InventoryFolderBase ReplicateArchivePathToUserInventory( |
213 | string fsPath, | 221 | string fsPath, |
214 | bool isDir, | 222 | bool isDir, |
215 | InventoryFolderImpl rootDestinationFolder, | 223 | InventoryFolderBase rootDestFolder, |
216 | Dictionary <string, InventoryFolderImpl> foldersCreated, | 224 | Dictionary <string, InventoryFolderBase> foldersCreated, |
217 | List<InventoryNodeBase> nodesLoaded) | 225 | List<InventoryNodeBase> nodesLoaded) |
218 | { | 226 | { |
219 | fsPath = fsPath.Substring(ArchiveConstants.INVENTORY_PATH.Length); | 227 | fsPath = fsPath.Substring(ArchiveConstants.INVENTORY_PATH.Length); |
@@ -226,17 +234,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
226 | 234 | ||
227 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); | 235 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Loading to folder {0}", fsPath); |
228 | 236 | ||
229 | InventoryFolderImpl foundFolder = null; | 237 | InventoryFolderBase destFolder = null; |
230 | 238 | ||
231 | // XXX: Nasty way of dealing with a path that has no directory component | 239 | // XXX: Nasty way of dealing with a path that has no directory component |
232 | if (fsPath.Length > 0) | 240 | if (fsPath.Length > 0) |
233 | { | 241 | { |
234 | while (null == foundFolder && fsPath.Length > 0) | 242 | while (null == destFolder && fsPath.Length > 0) |
235 | { | 243 | { |
236 | if (foldersCreated.ContainsKey(fsPath)) | 244 | if (foldersCreated.ContainsKey(fsPath)) |
237 | { | 245 | { |
238 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Found previously created fs path {0}", fsPath); | 246 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Found previously created fs path {0}", fsPath); |
239 | foundFolder = foldersCreated[fsPath]; | 247 | destFolder = foldersCreated[fsPath]; |
240 | } | 248 | } |
241 | else | 249 | else |
242 | { | 250 | { |
@@ -253,14 +261,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
253 | "[INVENTORY ARCHIVER]: Found no previously created fs path for {0}", | 261 | "[INVENTORY ARCHIVER]: Found no previously created fs path for {0}", |
254 | originalFsPath); | 262 | originalFsPath); |
255 | fsPath = string.Empty; | 263 | fsPath = string.Empty; |
256 | foundFolder = rootDestinationFolder; | 264 | destFolder = rootDestFolder; |
257 | } | 265 | } |
258 | } | 266 | } |
259 | } | 267 | } |
260 | } | 268 | } |
261 | else | 269 | else |
262 | { | 270 | { |
263 | foundFolder = rootDestinationFolder; | 271 | destFolder = rootDestFolder; |
264 | } | 272 | } |
265 | 273 | ||
266 | string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); | 274 | string fsPathSectionToCreate = originalFsPath.Substring(fsPath.Length); |
@@ -275,30 +283,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
275 | int identicalNameIdentifierIndex | 283 | int identicalNameIdentifierIndex |
276 | = rawDirsToCreate[i].LastIndexOf( | 284 | = rawDirsToCreate[i].LastIndexOf( |
277 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); | 285 | ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR); |
278 | string folderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); | ||
279 | 286 | ||
287 | string newFolderName = rawDirsToCreate[i].Remove(identicalNameIdentifierIndex); | ||
280 | UUID newFolderId = UUID.Random(); | 288 | UUID newFolderId = UUID.Random(); |
281 | m_userInfo.CreateFolder( | 289 | |
282 | folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); | 290 | destFolder |
283 | 291 | = new InventoryFolderBase( | |
284 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName); | 292 | newFolderId, newFolderName, m_userInfo.UserProfile.ID, |
285 | foundFolder = foundFolder.GetChildFolder(newFolderId); | 293 | (short)AssetType.Folder, destFolder.ID, 0); |
286 | m_log.DebugFormat( | 294 | m_scene.InventoryService.AddFolder(destFolder); |
287 | "[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}", | 295 | |
288 | foundFolder.Name, foundFolder.ID); | 296 | // UUID newFolderId = UUID.Random(); |
297 | // m_scene.InventoryService.AddFolder( | ||
298 | // m_userInfo.CreateFolder( | ||
299 | // folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID); | ||
300 | |||
301 | // m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName); | ||
302 | // foundFolder = foundFolder.GetChildFolder(newFolderId); | ||
303 | // m_log.DebugFormat( | ||
304 | // "[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}", | ||
305 | // foundFolder.Name, foundFolder.ID); | ||
289 | 306 | ||
290 | // Record that we have now created this folder | 307 | // Record that we have now created this folder |
291 | fsPath += rawDirsToCreate[i] + "/"; | 308 | fsPath += rawDirsToCreate[i] + "/"; |
292 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath); | 309 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Recording creation of fs path {0}", fsPath); |
293 | foldersCreated[fsPath] = foundFolder; | 310 | foldersCreated[fsPath] = destFolder; |
294 | 311 | ||
295 | if (0 == i) | 312 | if (0 == i) |
296 | nodesLoaded.Add(foundFolder); | 313 | nodesLoaded.Add(destFolder); |
297 | 314 | ||
298 | i++; | 315 | i++; |
299 | } | 316 | } |
300 | 317 | ||
301 | return foundFolder; | 318 | return destFolder; |
302 | 319 | ||
303 | /* | 320 | /* |
304 | string[] rawFolders = filePath.Split(new char[] { '/' }); | 321 | string[] rawFolders = filePath.Split(new char[] { '/' }); |
@@ -371,7 +388,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
371 | asset.Type = assetType; | 388 | asset.Type = assetType; |
372 | asset.Data = data; | 389 | asset.Data = data; |
373 | 390 | ||
374 | m_assetService.Store(asset); | 391 | m_scene.AssetService.Store(asset); |
375 | 392 | ||
376 | return true; | 393 | return true; |
377 | } | 394 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs new file mode 100644 index 0000000..2eeb637 --- /dev/null +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveUtils.cs | |||
@@ -0,0 +1,212 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Services.Interfaces; | ||
33 | |||
34 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Utility methods for inventory archiving | ||
38 | /// </summary> | ||
39 | public static class InventoryArchiveUtils | ||
40 | { | ||
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 | } | ||
75 | |||
76 | /// <summary> | ||
77 | /// Find a folder given a PATH_DELIMITER delimited path starting from this folder | ||
78 | /// </summary> | ||
79 | /// | ||
80 | /// This method does not handle paths that contain multiple delimitors | ||
81 | /// | ||
82 | /// FIXME: We do not yet handle situations where folders have the same name. We could handle this by some | ||
83 | /// XPath like expression | ||
84 | /// | ||
85 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. | ||
86 | /// | ||
87 | /// <param name="inventoryService"> | ||
88 | /// Inventory service to query | ||
89 | /// </param> | ||
90 | /// <param name="startFolder"> | ||
91 | /// The folder from which the path starts | ||
92 | /// </param> | ||
93 | /// <param name="path"> | ||
94 | /// The path to the required folder. | ||
95 | /// It this is empty or consists only of the PATH_DELIMTER then this folder itself is returned. | ||
96 | /// </param> | ||
97 | /// <returns>null if the folder is not found</returns> | ||
98 | public static InventoryFolderBase FindFolderByPath( | ||
99 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) | ||
100 | { | ||
101 | if (path == string.Empty) | ||
102 | return startFolder; | ||
103 | |||
104 | path = path.Trim(); | ||
105 | |||
106 | if (path == PATH_DELIMITER) | ||
107 | return startFolder; | ||
108 | |||
109 | InventoryFolderBase foundFolder = null; | ||
110 | |||
111 | string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); | ||
112 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); | ||
113 | |||
114 | foreach (InventoryFolderBase folder in contents.Folders) | ||
115 | { | ||
116 | if (folder.Name == components[0]) | ||
117 | { | ||
118 | if (components.Length > 1) | ||
119 | return FindFolderByPath(inventoryService, foundFolder, components[1]); | ||
120 | else | ||
121 | return folder; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | // We didn't find a folder with the right name | ||
126 | return null; | ||
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 | } | ||
160 | |||
161 | /// <summary> | ||
162 | /// Find an item given a PATH_DELIMITOR delimited path starting from this folder. | ||
163 | /// | ||
164 | /// This method does not handle paths that contain multiple delimitors | ||
165 | /// | ||
166 | /// FIXME: We do not yet handle situations where folders or items have the same name. We could handle this by some | ||
167 | /// XPath like expression | ||
168 | /// | ||
169 | /// FIXME: Delimitors which occur in names themselves are not currently escapable. | ||
170 | /// </summary> | ||
171 | /// | ||
172 | /// <param name="inventoryService"> | ||
173 | /// Inventory service to query | ||
174 | /// </param> | ||
175 | /// <param name="startFolder"> | ||
176 | /// The folder from which the path starts | ||
177 | /// </param> | ||
178 | /// <param name="path"> | ||
179 | /// <param name="path"> | ||
180 | /// The path to the required item. | ||
181 | /// </param> | ||
182 | /// <returns>null if the item is not found</returns> | ||
183 | public static InventoryItemBase FindItemByPath( | ||
184 | IInventoryService inventoryService, InventoryFolderBase startFolder, string path) | ||
185 | { | ||
186 | string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); | ||
187 | |||
188 | if (components.Length == 1) | ||
189 | { | ||
190 | List<InventoryItemBase> items = inventoryService.GetFolderItems(startFolder.Owner, startFolder.ID); | ||
191 | foreach (InventoryItemBase item in items) | ||
192 | { | ||
193 | if (item.Name == components[0]) | ||
194 | return item; | ||
195 | } | ||
196 | } | ||
197 | else | ||
198 | { | ||
199 | InventoryCollection contents = inventoryService.GetFolderContent(startFolder.Owner, startFolder.ID); | ||
200 | |||
201 | foreach (InventoryFolderBase folder in contents.Folders) | ||
202 | { | ||
203 | if (folder.Name == components[0]) | ||
204 | return FindItemByPath(inventoryService, folder, components[1]); | ||
205 | } | ||
206 | } | ||
207 | |||
208 | // We didn't find an item or intermediate folder with the given name | ||
209 | return null; | ||
210 | } | ||
211 | } | ||
212 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 18728c6..dee4a5d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -60,6 +60,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
60 | protected UuidGatherer m_assetGatherer; | 60 | protected UuidGatherer m_assetGatherer; |
61 | 61 | ||
62 | /// <value> | 62 | /// <value> |
63 | /// We only use this to request modules | ||
64 | /// </value> | ||
65 | protected Scene m_scene; | ||
66 | |||
67 | /// <value> | ||
63 | /// ID of this request | 68 | /// ID of this request |
64 | /// </value> | 69 | /// </value> |
65 | protected Guid m_id; | 70 | protected Guid m_id; |
@@ -83,10 +88,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
83 | /// Constructor | 88 | /// Constructor |
84 | /// </summary> | 89 | /// </summary> |
85 | public InventoryArchiveWriteRequest( | 90 | public InventoryArchiveWriteRequest( |
86 | Guid id, InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, string savePath) | 91 | Guid id, InventoryArchiverModule module, Scene scene, |
92 | CachedUserInfo userInfo, string invPath, string savePath) | ||
87 | : this( | 93 | : this( |
88 | id, | 94 | id, |
89 | module, | 95 | module, |
96 | scene, | ||
90 | userInfo, | 97 | userInfo, |
91 | invPath, | 98 | invPath, |
92 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) | 99 | new GZipStream(new FileStream(savePath, FileMode.Create), CompressionMode.Compress)) |
@@ -97,14 +104,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
97 | /// Constructor | 104 | /// Constructor |
98 | /// </summary> | 105 | /// </summary> |
99 | public InventoryArchiveWriteRequest( | 106 | public InventoryArchiveWriteRequest( |
100 | Guid id, InventoryArchiverModule module, CachedUserInfo userInfo, string invPath, Stream saveStream) | 107 | Guid id, InventoryArchiverModule module, Scene scene, |
108 | CachedUserInfo userInfo, string invPath, Stream saveStream) | ||
101 | { | 109 | { |
102 | m_id = id; | 110 | m_id = id; |
103 | m_module = module; | 111 | m_module = module; |
112 | m_scene = scene; | ||
104 | m_userInfo = userInfo; | 113 | m_userInfo = userInfo; |
105 | m_invPath = invPath; | 114 | m_invPath = invPath; |
106 | m_saveStream = saveStream; | 115 | m_saveStream = saveStream; |
107 | m_assetGatherer = new UuidGatherer(m_module.AssetService); | 116 | m_assetGatherer = new UuidGatherer(m_scene.AssetService); |
108 | } | 117 | } |
109 | 118 | ||
110 | protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) | 119 | protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids) |
@@ -135,7 +144,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
135 | m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; | 144 | m_userUuids[inventoryItem.CreatorIdAsUuid] = 1; |
136 | 145 | ||
137 | InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone(); | 146 | InventoryItemBase saveItem = (InventoryItemBase)inventoryItem.Clone(); |
138 | saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_module.CommsManager); | 147 | saveItem.CreatorId = OspResolver.MakeOspa(saveItem.CreatorIdAsUuid, m_scene.CommsManager); |
139 | 148 | ||
140 | string serialization = UserInventoryItemSerializer.Serialize(saveItem); | 149 | string serialization = UserInventoryItemSerializer.Serialize(saveItem); |
141 | m_archiveWriter.WriteFile(filename, serialization); | 150 | m_archiveWriter.WriteFile(filename, serialization); |
@@ -149,7 +158,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
149 | /// <param name="inventoryFolder">The inventory folder to save</param> | 158 | /// <param name="inventoryFolder">The inventory folder to save</param> |
150 | /// <param name="path">The path to which the folder should be saved</param> | 159 | /// <param name="path">The path to which the folder should be saved</param> |
151 | /// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param> | 160 | /// <param name="saveThisFolderItself">If true, save this folder itself. If false, only saves contents</param> |
152 | protected void SaveInvFolder(InventoryFolderImpl inventoryFolder, string path, bool saveThisFolderItself) | 161 | protected void SaveInvFolder(InventoryFolderBase inventoryFolder, string path, bool saveThisFolderItself) |
153 | { | 162 | { |
154 | if (saveThisFolderItself) | 163 | if (saveThisFolderItself) |
155 | { | 164 | { |
@@ -164,15 +173,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
164 | m_archiveWriter.WriteDir(path); | 173 | m_archiveWriter.WriteDir(path); |
165 | } | 174 | } |
166 | 175 | ||
167 | List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls(); | 176 | InventoryCollection contents |
168 | List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); | 177 | = m_scene.InventoryService.GetFolderContent(inventoryFolder.Owner, inventoryFolder.ID); |
178 | //List<InventoryFolderImpl> childFolders = inventoryFolder.RequestListOfFolderImpls(); | ||
179 | //List<InventoryItemBase> items = inventoryFolder.RequestListOfItems(); | ||
169 | 180 | ||
170 | /* | 181 | /* |
171 | Dictionary identicalFolderNames = new Dictionary<string, int>(); | 182 | Dictionary identicalFolderNames = new Dictionary<string, int>(); |
172 | 183 | ||
173 | foreach (InventoryFolderImpl folder in inventories) | 184 | foreach (InventoryFolderImpl folder in inventories) |
174 | { | 185 | { |
175 | |||
176 | if (!identicalFolderNames.ContainsKey(folder.Name)) | 186 | if (!identicalFolderNames.ContainsKey(folder.Name)) |
177 | identicalFolderNames[folder.Name] = 0; | 187 | identicalFolderNames[folder.Name] = 0; |
178 | else | 188 | else |
@@ -188,12 +198,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
188 | } | 198 | } |
189 | */ | 199 | */ |
190 | 200 | ||
191 | foreach (InventoryFolderImpl childFolder in childFolders) | 201 | foreach (InventoryFolderBase childFolder in contents.Folders) |
192 | { | 202 | { |
193 | SaveInvFolder(childFolder, path, true); | 203 | SaveInvFolder(childFolder, path, true); |
194 | } | 204 | } |
195 | 205 | ||
196 | foreach (InventoryItemBase item in items) | 206 | foreach (InventoryItemBase item in contents.Items) |
197 | { | 207 | { |
198 | SaveInvItem(item, path); | 208 | SaveInvItem(item, path); |
199 | } | 209 | } |
@@ -204,9 +214,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
204 | /// </summary> | 214 | /// </summary> |
205 | public void Execute() | 215 | public void Execute() |
206 | { | 216 | { |
207 | InventoryFolderImpl inventoryFolder = null; | 217 | InventoryFolderBase inventoryFolder = null; |
208 | InventoryItemBase inventoryItem = null; | 218 | InventoryItemBase inventoryItem = null; |
219 | InventoryFolderBase rootFolder = m_scene.InventoryService.GetRootFolder(m_userInfo.UserProfile.ID); | ||
209 | 220 | ||
221 | // XXX: Very temporarily, drop and refetch inventory to make sure we have any newly created items in cache | ||
222 | // This will disappear very soon once we stop using the old cached inventory. | ||
223 | /* | ||
224 | m_userInfo.DropInventory(); | ||
225 | m_userInfo.FetchInventory(); | ||
226 | */ | ||
227 | |||
228 | /* | ||
210 | if (!m_userInfo.HasReceivedInventory) | 229 | if (!m_userInfo.HasReceivedInventory) |
211 | { | 230 | { |
212 | // If the region server has access to the user admin service (by which users are created), | 231 | // If the region server has access to the user admin service (by which users are created), |
@@ -215,7 +234,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
215 | // | 234 | // |
216 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might | 235 | // FIXME: FetchInventory should probably be assumed to by async anyway, since even standalones might |
217 | // use a remote inventory service, though this is vanishingly rare at the moment. | 236 | // use a remote inventory service, though this is vanishingly rare at the moment. |
218 | if (null == m_module.CommsManager.UserAdminService) | 237 | if (null == m_scene.CommsManager.UserAdminService) |
219 | { | 238 | { |
220 | m_log.ErrorFormat( | 239 | m_log.ErrorFormat( |
221 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", | 240 | "[INVENTORY ARCHIVER]: Have not yet received inventory info for user {0} {1}", |
@@ -228,11 +247,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
228 | m_userInfo.FetchInventory(); | 247 | m_userInfo.FetchInventory(); |
229 | } | 248 | } |
230 | } | 249 | } |
250 | */ | ||
231 | 251 | ||
232 | bool foundStar = false; | 252 | bool foundStar = false; |
233 | 253 | ||
234 | // Eliminate double slashes and any leading / on the path. This might be better done within InventoryFolderImpl | 254 | // Eliminate double slashes and any leading / on the path. |
235 | // itself (possibly at a small loss in efficiency). | ||
236 | string[] components | 255 | string[] components |
237 | = m_invPath.Split( | 256 | = m_invPath.Split( |
238 | new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); | 257 | new string[] { InventoryFolderImpl.PATH_DELIMITER }, StringSplitOptions.RemoveEmptyEntries); |
@@ -257,18 +276,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
257 | // Therefore if we still start with a / after the split, then we need the root folder | 276 | // Therefore if we still start with a / after the split, then we need the root folder |
258 | if (m_invPath.Length == 0) | 277 | if (m_invPath.Length == 0) |
259 | { | 278 | { |
260 | inventoryFolder = m_userInfo.RootFolder; | 279 | inventoryFolder = rootFolder; |
261 | } | 280 | } |
262 | else | 281 | else |
263 | { | 282 | { |
264 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); | 283 | m_invPath = m_invPath.Remove(m_invPath.LastIndexOf(InventoryFolderImpl.PATH_DELIMITER)); |
265 | inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); | 284 | inventoryFolder |
285 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, rootFolder, m_invPath); | ||
286 | //inventoryFolder = m_userInfo.RootFolder.FindFolderByPath(m_invPath); | ||
266 | } | 287 | } |
267 | 288 | ||
268 | // The path may point to an item instead | 289 | // The path may point to an item instead |
269 | if (inventoryFolder == null) | 290 | if (inventoryFolder == null) |
270 | { | 291 | { |
271 | inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); | 292 | inventoryItem = InventoryArchiveUtils.FindItemByPath(m_scene.InventoryService, rootFolder, m_invPath); |
293 | //inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath); | ||
272 | } | 294 | } |
273 | 295 | ||
274 | m_archiveWriter = new TarArchiveWriter(m_saveStream); | 296 | m_archiveWriter = new TarArchiveWriter(m_saveStream); |
@@ -306,7 +328,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
306 | SaveUsers(); | 328 | SaveUsers(); |
307 | new AssetsRequest( | 329 | new AssetsRequest( |
308 | new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, | 330 | new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, |
309 | m_module.AssetService, ReceivedAllAssets).Execute(); | 331 | m_scene.AssetService, ReceivedAllAssets).Execute(); |
310 | } | 332 | } |
311 | 333 | ||
312 | /// <summary> | 334 | /// <summary> |
@@ -320,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
320 | { | 342 | { |
321 | // Record the creator of this item | 343 | // Record the creator of this item |
322 | CachedUserInfo creator | 344 | CachedUserInfo creator |
323 | = m_module.CommsManager.UserProfileCacheService.GetUserDetails(creatorId); | 345 | = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(creatorId); |
324 | 346 | ||
325 | if (creator != null) | 347 | if (creator != null) |
326 | { | 348 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 55d7997..2c36270 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -69,19 +69,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
69 | /// </value> | 69 | /// </value> |
70 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | 70 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); |
71 | private Scene m_aScene; | 71 | private Scene m_aScene; |
72 | |||
73 | /// <value> | ||
74 | /// The comms manager we will use for all comms requests | ||
75 | /// </value> | ||
76 | protected internal CommunicationsManager CommsManager; | ||
77 | protected internal IAssetService AssetService; | ||
78 | 72 | ||
79 | public void Initialise(Scene scene, IConfigSource source) | 73 | public void Initialise(Scene scene, IConfigSource source) |
80 | { | 74 | { |
81 | if (m_scenes.Count == 0) | 75 | if (m_scenes.Count == 0) |
82 | { | 76 | { |
83 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); | 77 | scene.RegisterModuleInterface<IInventoryArchiverModule>(this); |
84 | CommsManager = scene.CommsManager; | ||
85 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; | 78 | OnInventoryArchiveSaved += SaveInvConsoleCommandCompleted; |
86 | 79 | ||
87 | scene.AddCommand( | 80 | scene.AddCommand( |
@@ -99,11 +92,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
99 | 92 | ||
100 | m_scenes[scene.RegionInfo.RegionID] = scene; | 93 | m_scenes[scene.RegionInfo.RegionID] = scene; |
101 | } | 94 | } |
102 | 95 | ||
103 | public void PostInitialise() | 96 | public void PostInitialise() {} |
104 | { | ||
105 | AssetService = m_aScene.AssetService; | ||
106 | } | ||
107 | 97 | ||
108 | public void Close() {} | 98 | public void Close() {} |
109 | 99 | ||
@@ -126,7 +116,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
126 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); | 116 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); |
127 | 117 | ||
128 | if (userInfo != null) | 118 | if (userInfo != null) |
129 | new InventoryArchiveWriteRequest(id, this, userInfo, invPath, saveStream).Execute(); | 119 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); |
130 | } | 120 | } |
131 | } | 121 | } |
132 | 122 | ||
@@ -137,7 +127,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
137 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); | 127 | CachedUserInfo userInfo = GetUserInfo(firstName, lastName); |
138 | 128 | ||
139 | if (userInfo != null) | 129 | if (userInfo != null) |
140 | new InventoryArchiveWriteRequest(id, this, userInfo, invPath, savePath).Execute(); | 130 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); |
141 | } | 131 | } |
142 | } | 132 | } |
143 | 133 | ||
@@ -150,7 +140,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
150 | if (userInfo != null) | 140 | if (userInfo != null) |
151 | { | 141 | { |
152 | InventoryArchiveReadRequest request = | 142 | InventoryArchiveReadRequest request = |
153 | new InventoryArchiveReadRequest(userInfo, invPath, loadStream, CommsManager, AssetService); | 143 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); |
154 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 144 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
155 | } | 145 | } |
156 | } | 146 | } |
@@ -165,7 +155,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
165 | if (userInfo != null) | 155 | if (userInfo != null) |
166 | { | 156 | { |
167 | InventoryArchiveReadRequest request = | 157 | InventoryArchiveReadRequest request = |
168 | new InventoryArchiveReadRequest(userInfo, invPath, loadPath, CommsManager, AssetService); | 158 | new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); |
169 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 159 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
170 | } | 160 | } |
171 | } | 161 | } |
@@ -261,7 +251,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
261 | /// <returns></returns> | 251 | /// <returns></returns> |
262 | protected CachedUserInfo GetUserInfo(string firstName, string lastName) | 252 | protected CachedUserInfo GetUserInfo(string firstName, string lastName) |
263 | { | 253 | { |
264 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); | 254 | CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); |
265 | if (null == userInfo) | 255 | if (null == userInfo) |
266 | { | 256 | { |
267 | m_log.ErrorFormat( | 257 | m_log.ErrorFormat( |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index a151c9d..c21adef 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -77,7 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
77 | /// </summary> | 77 | /// </summary> |
78 | // Commenting for now! The mock inventory service needs more beef, at least for | 78 | // Commenting for now! The mock inventory service needs more beef, at least for |
79 | // GetFolderForType | 79 | // GetFolderForType |
80 | //[Test] | 80 | [Test] |
81 | public void TestSaveIarV0_1() | 81 | public void TestSaveIarV0_1() |
82 | { | 82 | { |
83 | TestHelper.InMethod(); | 83 | TestHelper.InMethod(); |
@@ -93,7 +93,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
93 | string userFirstName = "Jock"; | 93 | string userFirstName = "Jock"; |
94 | string userLastName = "Stirrup"; | 94 | string userLastName = "Stirrup"; |
95 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 95 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
96 | // CachedUserInfo userInfo; | ||
97 | 96 | ||
98 | lock (this) | 97 | lock (this) |
99 | { | 98 | { |
@@ -136,16 +135,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
136 | item1.Name = "My Little Dog"; | 135 | item1.Name = "My Little Dog"; |
137 | item1.AssetID = asset1.FullID; | 136 | item1.AssetID = asset1.FullID; |
138 | item1.ID = item1Id; | 137 | item1.ID = item1Id; |
139 | //userInfo.RootFolder.FindFolderByPath("Objects").ID; | 138 | InventoryFolderBase objsFolder |
140 | //InventoryFolderBase objsFolder = scene.InventoryService.GetFolderForType(userId, AssetType.Object); | 139 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userId, "Objects"); |
141 | Console.WriteLine("here2"); | ||
142 | IInventoryService inventoryService = scene.InventoryService; | ||
143 | InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); | ||
144 | InventoryCollection rootContents = inventoryService.GetFolderContent(userId, rootFolder.ID); | ||
145 | InventoryFolderBase objsFolder = null; | ||
146 | foreach (InventoryFolderBase folder in rootContents.Folders) | ||
147 | if (folder.Name == "Objects") | ||
148 | objsFolder = folder; | ||
149 | item1.Folder = objsFolder.ID; | 140 | item1.Folder = objsFolder.ID; |
150 | scene.AddInventoryItem(userId, item1); | 141 | scene.AddInventoryItem(userId, item1); |
151 | 142 | ||
@@ -155,7 +146,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
155 | mre.Reset(); | 146 | mre.Reset(); |
156 | archiverModule.ArchiveInventory( | 147 | archiverModule.ArchiveInventory( |
157 | Guid.NewGuid(), userFirstName, userLastName, "Objects", archiveWriteStream); | 148 | Guid.NewGuid(), userFirstName, userLastName, "Objects", archiveWriteStream); |
158 | mre.WaitOne(); | 149 | mre.WaitOne(60000, false); |
159 | 150 | ||
160 | byte[] archive = archiveWriteStream.ToArray(); | 151 | byte[] archive = archiveWriteStream.ToArray(); |
161 | MemoryStream archiveReadStream = new MemoryStream(archive); | 152 | MemoryStream archiveReadStream = new MemoryStream(archive); |
@@ -275,7 +266,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
275 | CachedUserInfo userInfo | 266 | CachedUserInfo userInfo |
276 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); | 267 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); |
277 | 268 | ||
278 | InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); | 269 | InventoryItemBase foundItem |
270 | = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, itemName); | ||
271 | |||
279 | Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); | 272 | Assert.That(foundItem, Is.Not.Null, "Didn't find loaded item"); |
280 | Assert.That( | 273 | Assert.That( |
281 | foundItem.CreatorId, Is.EqualTo(item1.CreatorId), | 274 | foundItem.CreatorId, Is.EqualTo(item1.CreatorId), |
@@ -385,9 +378,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
385 | Monitor.Wait(this, 60000); | 378 | Monitor.Wait(this, 60000); |
386 | } | 379 | } |
387 | 380 | ||
388 | Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); | 381 | //Console.WriteLine("userInfo.RootFolder 1: {0}", userInfo.RootFolder); |
389 | 382 | ||
390 | Dictionary <string, InventoryFolderImpl> foldersCreated = new Dictionary<string, InventoryFolderImpl>(); | 383 | Dictionary <string, InventoryFolderBase> foldersCreated = new Dictionary<string, InventoryFolderBase>(); |
391 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); | 384 | List<InventoryNodeBase> nodesLoaded = new List<InventoryNodeBase>(); |
392 | 385 | ||
393 | string folder1Name = "a"; | 386 | string folder1Name = "a"; |
@@ -405,17 +398,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
405 | "{0}{1}/{2}/{3}", | 398 | "{0}{1}/{2}/{3}", |
406 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName); | 399 | ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName); |
407 | 400 | ||
408 | Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); | 401 | //Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder); |
409 | 402 | ||
410 | new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null) | 403 | new InventoryArchiveReadRequest(scene, userInfo, null, (Stream)null) |
411 | .ReplicateArchivePathToUserInventory( | 404 | .ReplicateArchivePathToUserInventory( |
412 | itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded); | 405 | itemArchivePath, false, scene.InventoryService.GetRootFolder(userInfo.UserProfile.ID), |
406 | foldersCreated, nodesLoaded); | ||
413 | 407 | ||
414 | Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); | 408 | //Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder); |
415 | InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); | 409 | //InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a"); |
410 | InventoryFolderBase folder1 | ||
411 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, userInfo.UserProfile.ID, "a"); | ||
416 | Assert.That(folder1, Is.Not.Null, "Could not find folder a"); | 412 | Assert.That(folder1, Is.Not.Null, "Could not find folder a"); |
417 | InventoryFolderImpl folder2 = folder1.FindFolderByPath("b"); | 413 | InventoryFolderBase folder2 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, folder1, "b"); |
418 | Assert.That(folder2, Is.Not.Null, "Could not find folder b"); | 414 | Assert.That(folder2, Is.Not.Null, "Could not find folder b"); |
419 | } | 415 | } |
420 | } | 416 | } |
421 | } | 417 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs index 838cafb..917ca44 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/ScriptBase.cs | |||
@@ -112,7 +112,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
112 | if (!inits.ContainsKey(api)) | 112 | if (!inits.ContainsKey(api)) |
113 | return; | 113 | return; |
114 | 114 | ||
115 | ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); | 115 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject); |
116 | RemotingServices.GetLifetimeService(data as MarshalByRefObject); | ||
116 | // lease.Register(m_sponser); | 117 | // lease.Register(m_sponser); |
117 | 118 | ||
118 | MethodInfo mi = inits[api]; | 119 | MethodInfo mi = inits[api]; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 225126d..04f7862 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -260,7 +260,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
260 | Path.GetFileNameWithoutExtension(assembly), | 260 | Path.GetFileNameWithoutExtension(assembly), |
261 | "SecondLife.Script"); | 261 | "SecondLife.Script"); |
262 | 262 | ||
263 | ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | 263 | //ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); |
264 | RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass); | ||
264 | // lease.Register(this); | 265 | // lease.Register(this); |
265 | } | 266 | } |
266 | catch (Exception) | 267 | catch (Exception) |
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs index ce116f2..daef38b 100644 --- a/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/TestInventoryDataPlugin.cs | |||
@@ -84,7 +84,17 @@ namespace OpenSim.Tests.Common.Mock | |||
84 | 84 | ||
85 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) | 85 | public List<InventoryItemBase> getInventoryInFolder(UUID folderID) |
86 | { | 86 | { |
87 | return new List<InventoryItemBase>(); | 87 | m_log.DebugFormat("[MOCK INV DB]: Getting items in folder {0}", folderID); |
88 | |||
89 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | ||
90 | |||
91 | foreach (InventoryItemBase item in m_items.Values) | ||
92 | { | ||
93 | if (item.Folder == folderID) | ||
94 | items.Add(item); | ||
95 | } | ||
96 | |||
97 | return items; | ||
88 | } | 98 | } |
89 | 99 | ||
90 | public List<InventoryFolderBase> getUserRootFolders(UUID user) { return null; } | 100 | public List<InventoryFolderBase> getUserRootFolders(UUID user) { return null; } |
@@ -154,7 +164,13 @@ namespace OpenSim.Tests.Common.Mock | |||
154 | m_folders.Remove(folderId); | 164 | m_folders.Remove(folderId); |
155 | } | 165 | } |
156 | 166 | ||
157 | public void addInventoryItem(InventoryItemBase item) { m_items[item.ID] = item; } | 167 | public void addInventoryItem(InventoryItemBase item) |
168 | { | ||
169 | m_log.DebugFormat( | ||
170 | "[MOCK INV DB]: Adding inventory item {0} {1} in {2}", item.Name, item.ID, item.Folder); | ||
171 | |||
172 | m_items[item.ID] = item; | ||
173 | } | ||
158 | 174 | ||
159 | public void updateInventoryItem(InventoryItemBase item) { addInventoryItem(item); } | 175 | public void updateInventoryItem(InventoryItemBase item) { addInventoryItem(item); } |
160 | 176 | ||