* Rex merges, Inventory server
parent
79cb89f406
commit
f06b6e2274
|
@ -1,204 +1,206 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
|
|
||||||
namespace OpenSim.Grid.InventoryServer
|
namespace OpenSim.Grid.InventoryServer
|
||||||
{
|
{
|
||||||
public class GridInventoryService : InventoryServiceBase
|
public class GridInventoryService : InventoryServiceBase
|
||||||
{
|
{
|
||||||
public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
InventoryItemInfo itemCallBack)
|
|
||||||
{
|
public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
|
||||||
}
|
InventoryItemInfo itemCallBack)
|
||||||
|
{
|
||||||
private bool TryGetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList,
|
}
|
||||||
out List<InventoryItemBase> itemsList)
|
|
||||||
{
|
private bool TryGetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList,
|
||||||
List<InventoryFolderBase> rootFolders = RequestFirstLevelFolders(userID);
|
out List<InventoryItemBase> itemsList)
|
||||||
List<InventoryItemBase> allItems = new List<InventoryItemBase>();
|
{
|
||||||
List<InventoryFolderBase> allFolders = new List<InventoryFolderBase>();
|
List<InventoryFolderBase> rootFolders = RequestFirstLevelFolders(userID);
|
||||||
|
List<InventoryItemBase> allItems = new List<InventoryItemBase>();
|
||||||
if (rootFolders != null)
|
List<InventoryFolderBase> allFolders = new List<InventoryFolderBase>();
|
||||||
{
|
|
||||||
allFolders.InsertRange(0, rootFolders);
|
if (rootFolders != null)
|
||||||
foreach (InventoryFolderBase subfolder in rootFolders)
|
{
|
||||||
{
|
allFolders.InsertRange(0, rootFolders);
|
||||||
List<InventoryFolderBase> subFolders = GetAllFolders(subfolder.folderID);
|
foreach (InventoryFolderBase subfolder in rootFolders)
|
||||||
if (subFolders != null)
|
{
|
||||||
{
|
List<InventoryFolderBase> subFolders = GetAllFolders(subfolder.folderID);
|
||||||
allFolders.InsertRange(0, subFolders);
|
if (subFolders != null)
|
||||||
}
|
{
|
||||||
}
|
allFolders.InsertRange(0, subFolders);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
foreach (InventoryFolderBase folder in allFolders)
|
}
|
||||||
{
|
|
||||||
List<InventoryItemBase> items = RequestFolderItems(folder.folderID);
|
foreach (InventoryFolderBase folder in allFolders)
|
||||||
if (items != null)
|
{
|
||||||
{
|
List<InventoryItemBase> items = RequestFolderItems(folder.folderID);
|
||||||
allItems.InsertRange(0, items);
|
if (items != null)
|
||||||
}
|
{
|
||||||
}
|
allItems.InsertRange(0, items);
|
||||||
|
}
|
||||||
folderList = allFolders;
|
}
|
||||||
itemsList = allItems;
|
|
||||||
if (folderList != null)
|
folderList = allFolders;
|
||||||
{
|
itemsList = allItems;
|
||||||
return true;
|
if (folderList != null)
|
||||||
}
|
{
|
||||||
else
|
return true;
|
||||||
{
|
}
|
||||||
return false;
|
else
|
||||||
}
|
{
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
private List<InventoryFolderBase> GetAllFolders(LLUUID folder)
|
}
|
||||||
{
|
|
||||||
List<InventoryFolderBase> allFolders = new List<InventoryFolderBase>();
|
private List<InventoryFolderBase> GetAllFolders(LLUUID folder)
|
||||||
List<InventoryFolderBase> folders = RequestSubFolders(folder);
|
{
|
||||||
if (folders != null)
|
List<InventoryFolderBase> allFolders = new List<InventoryFolderBase>();
|
||||||
{
|
List<InventoryFolderBase> folders = RequestSubFolders(folder);
|
||||||
allFolders.InsertRange(0, folders);
|
if (folders != null)
|
||||||
foreach (InventoryFolderBase subfolder in folders)
|
{
|
||||||
{
|
allFolders.InsertRange(0, folders);
|
||||||
List<InventoryFolderBase> subFolders = GetAllFolders(subfolder.folderID);
|
foreach (InventoryFolderBase subfolder in folders)
|
||||||
if (subFolders != null)
|
{
|
||||||
{
|
List<InventoryFolderBase> subFolders = GetAllFolders(subfolder.folderID);
|
||||||
allFolders.InsertRange(0, subFolders);
|
if (subFolders != null)
|
||||||
}
|
{
|
||||||
}
|
allFolders.InsertRange(0, subFolders);
|
||||||
}
|
}
|
||||||
return allFolders;
|
}
|
||||||
}
|
}
|
||||||
|
return allFolders;
|
||||||
|
}
|
||||||
public InventoryCollection GetUserInventory(Guid rawUserID)
|
|
||||||
{
|
|
||||||
LLUUID userID = new LLUUID(rawUserID);
|
public InventoryCollection GetUserInventory(Guid rawUserID)
|
||||||
|
{
|
||||||
// We get enough verbose messages later on for diagnostics
|
LLUUID userID = new LLUUID(rawUserID);
|
||||||
//MainLog.Instance.Verbose("INVENTORY", "Request for inventory for " + userID.ToString());
|
|
||||||
|
// We get enough verbose messages later on for diagnostics
|
||||||
InventoryCollection invCollection = new InventoryCollection();
|
//m_log.Info("[INVENTORY]: Request for inventory for " + userID.ToString());
|
||||||
List<InventoryFolderBase> folders;
|
|
||||||
List<InventoryItemBase> allItems;
|
InventoryCollection invCollection = new InventoryCollection();
|
||||||
if (TryGetUsersInventory(userID, out folders, out allItems))
|
List<InventoryFolderBase> folders;
|
||||||
{
|
List<InventoryItemBase> allItems;
|
||||||
invCollection.AllItems = allItems;
|
if (TryGetUsersInventory(userID, out folders, out allItems))
|
||||||
invCollection.Folders = folders;
|
{
|
||||||
invCollection.UserID = userID;
|
invCollection.AllItems = allItems;
|
||||||
}
|
invCollection.Folders = folders;
|
||||||
return invCollection;
|
invCollection.UserID = userID;
|
||||||
}
|
}
|
||||||
|
return invCollection;
|
||||||
public bool CreateUsersInventory(Guid rawUserID)
|
}
|
||||||
{
|
|
||||||
LLUUID userID = new LLUUID(rawUserID);
|
public bool CreateUsersInventory(Guid rawUserID)
|
||||||
|
{
|
||||||
MainLog.Instance.Verbose(
|
LLUUID userID = new LLUUID(rawUserID);
|
||||||
"INVENTORY", "Creating new set of inventory folders for " + userID.ToString());
|
|
||||||
|
m_log.Info(
|
||||||
CreateNewUserInventory(userID);
|
"[INVENTORY]: Creating new set of inventory folders for " + userID.ToString());
|
||||||
return true;
|
|
||||||
}
|
CreateNewUserInventory(userID);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
AddFolder(folder);
|
public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
|
||||||
}
|
{
|
||||||
|
AddFolder(folder);
|
||||||
public override void MoveExistingInventoryFolder(InventoryFolderBase folder)
|
}
|
||||||
{
|
|
||||||
MoveFolder(folder);
|
public override void MoveExistingInventoryFolder(InventoryFolderBase folder)
|
||||||
}
|
{
|
||||||
|
MoveFolder(folder);
|
||||||
public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
|
}
|
||||||
{
|
|
||||||
AddItem(item);
|
public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
|
||||||
}
|
{
|
||||||
|
AddItem(item);
|
||||||
public bool AddInventoryFolder(InventoryFolderBase folder)
|
}
|
||||||
{
|
|
||||||
// Right now, this actions act more like an update/insert combination than a simple create.
|
public bool AddInventoryFolder(InventoryFolderBase folder)
|
||||||
MainLog.Instance.Verbose(
|
{
|
||||||
"INVENTORY",
|
// Right now, this actions act more like an update/insert combination than a simple create.
|
||||||
"Updating in " + folder.parentID.ToString()
|
m_log.Info(
|
||||||
+ ", folder " + folder.name);
|
"[INVENTORY]: " +
|
||||||
|
"Updating in " + folder.parentID.ToString()
|
||||||
AddNewInventoryFolder(folder.agentID, folder);
|
+ ", folder " + folder.name);
|
||||||
return true;
|
|
||||||
}
|
AddNewInventoryFolder(folder.agentID, folder);
|
||||||
|
return true;
|
||||||
public bool MoveInventoryFolder(InventoryFolderBase folder)
|
}
|
||||||
{
|
|
||||||
MainLog.Instance.Verbose(
|
public bool MoveInventoryFolder(InventoryFolderBase folder)
|
||||||
"INVENTORY",
|
{
|
||||||
"Moving folder " + folder.folderID
|
m_log.Info(
|
||||||
+ " to " + folder.parentID.ToString());
|
"[INVENTORY]: " +
|
||||||
|
"Moving folder " + folder.folderID
|
||||||
MoveExistingInventoryFolder(folder);
|
+ " to " + folder.parentID.ToString());
|
||||||
return true;
|
|
||||||
}
|
MoveExistingInventoryFolder(folder);
|
||||||
|
return true;
|
||||||
public bool AddInventoryItem(InventoryItemBase item)
|
}
|
||||||
{
|
|
||||||
// Right now, this actions act more like an update/insert combination than a simple create.
|
public bool AddInventoryItem(InventoryItemBase item)
|
||||||
MainLog.Instance.Verbose(
|
{
|
||||||
"INVENTORY",
|
// Right now, this actions act more like an update/insert combination than a simple create.
|
||||||
"Updating in " + item.parentFolderID.ToString()
|
m_log.Info(
|
||||||
+ ", item " + item.inventoryName);
|
"[INVENTORY]: " +
|
||||||
|
"Updating in " + item.parentFolderID.ToString()
|
||||||
AddNewInventoryItem(item.avatarID, item);
|
+ ", item " + item.inventoryName);
|
||||||
return true;
|
|
||||||
}
|
AddNewInventoryItem(item.avatarID, item);
|
||||||
|
return true;
|
||||||
public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
|
}
|
||||||
{
|
|
||||||
// extra spaces to align with other inventory messages
|
public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
|
||||||
MainLog.Instance.Verbose(
|
{
|
||||||
"INVENTORY",
|
// extra spaces to align with other inventory messages
|
||||||
"Deleting in " + item.parentFolderID.ToString()
|
m_log.Info(
|
||||||
+ ", item " + item.inventoryName);
|
"[INVENTORY]: " +
|
||||||
|
"Deleting in " + item.parentFolderID.ToString()
|
||||||
DeleteItem(item);
|
+ ", item " + item.inventoryName);
|
||||||
}
|
|
||||||
|
DeleteItem(item);
|
||||||
public bool DeleteInvItem(InventoryItemBase item)
|
}
|
||||||
{
|
|
||||||
DeleteInventoryItem(item.avatarID, item);
|
public bool DeleteInvItem(InventoryItemBase item)
|
||||||
return true;
|
{
|
||||||
}
|
DeleteInventoryItem(item.avatarID, item);
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,210 +1,212 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
|
|
||||||
namespace OpenSim.Grid.InventoryServer
|
namespace OpenSim.Grid.InventoryServer
|
||||||
{
|
{
|
||||||
public class InventoryManager
|
public class InventoryManager
|
||||||
{
|
{
|
||||||
private IInventoryData _databasePlugin;
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
/// <summary>
|
private IInventoryData _databasePlugin;
|
||||||
/// Adds a new inventory server plugin - user servers will be requested in the order they were loaded.
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
/// <param name="FileName">The filename to the inventory server plugin DLL</param>
|
/// Adds a new inventory server plugin - user servers will be requested in the order they were loaded.
|
||||||
public void AddDatabasePlugin(string FileName)
|
/// </summary>
|
||||||
{
|
/// <param name="FileName">The filename to the inventory server plugin DLL</param>
|
||||||
MainLog.Instance.Verbose(OpenInventory_Main.LogName, "Invenstorage: Attempting to load " + FileName);
|
public void AddDatabasePlugin(string FileName)
|
||||||
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
|
{
|
||||||
|
m_log.Info("[" + OpenInventory_Main.LogName + "]: Invenstorage: Attempting to load " + FileName);
|
||||||
MainLog.Instance.Verbose(OpenInventory_Main.LogName,
|
Assembly pluginAssembly = Assembly.LoadFrom(FileName);
|
||||||
"Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
|
|
||||||
foreach (Type pluginType in pluginAssembly.GetTypes())
|
m_log.Info("[" + OpenInventory_Main.LogName + "]: " +
|
||||||
{
|
"Invenstorage: Found " + pluginAssembly.GetTypes().Length + " interfaces.");
|
||||||
if (!pluginType.IsAbstract)
|
foreach (Type pluginType in pluginAssembly.GetTypes())
|
||||||
{
|
{
|
||||||
Type typeInterface = pluginType.GetInterface("IInventoryData", true);
|
if (!pluginType.IsAbstract)
|
||||||
|
{
|
||||||
if (typeInterface != null)
|
Type typeInterface = pluginType.GetInterface("IInventoryData", true);
|
||||||
{
|
|
||||||
IInventoryData plug =
|
if (typeInterface != null)
|
||||||
(IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
{
|
||||||
plug.Initialise();
|
IInventoryData plug =
|
||||||
_databasePlugin = plug;
|
(IInventoryData) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
|
||||||
MainLog.Instance.Verbose(OpenInventory_Main.LogName,
|
plug.Initialise();
|
||||||
"Invenstorage: Added IInventoryData Interface");
|
_databasePlugin = plug;
|
||||||
break;
|
m_log.Info("[" + OpenInventory_Main.LogName + "]: " +
|
||||||
}
|
"Invenstorage: Added IInventoryData Interface");
|
||||||
|
break;
|
||||||
typeInterface = null;
|
}
|
||||||
}
|
|
||||||
}
|
typeInterface = null;
|
||||||
|
}
|
||||||
pluginAssembly = null;
|
}
|
||||||
}
|
|
||||||
|
pluginAssembly = null;
|
||||||
protected static SerializableInventory loadInventoryFromXmlFile(string fileName)
|
}
|
||||||
{
|
|
||||||
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
|
protected static SerializableInventory loadInventoryFromXmlFile(string fileName)
|
||||||
XmlReader reader = new XmlTextReader(fs);
|
{
|
||||||
XmlSerializer x = new XmlSerializer(typeof (SerializableInventory));
|
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
|
||||||
SerializableInventory inventory = (SerializableInventory) x.Deserialize(reader);
|
XmlReader reader = new XmlTextReader(fs);
|
||||||
fs.Close();
|
XmlSerializer x = new XmlSerializer(typeof (SerializableInventory));
|
||||||
fs.Dispose();
|
SerializableInventory inventory = (SerializableInventory) x.Deserialize(reader);
|
||||||
return inventory;
|
fs.Close();
|
||||||
}
|
fs.Dispose();
|
||||||
|
return inventory;
|
||||||
protected static void saveInventoryToStream(SerializableInventory inventory, Stream s)
|
}
|
||||||
{
|
|
||||||
XmlTextWriter writer = new XmlTextWriter(s, Encoding.UTF8);
|
protected static void saveInventoryToStream(SerializableInventory inventory, Stream s)
|
||||||
writer.Formatting = Formatting.Indented;
|
{
|
||||||
XmlSerializer x = new XmlSerializer(typeof (SerializableInventory));
|
XmlTextWriter writer = new XmlTextWriter(s, Encoding.UTF8);
|
||||||
x.Serialize(writer, inventory);
|
writer.Formatting = Formatting.Indented;
|
||||||
}
|
XmlSerializer x = new XmlSerializer(typeof (SerializableInventory));
|
||||||
|
x.Serialize(writer, inventory);
|
||||||
protected static bool fixupFolder(SerializableInventory.SerializableFolder f,
|
}
|
||||||
SerializableInventory.SerializableFolder parent)
|
|
||||||
{
|
protected static bool fixupFolder(SerializableInventory.SerializableFolder f,
|
||||||
bool modified = false;
|
SerializableInventory.SerializableFolder parent)
|
||||||
|
{
|
||||||
// ensure we have a valid folder id
|
bool modified = false;
|
||||||
if (f.folderID == LLUUID.Zero)
|
|
||||||
{
|
// ensure we have a valid folder id
|
||||||
f.folderID = LLUUID.Random();
|
if (f.folderID == LLUUID.Zero)
|
||||||
modified = true;
|
{
|
||||||
}
|
f.folderID = LLUUID.Random();
|
||||||
|
modified = true;
|
||||||
// ensure we have valid agent id
|
}
|
||||||
if (f.agentID == LLUUID.Zero)
|
|
||||||
{
|
// ensure we have valid agent id
|
||||||
if (parent != null)
|
if (f.agentID == LLUUID.Zero)
|
||||||
f.agentID = parent.agentID;
|
{
|
||||||
else
|
if (parent != null)
|
||||||
f.agentID = f.folderID;
|
f.agentID = parent.agentID;
|
||||||
modified = true;
|
else
|
||||||
}
|
f.agentID = f.folderID;
|
||||||
|
modified = true;
|
||||||
if (f.parentID == LLUUID.Zero && parent != null)
|
}
|
||||||
{
|
|
||||||
f.parentID = parent.folderID;
|
if (f.parentID == LLUUID.Zero && parent != null)
|
||||||
modified = true;
|
{
|
||||||
}
|
f.parentID = parent.folderID;
|
||||||
|
modified = true;
|
||||||
|
}
|
||||||
foreach (SerializableInventory.SerializableFolder child in f.SubFolders)
|
|
||||||
{
|
|
||||||
modified |= fixupFolder(child, f);
|
foreach (SerializableInventory.SerializableFolder child in f.SubFolders)
|
||||||
}
|
{
|
||||||
|
modified |= fixupFolder(child, f);
|
||||||
return modified;
|
}
|
||||||
}
|
|
||||||
|
return modified;
|
||||||
protected static bool fixupInventory(SerializableInventory inventory)
|
}
|
||||||
{
|
|
||||||
return fixupFolder(inventory.root, null);
|
protected static bool fixupInventory(SerializableInventory inventory)
|
||||||
}
|
{
|
||||||
|
return fixupFolder(inventory.root, null);
|
||||||
public class GetInventory : BaseStreamHandler
|
}
|
||||||
{
|
|
||||||
private SerializableInventory _inventory;
|
public class GetInventory : BaseStreamHandler
|
||||||
private InventoryManager _manager;
|
{
|
||||||
|
private SerializableInventory _inventory;
|
||||||
public GetInventory(InventoryManager manager)
|
private InventoryManager _manager;
|
||||||
: base("GET", "/inventory")
|
|
||||||
{
|
public GetInventory(InventoryManager manager)
|
||||||
_manager = manager;
|
: base("GET", "/inventory")
|
||||||
|
{
|
||||||
_inventory = loadInventoryFromXmlFile("attic/inventory/Inventory_Library.xml");
|
_manager = manager;
|
||||||
if (fixupInventory(_inventory))
|
|
||||||
{
|
_inventory = loadInventoryFromXmlFile("attic/inventory/Inventory_Library.xml");
|
||||||
FileStream fs = new FileStream("attic/inventory/Inventory_Library.xml", FileMode.Truncate, FileAccess.Write);
|
if (fixupInventory(_inventory))
|
||||||
saveInventoryToStream(_inventory, fs);
|
{
|
||||||
fs.Flush();
|
FileStream fs = new FileStream("attic/inventory/Inventory_Library.xml", FileMode.Truncate, FileAccess.Write);
|
||||||
fs.Close();
|
saveInventoryToStream(_inventory, fs);
|
||||||
MainLog.Instance.Debug(OpenInventory_Main.LogName, "Modified");
|
fs.Flush();
|
||||||
}
|
fs.Close();
|
||||||
}
|
m_log.Debug("[" + OpenInventory_Main.LogName + "]: Modified");
|
||||||
|
}
|
||||||
private void CreateDefaultInventory(LLUUID userID)
|
}
|
||||||
{
|
|
||||||
}
|
private void CreateDefaultInventory(LLUUID userID)
|
||||||
|
{
|
||||||
private byte[] GetUserInventory(LLUUID userID)
|
}
|
||||||
{
|
|
||||||
MainLog.Instance.Notice(OpenInventory_Main.LogName, "Getting Inventory for user {0}", userID.ToString());
|
private byte[] GetUserInventory(LLUUID userID)
|
||||||
byte[] result = new byte[] {};
|
{
|
||||||
|
m_log.InfoFormat("[" + OpenInventory_Main.LogName + "]: Getting Inventory for user {0}", userID.ToString());
|
||||||
InventoryFolderBase fb = _manager._databasePlugin.getUserRootFolder(userID);
|
byte[] result = new byte[] {};
|
||||||
if (fb == null)
|
|
||||||
{
|
InventoryFolderBase fb = _manager._databasePlugin.getUserRootFolder(userID);
|
||||||
MainLog.Instance.Notice(OpenInventory_Main.LogName, "Inventory not found for user {0}, creating new",
|
if (fb == null)
|
||||||
userID.ToString());
|
{
|
||||||
CreateDefaultInventory(userID);
|
m_log.InfoFormat("[" + OpenInventory_Main.LogName + "]: Inventory not found for user {0}, creating new",
|
||||||
}
|
userID.ToString());
|
||||||
|
CreateDefaultInventory(userID);
|
||||||
return result;
|
}
|
||||||
}
|
|
||||||
|
return result;
|
||||||
public override byte[] Handle(string path, Stream request)
|
}
|
||||||
{
|
|
||||||
byte[] result = new byte[] {};
|
public override byte[] Handle(string path, Stream request)
|
||||||
|
{
|
||||||
string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
|
byte[] result = new byte[] {};
|
||||||
if (parms.Length > 1)
|
|
||||||
{
|
string[] parms = path.Split(new char[] {'/'}, StringSplitOptions.RemoveEmptyEntries);
|
||||||
if (string.Compare(parms[1], "library", true) == 0)
|
if (parms.Length > 1)
|
||||||
{
|
{
|
||||||
MemoryStream ms = new MemoryStream();
|
if (string.Compare(parms[1], "library", true) == 0)
|
||||||
saveInventoryToStream(_inventory, ms);
|
{
|
||||||
|
MemoryStream ms = new MemoryStream();
|
||||||
result = ms.GetBuffer();
|
saveInventoryToStream(_inventory, ms);
|
||||||
Array.Resize<byte>(ref result, (int) ms.Length);
|
|
||||||
}
|
result = ms.GetBuffer();
|
||||||
else if (string.Compare(parms[1], "user", true) == 0)
|
Array.Resize<byte>(ref result, (int) ms.Length);
|
||||||
{
|
}
|
||||||
if (parms.Length > 2)
|
else if (string.Compare(parms[1], "user", true) == 0)
|
||||||
{
|
{
|
||||||
result = GetUserInventory(new LLUUID(parms[2]));
|
if (parms.Length > 2)
|
||||||
}
|
{
|
||||||
}
|
result = GetUserInventory(new LLUUID(parms[2]));
|
||||||
}
|
}
|
||||||
return result;
|
}
|
||||||
}
|
}
|
||||||
}
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,134 +1,135 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
|
|
||||||
namespace OpenSim.Grid.InventoryServer
|
namespace OpenSim.Grid.InventoryServer
|
||||||
{
|
{
|
||||||
public class OpenInventory_Main : conscmd_callback
|
public class OpenInventory_Main : BaseOpenSimServer, conscmd_callback
|
||||||
{
|
{
|
||||||
private LogBase m_console;
|
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
private InventoryManager m_inventoryManager;
|
|
||||||
private InventoryConfig m_config;
|
private InventoryManager m_inventoryManager;
|
||||||
private GridInventoryService m_inventoryService;
|
private InventoryConfig m_config;
|
||||||
|
private GridInventoryService m_inventoryService;
|
||||||
public const string LogName = "INVENTORY";
|
|
||||||
|
public const string LogName = "INVENTORY";
|
||||||
[STAThread]
|
|
||||||
public static void Main(string[] args)
|
[STAThread]
|
||||||
{
|
public static void Main(string[] args)
|
||||||
OpenInventory_Main theServer = new OpenInventory_Main();
|
{
|
||||||
theServer.Startup();
|
log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
||||||
theServer.Work();
|
OpenInventory_Main theServer = new OpenInventory_Main();
|
||||||
}
|
theServer.Startup();
|
||||||
|
|
||||||
public OpenInventory_Main()
|
theServer.Work();
|
||||||
{
|
}
|
||||||
m_console = new LogBase("opengrid-inventory-console.log", LogName, this, true);
|
|
||||||
MainLog.Instance = m_console;
|
public OpenInventory_Main()
|
||||||
}
|
{
|
||||||
|
m_console = new ConsoleBase(LogName, this);
|
||||||
public void Startup()
|
MainConsole.Instance = m_console;
|
||||||
{
|
}
|
||||||
MainLog.Instance.Notice("Initialising inventory manager...");
|
|
||||||
m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml")));
|
public void Startup()
|
||||||
|
{
|
||||||
m_inventoryService = new GridInventoryService();
|
m_log.Info("Initialising inventory manager...");
|
||||||
// m_inventoryManager = new InventoryManager();
|
m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml")));
|
||||||
m_inventoryService.AddPlugin(m_config.DatabaseProvider);
|
|
||||||
|
m_inventoryService = new GridInventoryService();
|
||||||
MainLog.Instance.Notice(LogName, "Starting HTTP server ...");
|
// m_inventoryManager = new InventoryManager();
|
||||||
BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort);
|
m_inventoryService.AddPlugin(m_config.DatabaseProvider);
|
||||||
httpServer.AddStreamHandler(
|
|
||||||
new RestDeserialisehandler<Guid, InventoryCollection>("POST", "/GetInventory/",
|
m_log.Info("[" + LogName + "]: Starting HTTP server ...");
|
||||||
m_inventoryService.GetUserInventory));
|
BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort);
|
||||||
httpServer.AddStreamHandler(
|
httpServer.AddStreamHandler(
|
||||||
new RestDeserialisehandler<Guid, bool>("POST", "/CreateInventory/",
|
new RestDeserialisehandler<Guid, InventoryCollection>("POST", "/GetInventory/",
|
||||||
m_inventoryService.CreateUsersInventory));
|
m_inventoryService.GetUserInventory));
|
||||||
httpServer.AddStreamHandler(
|
httpServer.AddStreamHandler(
|
||||||
new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/NewFolder/",
|
new RestDeserialisehandler<Guid, bool>("POST", "/CreateInventory/",
|
||||||
m_inventoryService.AddInventoryFolder));
|
m_inventoryService.CreateUsersInventory));
|
||||||
|
httpServer.AddStreamHandler(
|
||||||
httpServer.AddStreamHandler(
|
new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/NewFolder/",
|
||||||
new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/MoveFolder/",
|
m_inventoryService.AddInventoryFolder));
|
||||||
m_inventoryService.MoveInventoryFolder));
|
|
||||||
|
httpServer.AddStreamHandler(
|
||||||
httpServer.AddStreamHandler(
|
new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/MoveFolder/",
|
||||||
new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/NewItem/",
|
m_inventoryService.MoveInventoryFolder));
|
||||||
m_inventoryService.AddInventoryItem));
|
|
||||||
httpServer.AddStreamHandler(
|
httpServer.AddStreamHandler(
|
||||||
new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/DeleteItem/",
|
new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/NewItem/",
|
||||||
m_inventoryService.DeleteInvItem));
|
m_inventoryService.AddInventoryItem));
|
||||||
|
httpServer.AddStreamHandler(
|
||||||
httpServer.AddStreamHandler(
|
new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/DeleteItem/",
|
||||||
new RestDeserialisehandler<Guid, List<InventoryFolderBase>>("POST", "/RootFolders/",
|
m_inventoryService.DeleteInvItem));
|
||||||
m_inventoryService.RequestFirstLevelFolders));
|
|
||||||
|
httpServer.AddStreamHandler(
|
||||||
// httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager));
|
new RestDeserialisehandler<Guid, List<InventoryFolderBase>>("POST", "/RootFolders/",
|
||||||
|
m_inventoryService.RequestFirstLevelFolders));
|
||||||
httpServer.Start();
|
|
||||||
MainLog.Instance.Notice(LogName, "Started HTTP server");
|
// httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager));
|
||||||
}
|
|
||||||
|
httpServer.Start();
|
||||||
private void Work()
|
m_log.Info("[" + LogName + "]: Started HTTP server");
|
||||||
{
|
}
|
||||||
m_console.Notice("Enter help for a list of commands\n");
|
|
||||||
|
private void Work()
|
||||||
while (true)
|
{
|
||||||
{
|
m_console.Notice("Enter help for a list of commands\n");
|
||||||
m_console.MainLogPrompt();
|
|
||||||
}
|
while (true)
|
||||||
}
|
{
|
||||||
|
m_console.Prompt();
|
||||||
public void RunCmd(string cmd, string[] cmdparams)
|
}
|
||||||
{
|
}
|
||||||
switch (cmd)
|
|
||||||
{
|
public override void RunCmd(string cmd, string[] cmdparams)
|
||||||
case "quit":
|
{
|
||||||
case "add-user":
|
base.RunCmd(cmd, cmdparams);
|
||||||
m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID);
|
|
||||||
break;
|
switch (cmd)
|
||||||
case "shutdown":
|
{
|
||||||
m_console.Close();
|
case "quit":
|
||||||
Environment.Exit(0);
|
case "add-user":
|
||||||
break;
|
m_inventoryService.CreateUsersInventory(LLUUID.Random().UUID);
|
||||||
}
|
break;
|
||||||
}
|
case "shutdown":
|
||||||
|
m_console.Close();
|
||||||
public void Show(string ShowWhat)
|
Environment.Exit(0);
|
||||||
{
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue