Major change in the way inventory is downloaded: added a method throughout IIventoryService that fetches sets of folders at once. Also added folder id in the InventoryCollection data structure, so that we don't need to go to inventory server again just for that. This reduces the chatter between sims and inventory server by... a lot. On my tests, this reduces initial inventory download down to 30% of what it currently is.
parent
ca4569eeb4
commit
c74cef0f42
|
@ -57,11 +57,9 @@ namespace OpenSim.Capabilities.Handlers
|
|||
m_LibraryService = libService;
|
||||
}
|
||||
|
||||
|
||||
public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
// lock (m_fetchLock)
|
||||
// {
|
||||
// m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request {0}", request);
|
||||
|
||||
// nasty temporary hack here, the linden client falsely
|
||||
// identifies the uuid 00000000-0000-0000-0000-000000000000
|
||||
|
@ -94,9 +92,9 @@ namespace OpenSim.Capabilities.Handlers
|
|||
string response = "";
|
||||
string bad_folders_response = "";
|
||||
|
||||
List<LLSDFetchInventoryDescendents> folders = new List<LLSDFetchInventoryDescendents>();
|
||||
for (int i = 0; i < foldersrequested.Count; i++)
|
||||
{
|
||||
string inventoryitemstr = "";
|
||||
Hashtable inventoryhash = (Hashtable)foldersrequested[i];
|
||||
|
||||
LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents();
|
||||
|
@ -108,22 +106,34 @@ namespace OpenSim.Capabilities.Handlers
|
|||
catch (Exception e)
|
||||
{
|
||||
m_log.Debug("[WEB FETCH INV DESC HANDLER]: caught exception doing OSD deserialize" + e);
|
||||
continue;
|
||||
}
|
||||
LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest);
|
||||
|
||||
if (null == reply)
|
||||
{
|
||||
bad_folders_response += "<uuid>" + llsdRequest.folder_id.ToString() + "</uuid>";
|
||||
folders.Add(llsdRequest);
|
||||
}
|
||||
else
|
||||
|
||||
if (folders.Count > 0)
|
||||
{
|
||||
List<InventoryCollectionWithDescendents> invcollSet = Fetch(folders);
|
||||
//m_log.DebugFormat("[XXX]: Got {0} folders from a request of {1}", invcollSet.Count, folders.Count);
|
||||
if (invcollSet == null)
|
||||
{
|
||||
m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Multiple folder fetch failed. Trying old protocol.");
|
||||
return FetchInventoryDescendentsRequest(foldersrequested, httpRequest, httpResponse);
|
||||
}
|
||||
|
||||
string inventoryitemstr = string.Empty;
|
||||
foreach (InventoryCollectionWithDescendents icoll in invcollSet)
|
||||
{
|
||||
LLSDInventoryDescendents reply = ToLLSD(icoll.Collection, icoll.Descendents);
|
||||
|
||||
inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply);
|
||||
inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", "");
|
||||
inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", "");
|
||||
}
|
||||
|
||||
response += inventoryitemstr;
|
||||
}
|
||||
}
|
||||
|
||||
if (response.Length == 0)
|
||||
{
|
||||
|
@ -154,7 +164,6 @@ namespace OpenSim.Capabilities.Handlers
|
|||
|
||||
return response;
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -215,6 +224,118 @@ namespace OpenSim.Capabilities.Handlers
|
|||
return reply;
|
||||
}
|
||||
|
||||
private LLSDInventoryDescendents ToLLSD(InventoryCollection inv, int descendents)
|
||||
{
|
||||
LLSDInventoryDescendents reply = new LLSDInventoryDescendents();
|
||||
LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents();
|
||||
contents.agent_id = inv.OwnerID;
|
||||
contents.owner_id = inv.OwnerID;
|
||||
contents.folder_id = inv.FolderID;
|
||||
|
||||
reply.folders.Array.Add(contents);
|
||||
|
||||
if (inv.Folders != null)
|
||||
{
|
||||
foreach (InventoryFolderBase invFolder in inv.Folders)
|
||||
{
|
||||
contents.categories.Array.Add(ConvertInventoryFolder(invFolder));
|
||||
}
|
||||
|
||||
descendents += inv.Folders.Count;
|
||||
}
|
||||
|
||||
if (inv.Items != null)
|
||||
{
|
||||
foreach (InventoryItemBase invItem in inv.Items)
|
||||
{
|
||||
contents.items.Array.Add(ConvertInventoryItem(invItem));
|
||||
}
|
||||
}
|
||||
|
||||
contents.descendents = descendents;
|
||||
contents.version = inv.Version;
|
||||
|
||||
return reply;
|
||||
}
|
||||
/// <summary>
|
||||
/// Old style. Soon to be deprecated.
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="httpRequest"></param>
|
||||
/// <param name="httpResponse"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete]
|
||||
private string FetchInventoryDescendentsRequest(ArrayList foldersrequested, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||
{
|
||||
//m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request for {0} folders", foldersrequested.Count);
|
||||
|
||||
string response = "";
|
||||
string bad_folders_response = "";
|
||||
|
||||
for (int i = 0; i < foldersrequested.Count; i++)
|
||||
{
|
||||
string inventoryitemstr = "";
|
||||
Hashtable inventoryhash = (Hashtable)foldersrequested[i];
|
||||
|
||||
LLSDFetchInventoryDescendents llsdRequest = new LLSDFetchInventoryDescendents();
|
||||
|
||||
try
|
||||
{
|
||||
LLSDHelpers.DeserialiseOSDMap(inventoryhash, llsdRequest);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Debug("[WEB FETCH INV DESC HANDLER]: caught exception doing OSD deserialize" + e);
|
||||
}
|
||||
|
||||
LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest);
|
||||
|
||||
if (null == reply)
|
||||
{
|
||||
bad_folders_response += "<uuid>" + llsdRequest.folder_id.ToString() + "</uuid>";
|
||||
}
|
||||
else
|
||||
{
|
||||
inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply);
|
||||
inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", "");
|
||||
inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", "");
|
||||
}
|
||||
|
||||
response += inventoryitemstr;
|
||||
}
|
||||
|
||||
if (response.Length == 0)
|
||||
{
|
||||
/* Viewers expect a bad_folders array when not available */
|
||||
if (bad_folders_response.Length != 0)
|
||||
{
|
||||
response = "<llsd><map><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>";
|
||||
}
|
||||
else
|
||||
{
|
||||
response = "<llsd><map><key>folders</key><array /></map></llsd>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bad_folders_response.Length != 0)
|
||||
{
|
||||
response = "<llsd><map><key>folders</key><array>" + response + "</array><key>bad_folders</key><array>" + bad_folders_response + "</array></map></llsd>";
|
||||
}
|
||||
else
|
||||
{
|
||||
response = "<llsd><map><key>folders</key><array>" + response + "</array></map></llsd>";
|
||||
}
|
||||
}
|
||||
|
||||
// m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Replying to CAPS fetch inventory request");
|
||||
//m_log.Debug("[WEB FETCH INV DESC HANDLER] "+response);
|
||||
|
||||
return response;
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle the caps inventory descendents fetch.
|
||||
/// </summary>
|
||||
|
@ -226,6 +347,7 @@ namespace OpenSim.Capabilities.Handlers
|
|||
/// <param name="sortOrder"></param>
|
||||
/// <param name="version"></param>
|
||||
/// <returns>An empty InventoryCollection if the inventory look up failed</returns>
|
||||
[Obsolete]
|
||||
private InventoryCollection Fetch(
|
||||
UUID agentID, UUID folderID, UUID ownerID,
|
||||
bool fetchFolders, bool fetchItems, int sortOrder, out int version, out int descendents)
|
||||
|
@ -264,7 +386,6 @@ namespace OpenSim.Capabilities.Handlers
|
|||
m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Could not get contents of folder {0} for user {1}", folderID, agentID);
|
||||
return contents;
|
||||
}
|
||||
|
||||
contents = fetchedContents;
|
||||
InventoryFolderBase containingFolder = new InventoryFolderBase();
|
||||
containingFolder.ID = folderID;
|
||||
|
@ -410,6 +531,160 @@ namespace OpenSim.Capabilities.Handlers
|
|||
return contents;
|
||||
|
||||
}
|
||||
|
||||
private void AddLibraryFolders(List<LLSDFetchInventoryDescendents> fetchFolders, List<InventoryCollectionWithDescendents> result)
|
||||
{
|
||||
InventoryFolderImpl fold;
|
||||
if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null)
|
||||
{
|
||||
List<LLSDFetchInventoryDescendents> libfolders = fetchFolders.FindAll(f => f.owner_id == m_LibraryService.LibraryRootFolder.Owner);
|
||||
fetchFolders.RemoveAll(f => libfolders.Contains(f));
|
||||
|
||||
foreach (LLSDFetchInventoryDescendents f in libfolders)
|
||||
{
|
||||
if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(f.folder_id)) != null)
|
||||
{
|
||||
InventoryCollectionWithDescendents ret = new InventoryCollectionWithDescendents();
|
||||
ret.Collection = new InventoryCollection();
|
||||
ret.Collection.Folders = new List<InventoryFolderBase>();
|
||||
ret.Collection.Items = fold.RequestListOfItems();
|
||||
ret.Collection.OwnerID = m_LibraryService.LibraryRootFolder.Owner;
|
||||
ret.Collection.FolderID = f.folder_id;
|
||||
ret.Collection.Version = fold.Version;
|
||||
|
||||
ret.Descendents = ret.Collection.Items.Count;
|
||||
|
||||
result.Add(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<InventoryCollectionWithDescendents> Fetch(List<LLSDFetchInventoryDescendents> fetchFolders)
|
||||
{
|
||||
//m_log.DebugFormat(
|
||||
// "[WEB FETCH INV DESC HANDLER]: Fetching {0} folders for owner {1}", fetchFolders.Count, fetchFolders[0].owner_id);
|
||||
|
||||
// FIXME MAYBE: We're not handling sortOrder!
|
||||
|
||||
List<InventoryCollectionWithDescendents> result = new List<InventoryCollectionWithDescendents>();
|
||||
|
||||
AddLibraryFolders(fetchFolders, result);
|
||||
|
||||
if (fetchFolders.Count > 0)
|
||||
{
|
||||
UUID[] fids = new UUID[fetchFolders.Count];
|
||||
int i = 0;
|
||||
foreach (LLSDFetchInventoryDescendents f in fetchFolders)
|
||||
fids[i++] = f.folder_id;
|
||||
|
||||
InventoryCollection[] fetchedContents = m_InventoryService.GetMultipleFoldersContent(fetchFolders[0].owner_id, fids);
|
||||
|
||||
if (fetchedContents == null || (fetchedContents != null && fetchedContents.Length == 0))
|
||||
{
|
||||
//m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Could not get contents of multiple folders for user {0}", fetchFolders[0].owner_id);
|
||||
return null;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
// Do some post-processing. May need to fetch more from inv server for links
|
||||
foreach (InventoryCollection contents in fetchedContents)
|
||||
{
|
||||
InventoryCollectionWithDescendents coll = new InventoryCollectionWithDescendents();
|
||||
coll.Collection = contents;
|
||||
|
||||
// Find the original request
|
||||
LLSDFetchInventoryDescendents freq = fetchFolders[i++];
|
||||
|
||||
// The inventory server isn't sending FolderID in the collection...
|
||||
// Must fetch it individually
|
||||
if (contents.FolderID == UUID.Zero)
|
||||
{
|
||||
InventoryFolderBase containingFolder = new InventoryFolderBase();
|
||||
containingFolder.ID = freq.folder_id;
|
||||
containingFolder.Owner = freq.owner_id;
|
||||
containingFolder = m_InventoryService.GetFolder(containingFolder);
|
||||
|
||||
if (containingFolder != null)
|
||||
{
|
||||
contents.FolderID = containingFolder.ID;
|
||||
contents.OwnerID = containingFolder.Owner;
|
||||
contents.Version = containingFolder.Version;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[WEB FETCH INV DESC HANDLER]: Unable to fetch folder {0}", freq.folder_id);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (freq.fetch_items && contents.Items != null)
|
||||
{
|
||||
List<InventoryItemBase> itemsToReturn = contents.Items;
|
||||
List<InventoryItemBase> originalItems = new List<InventoryItemBase>(itemsToReturn);
|
||||
|
||||
// descendents must only include the links, not the linked items we add
|
||||
coll.Descendents = originalItems.Count;
|
||||
|
||||
// Add target items for links in this folder before the links themselves.
|
||||
foreach (InventoryItemBase item in originalItems)
|
||||
{
|
||||
if (item.AssetType == (int)AssetType.Link)
|
||||
{
|
||||
InventoryItemBase linkedItem = m_InventoryService.GetItem(new InventoryItemBase(item.AssetID));
|
||||
|
||||
// Take care of genuinely broken links where the target doesn't exist
|
||||
// HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
|
||||
// but no viewer has been observed to set these up and this is the lazy way of avoiding cycles
|
||||
// rather than having to keep track of every folder requested in the recursion.
|
||||
if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link)
|
||||
{
|
||||
itemsToReturn.Insert(0, linkedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now scan for folder links and insert the items they target and those links at the head of the return data
|
||||
foreach (InventoryItemBase item in originalItems)
|
||||
{
|
||||
if (item.AssetType == (int)AssetType.LinkFolder)
|
||||
{
|
||||
InventoryCollection linkedFolderContents = m_InventoryService.GetFolderContent(coll.Collection.OwnerID, item.AssetID);
|
||||
List<InventoryItemBase> links = linkedFolderContents.Items;
|
||||
|
||||
itemsToReturn.InsertRange(0, links);
|
||||
|
||||
foreach (InventoryItemBase link in linkedFolderContents.Items)
|
||||
{
|
||||
// Take care of genuinely broken links where the target doesn't exist
|
||||
// HACK: Also, don't follow up links that just point to other links. In theory this is legitimate,
|
||||
// but no viewer has been observed to set these up and this is the lazy way of avoiding cycles
|
||||
// rather than having to keep track of every folder requested in the recursion.
|
||||
if (link != null)
|
||||
{
|
||||
//m_log.DebugFormat(
|
||||
// "[WEB FETCH INV DESC HANDLER]: Adding item {0} {1} from folder {2} linked from {3}",
|
||||
// link.Name, (AssetType)link.AssetType, item.AssetID, contents.FolderID);
|
||||
|
||||
InventoryItemBase linkedItem
|
||||
= m_InventoryService.GetItem(new InventoryItemBase(link.AssetID));
|
||||
|
||||
if (linkedItem != null)
|
||||
itemsToReturn.Insert(0, linkedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.Add(coll);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Convert an internal inventory folder object into an LLSD object.
|
||||
/// </summary>
|
||||
|
@ -462,4 +737,10 @@ namespace OpenSim.Capabilities.Handlers
|
|||
return llsdItem;
|
||||
}
|
||||
}
|
||||
|
||||
struct InventoryCollectionWithDescendents
|
||||
{
|
||||
public InventoryCollection Collection;
|
||||
public int Descendents;
|
||||
}
|
||||
}
|
|
@ -37,6 +37,8 @@ namespace OpenSim.Framework
|
|||
{
|
||||
public List<InventoryFolderBase> Folders;
|
||||
public List<InventoryItemBase> Items;
|
||||
public UUID UserID;
|
||||
public UUID OwnerID;
|
||||
public UUID FolderID;
|
||||
public int Version;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
|
||||
Scene.EventManager.OnRegisterCaps += RegisterCaps;
|
||||
|
||||
int nworkers = 1; // was 2
|
||||
int nworkers = 2; // was 2
|
||||
if (ProcessQueuedRequestsAsync && m_workerThreads == null)
|
||||
{
|
||||
m_workerThreads = new Thread[nworkers];
|
||||
|
@ -365,7 +365,11 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
requestinfo.request["body"].ToString(), String.Empty, String.Empty, null, null);
|
||||
|
||||
lock (responses)
|
||||
{
|
||||
if (responses.ContainsKey(requestID))
|
||||
m_log.WarnFormat("[FETCH INVENTORY DESCENDENTS2 MODULE]: Caught in the act of loosing responses! Please report this on mantis #7054");
|
||||
responses[requestID] = response;
|
||||
}
|
||||
|
||||
WebFetchInvDescModule.ProcessedRequestsCount++;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library
|
|||
{
|
||||
InventoryFolderImpl folder = null;
|
||||
InventoryCollection inv = new InventoryCollection();
|
||||
inv.UserID = m_Library.Owner;
|
||||
inv.OwnerID = m_Library.Owner;
|
||||
|
||||
if (folderID != m_Library.ID)
|
||||
{
|
||||
|
@ -87,6 +87,18 @@ namespace OpenSim.Region.CoreModules.Framework.Library
|
|||
return inv;
|
||||
}
|
||||
|
||||
public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
|
||||
{
|
||||
InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length];
|
||||
int i = 0;
|
||||
foreach (UUID fid in folderIDs)
|
||||
{
|
||||
invColl[i++] = GetFolderContent(principalID, fid);
|
||||
}
|
||||
|
||||
return invColl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a new folder to the user's inventory
|
||||
/// </summary>
|
||||
|
|
|
@ -389,6 +389,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
|||
return connector.GetFolderContent(userID, folderID);
|
||||
}
|
||||
|
||||
public InventoryCollection[] GetMultipleFoldersContent(UUID userID, UUID[] folderIDs)
|
||||
{
|
||||
string invURL = GetInventoryServiceURL(userID);
|
||||
|
||||
if (invURL == null) // not there, forward to local inventory connector to resolve
|
||||
lock (m_Lock)
|
||||
return m_LocalGridInventoryService.GetMultipleFoldersContent(userID, folderIDs);
|
||||
|
||||
else
|
||||
{
|
||||
InventoryCollection[] coll = new InventoryCollection[folderIDs.Length];
|
||||
int i = 0;
|
||||
foreach (UUID fid in folderIDs)
|
||||
coll[i++] = GetFolderContent(userID, fid);
|
||||
|
||||
return coll;
|
||||
}
|
||||
}
|
||||
|
||||
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
|
||||
{
|
||||
//m_log.Debug("[HG INVENTORY CONNECTOR]: GetFolderItems " + folderID);
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
|||
if (m_Inventories.TryGetValue(userID, out inv))
|
||||
{
|
||||
c = new InventoryCollection();
|
||||
c.UserID = userID;
|
||||
c.OwnerID = userID;
|
||||
|
||||
c.Folders = inv.Folders.FindAll(delegate(InventoryFolderBase f)
|
||||
{
|
||||
|
|
|
@ -195,6 +195,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
|||
return invCol;
|
||||
}
|
||||
|
||||
public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
|
||||
{
|
||||
InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length];
|
||||
int i = 0;
|
||||
foreach (UUID fid in folderIDs)
|
||||
{
|
||||
invColl[i++] = GetFolderContent(principalID, fid);
|
||||
}
|
||||
|
||||
return invColl;
|
||||
|
||||
}
|
||||
|
||||
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
|
||||
{
|
||||
return m_InventoryService.GetFolderItems(userID, folderID);
|
||||
|
|
|
@ -204,6 +204,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
|
|||
return invCol;
|
||||
}
|
||||
|
||||
public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
|
||||
{
|
||||
return m_RemoteConnector.GetMultipleFoldersContent(principalID, folderIDs);
|
||||
}
|
||||
|
||||
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
|
||||
{
|
||||
return m_RemoteConnector.GetFolderItems(userID, folderID);
|
||||
|
|
|
@ -41,7 +41,9 @@ using OpenSim.Server.Handlers.Base;
|
|||
using log4net;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Server.Handlers.Asset
|
||||
using System.Threading;
|
||||
|
||||
namespace OpenSim.Server.Handlers.Inventory
|
||||
{
|
||||
public class XInventoryInConnector : ServiceConnector
|
||||
{
|
||||
|
@ -123,6 +125,8 @@ namespace OpenSim.Server.Handlers.Asset
|
|||
return HandleGetFolderForType(request);
|
||||
case "GETFOLDERCONTENT":
|
||||
return HandleGetFolderContent(request);
|
||||
case "GETMULTIPLEFOLDERSCONTENT":
|
||||
return HandleGetMultipleFoldersContent(request);
|
||||
case "GETFOLDERITEMS":
|
||||
return HandleGetFolderItems(request);
|
||||
case "ADDFOLDER":
|
||||
|
@ -284,6 +288,8 @@ namespace OpenSim.Server.Handlers.Asset
|
|||
InventoryCollection icoll = m_InventoryService.GetFolderContent(principal, folderID);
|
||||
if (icoll != null)
|
||||
{
|
||||
result["FID"] = icoll.FolderID.ToString();
|
||||
result["VERSION"] = icoll.Version.ToString();
|
||||
Dictionary<string, object> folders = new Dictionary<string, object>();
|
||||
int i = 0;
|
||||
if (icoll.Folders != null)
|
||||
|
@ -314,6 +320,70 @@ namespace OpenSim.Server.Handlers.Asset
|
|||
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] HandleGetMultipleFoldersContent(Dictionary<string, object> request)
|
||||
{
|
||||
Dictionary<string, object> resultSet = new Dictionary<string, object>();
|
||||
UUID principal = UUID.Zero;
|
||||
UUID.TryParse(request["PRINCIPAL"].ToString(), out principal);
|
||||
string folderIDstr = request["FOLDERS"].ToString();
|
||||
int count = 0;
|
||||
Int32.TryParse(request["COUNT"].ToString(), out count);
|
||||
|
||||
UUID[] fids = new UUID[count];
|
||||
string[] uuids = folderIDstr.Split(',');
|
||||
int i = 0;
|
||||
foreach (string id in uuids)
|
||||
{
|
||||
UUID fid = UUID.Zero;
|
||||
if (UUID.TryParse(id, out fid))
|
||||
fids[i] = fid;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
count = 0;
|
||||
InventoryCollection[] icollList = m_InventoryService.GetMultipleFoldersContent(principal, fids);
|
||||
if (icollList != null && icollList.Length > 0)
|
||||
{
|
||||
foreach (InventoryCollection icoll in icollList)
|
||||
{
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
result["FID"] = icoll.FolderID.ToString();
|
||||
result["VERSION"] = icoll.Version.ToString();
|
||||
result["OWNER"] = icoll.OwnerID.ToString();
|
||||
Dictionary<string, object> folders = new Dictionary<string, object>();
|
||||
i = 0;
|
||||
if (icoll.Folders != null)
|
||||
{
|
||||
foreach (InventoryFolderBase f in icoll.Folders)
|
||||
{
|
||||
folders["folder_" + i.ToString()] = EncodeFolder(f);
|
||||
i++;
|
||||
}
|
||||
result["FOLDERS"] = folders;
|
||||
}
|
||||
i = 0;
|
||||
if (icoll.Items != null)
|
||||
{
|
||||
Dictionary<string, object> items = new Dictionary<string, object>();
|
||||
foreach (InventoryItemBase it in icoll.Items)
|
||||
{
|
||||
items["item_" + i.ToString()] = EncodeItem(it);
|
||||
i++;
|
||||
}
|
||||
result["ITEMS"] = items;
|
||||
}
|
||||
|
||||
resultSet["F_" + fids[count++]] = result;
|
||||
//m_log.DebugFormat("[XXX]: Sending {0} {1}", fids[count-1], icoll.FolderID);
|
||||
}
|
||||
}
|
||||
|
||||
string xmlString = ServerUtils.BuildXmlResponse(resultSet);
|
||||
|
||||
//m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
|
||||
return Util.UTF8NoBomEncoding.GetBytes(xmlString);
|
||||
}
|
||||
|
||||
byte[] HandleGetFolderItems(Dictionary<string, object> request)
|
||||
{
|
||||
Dictionary<string,object> result = new Dictionary<string,object>();
|
||||
|
|
|
@ -205,7 +205,7 @@ namespace OpenSim.Services.Connectors
|
|||
InventoryCollection inventory = new InventoryCollection();
|
||||
inventory.Folders = new List<InventoryFolderBase>();
|
||||
inventory.Items = new List<InventoryItemBase>();
|
||||
inventory.UserID = principalID;
|
||||
inventory.OwnerID = principalID;
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -236,6 +236,85 @@ namespace OpenSim.Services.Connectors
|
|||
return inventory;
|
||||
}
|
||||
|
||||
public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
|
||||
{
|
||||
InventoryCollection[] inventoryArr = new InventoryCollection[folderIDs.Length];
|
||||
//m_log.DebugFormat("[XXX]: In GetMultipleFoldersContent {0}", folderIDs.Length);
|
||||
try
|
||||
{
|
||||
Dictionary<string, object> resultSet = MakeRequest("GETMULTIPLEFOLDERSCONTENT",
|
||||
new Dictionary<string, object> {
|
||||
{ "PRINCIPAL", principalID.ToString() },
|
||||
{ "FOLDERS", String.Join(",", folderIDs) },
|
||||
{ "COUNT", folderIDs.Length.ToString() }
|
||||
});
|
||||
|
||||
if (!CheckReturn(resultSet))
|
||||
return null;
|
||||
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, object> kvp in resultSet)
|
||||
{
|
||||
InventoryCollection inventory = new InventoryCollection();
|
||||
if (kvp.Key.StartsWith("F_"))
|
||||
{
|
||||
UUID fid = UUID.Zero;
|
||||
if (UUID.TryParse(kvp.Key.Substring(2), out fid) && fid == folderIDs[i])
|
||||
{
|
||||
inventory.Folders = new List<InventoryFolderBase>();
|
||||
inventory.Items = new List<InventoryItemBase>();
|
||||
|
||||
Dictionary<string, object> ret = (Dictionary<string, object>)kvp.Value;
|
||||
|
||||
if (ret.ContainsKey("FID"))
|
||||
{
|
||||
if (!UUID.TryParse(ret["FID"].ToString(), out inventory.FolderID))
|
||||
m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Could not parse folder id {0}", ret["FID"].ToString());
|
||||
}
|
||||
else
|
||||
m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: FID key not present in response");
|
||||
|
||||
inventory.Version = -1;
|
||||
if (ret.ContainsKey("VERSION"))
|
||||
Int32.TryParse(ret["VERSION"].ToString(), out inventory.Version);
|
||||
if (ret.ContainsKey("OWNER"))
|
||||
UUID.TryParse(ret["OWNER"].ToString(), out inventory.OwnerID);
|
||||
|
||||
//m_log.DebugFormat("[XXX]: Received {0} ({1}) {2} {3}", inventory.FolderID, fid, inventory.Version, inventory.OwnerID);
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
inventoryArr[i] = inventory;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Folder id does not match. Expected {0} got {1}",
|
||||
folderIDs[i], fid);
|
||||
}
|
||||
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("[XINVENTORY SERVICES CONNECTOR]: Exception in GetMultipleFoldersContent: {0}", e.Message);
|
||||
}
|
||||
|
||||
return inventoryArr;
|
||||
}
|
||||
public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
|
||||
{
|
||||
Dictionary<string,object> ret = MakeRequest("GETFOLDERITEMS",
|
||||
|
|
|
@ -340,7 +340,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
|||
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
|
||||
{
|
||||
InventoryCollection inventory = new InventoryCollection();
|
||||
inventory.UserID = userID;
|
||||
inventory.OwnerID = userID;
|
||||
|
||||
NameValueCollection requestArgs = new NameValueCollection
|
||||
{
|
||||
|
@ -371,6 +371,18 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
|||
return inventory;
|
||||
}
|
||||
|
||||
public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
|
||||
{
|
||||
InventoryCollection[] invColl = new InventoryCollection[folderIDs.Length];
|
||||
int i = 0;
|
||||
foreach (UUID fid in folderIDs)
|
||||
{
|
||||
invColl[i++] = GetFolderContent(principalID, fid);
|
||||
}
|
||||
|
||||
return invColl;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the items inside a folder
|
||||
/// </summary>
|
||||
|
@ -380,7 +392,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
|
|||
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
|
||||
{
|
||||
InventoryCollection inventory = new InventoryCollection();
|
||||
inventory.UserID = userID;
|
||||
inventory.OwnerID = userID;
|
||||
|
||||
NameValueCollection requestArgs = new NameValueCollection
|
||||
{
|
||||
|
|
|
@ -154,6 +154,13 @@ namespace OpenSim.Services.HypergridService
|
|||
//{
|
||||
//}
|
||||
|
||||
// NOGO
|
||||
//
|
||||
public override InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderID)
|
||||
{
|
||||
return new InventoryCollection[0];
|
||||
}
|
||||
|
||||
//public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
|
||||
//{
|
||||
//}
|
||||
|
|
|
@ -77,6 +77,14 @@ namespace OpenSim.Services.Interfaces
|
|||
/// <returns>Inventory content. null if the request failed.</returns>
|
||||
InventoryCollection GetFolderContent(UUID userID, UUID folderID);
|
||||
|
||||
/// <summary>
|
||||
/// Gets everything (folders and items) inside a folder
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="folderIDs"></param>
|
||||
/// <returns>Inventory content. null if the request failed.</returns>
|
||||
InventoryCollection[] GetMultipleFoldersContent(UUID userID, UUID[] folderIDs);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the items inside a folder
|
||||
/// </summary>
|
||||
|
|
|
@ -291,7 +291,7 @@ namespace OpenSim.Services.InventoryService
|
|||
//
|
||||
//m_log.DebugFormat("[XINVENTORY SERVICE]: Fetch contents for folder {0}", folderID.ToString());
|
||||
InventoryCollection inventory = new InventoryCollection();
|
||||
inventory.UserID = principalID;
|
||||
inventory.OwnerID = principalID;
|
||||
inventory.Folders = new List<InventoryFolderBase>();
|
||||
inventory.Items = new List<InventoryItemBase>();
|
||||
|
||||
|
@ -315,9 +315,28 @@ namespace OpenSim.Services.InventoryService
|
|||
inventory.Items.Add(ConvertToOpenSim(i));
|
||||
}
|
||||
|
||||
InventoryFolderBase f = new InventoryFolderBase(folderID, principalID);
|
||||
f = GetFolder(f);
|
||||
if (f != null)
|
||||
{
|
||||
inventory.Version = f.Version;
|
||||
inventory.OwnerID = f.Owner;
|
||||
}
|
||||
inventory.FolderID = folderID;
|
||||
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public virtual InventoryCollection[] GetMultipleFoldersContent(UUID principalID, UUID[] folderIDs)
|
||||
{
|
||||
InventoryCollection[] multiple = new InventoryCollection[folderIDs.Length];
|
||||
int i = 0;
|
||||
foreach (UUID fid in folderIDs)
|
||||
multiple[i++] = GetFolderContent(principalID, fid);
|
||||
|
||||
return multiple;
|
||||
}
|
||||
|
||||
public virtual List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
|
||||
{
|
||||
// m_log.DebugFormat("[XINVENTORY]: Fetch items for folder {0}", folderID);
|
||||
|
|
Loading…
Reference in New Issue