Finish the implementation of GetUserInventory, even though it's still not used.
parent
8fd86c9156
commit
6eaff18961
|
@ -297,14 +297,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
return m_LocalGridInventoryService.CreateUserInventory(userID);
|
return m_LocalGridInventoryService.CreateUserInventory(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
|
public List<InventoryFolderBase> GetInventorySkeleton(UUID userID)
|
||||||
{
|
{
|
||||||
return m_LocalGridInventoryService.GetInventorySkeleton(userId);
|
string invURL = GetInventoryServiceURL(userID);
|
||||||
|
|
||||||
|
if (invURL == null) // not there, forward to local inventory connector to resolve
|
||||||
|
return m_LocalGridInventoryService.GetInventorySkeleton(userID);
|
||||||
|
|
||||||
|
IInventoryService connector = GetConnector(invURL);
|
||||||
|
|
||||||
|
return connector.GetInventorySkeleton(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryCollection GetUserInventory(UUID userID)
|
public InventoryCollection GetUserInventory(UUID userID)
|
||||||
{
|
{
|
||||||
return null;
|
string invURL = GetInventoryServiceURL(userID);
|
||||||
|
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: GetUserInventory for {0} {1}", userID, invURL);
|
||||||
|
|
||||||
|
if (invURL == null) // not there, forward to local inventory connector to resolve
|
||||||
|
return m_LocalGridInventoryService.GetUserInventory(userID);
|
||||||
|
|
||||||
|
InventoryCollection c = m_Cache.GetUserInventory(userID);
|
||||||
|
if (c != null)
|
||||||
|
return c;
|
||||||
|
|
||||||
|
IInventoryService connector = GetConnector(invURL);
|
||||||
|
c = connector.GetUserInventory(userID);
|
||||||
|
|
||||||
|
m_Cache.Cache(userID, c);
|
||||||
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
|
public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
|
||||||
|
@ -362,8 +383,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
if (invURL == null) // not there, forward to local inventory connector to resolve
|
if (invURL == null) // not there, forward to local inventory connector to resolve
|
||||||
return m_LocalGridInventoryService.GetFolderContent(userID, folderID);
|
return m_LocalGridInventoryService.GetFolderContent(userID, folderID);
|
||||||
|
|
||||||
IInventoryService connector = GetConnector(invURL);
|
InventoryCollection c = m_Cache.GetFolderContent(userID, folderID);
|
||||||
|
if (c != null)
|
||||||
|
{
|
||||||
|
m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderContent found content in cache " + folderID);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
IInventoryService connector = GetConnector(invURL);
|
||||||
return connector.GetFolderContent(userID, folderID);
|
return connector.GetFolderContent(userID, folderID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -377,8 +404,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
if (invURL == null) // not there, forward to local inventory connector to resolve
|
if (invURL == null) // not there, forward to local inventory connector to resolve
|
||||||
return m_LocalGridInventoryService.GetFolderItems(userID, folderID);
|
return m_LocalGridInventoryService.GetFolderItems(userID, folderID);
|
||||||
|
|
||||||
IInventoryService connector = GetConnector(invURL);
|
List<InventoryItemBase> items = m_Cache.GetFolderItems(userID, folderID);
|
||||||
|
if (items != null)
|
||||||
|
{
|
||||||
|
m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderItems found items in cache " + folderID);
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
IInventoryService connector = GetConnector(invURL);
|
||||||
return connector.GetFolderItems(userID, folderID);
|
return connector.GetFolderItems(userID, folderID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
|
|
||||||
private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>();
|
private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>();
|
||||||
private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>();
|
private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>();
|
||||||
|
private static ExpiringCache<UUID, InventoryCollection> m_Inventories = new ExpiringCache<UUID, InventoryCollection>();
|
||||||
|
|
||||||
public void Cache(UUID userID, InventoryFolderBase root)
|
public void Cache(UUID userID, InventoryFolderBase root)
|
||||||
{
|
{
|
||||||
|
@ -55,5 +56,55 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Cache(UUID userID, InventoryCollection inv)
|
||||||
|
{
|
||||||
|
lock (m_Inventories)
|
||||||
|
m_Inventories.AddOrUpdate(userID, inv, 120);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryCollection GetUserInventory(UUID userID)
|
||||||
|
{
|
||||||
|
InventoryCollection inv = null;
|
||||||
|
if (m_Inventories.TryGetValue(userID, out inv))
|
||||||
|
return inv;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
|
||||||
|
{
|
||||||
|
InventoryCollection inv = null;
|
||||||
|
InventoryCollection c;
|
||||||
|
if (m_Inventories.TryGetValue(userID, out inv))
|
||||||
|
{
|
||||||
|
c = new InventoryCollection();
|
||||||
|
c.UserID = userID;
|
||||||
|
|
||||||
|
c.Folders = inv.Folders.FindAll(delegate(InventoryFolderBase f)
|
||||||
|
{
|
||||||
|
return f.ParentID == folderID;
|
||||||
|
});
|
||||||
|
c.Items = inv.Items.FindAll(delegate(InventoryItemBase i)
|
||||||
|
{
|
||||||
|
return i.Folder == folderID;
|
||||||
|
});
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
|
||||||
|
{
|
||||||
|
InventoryCollection inv = null;
|
||||||
|
if (m_Inventories.TryGetValue(userID, out inv))
|
||||||
|
{
|
||||||
|
List<InventoryItemBase> items = inv.Items.FindAll(delegate(InventoryItemBase i)
|
||||||
|
{
|
||||||
|
return i.Folder == folderID;
|
||||||
|
});
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
|
|
||||||
public InventoryCollection GetUserInventory(UUID userID)
|
public InventoryCollection GetUserInventory(UUID userID)
|
||||||
{
|
{
|
||||||
return null;
|
return m_RemoteConnector.GetUserInventory(userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
|
public void GetUserInventory(UUID userID, InventoryReceiptCallback callback)
|
||||||
|
@ -193,11 +193,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
||||||
{
|
{
|
||||||
InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID);
|
InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID);
|
||||||
|
|
||||||
if (UserManager != null)
|
if (invCol != null && UserManager != null)
|
||||||
{
|
{
|
||||||
// Protect ourselves against the caller subsequently modifying the items list
|
// Protect ourselves against the caller subsequently modifying the items list
|
||||||
List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items);
|
List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items);
|
||||||
|
|
||||||
|
if (items != null && items.Count > 0)
|
||||||
Util.FireAndForget(delegate
|
Util.FireAndForget(delegate
|
||||||
{
|
{
|
||||||
foreach (InventoryItemBase item in items)
|
foreach (InventoryItemBase item in items)
|
||||||
|
|
|
@ -114,6 +114,8 @@ namespace OpenSim.Server.Handlers.Asset
|
||||||
return HandleCreateUserInventory(request);
|
return HandleCreateUserInventory(request);
|
||||||
case "GETINVENTORYSKELETON":
|
case "GETINVENTORYSKELETON":
|
||||||
return HandleGetInventorySkeleton(request);
|
return HandleGetInventorySkeleton(request);
|
||||||
|
case "GETUSERINVENTORY":
|
||||||
|
return HandleGetUserInventory(request);
|
||||||
case "GETROOTFOLDER":
|
case "GETROOTFOLDER":
|
||||||
return HandleGetRootFolder(request);
|
return HandleGetRootFolder(request);
|
||||||
case "GETFOLDERFORTYPE":
|
case "GETFOLDERFORTYPE":
|
||||||
|
@ -153,7 +155,7 @@ namespace OpenSim.Server.Handlers.Asset
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[XINVENTORY HANDLER]: Exception {0}", e);
|
m_log.DebugFormat("[XINVENTORY HANDLER]: Exception {0}", e.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FailureResult();
|
return FailureResult();
|
||||||
|
@ -248,6 +250,45 @@ namespace OpenSim.Server.Handlers.Asset
|
||||||
return encoding.GetBytes(xmlString);
|
return encoding.GetBytes(xmlString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte[] HandleGetUserInventory(Dictionary<string, object> request)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||||
|
UUID principal = UUID.Zero;
|
||||||
|
UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
|
||||||
|
|
||||||
|
InventoryCollection icoll = m_InventoryService.GetUserInventory(principal);
|
||||||
|
if (icoll != null)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> folders = new Dictionary<string, object>();
|
||||||
|
int i = 0;
|
||||||
|
if (icoll.Folders != null)
|
||||||
|
{
|
||||||
|
foreach (InventoryFolderBase f in icoll.Folders)
|
||||||
|
{
|
||||||
|
folders["folder_" + i.ToString()] = EncodeFolder(f);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
result["FOLDERS"] = folders;
|
||||||
|
}
|
||||||
|
if (icoll.Items != null)
|
||||||
|
{
|
||||||
|
i = 0;
|
||||||
|
Dictionary<string, object> items = new Dictionary<string, object>();
|
||||||
|
foreach (InventoryItemBase it in icoll.Items)
|
||||||
|
{
|
||||||
|
items["item_" + i.ToString()] = EncodeItem(it);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
result["ITEMS"] = items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||||
|
//m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
|
||||||
|
UTF8Encoding encoding = new UTF8Encoding();
|
||||||
|
return encoding.GetBytes(xmlString);
|
||||||
|
}
|
||||||
|
|
||||||
byte[] HandleGetRootFolder(Dictionary<string,object> request)
|
byte[] HandleGetRootFolder(Dictionary<string,object> request)
|
||||||
{
|
{
|
||||||
Dictionary<string,object> result = new Dictionary<string,object>();
|
Dictionary<string,object> result = new Dictionary<string,object>();
|
||||||
|
@ -294,13 +335,17 @@ namespace OpenSim.Server.Handlers.Asset
|
||||||
{
|
{
|
||||||
Dictionary<string, object> folders = new Dictionary<string, object>();
|
Dictionary<string, object> folders = new Dictionary<string, object>();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
if (icoll.Folders != null)
|
||||||
|
{
|
||||||
foreach (InventoryFolderBase f in icoll.Folders)
|
foreach (InventoryFolderBase f in icoll.Folders)
|
||||||
{
|
{
|
||||||
folders["folder_" + i.ToString()] = EncodeFolder(f);
|
folders["folder_" + i.ToString()] = EncodeFolder(f);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
result["FOLDERS"] = folders;
|
result["FOLDERS"] = folders;
|
||||||
|
}
|
||||||
|
if (icoll.Items != null)
|
||||||
|
{
|
||||||
i = 0;
|
i = 0;
|
||||||
Dictionary<string, object> items = new Dictionary<string, object>();
|
Dictionary<string, object> items = new Dictionary<string, object>();
|
||||||
foreach (InventoryItemBase it in icoll.Items)
|
foreach (InventoryItemBase it in icoll.Items)
|
||||||
|
@ -310,6 +355,7 @@ namespace OpenSim.Server.Handlers.Asset
|
||||||
}
|
}
|
||||||
result["ITEMS"] = items;
|
result["ITEMS"] = items;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
string xmlString = ServerUtils.BuildXmlResponse(result);
|
string xmlString = ServerUtils.BuildXmlResponse(result);
|
||||||
//m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
|
//m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
|
||||||
|
|
|
@ -111,19 +111,21 @@ namespace OpenSim.Services.Connectors
|
||||||
if (ret.Count == 0)
|
if (ret.Count == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
Dictionary<string, object> folders = (Dictionary<string, object>)ret["FOLDERS"];
|
||||||
|
|
||||||
|
List<InventoryFolderBase> fldrs = new List<InventoryFolderBase>();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
foreach (Object o in ret.Values)
|
foreach (Object o in folders.Values)
|
||||||
folders.Add(BuildFolder((Dictionary<string, object>)o));
|
fldrs.Add(BuildFolder((Dictionary<string, object>)o));
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat("[XINVENTORY CONNECTOR STUB]: Exception unwrapping folder list: {0}", e.Message);
|
m_log.DebugFormat("[XINVENTORY CONNECTOR STUB]: Exception unwrapping folder list: {0}", e.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
return folders;
|
return fldrs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryFolderBase GetRootFolder(UUID principalID)
|
public InventoryFolderBase GetRootFolder(UUID principalID)
|
||||||
|
@ -492,12 +494,41 @@ namespace OpenSim.Services.Connectors
|
||||||
return int.Parse(ret["RESULT"].ToString());
|
return int.Parse(ret["RESULT"].ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// These are either obsolete or unused
|
|
||||||
//
|
|
||||||
public InventoryCollection GetUserInventory(UUID principalID)
|
public InventoryCollection GetUserInventory(UUID principalID)
|
||||||
{
|
{
|
||||||
|
InventoryCollection inventory = new InventoryCollection();
|
||||||
|
inventory.Folders = new List<InventoryFolderBase>();
|
||||||
|
inventory.Items = new List<InventoryItemBase>();
|
||||||
|
inventory.UserID = principalID;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Dictionary<string, object> ret = MakeRequest("GETUSERINVENTORY",
|
||||||
|
new Dictionary<string, object> {
|
||||||
|
{ "PRINCIPAL", principalID.ToString() }
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ret == null)
|
||||||
return null;
|
return null;
|
||||||
|
if (ret.Count == 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Dictionary<string, object> folders =
|
||||||
|
(Dictionary<string, object>)ret["FOLDERS"];
|
||||||
|
Dictionary<string, object> items =
|
||||||
|
(Dictionary<string, object>)ret["ITEMS"];
|
||||||
|
|
||||||
|
foreach (Object o in folders.Values) // getting the values directly, we don't care about the keys folder_i
|
||||||
|
inventory.Folders.Add(BuildFolder((Dictionary<string, object>)o));
|
||||||
|
foreach (Object o in items.Values) // getting the values directly, we don't care about the keys item_i
|
||||||
|
inventory.Items.Add(BuildItem((Dictionary<string, object>)o));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.DebugFormat("[XINVENTORY CONNECTOR STUB]: Exception in GetUserInventory: {0}", e.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetUserInventory(UUID principalID, InventoryReceiptCallback callback)
|
public void GetUserInventory(UUID principalID, InventoryReceiptCallback callback)
|
||||||
|
|
|
@ -105,6 +105,12 @@ namespace OpenSim.Services.HypergridService
|
||||||
return new List<InventoryFolderBase>();
|
return new List<InventoryFolderBase>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override InventoryCollection GetUserInventory(UUID userID)
|
||||||
|
{
|
||||||
|
// NOGO for this inventory service
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public override InventoryFolderBase GetRootFolder(UUID principalID)
|
public override InventoryFolderBase GetRootFolder(UUID principalID)
|
||||||
{
|
{
|
||||||
//m_log.DebugFormat("[HG INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
|
//m_log.DebugFormat("[HG INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
|
||||||
|
|
Loading…
Reference in New Issue