From 0f367bd7bbc5d22d4834e1eb0f1671381485143e Mon Sep 17 00:00:00 2001 From: diva Date: Wed, 10 Jun 2009 13:18:32 +0000 Subject: Heart surgery no.2: the inventory service hooks. Several improvements in the connectors themselves. Several improvements in configurations. Needed to add a hack in IUserService and UserManagerBase, to be removed when that service is refactored. --- .../InventoryService/HGInventoryService.cs | 100 +++++++++++++++++---- .../Services/InventoryService/InventoryService.cs | 41 ++++----- .../InventoryService/InventoryServiceBase.cs | 40 ++++++--- 3 files changed, 132 insertions(+), 49 deletions(-) (limited to 'OpenSim/Services/InventoryService') diff --git a/OpenSim/Services/InventoryService/HGInventoryService.cs b/OpenSim/Services/InventoryService/HGInventoryService.cs index e5e40c6..0db80d0 100644 --- a/OpenSim/Services/InventoryService/HGInventoryService.cs +++ b/OpenSim/Services/InventoryService/HGInventoryService.cs @@ -109,6 +109,7 @@ namespace OpenSim.Services.InventoryService public void GetUserInventory(string id, UUID sessionID, InventoryReceiptCallback callback) { + m_log.Debug("[HGInventory]: GetUserInventory " + id); string url = string.Empty; string userID = string.Empty; @@ -120,57 +121,120 @@ namespace OpenSim.Services.InventoryService } - public bool AddFolder(string userID, InventoryFolderBase folder, UUID sessionID) + public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID) { - // TODO + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.AddFolder(userID, folder, sessionID); + } return false; } - public bool UpdateFolder(string userID, InventoryFolderBase folder, UUID sessionID) + public bool UpdateFolder(string id, InventoryFolderBase folder, UUID sessionID) { - // TODO + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.UpdateFolder(userID, folder, sessionID); + } return false; } - public bool MoveFolder(string userID, InventoryFolderBase folder, UUID sessionID) + public bool MoveFolder(string id, InventoryFolderBase folder, UUID sessionID) { - // TODO + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.MoveFolder(userID, folder, sessionID); + } return false; } - public bool PurgeFolder(string userID, InventoryFolderBase folder, UUID sessionID) + public bool PurgeFolder(string id, InventoryFolderBase folder, UUID sessionID) { - // TODO + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.PurgeFolder(userID, folder, sessionID); + } return false; } - public bool AddItem(string userID, InventoryItemBase item, UUID sessionID) + public bool AddItem(string id, InventoryItemBase item, UUID sessionID) { - // TODO + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.AddItem(userID, item, sessionID); + } return false; } - public bool UpdateItem(string userID, InventoryItemBase item, UUID sessionID) + public bool UpdateItem(string id, InventoryItemBase item, UUID sessionID) { - // TODO + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.UpdateItem(userID, item, sessionID); + } return false; } - public bool DeleteItem(string userID, InventoryItemBase item, UUID sessionID) + public bool DeleteItem(string id, InventoryItemBase item, UUID sessionID) { - // TODO + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.UpdateItem(userID, item, sessionID); + } return false; } - public InventoryItemBase QueryItem(string userID, InventoryItemBase item, UUID sessionID) + public InventoryItemBase QueryItem(string id, InventoryItemBase item, UUID sessionID) { - // TODO + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.QueryItem(userID, item, sessionID); + } return null; } - public InventoryFolderBase QueryFolder(string userID, InventoryFolderBase folder, UUID sessionID) + public InventoryFolderBase QueryFolder(string id, InventoryFolderBase folder, UUID sessionID) { - // TODO + string url = string.Empty; + string userID = string.Empty; + + if (StringToUrlAndUserID(id, out url, out userID)) + { + ISessionAuthInventoryService connector = GetConnector(url); + return connector.QueryFolder(userID, folder, sessionID); + } return null; } diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index f2a7b41..9dbd591 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs @@ -46,6 +46,7 @@ namespace OpenSim.Services.InventoryService public InventoryService(IConfigSource config) : base(config) { + m_log.Debug("[INVENTORY SERVICE]: Initialized."); } #region IInventoryServices methods @@ -57,7 +58,7 @@ namespace OpenSim.Services.InventoryService public List GetInventorySkeleton(UUID userId) { -// m_log.DebugFormat("[AGENT INVENTORY]: Getting inventory skeleton for {0}", userId); + m_log.DebugFormat("[INVENTORY SERVICE]: Getting inventory skeleton for {0}", userId); InventoryFolderBase rootFolder = RequestRootFolder(userId); @@ -79,7 +80,7 @@ namespace OpenSim.Services.InventoryService // foreach (InventoryFolderBase folder in userFolders) // { -// m_log.DebugFormat("[AGENT INVENTORY]: Got folder {0} {1}", folder.name, folder.folderID); +// m_log.DebugFormat("[INVENTORY SERVICE]: Got folder {0} {1}", folder.name, folder.folderID); // } return userFolders; @@ -113,7 +114,7 @@ namespace OpenSim.Services.InventoryService if (null != existingRootFolder) { m_log.WarnFormat( - "[AGENT INVENTORY]: Did not create a new inventory for user {0} since they already have " + "[INVENTORY SERVICE]: Did not create a new inventory for user {0} since they already have " + "a root inventory folder with id {1}", user, existingRootFolder.ID); } @@ -138,7 +139,7 @@ namespace OpenSim.Services.InventoryService /// The user's inventory. If an inventory cannot be found then an empty collection is returned. public InventoryCollection GetUserInventory(UUID userID) { - m_log.InfoFormat("[LOCAL INVENTORY SERVICE]: Processing request for inventory of {0}", userID); + m_log.InfoFormat("[INVENTORY SERVICE]: Processing request for inventory of {0}", userID); // Uncomment me to simulate a slow responding inventory server //Thread.Sleep(16000); @@ -149,7 +150,7 @@ namespace OpenSim.Services.InventoryService if (null == allFolders) { - m_log.WarnFormat("[LOCAL INVENTORY SERVICE]: No inventory found for user {0}", userID); + m_log.WarnFormat("[INVENTORY SERVICE]: No inventory found for user {0}", userID); return invCollection; } @@ -172,16 +173,16 @@ namespace OpenSim.Services.InventoryService // foreach (InventoryFolderBase folder in invCollection.Folders) // { - // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back folder {0} {1}", folder.Name, folder.ID); + // m_log.DebugFormat("[GRID INVENTORY SERVICE]: Sending back folder {0} {1}", folder.Name, folder.ID); // } // // foreach (InventoryItemBase item in invCollection.Items) // { - // m_log.DebugFormat("[GRID AGENT INVENTORY]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); + // m_log.DebugFormat("[GRID INVENTORY SERVICE]: Sending back item {0} {1}, folder {2}", item.Name, item.ID, item.Folder); // } m_log.InfoFormat( - "[LOCAL INVENTORY SERVICE]: Sending back inventory response to user {0} containing {1} folders and {2} items", + "[INVENTORY SERVICE]: Sending back inventory response to user {0} containing {1} folders and {2} items", invCollection.UserID, invCollection.Folders.Count, invCollection.Items.Count); return invCollection; @@ -194,7 +195,7 @@ namespace OpenSim.Services.InventoryService /// public void GetUserInventory(UUID userID, InventoryReceiptCallback callback) { - m_log.InfoFormat("[LOCAL INVENTORY SERVICE]: Requesting inventory for user {0}", userID); + m_log.InfoFormat("[INVENTORY SERVICE]: Requesting inventory for user {0}", userID); List folders = new List(); List items = new List(); @@ -231,15 +232,15 @@ namespace OpenSim.Services.InventoryService } m_log.InfoFormat( - "[LOCAL INVENTORY SERVICE]: Received inventory response for user {0} containing {1} folders and {2} items", + "[INVENTORY SERVICE]: Received inventory response for user {0} containing {1} folders and {2} items", userID, folders.Count, items.Count); } else { - m_log.WarnFormat("[LOCAL INVENTORY SERVICE]: User {0} inventory not available", userID); + m_log.WarnFormat("[INVENTORY SERVICE]: User {0} inventory not available", userID); } - callback(folders, items); + callback.BeginInvoke(folders, items, null, null); } public List GetActiveGestures(UUID userId) @@ -287,7 +288,7 @@ namespace OpenSim.Services.InventoryService public virtual bool AddFolder(InventoryFolderBase folder) { m_log.DebugFormat( - "[AGENT INVENTORY]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); + "[INVENTORY SERVICE]: Adding folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); foreach (IInventoryDataPlugin plugin in m_plugins) { @@ -302,7 +303,7 @@ namespace OpenSim.Services.InventoryService public virtual bool UpdateFolder(InventoryFolderBase folder) { m_log.DebugFormat( - "[AGENT INVENTORY]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); + "[INVENTORY SERVICE]: Updating folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); foreach (IInventoryDataPlugin plugin in m_plugins) { @@ -317,7 +318,7 @@ namespace OpenSim.Services.InventoryService public virtual bool MoveFolder(InventoryFolderBase folder) { m_log.DebugFormat( - "[AGENT INVENTORY]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); + "[INVENTORY SERVICE]: Moving folder {0} {1} to folder {2}", folder.Name, folder.ID, folder.ParentID); foreach (IInventoryDataPlugin plugin in m_plugins) { @@ -332,7 +333,7 @@ namespace OpenSim.Services.InventoryService public virtual bool AddItem(InventoryItemBase item) { m_log.DebugFormat( - "[AGENT INVENTORY]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); + "[INVENTORY SERVICE]: Adding item {0} {1} to folder {2}", item.Name, item.ID, item.Folder); foreach (IInventoryDataPlugin plugin in m_plugins) { @@ -347,7 +348,7 @@ namespace OpenSim.Services.InventoryService public virtual bool UpdateItem(InventoryItemBase item) { m_log.InfoFormat( - "[AGENT INVENTORY]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); + "[INVENTORY SERVICE]: Updating item {0} {1} in folder {2}", item.Name, item.ID, item.Folder); foreach (IInventoryDataPlugin plugin in m_plugins) { @@ -362,7 +363,7 @@ namespace OpenSim.Services.InventoryService public virtual bool DeleteItem(InventoryItemBase item) { m_log.InfoFormat( - "[AGENT INVENTORY]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); + "[INVENTORY SERVICE]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); foreach (IInventoryDataPlugin plugin in m_plugins) { @@ -407,13 +408,13 @@ namespace OpenSim.Services.InventoryService public virtual bool PurgeFolder(InventoryFolderBase folder) { m_log.DebugFormat( - "[AGENT INVENTORY]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); + "[INVENTORY SERVICE]: Purging folder {0} {1} of its contents", folder.Name, folder.ID); List subFolders = RequestSubFolders(folder.ID); foreach (InventoryFolderBase subFolder in subFolders) { -// m_log.DebugFormat("[AGENT INVENTORY]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); +// m_log.DebugFormat("[INVENTORY SERVICE]: Deleting folder {0} {1}", subFolder.Name, subFolder.ID); foreach (IInventoryDataPlugin plugin in m_plugins) { diff --git a/OpenSim/Services/InventoryService/InventoryServiceBase.cs b/OpenSim/Services/InventoryService/InventoryServiceBase.cs index 179d541..4526c34 100644 --- a/OpenSim/Services/InventoryService/InventoryServiceBase.cs +++ b/OpenSim/Services/InventoryService/InventoryServiceBase.cs @@ -44,19 +44,37 @@ namespace OpenSim.Services.InventoryService public InventoryServiceBase(IConfigSource config) : base(config) { - IConfig assetConfig = config.Configs["InventoryService"]; - if (assetConfig == null) + string dllName = String.Empty; + string connString = String.Empty; + + // + // Try reading the [DatabaseService] section first, if it exists + // + IConfig dbConfig = config.Configs["DatabaseService"]; + if (dbConfig != null) + { + dllName = dbConfig.GetString("StorageProvider", String.Empty); + connString = dbConfig.GetString("ConnectionString", String.Empty); + } + else + Console.WriteLine("------ dbConfig = null!"); + + // + // Try reading the more specific [InventoryService] section, if it exists + // + IConfig inventoryConfig = config.Configs["InventoryService"]; + if (inventoryConfig != null) + { + dllName = inventoryConfig.GetString("StorageProvider", dllName); + connString = inventoryConfig.GetString("ConnectionString", connString); + } + + // + // We tried, but this doesn't exist. We can't proceed. + // + if (dllName.Equals(String.Empty)) throw new Exception("No InventoryService configuration"); - string dllName = assetConfig.GetString("StorageProvider", - String.Empty); - - if (dllName == String.Empty) - throw new Exception("No StorageProvider configured"); - - string connString = assetConfig.GetString("ConnectionString", - String.Empty); - m_Database = LoadPlugin(dllName); if (m_Database == null) throw new Exception("Could not find a storage interface in the given module"); -- cgit v1.1