aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs103
1 files changed, 55 insertions, 48 deletions
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index b6ec558..6a6181a 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -109,7 +109,7 @@ namespace OpenSim.Services.HypergridService
109 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); 109 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
110 XInventoryFolder root = GetRootXFolder(principalID); 110 XInventoryFolder root = GetRootXFolder(principalID);
111 111
112 List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID); 112 List<XInventoryFolder> tree = GetFolderTree(principalID, suitcase.folderID);
113 if (tree == null || (tree != null && tree.Count == 0)) 113 if (tree == null || (tree != null && tree.Count == 0))
114 return null; 114 return null;
115 115
@@ -119,7 +119,7 @@ namespace OpenSim.Services.HypergridService
119 folders.Add(ConvertToOpenSim(x)); 119 folders.Add(ConvertToOpenSim(x));
120 } 120 }
121 121
122 SetAsRootFolder(suitcase, root); 122 SetAsNormalFolder(suitcase, root);
123 folders.Add(ConvertToOpenSim(suitcase)); 123 folders.Add(ConvertToOpenSim(suitcase));
124 124
125 return folders; 125 return folders;
@@ -136,10 +136,10 @@ namespace OpenSim.Services.HypergridService
136 XInventoryFolder suitcase = GetSuitcaseXFolder(userID); 136 XInventoryFolder suitcase = GetSuitcaseXFolder(userID);
137 XInventoryFolder root = GetRootXFolder(userID); 137 XInventoryFolder root = GetRootXFolder(userID);
138 138
139 List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID); 139 List<XInventoryFolder> tree = GetFolderTree(userID, suitcase.folderID);
140 if (tree == null || (tree != null && tree.Count == 0)) 140 if (tree == null || (tree != null && tree.Count == 0))
141 { 141 {
142 SetAsRootFolder(suitcase, root); 142 SetAsNormalFolder(suitcase, root);
143 userInventory.Folders.Add(ConvertToOpenSim(suitcase)); 143 userInventory.Folders.Add(ConvertToOpenSim(suitcase));
144 return userInventory; 144 return userInventory;
145 } 145 }
@@ -164,7 +164,7 @@ namespace OpenSim.Services.HypergridService
164 userInventory.Items.AddRange(items); 164 userInventory.Items.AddRange(items);
165 } 165 }
166 166
167 SetAsRootFolder(suitcase, root); 167 SetAsNormalFolder(suitcase, root);
168 userInventory.Folders.Add(ConvertToOpenSim(suitcase)); 168 userInventory.Folders.Add(ConvertToOpenSim(suitcase));
169 169
170 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items", 170 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items",
@@ -175,8 +175,6 @@ namespace OpenSim.Services.HypergridService
175 public override InventoryFolderBase GetRootFolder(UUID principalID) 175 public override InventoryFolderBase GetRootFolder(UUID principalID)
176 { 176 {
177 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID); 177 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
178 if (m_Database == null)
179 m_log.ErrorFormat("[XXX]: m_Database is NULL!");
180 178
181 // Let's find out the local root folder 179 // Let's find out the local root folder
182 XInventoryFolder root = GetRootXFolder(principalID); ; 180 XInventoryFolder root = GetRootXFolder(principalID); ;
@@ -202,7 +200,7 @@ namespace OpenSim.Services.HypergridService
202 CreateSystemFolders(principalID, suitcase.folderID); 200 CreateSystemFolders(principalID, suitcase.folderID);
203 } 201 }
204 202
205 SetAsRootFolder(suitcase, root); 203 SetAsNormalFolder(suitcase, root);
206 204
207 return ConvertToOpenSim(suitcase); 205 return ConvertToOpenSim(suitcase);
208 } 206 }
@@ -271,9 +269,8 @@ namespace OpenSim.Services.HypergridService
271 public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID) 269 public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
272 { 270 {
273 InventoryCollection coll = null; 271 InventoryCollection coll = null;
274 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
275 272
276 if (!IsWithinSuitcaseTree(folderID, suitcase)) 273 if (!IsWithinSuitcaseTree(principalID, folderID))
277 return new InventoryCollection(); 274 return new InventoryCollection();
278 275
279 coll = base.GetFolderContent(principalID, folderID); 276 coll = base.GetFolderContent(principalID, folderID);
@@ -290,9 +287,7 @@ namespace OpenSim.Services.HypergridService
290 { 287 {
291 // Let's do a bit of sanity checking, more than the base service does 288 // Let's do a bit of sanity checking, more than the base service does
292 // make sure the given folder exists under the suitcase tree of this user 289 // make sure the given folder exists under the suitcase tree of this user
293 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID); 290 if (!IsWithinSuitcaseTree(principalID, folderID))
294
295 if (!IsWithinSuitcaseTree(folderID, suitcase))
296 return new List<InventoryItemBase>(); 291 return new List<InventoryItemBase>();
297 292
298 return base.GetFolderItems(principalID, folderID); 293 return base.GetFolderItems(principalID, folderID);
@@ -303,21 +298,27 @@ namespace OpenSim.Services.HypergridService
303 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID); 298 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID);
304 // Let's do a bit of sanity checking, more than the base service does 299 // Let's do a bit of sanity checking, more than the base service does
305 // make sure the given folder's parent folder exists under the suitcase tree of this user 300 // make sure the given folder's parent folder exists under the suitcase tree of this user
306 XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner);
307 301
308 if (!IsWithinSuitcaseTree(folder.ParentID, suitcase)) 302 if (!IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
309 return false; 303 return false;
310 304
311 // OK, it's legit 305 // OK, it's legit
312 return base.AddFolder(folder); 306 if (base.AddFolder(folder))
307 {
308 List<XInventoryFolder> tree;
309 if (m_SuitcaseTrees.TryGetValue(folder.Owner, out tree))
310 tree.Add(ConvertFromOpenSim(folder));
311
312 return true;
313 }
314
315 return false;
313 } 316 }
314 317
315 public override bool UpdateFolder(InventoryFolderBase folder) 318 public override bool UpdateFolder(InventoryFolderBase folder)
316 { 319 {
317 XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner);
318
319 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version); 320 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version);
320 if (!IsWithinSuitcaseTree(folder.ID, suitcase)) 321 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID))
321 { 322 {
322 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name); 323 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name);
323 return false; 324 return false;
@@ -329,9 +330,8 @@ namespace OpenSim.Services.HypergridService
329 330
330 public override bool MoveFolder(InventoryFolderBase folder) 331 public override bool MoveFolder(InventoryFolderBase folder)
331 { 332 {
332 XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner); 333 if (!IsWithinSuitcaseTree(folder.Owner, folder.ID) ||
333 334 !IsWithinSuitcaseTree(folder.Owner, folder.ParentID))
334 if (!IsWithinSuitcaseTree(folder.ID, suitcase) || !IsWithinSuitcaseTree(folder.ParentID, suitcase))
335 return false; 335 return false;
336 336
337 return base.MoveFolder(folder); 337 return base.MoveFolder(folder);
@@ -353,9 +353,7 @@ namespace OpenSim.Services.HypergridService
353 { 353 {
354 // Let's do a bit of sanity checking, more than the base service does 354 // Let's do a bit of sanity checking, more than the base service does
355 // make sure the given folder's parent folder exists under the suitcase tree of this user 355 // make sure the given folder's parent folder exists under the suitcase tree of this user
356 XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); 356 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
357
358 if (!IsWithinSuitcaseTree(item.Folder, suitcase))
359 return false; 357 return false;
360 358
361 // OK, it's legit 359 // OK, it's legit
@@ -365,9 +363,7 @@ namespace OpenSim.Services.HypergridService
365 363
366 public override bool UpdateItem(InventoryItemBase item) 364 public override bool UpdateItem(InventoryItemBase item)
367 { 365 {
368 XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner); 366 if (!IsWithinSuitcaseTree(item.Owner, item.Folder))
369
370 if (!IsWithinSuitcaseTree(item.Folder, suitcase))
371 return false; 367 return false;
372 368
373 return base.UpdateItem(item); 369 return base.UpdateItem(item);
@@ -377,9 +373,7 @@ namespace OpenSim.Services.HypergridService
377 { 373 {
378 // Principal is b0rked. *sigh* 374 // Principal is b0rked. *sigh*
379 375
380 XInventoryFolder suitcase = GetSuitcaseXFolder(items[0].Owner); 376 if (!IsWithinSuitcaseTree(items[0].Owner, items[0].Folder))
381
382 if (!IsWithinSuitcaseTree(items[0].Folder, suitcase))
383 return false; 377 return false;
384 378
385 return base.MoveItems(principalID, items); 379 return base.MoveItems(principalID, items);
@@ -400,15 +394,8 @@ namespace OpenSim.Services.HypergridService
400 item.Name, item.ID, item.Folder); 394 item.Name, item.ID, item.Folder);
401 return null; 395 return null;
402 } 396 }
403 XInventoryFolder suitcase = GetSuitcaseXFolder(it.Owner);
404 if (suitcase == null)
405 {
406 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Root or Suitcase are null for user {0}",
407 it.Owner);
408 return null;
409 }
410 397
411 if (!IsWithinSuitcaseTree(it.Folder, suitcase)) 398 if (!IsWithinSuitcaseTree(it.Owner, it.Folder))
412 { 399 {
413 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase", 400 m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase",
414 it.Name, it.Folder); 401 it.Name, it.Folder);
@@ -431,9 +418,7 @@ namespace OpenSim.Services.HypergridService
431 418
432 if (f != null) 419 if (f != null)
433 { 420 {
434 XInventoryFolder suitcase = GetSuitcaseXFolder(f.Owner); 421 if (!IsWithinSuitcaseTree(f.Owner, f.ID))
435
436 if (!IsWithinSuitcaseTree(f.ID, suitcase))
437 return null; 422 return null;
438 } 423 }
439 424
@@ -481,22 +466,37 @@ namespace OpenSim.Services.HypergridService
481 466
482 if (folders != null && folders.Length > 0) 467 if (folders != null && folders.Length > 0)
483 return folders[0]; 468 return folders[0];
469
470 // check to see if we have the old Suitcase folder
471 folders = m_Database.GetFolders(
472 new string[] { "agentID", "folderName", "parentFolderID" },
473 new string[] { principalID.ToString(), "My Suitcase", UUID.Zero.ToString() });
474 if (folders != null && folders.Length > 0)
475 {
476 // Move it to under the root folder
477 XInventoryFolder root = GetRootXFolder(principalID);
478 folders[0].parentFolderID = root.folderID;
479 folders[0].type = 100;
480 m_Database.StoreFolder(folders[0]);
481 return folders[0];
482 }
483
484 return null; 484 return null;
485 } 485 }
486 486
487 private void SetAsRootFolder(XInventoryFolder suitcase, XInventoryFolder root) 487 private void SetAsNormalFolder(XInventoryFolder suitcase, XInventoryFolder root)
488 { 488 {
489 suitcase.type = (short)AssetType.Folder; 489 suitcase.type = (short)AssetType.Folder;
490 } 490 }
491 491
492 private List<XInventoryFolder> GetFolderTree(UUID folder) 492 private List<XInventoryFolder> GetFolderTree(UUID principalID, UUID folder)
493 { 493 {
494 List<XInventoryFolder> t = null; 494 List<XInventoryFolder> t = null;
495 if (m_SuitcaseTrees.TryGetValue(folder, out t)) 495 if (m_SuitcaseTrees.TryGetValue(principalID, out t))
496 return t; 496 return t;
497 497
498 t = GetFolderTreeRecursive(folder); 498 t = GetFolderTreeRecursive(folder);
499 m_SuitcaseTrees.AddOrUpdate(folder, t, 120); 499 m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes
500 return t; 500 return t;
501 } 501 }
502 502
@@ -528,11 +528,18 @@ namespace OpenSim.Services.HypergridService
528 /// <param name="root"></param> 528 /// <param name="root"></param>
529 /// <param name="suitcase"></param> 529 /// <param name="suitcase"></param>
530 /// <returns></returns> 530 /// <returns></returns>
531 private bool IsWithinSuitcaseTree(UUID folderID, XInventoryFolder suitcase) 531 private bool IsWithinSuitcaseTree(UUID principalID, UUID folderID)
532 { 532 {
533 XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
534 if (suitcase == null)
535 {
536 m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder", principalID);
537 return false;
538 }
539
533 List<XInventoryFolder> tree = new List<XInventoryFolder>(); 540 List<XInventoryFolder> tree = new List<XInventoryFolder>();
534 tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder 541 tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder
535 tree.AddRange(GetFolderTree(suitcase.folderID)); 542 tree.AddRange(GetFolderTree(principalID, suitcase.folderID));
536 XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) 543 XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl)
537 { 544 {
538 if (fl.folderID == folderID) return true; 545 if (fl.folderID == folderID) return true;