diff options
author | Justin Clarke Casey | 2008-05-04 00:06:34 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-05-04 00:06:34 +0000 |
commit | 0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae (patch) | |
tree | dfcf0200f8b8661635914a97d6162714aa143e90 /OpenSim | |
parent | * Add ability to defer item actions for AddItem() and DeleteItem(). This won... (diff) | |
download | opensim-SC_OLD-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.zip opensim-SC_OLD-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.tar.gz opensim-SC_OLD-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.tar.bz2 opensim-SC_OLD-0f716e3ac4d8af67fed7c23994d2c0f53d8eb2ae.tar.xz |
* Simplify CreateFolder() by folding previous special root case into FindFolder()
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | 89 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | 34 |
2 files changed, 46 insertions, 77 deletions
diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index 6f7c4da..5b84958 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs | |||
@@ -239,6 +239,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
239 | else | 239 | else |
240 | { | 240 | { |
241 | InventoryFolderImpl folder = RootFolder.FindFolder(folderInfo.ParentID); | 241 | InventoryFolderImpl folder = RootFolder.FindFolder(folderInfo.ParentID); |
242 | |||
242 | lock (folder.SubFolders) | 243 | lock (folder.SubFolders) |
243 | { | 244 | { |
244 | if (folder != null) | 245 | if (folder != null) |
@@ -323,72 +324,40 @@ namespace OpenSim.Framework.Communications.Cache | |||
323 | 324 | ||
324 | if (HasInventory) | 325 | if (HasInventory) |
325 | { | 326 | { |
326 | if (RootFolder.ID == parentID) | 327 | InventoryFolderImpl parentFolder = RootFolder.FindFolder(parentID); |
328 | |||
329 | if (null == parentFolder) | ||
327 | { | 330 | { |
328 | InventoryFolderImpl createdFolder = RootFolder.CreateNewSubFolder(folderID, folderName, folderType); | 331 | m_log.WarnFormat( |
332 | "[AGENT INVENTORY]: Tried to create folder {0} {1} but the parent {2} does not exist", | ||
333 | folderName, folderID, parentID); | ||
334 | |||
335 | return false; | ||
336 | } | ||
337 | |||
338 | InventoryFolderImpl createdFolder = parentFolder.CreateChildFolder(folderID, folderName, folderType); | ||
329 | 339 | ||
330 | if (createdFolder != null) | 340 | if (createdFolder != null) |
331 | { | 341 | { |
332 | InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); | 342 | InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); |
333 | createdBaseFolder.Owner = createdFolder.Owner; | 343 | createdBaseFolder.Owner = createdFolder.Owner; |
334 | createdBaseFolder.ID = createdFolder.ID; | 344 | createdBaseFolder.ID = createdFolder.ID; |
335 | createdBaseFolder.Name = createdFolder.Name; | 345 | createdBaseFolder.Name = createdFolder.Name; |
336 | createdBaseFolder.ParentID = createdFolder.ParentID; | 346 | createdBaseFolder.ParentID = createdFolder.ParentID; |
337 | createdBaseFolder.Type = createdFolder.Type; | 347 | createdBaseFolder.Type = createdFolder.Type; |
338 | createdBaseFolder.Version = createdFolder.Version; | 348 | createdBaseFolder.Version = createdFolder.Version; |
339 | 349 | ||
340 | m_commsManager.InventoryService.AddFolder(createdBaseFolder); | 350 | m_commsManager.InventoryService.AddFolder(createdBaseFolder); |
341 | 351 | ||
342 | return true; | 352 | return true; |
343 | } | ||
344 | else | ||
345 | { | ||
346 | m_log.WarnFormat( | ||
347 | "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", | ||
348 | folderName, folderID); | ||
349 | |||
350 | return false; | ||
351 | } | ||
352 | } | 353 | } |
353 | else | 354 | else |
354 | { | 355 | { |
355 | InventoryFolderImpl folder = RootFolder.FindFolder(parentID); | 356 | m_log.WarnFormat( |
357 | "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", | ||
358 | folderName, folderID); | ||
356 | 359 | ||
357 | if (folder != null) | 360 | return false; |
358 | { | ||
359 | InventoryFolderImpl createdFolder = folder.CreateNewSubFolder(folderID, folderName, folderType); | ||
360 | |||
361 | if (createdFolder != null) | ||
362 | { | ||
363 | InventoryFolderBase createdBaseFolder = new InventoryFolderBase(); | ||
364 | createdBaseFolder.Owner = createdFolder.Owner; | ||
365 | createdBaseFolder.ID = createdFolder.ID; | ||
366 | createdBaseFolder.Name = createdFolder.Name; | ||
367 | createdBaseFolder.ParentID = createdFolder.ParentID; | ||
368 | createdBaseFolder.Type = createdFolder.Type; | ||
369 | createdBaseFolder.Version = createdFolder.Version; | ||
370 | |||
371 | m_commsManager.InventoryService.AddFolder(createdBaseFolder); | ||
372 | |||
373 | return true; | ||
374 | } | ||
375 | else | ||
376 | { | ||
377 | m_log.WarnFormat( | ||
378 | "[AGENT INVENTORY]: Tried to create folder {0} {1} but the folder already exists", | ||
379 | folderName, folderID); | ||
380 | |||
381 | return false; | ||
382 | } | ||
383 | } | ||
384 | else | ||
385 | { | ||
386 | m_log.WarnFormat( | ||
387 | "[AGENT INVENTORY]: Could not find parent folder with id {0} in order to create folder {1} {2}", | ||
388 | parentID, folderName, folderID); | ||
389 | |||
390 | return false; | ||
391 | } | ||
392 | } | 361 | } |
393 | } | 362 | } |
394 | else | 363 | else |
diff --git a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs index af05af3..c8cec69 100644 --- a/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs +++ b/OpenSim/Framework/Communications/Cache/InventoryFolderImpl.cs | |||
@@ -69,7 +69,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
69 | /// <param name="folderName"></param> | 69 | /// <param name="folderName"></param> |
70 | /// <param name="type"></param> | 70 | /// <param name="type"></param> |
71 | /// <returns>The newly created subfolder. Returns null if the folder already exists</returns> | 71 | /// <returns>The newly created subfolder. Returns null if the folder already exists</returns> |
72 | public InventoryFolderImpl CreateNewSubFolder(LLUUID folderID, string folderName, ushort type) | 72 | public InventoryFolderImpl CreateChildFolder(LLUUID folderID, string folderName, ushort type) |
73 | { | 73 | { |
74 | lock (SubFolders) | 74 | lock (SubFolders) |
75 | { | 75 | { |
@@ -82,6 +82,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
82 | subFold.ParentID = this.ID; | 82 | subFold.ParentID = this.ID; |
83 | subFold.Owner = Owner; | 83 | subFold.Owner = Owner; |
84 | SubFolders.Add(subFold.ID, subFold); | 84 | SubFolders.Add(subFold.ID, subFold); |
85 | |||
85 | return subFold; | 86 | return subFold; |
86 | } | 87 | } |
87 | } | 88 | } |
@@ -135,7 +136,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
135 | } | 136 | } |
136 | 137 | ||
137 | /// <summary> | 138 | /// <summary> |
138 | /// Delete an item from the folder. | 139 | /// Deletes an item if it exists in this folder or any children |
139 | /// </summary> | 140 | /// </summary> |
140 | /// <param name="folderID"></param> | 141 | /// <param name="folderID"></param> |
141 | /// <returns></returns> | 142 | /// <returns></returns> |
@@ -157,6 +158,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
157 | foreach (InventoryFolderImpl folder in SubFolders.Values) | 158 | foreach (InventoryFolderImpl folder in SubFolders.Values) |
158 | { | 159 | { |
159 | found = folder.DeleteItem(itemID); | 160 | found = folder.DeleteItem(itemID); |
161 | |||
160 | if (found == true) | 162 | if (found == true) |
161 | { | 163 | { |
162 | break; | 164 | break; |
@@ -168,37 +170,35 @@ namespace OpenSim.Framework.Communications.Cache | |||
168 | } | 170 | } |
169 | 171 | ||
170 | /// <summary> | 172 | /// <summary> |
171 | /// Returns the folder requested if it exists as a descendent of this folder | 173 | /// Returns the folder requested if it is this folder or is a descendent of this folder. The search is depth |
174 | /// first. | ||
172 | /// </summary> | 175 | /// </summary> |
173 | /// <returns>The requested folder if it exists, null if it does not.</returns> | 176 | /// <returns>The requested folder if it exists, null if it does not.</returns> |
174 | public InventoryFolderImpl FindFolder(LLUUID folderID) | 177 | public InventoryFolderImpl FindFolder(LLUUID folderID) |
175 | { | 178 | { |
176 | InventoryFolderImpl returnFolder = null; | 179 | if (folderID == ID) |
180 | { | ||
181 | return this; | ||
182 | } | ||
177 | 183 | ||
178 | lock (SubFolders) | 184 | lock (SubFolders) |
179 | { | 185 | { |
180 | if (SubFolders.ContainsKey(folderID)) | 186 | foreach (InventoryFolderImpl folder in SubFolders.Values) |
181 | { | ||
182 | returnFolder = SubFolders[folderID]; | ||
183 | } | ||
184 | else | ||
185 | { | 187 | { |
186 | foreach (InventoryFolderImpl folder in SubFolders.Values) | 188 | InventoryFolderImpl returnFolder = folder.FindFolder(folderID); |
189 | |||
190 | if (returnFolder != null) | ||
187 | { | 191 | { |
188 | returnFolder = folder.FindFolder(folderID); | 192 | return returnFolder; |
189 | if (returnFolder != null) | ||
190 | { | ||
191 | break; | ||
192 | } | ||
193 | } | 193 | } |
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | return returnFolder; | 197 | return null; |
198 | } | 198 | } |
199 | 199 | ||
200 | /// <summary> | 200 | /// <summary> |
201 | /// Return the list of items in this folder | 201 | /// Return the list of child items in this folder |
202 | /// </summary> | 202 | /// </summary> |
203 | public List<InventoryItemBase> RequestListOfItems() | 203 | public List<InventoryItemBase> RequestListOfItems() |
204 | { | 204 | { |