* Remove old historical grid inventory code
parent
550018f02d
commit
8293be6811
|
@ -1,207 +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 OpenSim 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.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Xml;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
using libsecondlife;
|
|
||||||
using log4net;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Framework.Servers;
|
|
||||||
|
|
||||||
namespace OpenSim.Grid.InventoryServer
|
|
||||||
{
|
|
||||||
public class InventoryManager
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private IInventoryData _databasePlugin;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a new inventory server plugin - user servers will be requested in the order they were loaded.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="FileName">The filename to the inventory server plugin DLL</param>
|
|
||||||
public void AddDatabasePlugin(string FileName, string dbconnect)
|
|
||||||
{
|
|
||||||
m_log.Info("[" + OpenInventory_Main.LogName + "]: Invenstorage: Attempting to load " + FileName);
|
|
||||||
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
|
|
||||||
|
|
||||||
m_log.Info("[" + OpenInventory_Main.LogName + "]: " +
|
|
||||||
"Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
|
|
||||||
foreach (Type pluginType in pluginAssembly.GetTypes())
|
|
||||||
{
|
|
||||||
if (!pluginType.IsAbstract)
|
|
||||||
{
|
|
||||||
Type typeInterface = pluginType.GetInterface("IInventoryData", true);
|
|
||||||
|
|
||||||
if (typeInterface != null)
|
|
||||||
{
|
|
||||||
IInventoryData plug =
|
|
||||||
(IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
|
||||||
plug.Initialise(dbconnect);
|
|
||||||
_databasePlugin = plug;
|
|
||||||
m_log.Info("[" + OpenInventory_Main.LogName + "]: " +
|
|
||||||
"Invenstorage: Added IInventoryData Interface");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static SerializableInventory loadInventoryFromXmlFile(string fileName)
|
|
||||||
{
|
|
||||||
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
|
|
||||||
XmlReader reader = new XmlTextReader(fs);
|
|
||||||
XmlSerializer x = new XmlSerializer(typeof (SerializableInventory));
|
|
||||||
SerializableInventory inventory = (SerializableInventory) x.Deserialize(reader);
|
|
||||||
fs.Close();
|
|
||||||
fs.Dispose();
|
|
||||||
return inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void saveInventoryToStream(SerializableInventory inventory, Stream s)
|
|
||||||
{
|
|
||||||
XmlTextWriter writer = new XmlTextWriter(s, Encoding.UTF8);
|
|
||||||
writer.Formatting = Formatting.Indented;
|
|
||||||
XmlSerializer x = new XmlSerializer(typeof (SerializableInventory));
|
|
||||||
x.Serialize(writer, inventory);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static bool fixupFolder(SerializableInventory.SerializableFolder f,
|
|
||||||
SerializableInventory.SerializableFolder parent)
|
|
||||||
{
|
|
||||||
bool modified = false;
|
|
||||||
|
|
||||||
// ensure we have a valid folder id
|
|
||||||
if (f.ID == LLUUID.Zero)
|
|
||||||
{
|
|
||||||
f.ID = LLUUID.Random();
|
|
||||||
modified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensure we have valid agent id
|
|
||||||
if (f.Owner == LLUUID.Zero)
|
|
||||||
{
|
|
||||||
if (parent != null)
|
|
||||||
f.Owner = parent.Owner;
|
|
||||||
else
|
|
||||||
f.Owner = f.ID;
|
|
||||||
modified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (f.ParentID == LLUUID.Zero && parent != null)
|
|
||||||
{
|
|
||||||
f.ParentID = parent.ID;
|
|
||||||
modified = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach (SerializableInventory.SerializableFolder child in f.SubFolders)
|
|
||||||
{
|
|
||||||
modified |= fixupFolder(child, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static bool fixupInventory(SerializableInventory inventory)
|
|
||||||
{
|
|
||||||
return fixupFolder(inventory.root, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class GetInventory : BaseStreamHandler
|
|
||||||
{
|
|
||||||
private SerializableInventory _inventory;
|
|
||||||
private InventoryManager _manager;
|
|
||||||
|
|
||||||
public GetInventory(InventoryManager manager)
|
|
||||||
: base("GET", "/inventory")
|
|
||||||
{
|
|
||||||
_manager = manager;
|
|
||||||
|
|
||||||
_inventory = loadInventoryFromXmlFile("attic/inventory/Inventory_Library.xml");
|
|
||||||
if (fixupInventory(_inventory))
|
|
||||||
{
|
|
||||||
FileStream fs = new FileStream("attic/inventory/Inventory_Library.xml", FileMode.Truncate, FileAccess.Write);
|
|
||||||
saveInventoryToStream(_inventory, fs);
|
|
||||||
fs.Flush();
|
|
||||||
fs.Close();
|
|
||||||
m_log.Debug("[" + OpenInventory_Main.LogName + "]: Modified");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateDefaultInventory(LLUUID userID)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private byte[] GetUserInventory(LLUUID userID)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[" + OpenInventory_Main.LogName + "]: Getting Inventory for user {0}", userID.ToString());
|
|
||||||
byte[] result = new byte[] {};
|
|
||||||
|
|
||||||
InventoryFolderBase fb = _manager._databasePlugin.getUserRootFolder(userID);
|
|
||||||
if (fb == null)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[" + OpenInventory_Main.LogName + "]: Inventory not found for user {0}, creating new",
|
|
||||||
userID.ToString());
|
|
||||||
CreateDefaultInventory(userID);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override byte[] Handle(string path, Stream request)
|
|
||||||
{
|
|
||||||
byte[] result = new byte[] {};
|
|
||||||
|
|
||||||
string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
|
|
||||||
if (parms.Length > 1)
|
|
||||||
{
|
|
||||||
if (string.Compare(parms[1], "library", true) == 0)
|
|
||||||
{
|
|
||||||
MemoryStream ms = new MemoryStream();
|
|
||||||
saveInventoryToStream(_inventory, ms);
|
|
||||||
|
|
||||||
result = ms.GetBuffer();
|
|
||||||
Array.Resize<byte>(ref result, (int) ms.Length);
|
|
||||||
}
|
|
||||||
else if (string.Compare(parms[1], "user", true) == 0)
|
|
||||||
{
|
|
||||||
if (parms.Length > 2)
|
|
||||||
{
|
|
||||||
result = GetUserInventory(new LLUUID(parms[2]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -42,7 +42,6 @@ namespace OpenSim.Grid.InventoryServer
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
private InventoryManager m_inventoryManager;
|
|
||||||
private InventoryConfig m_config;
|
private InventoryConfig m_config;
|
||||||
private GridInventoryService m_inventoryService;
|
private GridInventoryService m_inventoryService;
|
||||||
|
|
||||||
|
@ -71,7 +70,6 @@ namespace OpenSim.Grid.InventoryServer
|
||||||
m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml")));
|
m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml")));
|
||||||
|
|
||||||
m_inventoryService = new GridInventoryService();
|
m_inventoryService = new GridInventoryService();
|
||||||
// m_inventoryManager = new InventoryManager();
|
|
||||||
m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
|
m_inventoryService.AddPlugin(m_config.DatabaseProvider, m_config.DatabaseConnect);
|
||||||
|
|
||||||
m_log.Info("[" + LogName + "]: Starting HTTP server ...");
|
m_log.Info("[" + LogName + "]: Starting HTTP server ...");
|
||||||
|
@ -121,8 +119,6 @@ namespace OpenSim.Grid.InventoryServer
|
||||||
m_httpServer.AddStreamHandler(
|
m_httpServer.AddStreamHandler(
|
||||||
new RestDeserialisehandler<Guid, List<InventoryFolderBase>>
|
new RestDeserialisehandler<Guid, List<InventoryFolderBase>>
|
||||||
("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton));
|
("POST", "/RootFolders/", m_inventoryService.GetInventorySkeleton));
|
||||||
|
|
||||||
// httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Work()
|
private void Work()
|
||||||
|
|
|
@ -1,62 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<inventory>
|
|
||||||
<folder>
|
|
||||||
<name>My Inventory</name>
|
|
||||||
<folderID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<type>9</type>
|
|
||||||
<folders>
|
|
||||||
<folder>
|
|
||||||
<name>Animations</name>
|
|
||||||
<type>20</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Body Parts</name>
|
|
||||||
<type>13</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Clothing</name>
|
|
||||||
<type>5</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Gestures</name>
|
|
||||||
<type>21</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Landmarks</name>
|
|
||||||
<type>3</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Lost And Found</name>
|
|
||||||
<type>16</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Notecards</name>
|
|
||||||
<type>7</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Objects</name>
|
|
||||||
<type>6</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Photo Album</name>
|
|
||||||
<type>15</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Scripts</name>
|
|
||||||
<type>10</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Sounds</name>
|
|
||||||
<type>1</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Textures</name>
|
|
||||||
<type>0</type>
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Trash</name>
|
|
||||||
<type>14</type>
|
|
||||||
</folder>
|
|
||||||
</folders>
|
|
||||||
</folder>
|
|
||||||
</inventory>
|
|
|
@ -1,134 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<inventory xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
|
||||||
<folder>
|
|
||||||
<name>Library</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000000-0000-0000-0000-000000000000" />
|
|
||||||
<folderID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<type>9</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders>
|
|
||||||
<folder>
|
|
||||||
<name>Animations</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="d052e0a1-0bf7-4f2a-8982-472df8e4d226" />
|
|
||||||
<type>20</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Body Parts</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="52abdfa6-d50f-4743-b7db-b37f97857941" />
|
|
||||||
<type>13</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Clothing</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="5820e65c-eaa9-4404-a2bc-4c63fec47c83" />
|
|
||||||
<type>5</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Gestures</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="530e1f34-14fa-4129-a373-e4ee65249b78" />
|
|
||||||
<type>21</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Landmarks</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="a1419cef-d7d7-476e-a088-165c747532a2" />
|
|
||||||
<type>3</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Notecards</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="b61598ea-2312-49f9-9b1c-5214ba55facc" />
|
|
||||||
<type>7</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Objects</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="ff757447-ea4d-4769-8751-e3bb13cd570d" />
|
|
||||||
<type>6</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Photo Album</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="d6cadddd-68e1-4fc3-bd24-319cd593fdc0" />
|
|
||||||
<type>15</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Scripts</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="f0e2c3dc-3f44-4730-8b33-6a911994fea1" />
|
|
||||||
<type>10</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Sounds</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="b8815d3c-52b0-447c-adea-3a1a442dbb2b" />
|
|
||||||
<type>1</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Textures</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="23e487c5-43af-4fe6-b211-75cfc91845a6" />
|
|
||||||
<type>0</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
<folder>
|
|
||||||
<name>Accessories</name>
|
|
||||||
<agentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<parentID UUID="00000112-000f-0000-0000-000100bba000" />
|
|
||||||
<folderID UUID="b4024e1c-9b1d-426e-a70e-55ae0078dc0b" />
|
|
||||||
<type>8</type>
|
|
||||||
<version>0</version>
|
|
||||||
<folders />
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
</folders>
|
|
||||||
<items />
|
|
||||||
</folder>
|
|
||||||
</inventory>
|
|
Loading…
Reference in New Issue