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. --- .../Communications/Hypergrid/HGUserServices.cs | 7 + .../Hypergrid/HGStandaloneInventoryModule.cs | 167 --------------------- .../Resources/CoreModulePlugin.addin.xml | 5 +- .../Inventory/HGInventoryBroker.cs | 40 ++--- .../Inventory/LocalInventoryServiceConnector.cs | 33 ++-- .../Inventory/RemoteInventoryServiceConnector.cs | 16 +- OpenSim/Region/Framework/Scenes/Scene.cs | 20 +++ 7 files changed, 87 insertions(+), 201 deletions(-) delete mode 100644 OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs index fd831bf..7352e2d 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs @@ -35,6 +35,7 @@ using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Clients; using OpenSim.Region.Communications.OGS1; using OpenSim.Region.Communications.Local; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.Communications.Hypergrid { @@ -63,6 +64,12 @@ namespace OpenSim.Region.Communications.Hypergrid m_localUserServices = local; } + public override void SetInventoryService(IInventoryService invService) + { + base.SetInventoryService(invService); + m_localUserServices.SetInventoryService(invService); + } + public override UUID AddUser( string firstName, string lastName, string password, string email, uint regX, uint regY, UUID uuid) { diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs deleted file mode 100644 index 6149822..0000000 --- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneInventoryModule.cs +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using log4net; -using Nini.Config; -using OpenMetaverse; -using OpenSim.Data; -using OpenSim.Framework; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Communications.Cache; -using OpenSim.Framework.Communications.Services; -using Caps = OpenSim.Framework.Communications.Capabilities.Caps; -using LLSDHelpers = OpenSim.Framework.Communications.Capabilities.LLSDHelpers; -using OpenSim.Framework.Servers; -using OpenSim.Framework.Servers.HttpServer; -using OpenSim.Region.Framework.Interfaces; -using OpenSim.Region.Framework.Scenes; -using OpenSim.Region.CoreModules.ServiceConnectors.Interregion; - -using OpenMetaverse.StructuredData; - -namespace OpenSim.Region.CoreModules.Hypergrid -{ - public class HGStandaloneInventoryModule : IRegionModule - { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static bool initialized = false; - private static bool enabled = false; - private static bool safemode = false; - - private bool m_doLookup = false; - Scene m_scene; - HGInventoryService m_inventoryService; - InventoryServiceBase m_inventoryBase; - - public bool DoLookup - { - get { return m_doLookup; } - set { m_doLookup = value; } - } - - #region IRegionModule interface - - public void Initialise(Scene scene, IConfigSource config) - { - if (!initialized) - { - initialized = true; - m_scene = scene; - - // This module is only on for standalones - enabled = !config.Configs["Startup"].GetBoolean("gridmode", true) && config.Configs["Startup"].GetBoolean("hypergrid", false); - if (config.Configs["Hypergrid"] != null) - safemode = config.Configs["Hypergrid"].GetBoolean("safemode", false); - } - } - - public void PostInitialise() - { - if (enabled) - { - m_log.Info("[HGStandaloneInvModule]: Starting..."); - //m_inventoryService = new InventoryService(m_scene); - m_inventoryBase = (InventoryServiceBase)m_scene.CommsManager.SecureInventoryService; - - m_inventoryService = new HGInventoryService(m_inventoryBase, m_scene.AssetService, - (UserManagerBase)m_scene.CommsManager.UserAdminService, m_scene.CommsManager.HttpServer, - m_scene.CommsManager.NetworkServersInfo.InventoryURL); - - AddHttpHandlers(m_scene.CommsManager.HttpServer); - m_inventoryService.AddHttpHandlers(); - } - } - - public void Close() - { - } - - public string Name - { - get { return "HGStandaloneInventoryModule"; } - } - - public bool IsSharedModule - { - get { return true; } - } - - #endregion - - public virtual void AddHttpHandlers(IHttpServer httpServer) - { - if (!safemode) - { - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/GetInventory/", m_inventoryService.GetUserInventory, CheckAuthSession)); - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/DeleteItem/", m_inventoryBase.DeleteItem, CheckAuthSession)); - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/UpdateFolder/", m_inventoryBase.UpdateFolder, CheckAuthSession)); - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/MoveFolder/", m_inventoryBase.MoveFolder, CheckAuthSession)); - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/PurgeFolder/", m_inventoryBase.PurgeFolder, CheckAuthSession)); - } - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/NewFolder/", m_inventoryBase.AddFolder, CheckAuthSession)); - - httpServer.AddStreamHandler( - new RestDeserialiseSecureHandler( - "POST", "/NewItem/", m_inventoryBase.AddItem, CheckAuthSession)); - - - } - - /// - /// Check that the source of an inventory request for a particular agent is a current session belonging to - /// that agent. - /// - /// - /// - /// - public bool CheckAuthSession(string session_id, string avatar_id) - { - return true; - } - - } - -} diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 9969ebe..10e2ec2 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -18,8 +18,11 @@ - + + + + diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/HGInventoryBroker.cs index 3a0011f..03b4873 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/HGInventoryBroker.cs @@ -84,13 +84,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory if (localDll == String.Empty) { m_log.Error("[HG INVENTORY CONNECTOR]: No LocalGridInventoryService named in section InventoryService"); - return; + //return; + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); } if (HGDll == String.Empty) { m_log.Error("[HG INVENTORY CONNECTOR]: No HypergridInventoryService named in section InventoryService"); - return; + //return; + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); } Object[] args = new Object[] { source }; @@ -116,7 +118,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory m_LocalGridInventoryURI = inventoryConfig.GetString("InventoryServerURI", string.Empty); m_Enabled = true; - m_log.Info("[HG INVENTORY CONNECTOR]: HG asset broker enabled"); + m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled"); } } } @@ -139,6 +141,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory m_Scene = scene; // HACK for now. Ugh! m_UserProfileService = m_Scene.CommsManager.UserProfileCacheService; + // ugh! + m_UserProfileService.SetInventoryService(this); + scene.CommsManager.UserService.SetInventoryService(this); + + m_Initialized = true; } scene.RegisterModuleInterface(this); @@ -153,7 +160,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory if (!m_Enabled) return; - m_log.InfoFormat("[INVENTORY CONNECTOR]: Enabled remote inventory for region {0}", scene.RegionInfo.RegionName); + m_log.InfoFormat("[INVENTORY CONNECTOR]: Enabled HG inventory for region {0}", scene.RegionInfo.RegionName); } @@ -161,10 +168,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory public bool CreateUserInventory(UUID userID) { - if (IsLocalGridUser(userID)) - return m_GridService.CreateUserInventory(userID); - else - return false; + return m_GridService.CreateUserInventory(userID); } public List GetInventorySkeleton(UUID userId) @@ -187,7 +191,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory else { UUID sessionID = GetSessionID(userID); - string uri = "http://" + GetUserInventoryURI(userID) + "/" + userID.ToString(); + string uri = GetUserInventoryURI(userID) + "/" + userID.ToString(); m_HGService.GetUserInventory(uri, sessionID, callback); } } @@ -207,7 +211,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory else { UUID sessionID = GetSessionID(folder.Owner); - string uri = "http://" + GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); + string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); return m_HGService.AddFolder(uri, folder, sessionID); } } @@ -222,7 +226,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory else { UUID sessionID = GetSessionID(folder.Owner); - string uri = "http://" + GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); + string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); return m_HGService.UpdateFolder(uri, folder, sessionID); } } @@ -237,7 +241,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory else { UUID sessionID = GetSessionID(folder.Owner); - string uri = "http://" + GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); + string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); return m_HGService.MoveFolder(uri, folder, sessionID); } } @@ -252,7 +256,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory else { UUID sessionID = GetSessionID(folder.Owner); - string uri = "http://" + GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); + string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); return m_HGService.PurgeFolder(uri, folder, sessionID); } } @@ -267,7 +271,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory else { UUID sessionID = GetSessionID(item.Owner); - string uri = "http://" + GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); + string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); return m_HGService.AddItem(uri, item, sessionID); } } @@ -282,7 +286,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory else { UUID sessionID = GetSessionID(item.Owner); - string uri = "http://" + GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); + string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); return m_HGService.UpdateItem(uri, item, sessionID); } } @@ -297,7 +301,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory else { UUID sessionID = GetSessionID(item.Owner); - string uri = "http://" + GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); + string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); return m_HGService.DeleteItem(uri, item, sessionID); } } @@ -312,7 +316,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory else { UUID sessionID = GetSessionID(item.Owner); - string uri = "http://" + GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); + string uri = GetUserInventoryURI(item.Owner) + "/" + item.Owner.ToString(); return m_HGService.QueryItem(uri, item, sessionID); } } @@ -327,7 +331,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory else { UUID sessionID = GetSessionID(folder.Owner); - string uri = "http://" + GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); + string uri = GetUserInventoryURI(folder.Owner) + "/" + folder.Owner.ToString(); return m_HGService.QueryFolder(uri, folder, sessionID); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs index 6b72e9b..ce64d4d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/LocalInventoryServiceConnector.cs @@ -27,6 +27,7 @@ using log4net; using Nini.Config; + using System; using System.Collections.Generic; using System.Reflection; @@ -38,10 +39,10 @@ using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; using OpenMetaverse; + namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory { - public class LocalInventoryServicesConnector : - ISharedRegionModule, IInventoryService + public class LocalInventoryServicesConnector : ISharedRegionModule, IInventoryService { private static readonly ILog m_log = LogManager.GetLogger( @@ -50,6 +51,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory private IInventoryService m_InventoryService; private bool m_Enabled = false; + private bool m_Initialized = false; public string Name { @@ -64,15 +66,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory string name = moduleConfig.GetString("InventoryServices", ""); if (name == Name) { - IConfig assetConfig = source.Configs["InventoryService"]; - if (assetConfig == null) + IConfig inventoryConfig = source.Configs["InventoryService"]; + if (inventoryConfig == null) { m_log.Error("[INVENTORY CONNECTOR]: InventoryService missing from OpenSim.ini"); return; } - string serviceDll = assetConfig.GetString("LocalServiceModule", - String.Empty); + string serviceDll = inventoryConfig.GetString("LocalServiceModule", String.Empty); if (serviceDll == String.Empty) { @@ -81,14 +82,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory } Object[] args = new Object[] { source }; - m_InventoryService = - ServerUtils.LoadPlugin(serviceDll, - args); + m_log.DebugFormat("[INVENTORY CONNECTOR]: Service dll = {0}", serviceDll); + + m_InventoryService = ServerUtils.LoadPlugin(serviceDll, args); if (m_InventoryService == null) { - m_log.Error("[INVENTORY CONNECTOR]: Can't load asset service"); - return; + m_log.Error("[INVENTORY CONNECTOR]: Can't load inventory service"); + //return; + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); } //List plugins @@ -121,7 +123,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory if (!m_Enabled) return; + if (!m_Initialized) + { + // ugh! + scene.CommsManager.UserProfileCacheService.SetInventoryService(this); + scene.CommsManager.UserService.SetInventoryService(this); + m_Initialized = true; + } + scene.RegisterModuleInterface(this); + } public void RemoveRegion(Scene scene) diff --git a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/RemoteInventoryServiceConnector.cs index b695fce..cd13c3d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/RemoteInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectors/Inventory/RemoteInventoryServiceConnector.cs @@ -40,12 +40,10 @@ using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory { - public class RemoteInventoryServicesConnector : - ISharedRegionModule, IInventoryService + public class RemoteInventoryServicesConnector : ISharedRegionModule, IInventoryService { private static readonly ILog m_log = - LogManager.GetLogger( - MethodBase.GetCurrentMethod().DeclaringType); + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_Enabled = false; private bool m_Initialized = false; @@ -57,6 +55,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory get { return "RemoteInventoryServicesConnector"; } } + public RemoteInventoryServicesConnector() + { + } + public RemoteInventoryServicesConnector(IConfigSource source) { Init(source); @@ -100,7 +102,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Inventory return; if (!m_Initialized) + { m_Scene = scene; + // ugh! + scene.CommsManager.UserProfileCacheService.SetInventoryService(this); + scene.CommsManager.UserService.SetInventoryService(this); + m_Initialized = true; + } scene.RegisterModuleInterface(this); } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d18af46..5349d87 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -146,6 +146,26 @@ namespace OpenSim.Region.Framework.Scenes } } + protected IInventoryService m_InventoryService = null; + + public IInventoryService InventoryService + { + get + { + if (m_InventoryService == null) + { + m_InventoryService = RequestModuleInterface(); + + if (m_InventoryService == null) + { + throw new Exception("No IInventoryService available."); + } + } + + return m_InventoryService; + } + } + protected IXMLRPC m_xmlrpcModule; protected IWorldComm m_worldCommModule; protected IAvatarFactory m_AvatarFactory; -- cgit v1.1