aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetInventoryServer/Plugins/Simple
diff options
context:
space:
mode:
authorMike Mazur2009-03-05 08:29:52 +0000
committerMike Mazur2009-03-05 08:29:52 +0000
commit367606227774c4551a8929b2b42f8d014efff318 (patch)
treef4d9bfe81c36c62a1c62bef29f95835aa61ffa0f /OpenSim/Grid/AssetInventoryServer/Plugins/Simple
parentA couple cosmetic changes in inventory storage plugin. (diff)
downloadopensim-SC_OLD-367606227774c4551a8929b2b42f8d014efff318.zip
opensim-SC_OLD-367606227774c4551a8929b2b42f8d014efff318.tar.gz
opensim-SC_OLD-367606227774c4551a8929b2b42f8d014efff318.tar.bz2
opensim-SC_OLD-367606227774c4551a8929b2b42f8d014efff318.tar.xz
Use Inventory{Item,Folder}Base in AssetInventoryServer.
Also the first inventory storage methods are implemented.
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs82
1 files changed, 41 insertions, 41 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs
index cab8700..4010818 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs
+++ b/OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 AssetInventoryServer server; 45 AssetInventoryServer server;
46 Dictionary<Uri, InventoryCollection> inventories = new Dictionary<Uri, InventoryCollection>(); 46 Dictionary<Uri, InventoryCollection> inventories = new Dictionary<Uri, InventoryCollection>();
47 Dictionary<Uri, List<InventoryItem>> activeGestures = new Dictionary<Uri, List<InventoryItem>>(); 47 Dictionary<Uri, List<InventoryItemBase>> activeGestures = new Dictionary<Uri, List<InventoryItemBase>>();
48 Utils.InventoryItemSerializer itemSerializer = new Utils.InventoryItemSerializer(); 48 Utils.InventoryItemSerializer itemSerializer = new Utils.InventoryItemSerializer();
49 Utils.InventoryFolderSerializer folderSerializer = new Utils.InventoryFolderSerializer(); 49 Utils.InventoryFolderSerializer folderSerializer = new Utils.InventoryFolderSerializer();
50 50
@@ -54,7 +54,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
54 54
55 #region Required Interfaces 55 #region Required Interfaces
56 56
57 public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItem item) 57 public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item)
58 { 58 {
59 item = null; 59 item = null;
60 BackendResponse ret; 60 BackendResponse ret;
@@ -69,7 +69,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
69 return ret; 69 return ret;
70 } 70 }
71 71
72 public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolder folder) 72 public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder)
73 { 73 {
74 folder = null; 74 folder = null;
75 BackendResponse ret; 75 BackendResponse ret;
@@ -90,25 +90,25 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
90 BackendResponse ret; 90 BackendResponse ret;
91 91
92 InventoryCollection collection; 92 InventoryCollection collection;
93 InventoryFolder folder; 93 InventoryFolderWithChildren folder;
94 94
95 if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder)) 95 if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
96 { 96 {
97 contents = new InventoryCollection(); 97 contents = new InventoryCollection();
98 contents.UserID = collection.UserID; 98 contents.UserID = collection.UserID;
99 contents.Folders = new Dictionary<UUID, InventoryFolder>(); 99 contents.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
100 contents.Items = new Dictionary<UUID, InventoryItem>(); 100 contents.Items = new Dictionary<UUID, InventoryItemBase>();
101 101
102 foreach (InventoryBase invBase in folder.Children.Values) 102 foreach (InventoryNodeBase invBase in folder.Children.Values)
103 { 103 {
104 if (invBase is InventoryItem) 104 if (invBase is InventoryItemBase)
105 { 105 {
106 InventoryItem invItem = invBase as InventoryItem; 106 InventoryItemBase invItem = invBase as InventoryItemBase;
107 contents.Items.Add(invItem.ID, invItem); 107 contents.Items.Add(invItem.ID, invItem);
108 } 108 }
109 else 109 else
110 { 110 {
111 InventoryFolder invFolder = invBase as InventoryFolder; 111 InventoryFolderWithChildren invFolder = invBase as InventoryFolderWithChildren;
112 contents.Folders.Add(invFolder.ID, invFolder); 112 contents.Folders.Add(invFolder.ID, invFolder);
113 } 113 }
114 } 114 }
@@ -124,7 +124,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
124 return ret; 124 return ret;
125 } 125 }
126 126
127 public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolder> folders) 127 public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders)
128 { 128 {
129 folders = null; 129 folders = null;
130 BackendResponse ret; 130 BackendResponse ret;
@@ -132,7 +132,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
132 InventoryCollection collection; 132 InventoryCollection collection;
133 if (inventories.TryGetValue(owner, out collection)) 133 if (inventories.TryGetValue(owner, out collection))
134 { 134 {
135 folders = new List<InventoryFolder>(collection.Folders.Values); 135 folders = new List<InventoryFolderWithChildren>(collection.Folders.Values);
136 return BackendResponse.Success; 136 return BackendResponse.Success;
137 } 137 }
138 else 138 else
@@ -158,7 +158,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
158 return ret; 158 return ret;
159 } 159 }
160 160
161 public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItem> gestures) 161 public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures)
162 { 162 {
163 gestures = null; 163 gestures = null;
164 BackendResponse ret; 164 BackendResponse ret;
@@ -172,7 +172,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
172 return ret; 172 return ret;
173 } 173 }
174 174
175 public BackendResponse TryCreateItem(Uri owner, InventoryItem item) 175 public BackendResponse TryCreateItem(Uri owner, InventoryItemBase item)
176 { 176 {
177 BackendResponse ret; 177 BackendResponse ret;
178 178
@@ -180,7 +180,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
180 if (inventories.TryGetValue(owner, out collection)) 180 if (inventories.TryGetValue(owner, out collection))
181 { 181 {
182 // Delete this item first if it already exists 182 // Delete this item first if it already exists
183 InventoryItem oldItem; 183 InventoryItemBase oldItem;
184 if (collection.Items.TryGetValue(item.ID, out oldItem)) 184 if (collection.Items.TryGetValue(item.ID, out oldItem))
185 TryDeleteItem(owner, item.ID); 185 TryDeleteItem(owner, item.ID);
186 186
@@ -193,7 +193,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
193 lock (collection) collection.Items[item.ID] = item; 193 lock (collection) collection.Items[item.ID] = item;
194 194
195 // Add the item to its parent folder 195 // Add the item to its parent folder
196 InventoryFolder parent; 196 InventoryFolderWithChildren parent;
197 if (collection.Folders.TryGetValue(item.Folder, out parent)) 197 if (collection.Folders.TryGetValue(item.Folder, out parent))
198 lock (parent.Children) parent.Children.Add(item.ID, item); 198 lock (parent.Children) parent.Children.Add(item.ID, item);
199 199
@@ -221,7 +221,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
221 return ret; 221 return ret;
222 } 222 }
223 223
224 public BackendResponse TryCreateFolder(Uri owner, InventoryFolder folder) 224 public BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder)
225 { 225 {
226 BackendResponse ret; 226 BackendResponse ret;
227 227
@@ -229,7 +229,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
229 if (inventories.TryGetValue(owner, out collection)) 229 if (inventories.TryGetValue(owner, out collection))
230 { 230 {
231 // Delete this folder first if it already exists 231 // Delete this folder first if it already exists
232 InventoryFolder oldFolder; 232 InventoryFolderWithChildren oldFolder;
233 if (collection.Folders.TryGetValue(folder.ID, out oldFolder)) 233 if (collection.Folders.TryGetValue(folder.ID, out oldFolder))
234 TryDeleteFolder(owner, folder.ID); 234 TryDeleteFolder(owner, folder.ID);
235 235
@@ -242,7 +242,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
242 lock (collection) collection.Folders[folder.ID] = folder; 242 lock (collection) collection.Folders[folder.ID] = folder;
243 243
244 // Add the folder to its parent folder 244 // Add the folder to its parent folder
245 InventoryFolder parent; 245 InventoryFolderWithChildren parent;
246 if (collection.Folders.TryGetValue(folder.ParentID, out parent)) 246 if (collection.Folders.TryGetValue(folder.ParentID, out parent))
247 lock (parent.Children) parent.Children.Add(folder.ID, folder); 247 lock (parent.Children) parent.Children.Add(folder.ID, folder);
248 248
@@ -263,7 +263,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
263 return ret; 263 return ret;
264 } 264 }
265 265
266 public BackendResponse TryCreateInventory(Uri owner, InventoryFolder rootFolder) 266 public BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder)
267 { 267 {
268 BackendResponse ret; 268 BackendResponse ret;
269 269
@@ -273,9 +273,9 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
273 { 273 {
274 InventoryCollection collection = new InventoryCollection(); 274 InventoryCollection collection = new InventoryCollection();
275 collection.UserID = rootFolder.Owner; 275 collection.UserID = rootFolder.Owner;
276 collection.Folders = new Dictionary<UUID, InventoryFolder>(); 276 collection.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
277 collection.Folders.Add(rootFolder.ID, rootFolder); 277 collection.Folders.Add(rootFolder.ID, rootFolder);
278 collection.Items = new Dictionary<UUID, InventoryItem>(); 278 collection.Items = new Dictionary<UUID, InventoryItemBase>();
279 279
280 inventories.Add(owner, collection); 280 inventories.Add(owner, collection);
281 281
@@ -318,11 +318,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
318 BackendResponse ret; 318 BackendResponse ret;
319 319
320 InventoryCollection collection; 320 InventoryCollection collection;
321 InventoryItem item; 321 InventoryItemBase item;
322 if (inventories.TryGetValue(owner, out collection) && collection.Items.TryGetValue(itemID, out item)) 322 if (inventories.TryGetValue(owner, out collection) && collection.Items.TryGetValue(itemID, out item))
323 { 323 {
324 // Remove the item from its parent folder 324 // Remove the item from its parent folder
325 InventoryFolder parent; 325 InventoryFolderWithChildren parent;
326 if (collection.Folders.TryGetValue(item.Folder, out parent)) 326 if (collection.Folders.TryGetValue(item.Folder, out parent))
327 lock (parent.Children) parent.Children.Remove(itemID); 327 lock (parent.Children) parent.Children.Remove(itemID);
328 328
@@ -371,11 +371,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
371 BackendResponse ret; 371 BackendResponse ret;
372 372
373 InventoryCollection collection; 373 InventoryCollection collection;
374 InventoryFolder folder; 374 InventoryFolderWithChildren folder;
375 if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder)) 375 if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
376 { 376 {
377 // Remove the folder from its parent folder 377 // Remove the folder from its parent folder
378 InventoryFolder parent; 378 InventoryFolderWithChildren parent;
379 if (collection.Folders.TryGetValue(folder.ParentID, out parent)) 379 if (collection.Folders.TryGetValue(folder.ParentID, out parent))
380 lock (parent.Children) parent.Children.Remove(folderID); 380 lock (parent.Children) parent.Children.Remove(folderID);
381 381
@@ -408,19 +408,19 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
408 BackendResponse ret; 408 BackendResponse ret;
409 409
410 InventoryCollection collection; 410 InventoryCollection collection;
411 InventoryFolder folder; 411 InventoryFolderWithChildren folder;
412 if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder)) 412 if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
413 { 413 {
414 // Delete all of the folder children 414 // Delete all of the folder children
415 foreach (InventoryBase obj in new List<InventoryBase>(folder.Children.Values)) 415 foreach (InventoryNodeBase obj in new List<InventoryNodeBase>(folder.Children.Values))
416 { 416 {
417 if (obj is InventoryItem) 417 if (obj is InventoryItemBase)
418 { 418 {
419 TryDeleteItem(owner, (obj as InventoryItem).ID); 419 TryDeleteItem(owner, (obj as InventoryItemBase).ID);
420 } 420 }
421 else 421 else
422 { 422 {
423 InventoryFolder childFolder = obj as InventoryFolder; 423 InventoryFolderWithChildren childFolder = obj as InventoryFolderWithChildren;
424 TryPurgeFolder(owner, childFolder.ID); 424 TryPurgeFolder(owner, childFolder.ID);
425 TryDeleteFolder(owner, childFolder.ID); 425 TryDeleteFolder(owner, childFolder.ID);
426 } 426 }
@@ -439,7 +439,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
439 439
440 #endregion Required Interfaces 440 #endregion Required Interfaces
441 441
442 void SaveItem(InventoryItem item) 442 void SaveItem(InventoryItemBase item)
443 { 443 {
444 string filename = String.Format("{0}-{1}.item", SanitizeFilename(item.Name), item.ID); 444 string filename = String.Format("{0}-{1}.item", SanitizeFilename(item.Name), item.ID);
445 445
@@ -453,7 +453,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
453 } 453 }
454 } 454 }
455 455
456 void SaveFolder(InventoryFolder folder) 456 void SaveFolder(InventoryFolderWithChildren folder)
457 { 457 {
458 string filename = String.Format("{0}-{1}.folder", SanitizeFilename(folder.Name), folder.ID); 458 string filename = String.Format("{0}-{1}.folder", SanitizeFilename(folder.Name), folder.ID);
459 459
@@ -530,42 +530,42 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
530 if (ownerID != UUID.Zero && owner != null) 530 if (ownerID != UUID.Zero && owner != null)
531 { 531 {
532 // Initialize the active gestures list for this agent 532 // Initialize the active gestures list for this agent
533 activeGestures.Add(owner, new List<InventoryItem>()); 533 activeGestures.Add(owner, new List<InventoryItemBase>());
534 534
535 InventoryCollection collection = new InventoryCollection(); 535 InventoryCollection collection = new InventoryCollection();
536 collection.UserID = ownerID; 536 collection.UserID = ownerID;
537 537
538 // Load all of the folders for this agent 538 // Load all of the folders for this agent
539 string[] folders = Directory.GetFiles(foldername, "*.folder", SearchOption.TopDirectoryOnly); 539 string[] folders = Directory.GetFiles(foldername, "*.folder", SearchOption.TopDirectoryOnly);
540 collection.Folders = new Dictionary<UUID,InventoryFolder>(folders.Length); 540 collection.Folders = new Dictionary<UUID,InventoryFolderWithChildren>(folders.Length);
541 541
542 for (int j = 0; j < folders.Length; j++) 542 for (int j = 0; j < folders.Length; j++)
543 { 543 {
544 InventoryFolder invFolder = (InventoryFolder)folderSerializer.Deserialize( 544 InventoryFolderWithChildren invFolder = (InventoryFolderWithChildren)folderSerializer.Deserialize(
545 new FileStream(folders[j], FileMode.Open, FileAccess.Read)); 545 new FileStream(folders[j], FileMode.Open, FileAccess.Read));
546 collection.Folders[invFolder.ID] = invFolder; 546 collection.Folders[invFolder.ID] = invFolder;
547 } 547 }
548 548
549 // Iterate over the folders collection, adding children to their parents 549 // Iterate over the folders collection, adding children to their parents
550 foreach (InventoryFolder invFolder in collection.Folders.Values) 550 foreach (InventoryFolderWithChildren invFolder in collection.Folders.Values)
551 { 551 {
552 InventoryFolder parent; 552 InventoryFolderWithChildren parent;
553 if (collection.Folders.TryGetValue(invFolder.ParentID, out parent)) 553 if (collection.Folders.TryGetValue(invFolder.ParentID, out parent))
554 parent.Children[invFolder.ID] = invFolder; 554 parent.Children[invFolder.ID] = invFolder;
555 } 555 }
556 556
557 // Load all of the items for this agent 557 // Load all of the items for this agent
558 string[] files = Directory.GetFiles(foldername, "*.item", SearchOption.TopDirectoryOnly); 558 string[] files = Directory.GetFiles(foldername, "*.item", SearchOption.TopDirectoryOnly);
559 collection.Items = new Dictionary<UUID, InventoryItem>(files.Length); 559 collection.Items = new Dictionary<UUID, InventoryItemBase>(files.Length);
560 560
561 for (int j = 0; j < files.Length; j++) 561 for (int j = 0; j < files.Length; j++)
562 { 562 {
563 InventoryItem invItem = (InventoryItem)itemSerializer.Deserialize( 563 InventoryItemBase invItem = (InventoryItemBase)itemSerializer.Deserialize(
564 new FileStream(files[j], FileMode.Open, FileAccess.Read)); 564 new FileStream(files[j], FileMode.Open, FileAccess.Read));
565 collection.Items[invItem.ID] = invItem; 565 collection.Items[invItem.ID] = invItem;
566 566
567 // Add items to their parent folders 567 // Add items to their parent folders
568 InventoryFolder parent; 568 InventoryFolderWithChildren parent;
569 if (collection.Folders.TryGetValue(invItem.Folder, out parent)) 569 if (collection.Folders.TryGetValue(invItem.Folder, out parent))
570 parent.Children[invItem.ID] = invItem; 570 parent.Children[invItem.ID] = invItem;
571 571