From 863195612bdef56165f2b4354bab280c371618b9 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Thu, 27 Sep 2007 14:57:43 +0000 Subject: Reverting back to 2017 since 2018 were causing Linux breakage; reopening Tleiades patch 444 and 445. --- OpenSim/Grid/InventoryServer/InventoryManager.cs | 131 ++++++++-------------- OpenSim/Grid/InventoryServer/InventoryService.cs | 136 ----------------------- OpenSim/Grid/InventoryServer/Main.cs | 113 +++---------------- 3 files changed, 62 insertions(+), 318 deletions(-) delete mode 100644 OpenSim/Grid/InventoryServer/InventoryService.cs (limited to 'OpenSim/Grid/InventoryServer') diff --git a/OpenSim/Grid/InventoryServer/InventoryManager.cs b/OpenSim/Grid/InventoryServer/InventoryManager.cs index a46f359..016b8bb 100644 --- a/OpenSim/Grid/InventoryServer/InventoryManager.cs +++ b/OpenSim/Grid/InventoryServer/InventoryManager.cs @@ -26,34 +26,37 @@ * */ using System; -using System.Text; -using System.Reflection; using System.Collections; using System.Collections.Generic; +using System.Text; +using OpenGrid.Framework.Data; using libsecondlife; +using System.Reflection; using System.Xml; -using OpenSim.Framework.Console; +using Nwc.XmlRpc; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; using OpenSim.Framework.Utilities; -using OpenSim.Framework.Data; -using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; -namespace OpenSim.Grid.InventoryServer +using System.Security.Cryptography; + +namespace OpenGridServices.InventoryServer { - class InventoryManager : IInventoryData + class InventoryManager { - IInventoryData _databasePlugin; + Dictionary _plugins = new Dictionary(); /// /// Adds a new inventory server plugin - user servers will be requested in the order they were loaded. /// /// The filename to the inventory server plugin DLL - public void AddDatabasePlugin(string FileName) + public void AddPlugin(string FileName) { - MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Invenstorage: Attempting to load " + FileName); + OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Attempting to load " + FileName); Assembly pluginAssembly = Assembly.LoadFrom(FileName); - MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); + OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); foreach (Type pluginType in pluginAssembly.GetTypes()) { if (!pluginType.IsAbstract) @@ -64,9 +67,8 @@ namespace OpenSim.Grid.InventoryServer { IInventoryData plug = (IInventoryData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); plug.Initialise(); - _databasePlugin = plug; - MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Invenstorage: Added IInventoryData Interface"); - break; + this._plugins.Add(plug.getName(), plug); + OpenSim.Framework.Console.MainConsole.Instance.Verbose( "Invenstorage: Added IUserData Interface"); } typeInterface = null; @@ -78,87 +80,46 @@ namespace OpenSim.Grid.InventoryServer public List getRootFolders(LLUUID user) { + foreach (KeyValuePair kvp in _plugins) + { + try + { + return kvp.Value.getUserRootFolders(user); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.Notice("Unable to get root folders via " + kvp.Key + " (" + e.ToString() + ")"); + } + } return null; } - #region IInventoryData Members - - - public List getInventoryInFolder(LLUUID folderID) - { - return _databasePlugin.getInventoryInFolder(folderID); - } - - public List getUserRootFolders(LLUUID user) - { - return _databasePlugin.getUserRootFolders(user); - } - - public List getInventoryFolders(LLUUID parentID) - { - return _databasePlugin.getInventoryFolders(parentID); - } - - public InventoryItemBase getInventoryItem(LLUUID item) - { - throw new Exception("The method or operation is not implemented."); - } - - public InventoryFolderBase getInventoryFolder(LLUUID folder) - { - return _databasePlugin.getInventoryFolder(folder); - } - - public void addInventoryItem(InventoryItemBase item) + public XmlRpcResponse XmlRpcInventoryRequest(XmlRpcRequest request) { - _databasePlugin.addInventoryItem(item); - } - - public void updateInventoryItem(InventoryItemBase item) - { - throw new Exception("The method or operation is not implemented."); - } - - public void deleteInventoryItem(InventoryItemBase item) - { - throw new Exception("The method or operation is not implemented."); - } + XmlRpcResponse response = new XmlRpcResponse(); + Hashtable requestData = (Hashtable)request.Params[0]; - public void addInventoryFolder(InventoryFolderBase folder) - { - _databasePlugin.addInventoryFolder(folder); - } + Hashtable responseData = new Hashtable(); - public void updateInventoryFolder(InventoryFolderBase folder) - { - throw new Exception("The method or operation is not implemented."); - } - - public void Initialise() - { - throw new Exception("The method or operation is not implemented."); - } + // Stuff happens here - public void Close() - { - throw new Exception("The method or operation is not implemented."); - } + if (requestData.ContainsKey("Access-type")) + { + if (requestData["access-type"] == "rootfolders") + { +// responseData["rootfolders"] = + } + } + else + { + responseData["error"] = "No access-type specified."; + } - public string getName() - { - throw new Exception("The method or operation is not implemented."); - } - public string getVersion() - { - throw new Exception("The method or operation is not implemented."); - } + // Stuff stops happening here - public void deleteInventoryCategory(InventoryCategory inventoryCategory) - { - _databasePlugin.deleteInventoryCategory(inventoryCategory); + response.Value = responseData; + return response; } - - #endregion } } diff --git a/OpenSim/Grid/InventoryServer/InventoryService.cs b/OpenSim/Grid/InventoryServer/InventoryService.cs deleted file mode 100644 index cbc0558..0000000 --- a/OpenSim/Grid/InventoryServer/InventoryService.cs +++ /dev/null @@ -1,136 +0,0 @@ -using System; -using System.Runtime.Remoting; -using System.Runtime.Remoting.Channels; -using System.Runtime.Remoting.Channels.Tcp; -using System.Runtime.Serialization.Formatters; -using System.Collections; -using System.Collections.Generic; - - -using libsecondlife; -using OpenSim.Framework.Data; -using OpenSim.Framework.Communications; -using OpenSim.Framework.Configuration; -using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; - -namespace OpenSim.Grid.InventoryServer -{ - class InventoryServiceSingleton : OpenSim.Framework.Communications.InventoryServiceBase - { - static InventoryManager _inventoryManager; - - static public InventoryManager InventoryManager - { - set { _inventoryManager = value; } - get { return _inventoryManager; } - } - -#region Singleton Pattern - static InventoryServiceSingleton instance=null; - - InventoryServiceSingleton() - { - } - - public static InventoryServiceSingleton Instance - { - get - { - if (instance==null) - { - instance = new InventoryServiceSingleton(); - } - return instance; - } - } -#endregion - -#region IInventoryServices Members - - public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack) - { - List folders = this.RequestFirstLevelFolders(userID); - InventoryFolderBase rootFolder = null; - - //need to make sure we send root folder first - foreach (InventoryFolderBase folder in folders) - { - if (folder.parentID == libsecondlife.LLUUID.Zero) - { - rootFolder = folder; - folderCallBack(userID, folder); - } - } - - if (rootFolder != null) - { - foreach (InventoryFolderBase folder in folders) - { - if (folder.folderID != rootFolder.folderID) - { - folderCallBack(userID, folder); - - List items = this.RequestFolderItems(folder.folderID); - foreach (InventoryItemBase item in items) - { - itemCallBack(userID, item); - } - } - } - } - - } - - public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) - { - _inventoryManager.addInventoryFolder(folder); - } - - public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) - { - throw new Exception("Not implemented exception"); - } - - public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) - { - throw new Exception("Not implemented exception"); - } - - public List RequestFolderItems(LLUUID folderID) - { - return _inventoryManager.getInventoryInFolder(folderID); - } - - -#endregion - } - - class InventoryService - { - InventoryServiceSingleton _inventoryServiceMethods; - public InventoryService(InventoryManager inventoryManager, InventoryConfig cfg) - { - // we only need to register the tcp channel once, and we don't know which other modules use remoting - if (ChannelServices.GetChannel("tcp") == null) - { - // Creating a custom formatter for a TcpChannel sink chain. - BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(); - serverProvider.TypeFilterLevel = TypeFilterLevel.Full; - - IDictionary props = new Hashtable(); - props["port"] = cfg.RemotingPort; - props["typeFilterLevel"] = TypeFilterLevel.Full; - - // Pass the properties for the port setting and the server provider in the server chain argument. (Client remains null here.) - ChannelServices.RegisterChannel(new TcpChannel(props, null, serverProvider), true); - } - - // Register the object - RemotingConfiguration.RegisterWellKnownServiceType(typeof(InventoryServiceSingleton), "Inventory", WellKnownObjectMode.Singleton); - - _inventoryServiceMethods = InventoryServiceSingleton.Instance; - InventoryServiceSingleton.InventoryManager = inventoryManager; - } - - } -} diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index 392c741..97addb0 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs @@ -31,130 +31,49 @@ using System.Collections.Generic; using System.Reflection; using System.IO; using System.Text; -using System.Xml; - using libsecondlife; +using OpenSim.Framework.User; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Console; +using OpenSim.Servers; using OpenSim.Framework.Utilities; -using OpenSim.Framework.Configuration; -using OpenSim.Framework.Data; -using InventoryCategory = OpenSim.Framework.Data.InventoryCategory; -namespace OpenSim.Grid.InventoryServer +namespace OpenGridServices.InventoryServer { - - public class OpenInventory_Main : conscmd_callback + public class OpenInventory_Main : BaseServer, conscmd_callback { + ConsoleBase m_console; + InventoryManager m_inventoryManager; - public const string MainLogName = "INVENTORY"; - - private InventoryConfig m_config; - LogBase m_console; - InventoryManager m_inventoryManager; ///connection the database backend - InventoryService m_inventoryService; ///Remoting interface, where messages arrive - [STAThread] public static void Main(string[] args) { - Console.WriteLine("Launching InventoryServer..."); - - OpenInventory_Main inventoryServer = new OpenInventory_Main(); - - inventoryServer.Startup(); - -// inventoryServer.RunCmd("load", new string[] { "library", "inventory_library.xml" }); -// inventoryServer.RunCmd("load", new string[] { "default", "inventory_default.xml" }); - - inventoryServer.Work(); } public OpenInventory_Main() { - - if (!Directory.Exists(Util.logDir())) - { - Directory.CreateDirectory(Util.logDir()); - } - - m_console = new LogBase(Path.Combine(Util.logDir(), "opensim-inventory-console.log"), "OpenInventory", this, false); - MainLog.Instance = m_console; - } - - private void Work() - { - m_console.Notice(OpenInventory_Main.MainLogName, "Enter help for a list of commands\n"); - - while (true) - { - m_console.MainLogPrompt(); - } + m_console = new ConsoleBase("opengrid-inventory-console.log", "OpenInventory", this, false); + MainConsole.Instance = m_console; } public void Startup() { - MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Initialising inventory manager..."); - - m_config = new InventoryConfig(OpenInventory_Main.MainLogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); - - // instantiate the manager, responsible for doing the actual storage + MainConsole.Instance.Notice("Initialising inventory manager..."); m_inventoryManager = new InventoryManager(); - m_inventoryManager.AddDatabasePlugin(m_config.DatabaseProvider); - - m_inventoryService = new InventoryService(m_inventoryManager, m_config); - // Dig out the embedded version number of this assembly - Assembly assembly = Assembly.GetExecutingAssembly(); - string serverExeName = assembly.ManifestModule.Name; - Version serverExeVersion = AssemblyName.GetAssemblyName(serverExeName).Version; + MainConsole.Instance.Notice("Starting HTTP server"); + BaseHttpServer httpServer = new BaseHttpServer(8004); - m_console.Status(OpenInventory_Main.MainLogName, "Inventoryserver {0}.{1}.{2}.{3} - Startup complete", serverExeVersion.Major, serverExeVersion.Minor, serverExeVersion.Revision, serverExeVersion.Build); - } - - - public void Load(string[] cmdparams) - { - string cmd = cmdparams[0]; - string fileName = cmdparams[1]; - - if (cmdparams.Length != 2) - { - cmd = "help"; - } - - switch (cmd) - { - case "library": - InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.Library, fileName); - break; - case "default": - InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.Default, fileName); - break; - case "user": - InventoryServiceSingleton.Instance.loadInventoryFromXmlFile(InventoryCategory.User, fileName); - break; - case "help": - m_console.Notice("load library , load library inventory, shared between all users"); - m_console.Notice("load default , load template inventory, used when creating a new user inventory"); - m_console.Notice("load user , load inventory for a specific users, warning this will reset the contents of the inventory"); - break; - } + httpServer.AddXmlRPCHandler("rootfolders", m_inventoryManager.XmlRpcInventoryRequest); + //httpServer.AddRestHandler("GET","/rootfolders/",Rest } public void RunCmd(string cmd, string[] cmdparams) { switch (cmd) - { - case "help": - m_console.Notice("load - load verious inventories, use \"load help\", to see a list of commands"); - m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); - m_console.Notice("quit - shutdown the grid (USE CAUTION!)"); - break; - case "load": - Load(cmdparams); - break; - case "quit": + { case "shutdown": - MainLog.Instance.Verbose(OpenInventory_Main.MainLogName, "Shutting down inventory server"); m_console.Close(); Environment.Exit(0); break; -- cgit v1.1