Use Inventory{Item,Folder}Base in AssetInventoryServer.
Also the first inventory storage methods are implemented.0.6.4-rc1
parent
d38bddfb76
commit
3676062277
|
@ -81,17 +81,17 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
|
|
||||||
public interface IInventoryStorageProvider : IAssetInventoryServerPlugin
|
public interface IInventoryStorageProvider : IAssetInventoryServerPlugin
|
||||||
{
|
{
|
||||||
BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItem item);
|
BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item);
|
||||||
BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolder folder);
|
BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder);
|
||||||
BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents);
|
BackendResponse TryFetchFolderContents(Uri owner, UUID folderID, out InventoryCollection contents);
|
||||||
BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolder> folders);
|
BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders);
|
||||||
BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory);
|
BackendResponse TryFetchInventory(Uri owner, out InventoryCollection inventory);
|
||||||
|
|
||||||
BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItem> gestures);
|
BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures);
|
||||||
|
|
||||||
BackendResponse TryCreateItem(Uri owner, InventoryItem item);
|
BackendResponse TryCreateItem(Uri owner, InventoryItemBase item);
|
||||||
BackendResponse TryCreateFolder(Uri owner, InventoryFolder folder);
|
BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder);
|
||||||
BackendResponse TryCreateInventory(Uri owner, InventoryFolder rootFolder);
|
BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder);
|
||||||
|
|
||||||
BackendResponse TryDeleteItem(Uri owner, UUID itemID);
|
BackendResponse TryDeleteItem(Uri owner, UUID itemID);
|
||||||
BackendResponse TryDeleteFolder(Uri owner, UUID folderID);
|
BackendResponse TryDeleteFolder(Uri owner, UUID folderID);
|
||||||
|
|
|
@ -28,78 +28,85 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
|
||||||
namespace OpenSim.Grid.AssetInventoryServer
|
namespace OpenSim.Grid.AssetInventoryServer
|
||||||
{
|
{
|
||||||
public class InventoryBase
|
//public class InventoryBase
|
||||||
{
|
//{
|
||||||
}
|
//}
|
||||||
|
|
||||||
public class InventoryFolder : InventoryBase
|
//public class InventoryFolder : InventoryBase
|
||||||
{
|
//{
|
||||||
public string Name;
|
// public string Name;
|
||||||
public UUID Owner;
|
// public UUID Owner;
|
||||||
public UUID ParentID;
|
// public UUID ParentID;
|
||||||
public UUID ID;
|
// public UUID ID;
|
||||||
public short Type;
|
// public short Type;
|
||||||
public ushort Version;
|
// public ushort Version;
|
||||||
|
|
||||||
|
// [NonSerialized]
|
||||||
|
// public Dictionary<UUID, InventoryBase> Children = new Dictionary<UUID, InventoryBase>();
|
||||||
|
|
||||||
|
// public InventoryFolder()
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public InventoryFolder(string name, UUID ownerID, UUID parentID, short assetType)
|
||||||
|
// {
|
||||||
|
// ID = UUID.Random();
|
||||||
|
// Name = name;
|
||||||
|
// Owner = ownerID;
|
||||||
|
// ParentID = parentID;
|
||||||
|
// Type = assetType;
|
||||||
|
// Version = 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public override string ToString()
|
||||||
|
// {
|
||||||
|
// return String.Format("{0} ({1})", Name, ID);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public class InventoryItem : InventoryBase
|
||||||
|
//{
|
||||||
|
// public UUID ID;
|
||||||
|
// public int InvType;
|
||||||
|
// public UUID Folder;
|
||||||
|
// public UUID Owner;
|
||||||
|
// public UUID Creator;
|
||||||
|
// public string Name;
|
||||||
|
// public string Description;
|
||||||
|
// public uint NextPermissions;
|
||||||
|
// public uint CurrentPermissions;
|
||||||
|
// public uint BasePermissions;
|
||||||
|
// public uint EveryOnePermissions;
|
||||||
|
// public uint GroupPermissions;
|
||||||
|
// public int AssetType;
|
||||||
|
// public UUID AssetID;
|
||||||
|
// public UUID GroupID;
|
||||||
|
// public bool GroupOwned;
|
||||||
|
// public int SalePrice;
|
||||||
|
// public byte SaleType;
|
||||||
|
// public uint Flags;
|
||||||
|
// public int CreationDate;
|
||||||
|
|
||||||
|
// public override string ToString()
|
||||||
|
// {
|
||||||
|
// return String.Format("{0} ({1})", Name, ID);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
public class InventoryFolderWithChildren : InventoryFolderBase
|
||||||
|
{
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public Dictionary<UUID, InventoryBase> Children = new Dictionary<UUID, InventoryBase>();
|
public Dictionary<UUID, InventoryNodeBase> Children = new Dictionary<UUID, InventoryNodeBase>();
|
||||||
|
|
||||||
public InventoryFolder()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public InventoryFolder(string name, UUID ownerID, UUID parentID, short assetType)
|
|
||||||
{
|
|
||||||
ID = UUID.Random();
|
|
||||||
Name = name;
|
|
||||||
Owner = ownerID;
|
|
||||||
ParentID = parentID;
|
|
||||||
Type = assetType;
|
|
||||||
Version = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return String.Format("{0} ({1})", Name, ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class InventoryItem : InventoryBase
|
|
||||||
{
|
|
||||||
public UUID ID;
|
|
||||||
public int InvType;
|
|
||||||
public UUID Folder;
|
|
||||||
public UUID Owner;
|
|
||||||
public UUID Creator;
|
|
||||||
public string Name;
|
|
||||||
public string Description;
|
|
||||||
public uint NextPermissions;
|
|
||||||
public uint CurrentPermissions;
|
|
||||||
public uint BasePermissions;
|
|
||||||
public uint EveryOnePermissions;
|
|
||||||
public uint GroupPermissions;
|
|
||||||
public int AssetType;
|
|
||||||
public UUID AssetID;
|
|
||||||
public UUID GroupID;
|
|
||||||
public bool GroupOwned;
|
|
||||||
public int SalePrice;
|
|
||||||
public byte SaleType;
|
|
||||||
public uint Flags;
|
|
||||||
public int CreationDate;
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return String.Format("{0} ({1})", Name, ID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InventoryCollection
|
public class InventoryCollection
|
||||||
{
|
{
|
||||||
public Dictionary<UUID, InventoryFolder> Folders;
|
public Dictionary<UUID, InventoryFolderWithChildren> Folders;
|
||||||
public Dictionary<UUID, InventoryItem> Items;
|
public Dictionary<UUID, InventoryItemBase> Items;
|
||||||
public UUID UserID;
|
public UUID UserID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/*
|
||||||
|
* 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 OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Framework.Communications;
|
||||||
|
using OpenSim.Data;
|
||||||
|
|
||||||
|
namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
|
{
|
||||||
|
public class OpenSimInventoryService : InventoryServiceBase
|
||||||
|
{
|
||||||
|
public override void RequestInventoryForUser(UUID userID, InventoryReceiptCallback callback) {}
|
||||||
|
|
||||||
|
public InventoryFolderBase GetInventoryFolder(UUID folderID)
|
||||||
|
{
|
||||||
|
foreach (IInventoryDataPlugin plugin in m_plugins)
|
||||||
|
{
|
||||||
|
return plugin.getInventoryFolder(folderID);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
|
@ -42,17 +42,19 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
const string EXTENSION_NAME = "OpenSimInventoryStorage"; // Used in metrics reporting
|
const string EXTENSION_NAME = "OpenSimInventoryStorage"; // Used in metrics reporting
|
||||||
|
|
||||||
//private AssetInventoryServer m_server;
|
private AssetInventoryServer m_server;
|
||||||
private IInventoryDataPlugin m_inventoryProvider;
|
private IInventoryDataPlugin m_inventoryProvider;
|
||||||
private IConfig m_openSimConfig;
|
private IConfig m_openSimConfig;
|
||||||
|
private OpenSimInventoryService m_inventoryService;
|
||||||
|
|
||||||
public OpenSimInventoryStoragePlugin()
|
public OpenSimInventoryStoragePlugin()
|
||||||
{
|
{
|
||||||
|
m_inventoryService = new OpenSimInventoryService();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region IInventoryStorageProvider implementation
|
#region IInventoryStorageProvider implementation
|
||||||
|
|
||||||
public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItem item)
|
public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item)
|
||||||
{
|
{
|
||||||
item = null;
|
item = null;
|
||||||
//BackendResponse ret;
|
//BackendResponse ret;
|
||||||
|
@ -74,7 +76,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
|
|
||||||
// if (reader.Read())
|
// if (reader.Read())
|
||||||
// {
|
// {
|
||||||
// item = new InventoryItem();
|
// item = new InventoryItemBase();
|
||||||
// item.ID = itemID;
|
// item.ID = itemID;
|
||||||
// item.AssetID = UUID.Parse(reader.GetString(0));
|
// item.AssetID = UUID.Parse(reader.GetString(0));
|
||||||
// item.AssetType = reader.GetInt32(1);
|
// item.AssetType = reader.GetInt32(1);
|
||||||
|
@ -116,7 +118,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
return BackendResponse.Success;
|
return BackendResponse.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolder folder)
|
public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder)
|
||||||
{
|
{
|
||||||
folder = null;
|
folder = null;
|
||||||
//BackendResponse ret;
|
//BackendResponse ret;
|
||||||
|
@ -136,7 +138,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
|
|
||||||
// if (reader.Read())
|
// if (reader.Read())
|
||||||
// {
|
// {
|
||||||
// folder = new InventoryFolder();
|
// folder = new InventoryFolderWithChildren();
|
||||||
// folder.Children = null; // This call only returns data for the folder itself, no children data
|
// folder.Children = null; // This call only returns data for the folder itself, no children data
|
||||||
// folder.ID = folderID;
|
// folder.ID = folderID;
|
||||||
// folder.Name = reader.GetString(0);
|
// folder.Name = reader.GetString(0);
|
||||||
|
@ -186,11 +188,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
// folderID.ToString());
|
// folderID.ToString());
|
||||||
// reader = command.ExecuteReader();
|
// reader = command.ExecuteReader();
|
||||||
|
|
||||||
// contents.Folders = new Dictionary<UUID, InventoryFolder>();
|
// contents.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
|
||||||
|
|
||||||
// while (reader.Read())
|
// while (reader.Read())
|
||||||
// {
|
// {
|
||||||
// InventoryFolder folder = new InventoryFolder();
|
// InventoryFolderWithChildren folder = new InventoryFolderWithChildren();
|
||||||
// folder.ParentID = folderID;
|
// folder.ParentID = folderID;
|
||||||
// folder.Children = null; // This call doesn't do recursion
|
// folder.Children = null; // This call doesn't do recursion
|
||||||
// folder.Name = reader.GetString(0);
|
// folder.Name = reader.GetString(0);
|
||||||
|
@ -216,11 +218,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
// folderID.ToString());
|
// folderID.ToString());
|
||||||
// reader = command.ExecuteReader();
|
// reader = command.ExecuteReader();
|
||||||
|
|
||||||
// contents.Items = new Dictionary<UUID, InventoryItem>();
|
// contents.Items = new Dictionary<UUID, InventoryItemBase>();
|
||||||
|
|
||||||
// while (reader.Read())
|
// while (reader.Read())
|
||||||
// {
|
// {
|
||||||
// InventoryItem item = new InventoryItem();
|
// InventoryItemBase item = new InventoryItemBase();
|
||||||
// item.Folder = folderID;
|
// item.Folder = folderID;
|
||||||
// item.AssetID = UUID.Parse(reader.GetString(0));
|
// item.AssetID = UUID.Parse(reader.GetString(0));
|
||||||
// item.AssetType = reader.GetInt32(1);
|
// item.AssetType = reader.GetInt32(1);
|
||||||
|
@ -263,7 +265,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
return BackendResponse.Success;
|
return BackendResponse.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolder> folders)
|
public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders)
|
||||||
{
|
{
|
||||||
folders = null;
|
folders = null;
|
||||||
//BackendResponse ret;
|
//BackendResponse ret;
|
||||||
|
@ -278,7 +280,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// dbConnection.Open();
|
// dbConnection.Open();
|
||||||
// folders = new List<InventoryFolder>();
|
// folders = new List<InventoryFolderWithChildren>();
|
||||||
|
|
||||||
// IDbCommand command = dbConnection.CreateCommand();
|
// IDbCommand command = dbConnection.CreateCommand();
|
||||||
// command.CommandText = String.Format("SELECT folderName,type,version,folderID,parentFolderID FROM inventoryfolders WHERE agentID='{0}'",
|
// command.CommandText = String.Format("SELECT folderName,type,version,folderID,parentFolderID FROM inventoryfolders WHERE agentID='{0}'",
|
||||||
|
@ -287,7 +289,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
|
|
||||||
// while (reader.Read())
|
// while (reader.Read())
|
||||||
// {
|
// {
|
||||||
// InventoryFolder folder = new InventoryFolder();
|
// InventoryFolderWithChildren folder = new InventoryFolderWithChildren();
|
||||||
// folder.Owner = ownerID;
|
// folder.Owner = ownerID;
|
||||||
// folder.Children = null; // This call does not create a folder hierarchy
|
// folder.Children = null; // This call does not create a folder hierarchy
|
||||||
// folder.Name = reader.GetString(0);
|
// folder.Name = reader.GetString(0);
|
||||||
|
@ -322,7 +324,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
{
|
{
|
||||||
inventory = null;
|
inventory = null;
|
||||||
//BackendResponse ret;
|
//BackendResponse ret;
|
||||||
//List<InventoryFolder> folders;
|
//List<InventoryFolderWithChildren> folders;
|
||||||
//UUID ownerID;
|
//UUID ownerID;
|
||||||
|
|
||||||
//ret = TryFetchFolderList(owner, out folders);
|
//ret = TryFetchFolderList(owner, out folders);
|
||||||
|
@ -331,8 +333,8 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
//{
|
//{
|
||||||
// // Add the retrieved folders to the inventory collection
|
// // Add the retrieved folders to the inventory collection
|
||||||
// inventory = new InventoryCollection();
|
// inventory = new InventoryCollection();
|
||||||
// inventory.Folders = new Dictionary<UUID, InventoryFolder>(folders.Count);
|
// inventory.Folders = new Dictionary<UUID, InventoryFolderWithChildren>(folders.Count);
|
||||||
// foreach (InventoryFolder folder in folders)
|
// foreach (InventoryFolderWithChildren folder in folders)
|
||||||
// inventory.Folders[folder.ID] = folder;
|
// inventory.Folders[folder.ID] = folder;
|
||||||
|
|
||||||
// // Fetch inventory items
|
// // Fetch inventory items
|
||||||
|
@ -354,11 +356,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
// reader = command.ExecuteReader();
|
// reader = command.ExecuteReader();
|
||||||
|
|
||||||
// inventory.UserID = ownerID;
|
// inventory.UserID = ownerID;
|
||||||
// inventory.Items = new Dictionary<UUID, InventoryItem>();
|
// inventory.Items = new Dictionary<UUID, InventoryItemBase>();
|
||||||
|
|
||||||
// while (reader.Read())
|
// while (reader.Read())
|
||||||
// {
|
// {
|
||||||
// InventoryItem item = new InventoryItem();
|
// InventoryItemBase item = new InventoryItemBase();
|
||||||
// item.Owner = ownerID;
|
// item.Owner = ownerID;
|
||||||
// item.AssetID = UUID.Parse(reader.GetString(0));
|
// item.AssetID = UUID.Parse(reader.GetString(0));
|
||||||
// item.AssetType = reader.GetInt32(1);
|
// item.AssetType = reader.GetInt32(1);
|
||||||
|
@ -403,7 +405,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
return BackendResponse.Success;
|
return BackendResponse.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItem> gestures)
|
public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures)
|
||||||
{
|
{
|
||||||
gestures = null;
|
gestures = null;
|
||||||
//BackendResponse ret;
|
//BackendResponse ret;
|
||||||
|
@ -429,7 +431,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
|
|
||||||
// while (reader.Read())
|
// while (reader.Read())
|
||||||
// {
|
// {
|
||||||
// InventoryItem item = new InventoryItem();
|
// InventoryItemBase item = new InventoryItemBase();
|
||||||
// item.Owner = ownerID;
|
// item.Owner = ownerID;
|
||||||
// item.AssetType = (int)AssetType.Gesture;
|
// item.AssetType = (int)AssetType.Gesture;
|
||||||
// item.Flags = (uint)1;
|
// item.Flags = (uint)1;
|
||||||
|
@ -473,75 +475,24 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
return BackendResponse.Success;
|
return BackendResponse.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryCreateItem(Uri owner, InventoryItem item)
|
public BackendResponse TryCreateItem(Uri owner, InventoryItemBase item)
|
||||||
{
|
{
|
||||||
//BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
|
||||||
//using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
|
if (m_inventoryService.AddItem(item))
|
||||||
//{
|
{
|
||||||
// try
|
ret = BackendResponse.Success;
|
||||||
// {
|
}
|
||||||
// dbConnection.Open();
|
else
|
||||||
|
{
|
||||||
|
ret = BackendResponse.Failure;
|
||||||
|
}
|
||||||
|
|
||||||
// MySqlCommand command = new MySqlCommand(
|
m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now);
|
||||||
// "REPLACE INTO inventoryitems (assetID,assetType,inventoryName,inventoryDescription,inventoryNextPermissions," +
|
return ret;
|
||||||
// "inventoryCurrentPermissions,invType,creatorID,inventoryBasePermissions,inventoryEveryOnePermissions,salePrice,saleType," +
|
|
||||||
// "creationDate,groupID,groupOwned,flags,inventoryID,avatarID,parentFolderID,inventoryGroupPermissions) VALUES " +
|
|
||||||
|
|
||||||
// "(?assetID,?assetType,?inventoryName,?inventoryDescription,?inventoryNextPermissions,?inventoryCurrentPermissions,?invType," +
|
|
||||||
// "?creatorID,?inventoryBasePermissions,?inventoryEveryOnePermissions,?salePrice,?saleType,?creationDate,?groupID,?groupOwned," +
|
|
||||||
// "?flags,?inventoryID,?avatarID,?parentFolderID,?inventoryGroupPermissions)", dbConnection);
|
|
||||||
|
|
||||||
// command.Parameters.AddWithValue("?assetID", item.AssetID.ToString());
|
|
||||||
// command.Parameters.AddWithValue("?assetType", item.AssetType);
|
|
||||||
// command.Parameters.AddWithValue("?inventoryName", item.Name);
|
|
||||||
// command.Parameters.AddWithValue("?inventoryDescription", item.Description);
|
|
||||||
// command.Parameters.AddWithValue("?inventoryNextPermissions", item.NextPermissions);
|
|
||||||
// command.Parameters.AddWithValue("?inventoryCurrentPermissions", item.CurrentPermissions);
|
|
||||||
// command.Parameters.AddWithValue("?invType", item.InvType);
|
|
||||||
// command.Parameters.AddWithValue("?creatorID", item.Creator.ToString());
|
|
||||||
// command.Parameters.AddWithValue("?inventoryBasePermissions", item.BasePermissions);
|
|
||||||
// command.Parameters.AddWithValue("?inventoryEveryOnePermissions", item.EveryOnePermissions);
|
|
||||||
// command.Parameters.AddWithValue("?salePrice", item.SalePrice);
|
|
||||||
// command.Parameters.AddWithValue("?saleType", item.SaleType);
|
|
||||||
// command.Parameters.AddWithValue("?creationDate", item.CreationDate);
|
|
||||||
// command.Parameters.AddWithValue("?groupID", item.GroupID.ToString());
|
|
||||||
// command.Parameters.AddWithValue("?groupOwned", item.GroupOwned);
|
|
||||||
// command.Parameters.AddWithValue("?flags", item.Flags);
|
|
||||||
// command.Parameters.AddWithValue("?inventoryID", item.ID);
|
|
||||||
// command.Parameters.AddWithValue("?avatarID", item.Owner);
|
|
||||||
// command.Parameters.AddWithValue("?parentFolderID", item.Folder);
|
|
||||||
// command.Parameters.AddWithValue("?inventoryGroupPermissions", item.GroupPermissions);
|
|
||||||
|
|
||||||
// int rowsAffected = command.ExecuteNonQuery();
|
|
||||||
// if (rowsAffected == 1)
|
|
||||||
// {
|
|
||||||
// ret = BackendResponse.Success;
|
|
||||||
// }
|
|
||||||
// else if (rowsAffected == 2)
|
|
||||||
// {
|
|
||||||
// m_log.Info("[OPENSIMINVENTORYSTORAGE]: Replaced inventory item " + item.ID.ToString());
|
|
||||||
// ret = BackendResponse.Success;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// m_log.ErrorFormat("[OPENSIMINVENTORYSTORAGE]: MySQL REPLACE query affected {0} rows", rowsAffected);
|
|
||||||
// ret = BackendResponse.Failure;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// catch (MySqlException ex)
|
|
||||||
// {
|
|
||||||
// m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message);
|
|
||||||
// ret = BackendResponse.Failure;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//m_server.MetricsProvider.LogInventoryCreate(EXTENSION_NAME, ret, owner, false, DateTime.Now);
|
|
||||||
//return ret;
|
|
||||||
return BackendResponse.Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryCreateFolder(Uri owner, InventoryFolder folder)
|
public BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder)
|
||||||
{
|
{
|
||||||
//BackendResponse ret;
|
//BackendResponse ret;
|
||||||
|
|
||||||
|
@ -590,7 +541,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
return BackendResponse.Success;
|
return BackendResponse.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryCreateInventory(Uri owner, InventoryFolder rootFolder)
|
public BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder)
|
||||||
{
|
{
|
||||||
return TryCreateFolder(owner, rootFolder);
|
return TryCreateFolder(owner, rootFolder);
|
||||||
}
|
}
|
||||||
|
@ -692,60 +643,19 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
|
|
||||||
public BackendResponse TryPurgeFolder(Uri owner, UUID folderID)
|
public BackendResponse TryPurgeFolder(Uri owner, UUID folderID)
|
||||||
{
|
{
|
||||||
//BackendResponse ret;
|
BackendResponse ret;
|
||||||
//UUID ownerID;
|
|
||||||
|
|
||||||
//if (Utils.TryGetOpenSimUUID(owner, out ownerID))
|
if (m_inventoryService.PurgeFolder(m_inventoryService.GetInventoryFolder(folderID)))
|
||||||
//{
|
{
|
||||||
// using (MySqlConnection dbConnection = new MySqlConnection(m_openSimConfig.GetString("inventory_database_connect")))
|
ret = BackendResponse.Success;
|
||||||
// {
|
}
|
||||||
// try
|
else
|
||||||
// {
|
{
|
||||||
// dbConnection.Open();
|
ret = BackendResponse.Failure;
|
||||||
|
}
|
||||||
|
|
||||||
// #region Delete items
|
m_server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now);
|
||||||
|
return ret;
|
||||||
// MySqlCommand command = new MySqlCommand(
|
|
||||||
// "DELETE FROM inventoryitems WHERE parentFolderID=?parentFolderID AND avatarID=?avatarID", dbConnection);
|
|
||||||
|
|
||||||
// command.Parameters.AddWithValue("?parentFolderID", folderID.ToString());
|
|
||||||
// command.Parameters.AddWithValue("?avatarID", ownerID.ToString());
|
|
||||||
|
|
||||||
// int rowsAffected = command.ExecuteNonQuery();
|
|
||||||
|
|
||||||
// #endregion Delete items
|
|
||||||
|
|
||||||
// #region Delete folders
|
|
||||||
|
|
||||||
// command = new MySqlCommand(
|
|
||||||
// "DELETE FROM inventoryfolders WHERE parentFolderID=?parentFolderID AND agentID=?agentID", dbConnection);
|
|
||||||
|
|
||||||
// command.Parameters.AddWithValue("?parentFolderID", folderID.ToString());
|
|
||||||
// command.Parameters.AddWithValue("?agentID", ownerID.ToString());
|
|
||||||
|
|
||||||
// rowsAffected += command.ExecuteNonQuery();
|
|
||||||
|
|
||||||
// #endregion Delete folders
|
|
||||||
|
|
||||||
// m_log.DebugFormat("[OPENSIMINVENTORYSTORAGE]: Deleted {0} inventory objects from MySQL in a folder purge", rowsAffected);
|
|
||||||
|
|
||||||
// ret = BackendResponse.Success;
|
|
||||||
// }
|
|
||||||
// catch (MySqlException ex)
|
|
||||||
// {
|
|
||||||
// m_log.Error("[OPENSIMINVENTORYSTORAGE]: Connection to MySQL backend failed: " + ex.Message);
|
|
||||||
// ret = BackendResponse.Failure;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// ret = BackendResponse.NotFound;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//m_server.MetricsProvider.LogInventoryPurgeFolder(EXTENSION_NAME, ret, owner, folderID, DateTime.Now);
|
|
||||||
//return ret;
|
|
||||||
return BackendResponse.Success;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ForEach(Action<AssetMetadata> action, int start, int count)
|
public int ForEach(Action<AssetMetadata> action, int start, int count)
|
||||||
|
@ -798,7 +708,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.OpenSim
|
||||||
|
|
||||||
public void Initialise(AssetInventoryServer server)
|
public void Initialise(AssetInventoryServer server)
|
||||||
{
|
{
|
||||||
//m_server = server;
|
m_server = server;
|
||||||
m_openSimConfig = server.ConfigFile.Configs["OpenSim"];
|
m_openSimConfig = server.ConfigFile.Configs["OpenSim"];
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
AssetInventoryServer server;
|
AssetInventoryServer server;
|
||||||
Dictionary<Uri, InventoryCollection> inventories = new Dictionary<Uri, InventoryCollection>();
|
Dictionary<Uri, InventoryCollection> inventories = new Dictionary<Uri, InventoryCollection>();
|
||||||
Dictionary<Uri, List<InventoryItem>> activeGestures = new Dictionary<Uri, List<InventoryItem>>();
|
Dictionary<Uri, List<InventoryItemBase>> activeGestures = new Dictionary<Uri, List<InventoryItemBase>>();
|
||||||
Utils.InventoryItemSerializer itemSerializer = new Utils.InventoryItemSerializer();
|
Utils.InventoryItemSerializer itemSerializer = new Utils.InventoryItemSerializer();
|
||||||
Utils.InventoryFolderSerializer folderSerializer = new Utils.InventoryFolderSerializer();
|
Utils.InventoryFolderSerializer folderSerializer = new Utils.InventoryFolderSerializer();
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
|
|
||||||
#region Required Interfaces
|
#region Required Interfaces
|
||||||
|
|
||||||
public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItem item)
|
public BackendResponse TryFetchItem(Uri owner, UUID itemID, out InventoryItemBase item)
|
||||||
{
|
{
|
||||||
item = null;
|
item = null;
|
||||||
BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
@ -69,7 +69,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolder folder)
|
public BackendResponse TryFetchFolder(Uri owner, UUID folderID, out InventoryFolderWithChildren folder)
|
||||||
{
|
{
|
||||||
folder = null;
|
folder = null;
|
||||||
BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
@ -90,25 +90,25 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
|
||||||
InventoryCollection collection;
|
InventoryCollection collection;
|
||||||
InventoryFolder folder;
|
InventoryFolderWithChildren folder;
|
||||||
|
|
||||||
if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
|
if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
|
||||||
{
|
{
|
||||||
contents = new InventoryCollection();
|
contents = new InventoryCollection();
|
||||||
contents.UserID = collection.UserID;
|
contents.UserID = collection.UserID;
|
||||||
contents.Folders = new Dictionary<UUID, InventoryFolder>();
|
contents.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
|
||||||
contents.Items = new Dictionary<UUID, InventoryItem>();
|
contents.Items = new Dictionary<UUID, InventoryItemBase>();
|
||||||
|
|
||||||
foreach (InventoryBase invBase in folder.Children.Values)
|
foreach (InventoryNodeBase invBase in folder.Children.Values)
|
||||||
{
|
{
|
||||||
if (invBase is InventoryItem)
|
if (invBase is InventoryItemBase)
|
||||||
{
|
{
|
||||||
InventoryItem invItem = invBase as InventoryItem;
|
InventoryItemBase invItem = invBase as InventoryItemBase;
|
||||||
contents.Items.Add(invItem.ID, invItem);
|
contents.Items.Add(invItem.ID, invItem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
InventoryFolder invFolder = invBase as InventoryFolder;
|
InventoryFolderWithChildren invFolder = invBase as InventoryFolderWithChildren;
|
||||||
contents.Folders.Add(invFolder.ID, invFolder);
|
contents.Folders.Add(invFolder.ID, invFolder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolder> folders)
|
public BackendResponse TryFetchFolderList(Uri owner, out List<InventoryFolderWithChildren> folders)
|
||||||
{
|
{
|
||||||
folders = null;
|
folders = null;
|
||||||
BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
@ -132,7 +132,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
InventoryCollection collection;
|
InventoryCollection collection;
|
||||||
if (inventories.TryGetValue(owner, out collection))
|
if (inventories.TryGetValue(owner, out collection))
|
||||||
{
|
{
|
||||||
folders = new List<InventoryFolder>(collection.Folders.Values);
|
folders = new List<InventoryFolderWithChildren>(collection.Folders.Values);
|
||||||
return BackendResponse.Success;
|
return BackendResponse.Success;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -158,7 +158,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItem> gestures)
|
public BackendResponse TryFetchActiveGestures(Uri owner, out List<InventoryItemBase> gestures)
|
||||||
{
|
{
|
||||||
gestures = null;
|
gestures = null;
|
||||||
BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
@ -172,7 +172,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryCreateItem(Uri owner, InventoryItem item)
|
public BackendResponse TryCreateItem(Uri owner, InventoryItemBase item)
|
||||||
{
|
{
|
||||||
BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
if (inventories.TryGetValue(owner, out collection))
|
if (inventories.TryGetValue(owner, out collection))
|
||||||
{
|
{
|
||||||
// Delete this item first if it already exists
|
// Delete this item first if it already exists
|
||||||
InventoryItem oldItem;
|
InventoryItemBase oldItem;
|
||||||
if (collection.Items.TryGetValue(item.ID, out oldItem))
|
if (collection.Items.TryGetValue(item.ID, out oldItem))
|
||||||
TryDeleteItem(owner, item.ID);
|
TryDeleteItem(owner, item.ID);
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
lock (collection) collection.Items[item.ID] = item;
|
lock (collection) collection.Items[item.ID] = item;
|
||||||
|
|
||||||
// Add the item to its parent folder
|
// Add the item to its parent folder
|
||||||
InventoryFolder parent;
|
InventoryFolderWithChildren parent;
|
||||||
if (collection.Folders.TryGetValue(item.Folder, out parent))
|
if (collection.Folders.TryGetValue(item.Folder, out parent))
|
||||||
lock (parent.Children) parent.Children.Add(item.ID, item);
|
lock (parent.Children) parent.Children.Add(item.ID, item);
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryCreateFolder(Uri owner, InventoryFolder folder)
|
public BackendResponse TryCreateFolder(Uri owner, InventoryFolderWithChildren folder)
|
||||||
{
|
{
|
||||||
BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
if (inventories.TryGetValue(owner, out collection))
|
if (inventories.TryGetValue(owner, out collection))
|
||||||
{
|
{
|
||||||
// Delete this folder first if it already exists
|
// Delete this folder first if it already exists
|
||||||
InventoryFolder oldFolder;
|
InventoryFolderWithChildren oldFolder;
|
||||||
if (collection.Folders.TryGetValue(folder.ID, out oldFolder))
|
if (collection.Folders.TryGetValue(folder.ID, out oldFolder))
|
||||||
TryDeleteFolder(owner, folder.ID);
|
TryDeleteFolder(owner, folder.ID);
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
lock (collection) collection.Folders[folder.ID] = folder;
|
lock (collection) collection.Folders[folder.ID] = folder;
|
||||||
|
|
||||||
// Add the folder to its parent folder
|
// Add the folder to its parent folder
|
||||||
InventoryFolder parent;
|
InventoryFolderWithChildren parent;
|
||||||
if (collection.Folders.TryGetValue(folder.ParentID, out parent))
|
if (collection.Folders.TryGetValue(folder.ParentID, out parent))
|
||||||
lock (parent.Children) parent.Children.Add(folder.ID, folder);
|
lock (parent.Children) parent.Children.Add(folder.ID, folder);
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BackendResponse TryCreateInventory(Uri owner, InventoryFolder rootFolder)
|
public BackendResponse TryCreateInventory(Uri owner, InventoryFolderWithChildren rootFolder)
|
||||||
{
|
{
|
||||||
BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
|
||||||
|
@ -273,9 +273,9 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
{
|
{
|
||||||
InventoryCollection collection = new InventoryCollection();
|
InventoryCollection collection = new InventoryCollection();
|
||||||
collection.UserID = rootFolder.Owner;
|
collection.UserID = rootFolder.Owner;
|
||||||
collection.Folders = new Dictionary<UUID, InventoryFolder>();
|
collection.Folders = new Dictionary<UUID, InventoryFolderWithChildren>();
|
||||||
collection.Folders.Add(rootFolder.ID, rootFolder);
|
collection.Folders.Add(rootFolder.ID, rootFolder);
|
||||||
collection.Items = new Dictionary<UUID, InventoryItem>();
|
collection.Items = new Dictionary<UUID, InventoryItemBase>();
|
||||||
|
|
||||||
inventories.Add(owner, collection);
|
inventories.Add(owner, collection);
|
||||||
|
|
||||||
|
@ -318,11 +318,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
|
||||||
InventoryCollection collection;
|
InventoryCollection collection;
|
||||||
InventoryItem item;
|
InventoryItemBase item;
|
||||||
if (inventories.TryGetValue(owner, out collection) && collection.Items.TryGetValue(itemID, out item))
|
if (inventories.TryGetValue(owner, out collection) && collection.Items.TryGetValue(itemID, out item))
|
||||||
{
|
{
|
||||||
// Remove the item from its parent folder
|
// Remove the item from its parent folder
|
||||||
InventoryFolder parent;
|
InventoryFolderWithChildren parent;
|
||||||
if (collection.Folders.TryGetValue(item.Folder, out parent))
|
if (collection.Folders.TryGetValue(item.Folder, out parent))
|
||||||
lock (parent.Children) parent.Children.Remove(itemID);
|
lock (parent.Children) parent.Children.Remove(itemID);
|
||||||
|
|
||||||
|
@ -371,11 +371,11 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
|
||||||
InventoryCollection collection;
|
InventoryCollection collection;
|
||||||
InventoryFolder folder;
|
InventoryFolderWithChildren folder;
|
||||||
if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
|
if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
|
||||||
{
|
{
|
||||||
// Remove the folder from its parent folder
|
// Remove the folder from its parent folder
|
||||||
InventoryFolder parent;
|
InventoryFolderWithChildren parent;
|
||||||
if (collection.Folders.TryGetValue(folder.ParentID, out parent))
|
if (collection.Folders.TryGetValue(folder.ParentID, out parent))
|
||||||
lock (parent.Children) parent.Children.Remove(folderID);
|
lock (parent.Children) parent.Children.Remove(folderID);
|
||||||
|
|
||||||
|
@ -408,19 +408,19 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
BackendResponse ret;
|
BackendResponse ret;
|
||||||
|
|
||||||
InventoryCollection collection;
|
InventoryCollection collection;
|
||||||
InventoryFolder folder;
|
InventoryFolderWithChildren folder;
|
||||||
if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
|
if (inventories.TryGetValue(owner, out collection) && collection.Folders.TryGetValue(folderID, out folder))
|
||||||
{
|
{
|
||||||
// Delete all of the folder children
|
// Delete all of the folder children
|
||||||
foreach (InventoryBase obj in new List<InventoryBase>(folder.Children.Values))
|
foreach (InventoryNodeBase obj in new List<InventoryNodeBase>(folder.Children.Values))
|
||||||
{
|
{
|
||||||
if (obj is InventoryItem)
|
if (obj is InventoryItemBase)
|
||||||
{
|
{
|
||||||
TryDeleteItem(owner, (obj as InventoryItem).ID);
|
TryDeleteItem(owner, (obj as InventoryItemBase).ID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
InventoryFolder childFolder = obj as InventoryFolder;
|
InventoryFolderWithChildren childFolder = obj as InventoryFolderWithChildren;
|
||||||
TryPurgeFolder(owner, childFolder.ID);
|
TryPurgeFolder(owner, childFolder.ID);
|
||||||
TryDeleteFolder(owner, childFolder.ID);
|
TryDeleteFolder(owner, childFolder.ID);
|
||||||
}
|
}
|
||||||
|
@ -439,7 +439,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
|
|
||||||
#endregion Required Interfaces
|
#endregion Required Interfaces
|
||||||
|
|
||||||
void SaveItem(InventoryItem item)
|
void SaveItem(InventoryItemBase item)
|
||||||
{
|
{
|
||||||
string filename = String.Format("{0}-{1}.item", SanitizeFilename(item.Name), item.ID);
|
string filename = String.Format("{0}-{1}.item", SanitizeFilename(item.Name), item.ID);
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveFolder(InventoryFolder folder)
|
void SaveFolder(InventoryFolderWithChildren folder)
|
||||||
{
|
{
|
||||||
string filename = String.Format("{0}-{1}.folder", SanitizeFilename(folder.Name), folder.ID);
|
string filename = String.Format("{0}-{1}.folder", SanitizeFilename(folder.Name), folder.ID);
|
||||||
|
|
||||||
|
@ -530,42 +530,42 @@ namespace OpenSim.Grid.AssetInventoryServer.Plugins.Simple
|
||||||
if (ownerID != UUID.Zero && owner != null)
|
if (ownerID != UUID.Zero && owner != null)
|
||||||
{
|
{
|
||||||
// Initialize the active gestures list for this agent
|
// Initialize the active gestures list for this agent
|
||||||
activeGestures.Add(owner, new List<InventoryItem>());
|
activeGestures.Add(owner, new List<InventoryItemBase>());
|
||||||
|
|
||||||
InventoryCollection collection = new InventoryCollection();
|
InventoryCollection collection = new InventoryCollection();
|
||||||
collection.UserID = ownerID;
|
collection.UserID = ownerID;
|
||||||
|
|
||||||
// Load all of the folders for this agent
|
// Load all of the folders for this agent
|
||||||
string[] folders = Directory.GetFiles(foldername, "*.folder", SearchOption.TopDirectoryOnly);
|
string[] folders = Directory.GetFiles(foldername, "*.folder", SearchOption.TopDirectoryOnly);
|
||||||
collection.Folders = new Dictionary<UUID,InventoryFolder>(folders.Length);
|
collection.Folders = new Dictionary<UUID,InventoryFolderWithChildren>(folders.Length);
|
||||||
|
|
||||||
for (int j = 0; j < folders.Length; j++)
|
for (int j = 0; j < folders.Length; j++)
|
||||||
{
|
{
|
||||||
InventoryFolder invFolder = (InventoryFolder)folderSerializer.Deserialize(
|
InventoryFolderWithChildren invFolder = (InventoryFolderWithChildren)folderSerializer.Deserialize(
|
||||||
new FileStream(folders[j], FileMode.Open, FileAccess.Read));
|
new FileStream(folders[j], FileMode.Open, FileAccess.Read));
|
||||||
collection.Folders[invFolder.ID] = invFolder;
|
collection.Folders[invFolder.ID] = invFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over the folders collection, adding children to their parents
|
// Iterate over the folders collection, adding children to their parents
|
||||||
foreach (InventoryFolder invFolder in collection.Folders.Values)
|
foreach (InventoryFolderWithChildren invFolder in collection.Folders.Values)
|
||||||
{
|
{
|
||||||
InventoryFolder parent;
|
InventoryFolderWithChildren parent;
|
||||||
if (collection.Folders.TryGetValue(invFolder.ParentID, out parent))
|
if (collection.Folders.TryGetValue(invFolder.ParentID, out parent))
|
||||||
parent.Children[invFolder.ID] = invFolder;
|
parent.Children[invFolder.ID] = invFolder;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load all of the items for this agent
|
// Load all of the items for this agent
|
||||||
string[] files = Directory.GetFiles(foldername, "*.item", SearchOption.TopDirectoryOnly);
|
string[] files = Directory.GetFiles(foldername, "*.item", SearchOption.TopDirectoryOnly);
|
||||||
collection.Items = new Dictionary<UUID, InventoryItem>(files.Length);
|
collection.Items = new Dictionary<UUID, InventoryItemBase>(files.Length);
|
||||||
|
|
||||||
for (int j = 0; j < files.Length; j++)
|
for (int j = 0; j < files.Length; j++)
|
||||||
{
|
{
|
||||||
InventoryItem invItem = (InventoryItem)itemSerializer.Deserialize(
|
InventoryItemBase invItem = (InventoryItemBase)itemSerializer.Deserialize(
|
||||||
new FileStream(files[j], FileMode.Open, FileAccess.Read));
|
new FileStream(files[j], FileMode.Open, FileAccess.Read));
|
||||||
collection.Items[invItem.ID] = invItem;
|
collection.Items[invItem.ID] = invItem;
|
||||||
|
|
||||||
// Add items to their parent folders
|
// Add items to their parent folders
|
||||||
InventoryFolder parent;
|
InventoryFolderWithChildren parent;
|
||||||
if (collection.Folders.TryGetValue(invItem.Folder, out parent))
|
if (collection.Folders.TryGetValue(invItem.Folder, out parent))
|
||||||
parent.Children[invItem.ID] = invItem;
|
parent.Children[invItem.ID] = invItem;
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ using System.Globalization;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using System.Xml.Serialization;
|
using System.Xml.Serialization;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
|
|
||||||
namespace OpenSim.Grid.AssetInventoryServer
|
namespace OpenSim.Grid.AssetInventoryServer
|
||||||
|
@ -278,9 +279,9 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
return ReadObject_InventoryCollection(true, true);
|
return ReadObject_InventoryCollection(true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryFolder ReadObject_InventoryFolder(bool isNullable, bool checkType)
|
public InventoryFolderWithChildren ReadObject_InventoryFolder(bool isNullable, bool checkType)
|
||||||
{
|
{
|
||||||
InventoryFolder ob = null;
|
InventoryFolderWithChildren ob = null;
|
||||||
if (isNullable && ReadNull()) return null;
|
if (isNullable && ReadNull()) return null;
|
||||||
|
|
||||||
if (checkType)
|
if (checkType)
|
||||||
|
@ -292,7 +293,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
throw CreateUnknownTypeException(t);
|
throw CreateUnknownTypeException(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
ob = (InventoryFolder)Activator.CreateInstance(typeof(InventoryFolder), true);
|
ob = (InventoryFolderWithChildren)Activator.CreateInstance(typeof(InventoryFolderWithChildren), true);
|
||||||
|
|
||||||
Reader.MoveToElement();
|
Reader.MoveToElement();
|
||||||
|
|
||||||
|
@ -373,9 +374,9 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
return ob;
|
return ob;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryItem ReadObject_InventoryItem(bool isNullable, bool checkType)
|
public InventoryItemBase ReadObject_InventoryItem(bool isNullable, bool checkType)
|
||||||
{
|
{
|
||||||
InventoryItem ob = null;
|
InventoryItemBase ob = null;
|
||||||
if (isNullable && ReadNull()) return null;
|
if (isNullable && ReadNull()) return null;
|
||||||
|
|
||||||
if (checkType)
|
if (checkType)
|
||||||
|
@ -387,7 +388,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
throw CreateUnknownTypeException(t);
|
throw CreateUnknownTypeException(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
ob = (InventoryItem)Activator.CreateInstance(typeof(InventoryItem), true);
|
ob = (InventoryItemBase)Activator.CreateInstance(typeof(InventoryItemBase), true);
|
||||||
|
|
||||||
Reader.MoveToElement();
|
Reader.MoveToElement();
|
||||||
|
|
||||||
|
@ -585,11 +586,11 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
Reader.Skip();
|
Reader.Skip();
|
||||||
if (ob.@Folders == null)
|
if (ob.@Folders == null)
|
||||||
{
|
{
|
||||||
ob.@Folders = new System.Collections.Generic.Dictionary<UUID, InventoryFolder>();
|
ob.@Folders = new System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren>();
|
||||||
}
|
}
|
||||||
if (ob.@Items == null)
|
if (ob.@Items == null)
|
||||||
{
|
{
|
||||||
ob.@Items = new System.Collections.Generic.Dictionary<UUID, InventoryItem>();
|
ob.@Items = new System.Collections.Generic.Dictionary<UUID, InventoryItemBase>();
|
||||||
}
|
}
|
||||||
return ob;
|
return ob;
|
||||||
}
|
}
|
||||||
|
@ -610,10 +611,10 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
}
|
}
|
||||||
else if (Reader.LocalName == "Items" && Reader.NamespaceURI == "" && !b44)
|
else if (Reader.LocalName == "Items" && Reader.NamespaceURI == "" && !b44)
|
||||||
{
|
{
|
||||||
System.Collections.Generic.Dictionary<UUID, InventoryItem> o46 = ob.@Items;
|
System.Collections.Generic.Dictionary<UUID, InventoryItemBase> o46 = ob.@Items;
|
||||||
if (((object)o46) == null)
|
if (((object)o46) == null)
|
||||||
{
|
{
|
||||||
o46 = new System.Collections.Generic.Dictionary<UUID, InventoryItem>();
|
o46 = new System.Collections.Generic.Dictionary<UUID, InventoryItemBase>();
|
||||||
ob.@Items = o46;
|
ob.@Items = o46;
|
||||||
}
|
}
|
||||||
if (Reader.IsEmptyElement)
|
if (Reader.IsEmptyElement)
|
||||||
|
@ -634,7 +635,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
{
|
{
|
||||||
if (((object)o46) == null)
|
if (((object)o46) == null)
|
||||||
throw CreateReadOnlyCollectionException("System.Collections.Generic.List<InventoryItemBase>");
|
throw CreateReadOnlyCollectionException("System.Collections.Generic.List<InventoryItemBase>");
|
||||||
InventoryItem item = ReadObject_InventoryItem(true, true);
|
InventoryItemBase item = ReadObject_InventoryItem(true, true);
|
||||||
o46.Add(item.ID, item);
|
o46.Add(item.ID, item);
|
||||||
n47++;
|
n47++;
|
||||||
}
|
}
|
||||||
|
@ -650,10 +651,10 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
}
|
}
|
||||||
else if (Reader.LocalName == "Folders" && Reader.NamespaceURI == "" && !b43)
|
else if (Reader.LocalName == "Folders" && Reader.NamespaceURI == "" && !b43)
|
||||||
{
|
{
|
||||||
System.Collections.Generic.Dictionary<UUID, InventoryFolder> o48 = ob.@Folders;
|
System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren> o48 = ob.@Folders;
|
||||||
if (((object)o48) == null)
|
if (((object)o48) == null)
|
||||||
{
|
{
|
||||||
o48 = new System.Collections.Generic.Dictionary<UUID, InventoryFolder>();
|
o48 = new System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren>();
|
||||||
ob.@Folders = o48;
|
ob.@Folders = o48;
|
||||||
}
|
}
|
||||||
if (Reader.IsEmptyElement)
|
if (Reader.IsEmptyElement)
|
||||||
|
@ -674,7 +675,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
{
|
{
|
||||||
if (((object)o48) == null)
|
if (((object)o48) == null)
|
||||||
throw CreateReadOnlyCollectionException("System.Collections.Generic.List<InventoryFolderBase>");
|
throw CreateReadOnlyCollectionException("System.Collections.Generic.List<InventoryFolderBase>");
|
||||||
InventoryFolder folder = ReadObject_InventoryFolder(true, true);
|
InventoryFolderWithChildren folder = ReadObject_InventoryFolder(true, true);
|
||||||
o48.Add(folder.ID, folder);
|
o48.Add(folder.ID, folder);
|
||||||
n49++;
|
n49++;
|
||||||
}
|
}
|
||||||
|
@ -700,11 +701,11 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
}
|
}
|
||||||
if (ob.@Folders == null)
|
if (ob.@Folders == null)
|
||||||
{
|
{
|
||||||
ob.@Folders = new System.Collections.Generic.Dictionary<UUID, InventoryFolder>();
|
ob.@Folders = new System.Collections.Generic.Dictionary<UUID, InventoryFolderWithChildren>();
|
||||||
}
|
}
|
||||||
if (ob.@Items == null)
|
if (ob.@Items == null)
|
||||||
{
|
{
|
||||||
ob.@Items = new System.Collections.Generic.Dictionary<UUID, InventoryItem>();
|
ob.@Items = new System.Collections.Generic.Dictionary<UUID, InventoryItemBase>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadEndElement();
|
ReadEndElement();
|
||||||
|
@ -793,7 +794,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
public void WriteRoot_InventoryFolder(object o)
|
public void WriteRoot_InventoryFolder(object o)
|
||||||
{
|
{
|
||||||
WriteStartDocument();
|
WriteStartDocument();
|
||||||
InventoryFolder ob = (InventoryFolder)o;
|
InventoryFolderWithChildren ob = (InventoryFolderWithChildren)o;
|
||||||
TopLevelElement();
|
TopLevelElement();
|
||||||
WriteObject_InventoryFolder(ob, "InventoryFolderBase", "", true, false, true);
|
WriteObject_InventoryFolder(ob, "InventoryFolderBase", "", true, false, true);
|
||||||
}
|
}
|
||||||
|
@ -801,7 +802,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
public void WriteRoot_InventoryItem(object o)
|
public void WriteRoot_InventoryItem(object o)
|
||||||
{
|
{
|
||||||
WriteStartDocument();
|
WriteStartDocument();
|
||||||
InventoryItem ob = (InventoryItem)o;
|
InventoryItemBase ob = (InventoryItemBase)o;
|
||||||
TopLevelElement();
|
TopLevelElement();
|
||||||
WriteObject_InventoryItem(ob, "InventoryItemBase", "", true, false, true);
|
WriteObject_InventoryItem(ob, "InventoryItemBase", "", true, false, true);
|
||||||
}
|
}
|
||||||
|
@ -814,7 +815,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
WriteObject_InventoryCollection(ob, "InventoryCollection", "", true, false, true);
|
WriteObject_InventoryCollection(ob, "InventoryCollection", "", true, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteObject_InventoryFolder(InventoryFolder ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
|
void WriteObject_InventoryFolder(InventoryFolderWithChildren ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
|
||||||
{
|
{
|
||||||
if (((object)ob) == null)
|
if (((object)ob) == null)
|
||||||
{
|
{
|
||||||
|
@ -824,7 +825,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Type type = ob.GetType();
|
System.Type type = ob.GetType();
|
||||||
if (type == typeof(InventoryFolder))
|
if (type == typeof(InventoryFolderWithChildren))
|
||||||
{ }
|
{ }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -847,7 +848,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
if (writeWrappingElem) WriteEndElement(ob);
|
if (writeWrappingElem) WriteEndElement(ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteObject_InventoryItem(InventoryItem ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
|
void WriteObject_InventoryItem(InventoryItemBase ob, string element, string namesp, bool isNullable, bool needType, bool writeWrappingElem)
|
||||||
{
|
{
|
||||||
if (((object)ob) == null)
|
if (((object)ob) == null)
|
||||||
{
|
{
|
||||||
|
@ -857,7 +858,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Type type = ob.GetType();
|
System.Type type = ob.GetType();
|
||||||
if (type == typeof(InventoryItem))
|
if (type == typeof(InventoryItemBase))
|
||||||
{ }
|
{ }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -921,7 +922,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
if (ob.@Folders != null)
|
if (ob.@Folders != null)
|
||||||
{
|
{
|
||||||
WriteStartElement("Folders", "", ob.@Folders);
|
WriteStartElement("Folders", "", ob.@Folders);
|
||||||
foreach (InventoryFolder folder in ob.Folders.Values)
|
foreach (InventoryFolderWithChildren folder in ob.Folders.Values)
|
||||||
{
|
{
|
||||||
WriteObject_InventoryFolder(folder, "InventoryFolderBase", "", true, false, true);
|
WriteObject_InventoryFolder(folder, "InventoryFolderBase", "", true, false, true);
|
||||||
}
|
}
|
||||||
|
@ -930,7 +931,7 @@ namespace OpenSim.Grid.AssetInventoryServer
|
||||||
if (ob.@Items != null)
|
if (ob.@Items != null)
|
||||||
{
|
{
|
||||||
WriteStartElement("Items", "", ob.@Items);
|
WriteStartElement("Items", "", ob.@Items);
|
||||||
foreach (InventoryItem item in ob.Items.Values)
|
foreach (InventoryItemBase item in ob.Items.Values)
|
||||||
{
|
{
|
||||||
WriteObject_InventoryItem(item, "InventoryItemBase", "", true, false, true);
|
WriteObject_InventoryItem(item, "InventoryItemBase", "", true, false, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -919,6 +919,7 @@
|
||||||
<Reference name="OpenMetaverseTypes"/>
|
<Reference name="OpenMetaverseTypes"/>
|
||||||
<Reference name="OpenSim.Data" />
|
<Reference name="OpenSim.Data" />
|
||||||
<Reference name="OpenSim.Framework" />
|
<Reference name="OpenSim.Framework" />
|
||||||
|
<Reference name="OpenSim.Framework.Communications" />
|
||||||
<Reference name="OpenSim.Grid.AssetInventoryServer" />
|
<Reference name="OpenSim.Grid.AssetInventoryServer" />
|
||||||
<Reference name="OpenSim.Framework.Servers"/>
|
<Reference name="OpenSim.Framework.Servers"/>
|
||||||
<Reference name="log4net"/>
|
<Reference name="log4net"/>
|
||||||
|
|
Loading…
Reference in New Issue