aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/AssetInventoryServer/Plugins
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
parentA couple cosmetic changes in inventory storage plugin. (diff)
downloadopensim-SC-367606227774c4551a8929b2b42f8d014efff318.zip
opensim-SC-367606227774c4551a8929b2b42f8d014efff318.tar.gz
opensim-SC-367606227774c4551a8929b2b42f8d014efff318.tar.bz2
opensim-SC-367606227774c4551a8929b2b42f8d014efff318.tar.xz
Use Inventory{Item,Folder}Base in AssetInventoryServer.
Also the first inventory storage methods are implemented.
Diffstat (limited to 'OpenSim/Grid/AssetInventoryServer/Plugins')
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs49
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs186
-rw-r--r--OpenSim/Grid/AssetInventoryServer/Plugins/Simple/SimpleInventoryStoragePlugin.cs82
3 files changed, 138 insertions, 179 deletions
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs
new file mode 100644
index 0000000..d742d25
--- /dev/null
+++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryService.cs
@@ -0,0 +1,49 @@
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
28using OpenMetaverse;
29using OpenSim.Framework;
30using OpenSim.Framework.Communications;
31using OpenSim.Data;
32
33namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
34{
35 public class OpenSimInventoryService : InventoryServiceBase
36 {
37 public override void RequestInventoryForUser(UUID userID, InventoryReceiptCallback callback) {}
38
39 public InventoryFolderBase GetInventoryFolder(UUID folderID)
40 {
41 foreach (IInventoryDataPlugin plugin in m_plugins)
42 {
43 return plugin.getInventoryFolder(folderID);
44 }
45
46 return null;
47 }
48 }
49}
diff --git a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs
index 7c9646e..851cc4a 100644
--- a/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs
+++ b/OpenSim/Grid/AssetInventoryServer/Plugins/OpenSim/OpenSimInventoryStoragePlugin.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -42,17 +42,19 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 const string EXTENSION_NAME = "OpenSimInventoryStorage"; // Used in metrics reporting 43 const string EXTENSION_NAME = "OpenSimInventoryStorage"; // Used in metrics reporting
44 44
45 //private AssetInventoryServer m_server; 45 private AssetInventoryServer m_server;
46 private IInventoryDataPlugin m_inventoryProvider; 46 private IInventoryDataPlugin m_inventoryProvider;
47 private IConfig m_openSimConfig; 47 private IConfig m_openSimConfig;
48 private OpenSimInventoryService m_inventoryService;
48 49
49 public OpenSimInventoryStoragePlugin() 50 public OpenSimInventoryStoragePlugin()
50 { 51 {
52 m_inventoryService = new OpenSimInventoryService();
51 } 53 }
52 54
53 #region IInventoryStorageProvider implementation 55 #region IInventoryStorageProvider implementation
54 56
55 public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItem item) 57 public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item)
56 { 58 {
57 item = null; 59 item = null;
58 //BackendResponse ret; 60 //BackendResponse ret;
@@ -74,7 +76,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
74 76
75 // if (reader.Read()) 77 // if (reader.Read())
76 // { 78 // {
77 // item = new InventoryItem(); 79 // item = new InventoryItemBase();
78 // item.ID = itemID; 80 // item.ID = itemID;
79 // item.AssetID = UUID.Parse(reader.GetString(0)); 81 // item.AssetID = UUID.Parse(reader.GetString(0));
80 // item.AssetType = reader.GetInt32(1); 82 // item.AssetType = reader.GetInt32(1);
@@ -116,7 +118,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
116 return BackendResponse.Success; 118 return BackendResponse.Success;
117 } 119 }
118 120
119 public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolder folder) 121 public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder)
120 { 122 {
121 folder = null; 123 folder = null;
122 //BackendResponse ret; 124 //BackendResponse ret;
@@ -136,7 +138,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
136 138
137 // if (reader.Read()) 139 // if (reader.Read())
138 // { 140 // {
139 // folder = new InventoryFolder(); 141 // folder = new InventoryFolderWithChildren();
140 // folder.Children = null; // This call only returns data for the folder itself, no children data 142 // folder.Children = null; // This call only returns data for the folder itself, no children data
141 // folder.ID = folderID; 143 // folder.ID = folderID;
142 // folder.Name = reader.GetString(0); 144 // folder.Name = reader.GetString(0);
@@ -186,11 +188,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
186 // folderID.ToString()); 188 // folderID.ToString());
187 // reader = command.ExecuteReader(); 189 // reader = command.ExecuteReader();
188 190
189 // contents.Folders = new Dictionary<UUID, InventoryFolder>(); 191 // contents.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
190 192
191 // while (reader.Read()) 193 // while (reader.Read())
192 // { 194 // {
193 // InventoryFolder folder = new InventoryFolder(); 195 // InventoryFolderWithChildren folder = new InventoryFolderWithChildren();
194 // folder.ParentID = folderID; 196 // folder.ParentID = folderID;
195 // folder.Children = null; // This call doesn't do recursion 197 // folder.Children = null; // This call doesn't do recursion
196 // folder.Name = reader.GetString(0); 198 // folder.Name = reader.GetString(0);
@@ -216,11 +218,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
216 // folderID.ToString()); 218 // folderID.ToString());
217 // reader = command.ExecuteReader(); 219 // reader = command.ExecuteReader();
218 220
219 // contents.Items = new Dictionary<UUID, InventoryItem>(); 221 // contents.Items = new Dictionary<UUID, InventoryItemBase>();
220 222
221 // while (reader.Read()) 223 // while (reader.Read())
222 // { 224 // {
223 // InventoryItem item = new InventoryItem(); 225 // InventoryItemBase item = new InventoryItemBase();
224 // item.Folder = folderID; 226 // item.Folder = folderID;
225 // item.AssetID = UUID.Parse(reader.GetString(0)); 227 // item.AssetID = UUID.Parse(reader.GetString(0));
226 // item.AssetType = reader.GetInt32(1); 228 // item.AssetType = reader.GetInt32(1);
@@ -263,7 +265,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
263 return BackendResponse.Success; 265 return BackendResponse.Success;
264 } 266 }
265 267
266 public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolder> folders) 268 public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders)
267 { 269 {
268 folders = null; 270 folders = null;
269 //BackendResponse ret; 271 //BackendResponse ret;
@@ -278,7 +280,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
278 // try 280 // try
279 // { 281 // {
280 // dbConnection.Open(); 282 // dbConnection.Open();
281 // folders = new List<InventoryFolder>(); 283 // folders = new List<InventoryFolderWithChildren>();
282 284
283 // IDbCommand command = dbConnection.CreateCommand(); 285 // IDbCommand command = dbConnection.CreateCommand();
284 // command.CommandText = String.Format("SELECT folderName,type,version,folderID,parentFolderID FROM inventoryfolders WHERE agentID='{0}'", 286 // command.CommandText = String.Format("SELECT folderName,type,version,folderID,parentFolderID FROM inventoryfolders WHERE agentID='{0}'",
@@ -287,7 +289,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
287 289
288 // while (reader.Read()) 290 // while (reader.Read())
289 // { 291 // {
290 // InventoryFolder folder = new InventoryFolder(); 292 // InventoryFolderWithChildren folder = new InventoryFolderWithChildren();
291 // folder.Owner = ownerID; 293 // folder.Owner = ownerID;
292 // folder.Children = null; // This call does not create a folder hierarchy 294 // folder.Children = null; // This call does not create a folder hierarchy
293 // folder.Name = reader.GetString(0); 295 // folder.Name = reader.GetString(0);
@@ -322,7 +324,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
322 { 324 {
323 inventory = null; 325 inventory = null;
324 //BackendResponse ret; 326 //BackendResponse ret;
325 //List<InventoryFolder> folders; 327 //List<InventoryFolderWithChildren> folders;
326 //UUID ownerID; 328 //UUID ownerID;
327 329
328 //ret = TryFetchFolderList(owner, out folders); 330 //ret = TryFetchFolderList(owner, out folders);
@@ -331,8 +333,8 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
331 //{ 333 //{
332 // // Add the retrieved folders to the inventory collection 334 // // Add the retrieved folders to the inventory collection
333 // inventory = new InventoryCollection(); 335 // inventory = new InventoryCollection();
334 // inventory.Folders = new Dictionary<UUID, InventoryFolder>(folders.Count); 336 // inventory.Folders = new Dictionary<UUID, InventoryFolderWithChildren>(folders.Count);
335 // foreach (InventoryFolder folder in folders) 337 // foreach (InventoryFolderWithChildren folder in folders)
336 // inventory.Folders[folder.ID] = folder; 338 // inventory.Folders[folder.ID] = folder;
337 339
338 // // Fetch inventory items 340 // // Fetch inventory items
@@ -354,11 +356,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
354 // reader = command.ExecuteReader(); 356 // reader = command.ExecuteReader();
355 357
356 // inventory.UserID = ownerID; 358 // inventory.UserID = ownerID;
357 // inventory.Items = new Dictionary<UUID, InventoryItem>(); 359 // inventory.Items = new Dictionary<UUID, InventoryItemBase>();
358 360
359 // while (reader.Read()) 361 // while (reader.Read())
360 // { 362 // {
361 // InventoryItem item = new InventoryItem(); 363 // InventoryItemBase item = new InventoryItemBase();
362 // item.Owner = ownerID; 364 // item.Owner = ownerID;
363 // item.AssetID = UUID.Parse(reader.GetString(0)); 365 // item.AssetID = UUID.Parse(reader.GetString(0));
364 // item.AssetType = reader.GetInt32(1); 366 // item.AssetType = reader.GetInt32(1);
@@ -403,7 +405,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
403 return BackendResponse.Success; 405 return BackendResponse.Success;
404 } 406 }
405 407
406 public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItem> gestures) 408 public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures)
407 { 409 {
408 gestures = null; 410 gestures = null;
409 //BackendResponse ret; 411 //BackendResponse ret;
@@ -429,7 +431,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
429 431
430 // while (reader.Read()) 432 // while (reader.Read())
431 // { 433 // {
432 // InventoryItem item = new InventoryItem(); 434 // InventoryItemBase item = new InventoryItemBase();
433 // item.Owner = ownerID; 435 // item.Owner = ownerID;
434 // item.AssetType = (int)AssetType.Gesture; 436 // item.AssetType = (int)AssetType.Gesture;
435 // item.Flags = (uint)1; 437 // item.Flags = (uint)1;
@@ -473,75 +475,24 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
473 return BackendResponse.Success; 475 return BackendResponse.Success;
474 } 476 }
475 477
476 public BackendResponse TryCreateItem(Uri owner, InventoryItem item) 478 public BackendResponse TryCreateItem(Uri owner, InventoryItemBase item)
477 { 479 {
478 //BackendResponse ret; 480 BackendResponse ret;
479 481
480 //using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) 482 if (m_inventoryService.AddItem(item))
481 //{ 483 {
482 // try 484 ret = BackendResponse.Success;
483 // { 485 }
484 // dbConnection.Open(); 486 else
485 487 {
486 // MySqlCommand command = new MySqlCommand( 488 ret = BackendResponse.Failure;
487 // "REPLACE INTO inventoryitems (assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," + 489 }
488 // "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," +
489 // "creationDate,groupID,groupOwned,flags,inventoryID,avatarID,parentFolderID,inventoryGroupPermissions) VALUES " +
490
491 // "(?assetID,?assetType,?inventoryName,?inventoryDescription,?inventoryNextPermissions,?inventoryCurrentPermissions,?invType," +
492 // "?creatorID,?inventoryBasePermissions,?inventoryEveryOnePermissions,?salePrice,?saleType,?creationDate,?groupID,?groupOwned," +
493 // "?flags,?inventoryID,?avatarID,?parentFolderID,?inventoryGroupPermissions)", dbConnection);
494
495 // command.Parameters.AddWithValue("?assetID", item.AssetID.ToString());
496 // command.Parameters.AddWithValue("?assetType", item.AssetType);
497 // command.Parameters.AddWithValue("?inventoryName", item.Name);
498 // command.Parameters.AddWithValue("?inventoryDescription", item.Description);
499 // command.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions);
500 // command.Parameters.AddWithValue("?inventoryCurrentPermissions", item.CurrentPermissions);
501 // command.Parameters.AddWithValue("?invType", item.InvType);
502 // command.Parameters.AddWithValue("?creatorID", item.Creator.ToString());
503 // command.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions);
504 // command.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
505 // command.Parameters.AddWithValue("?salePrice", item.SalePrice);
506 // command.Parameters.AddWithValue("?saleType", item.SaleType);
507 // command.Parameters.AddWithValue("?creationDate", item.CreationDate);
508 // command.Parameters.AddWithValue("?groupID", item.GroupID.ToString());
509 // command.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
510 // command.Parameters.AddWithValue("?flags", item.Flags);
511 // command.Parameters.AddWithValue("?inventoryID", item.ID);
512 // command.Parameters.AddWithValue("?avatarID", item.Owner);
513 // command.Parameters.AddWithValue("?parentFolderID", item.Folder);
514 // command.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
515
516 // int rowsAffected = command.ExecuteNonQuery();
517 // if (rowsAffected == 1)
518 // {
519 // ret = BackendResponse.Success;
520 // }
521 // else if (rowsAffected == 2)
522 // {
523 // m_log.Info("[OPENSIMINVENTORYSTORAGE]: Replaced inventory item " + item.ID.ToString());
524 // ret = BackendResponse.Success;
525 // }
526 // else
527 // {
528 // m_log.ErrorFormat("[OPENSIMINVENTORYSTORAGE]: MySQL REPLACE query affected {0} rows", rowsAffected);
529 // ret = BackendResponse.Failure;
530 // }
531 // }
532 // catch (MySqlException ex)
533 // {
534 // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message);
535 // ret = BackendResponse.Failure;
536 // }
537 //}
538 490
539 //m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now); 491 m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now);
540 //return ret; 492 return ret;
541 return BackendResponse.Success;
542 } 493 }
543 494
544 public BackendResponse TryCreateFolder(Uri owner, InventoryFolder folder) 495 public BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder)
545 { 496 {
546 //BackendResponse ret; 497 //BackendResponse ret;
547 498
@@ -590,7 +541,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
590 return BackendResponse.Success; 541 return BackendResponse.Success;
591 } 542 }
592 543
593 public BackendResponse TryCreateInventory(Uri owner, InventoryFolder rootFolder) 544 public BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder)
594 { 545 {
595 return TryCreateFolder(owner, rootFolder); 546 return TryCreateFolder(owner, rootFolder);
596 } 547 }
@@ -692,60 +643,19 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
692 643
693 public BackendResponse TryPurgeFolder(Uri owner, UUID folderID) 644 public BackendResponse TryPurgeFolder(Uri owner, UUID folderID)
694 { 645 {
695 //BackendResponse ret; 646 BackendResponse ret;
696 //UUID ownerID;
697 647
698 //if (Utils.TryGetOpenSimUUID(owner, out ownerID)) 648 if (m_inventoryService.PurgeFolder(m_inventoryService.GetInventoryFolder(folderID)))
699 //{ 649 {
700 // using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect"))) 650 ret = BackendResponse.Success;
701 // { 651 }
702 // try 652 else
703 // { 653 {
704 // dbConnection.Open(); 654 ret = BackendResponse.Failure;
705 655 }
706 // #region Delete items
707
708 // MySqlCommand command = new MySqlCommand(
709 // "DELETE FROM inventoryitems WHERE parentFolderID=?parentFolderID AND avatarID=?avatarID", dbConnection);
710
711 // command.Parameters.AddWithValue("?parentFolderID", folderID.ToString());
712 // command.Parameters.AddWithValue("?avatarID", ownerID.ToString());
713
714 // int rowsAffected = command.ExecuteNonQuery();
715
716 // #endregion Delete items
717
718 // #region Delete folders
719
720 // command = new MySqlCommand(
721 // "DELETE FROM inventoryfolders WHERE parentFolderID=?parentFolderID AND agentID=?agentID", dbConnection);
722
723 // command.Parameters.AddWithValue("?parentFolderID", folderID.ToString());
724 // command.Parameters.AddWithValue("?agentID", ownerID.ToString());
725
726 // rowsAffected += command.ExecuteNonQuery();
727
728 // #endregion Delete folders
729
730 // m_log.DebugFormat("[OPENSIMINVENTORYSTORAGE]: Deleted {0} inventory objects from MySQL in a folder purge", rowsAffected);
731
732 // ret = BackendResponse.Success;
733 // }
734 // catch (MySqlException ex)
735 // {
736 // m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message);
737 // ret = BackendResponse.Failure;
738 // }
739 // }
740 //}
741 //else
742 //{
743 // ret = BackendResponse.NotFound;
744 //}
745 656
746 //m_server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now); 657 m_server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now);
747 //return ret; 658 return ret;
748 return BackendResponse.Success;
749 } 659 }
750 660
751 public int ForEach(Action<AssetMetadata> action, int start, int count) 661 public int ForEach(Action<AssetMetadata> action, int start, int count)
@@ -798,7 +708,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
798 708
799 public void Initialise(AssetInventoryServer server) 709 public void Initialise(AssetInventoryServer server)
800 { 710 {
801 //m_server = server; 711 m_server = server;
802 m_openSimConfig = server.ConfigFile.Configs["OpenSim"]; 712 m_openSimConfig = server.ConfigFile.Configs["OpenSim"];
803 713
804 try 714 try
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