some cleanup on FetchInvDescHandler
parent
eaefae7e20
commit
46c55b6fa0
|
@ -61,7 +61,6 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
m_Scene = s;
|
m_Scene = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
public string FetchInventoryDescendentsRequest(string request, string path, string param, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
//m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request);
|
//m_log.DebugFormat("[XXX]: FetchInventoryDescendentsRequest in {0}, {1}", (m_Scene == null) ? "none" : m_Scene.Name, request);
|
||||||
|
@ -137,13 +136,13 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
string inventoryitemstr = string.Empty;
|
string inventoryitemstr = string.Empty;
|
||||||
foreach (InventoryCollectionWithDescendents icoll in invcollSet)
|
foreach (InventoryCollectionWithDescendents icoll in invcollSet)
|
||||||
{
|
{
|
||||||
LLSDInventoryDescendents reply = ToLLSD(icoll.Collection, icoll.Descendents);
|
LLSDInventoryFolderContents thiscontents = contentsToLLSD(icoll.Collection, icoll.Descendents);
|
||||||
|
inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(thiscontents);
|
||||||
inventoryitemstr = LLSDHelpers.SerialiseLLSDReply(reply);
|
// inventoryitemstr = inventoryitemstr.Replace("<llsd>", "");
|
||||||
inventoryitemstr = inventoryitemstr.Replace("<llsd><map><key>folders</key><array>", "");
|
// inventoryitemstr = inventoryitemstr.Replace("</llsd>", "");
|
||||||
inventoryitemstr = inventoryitemstr.Replace("</array></map></llsd>", "");
|
// inventoryitemstr = inventoryitemstr.Substring(6,inventoryitemstr.Length - 13);
|
||||||
|
// tmpresponse.Append(inventoryitemstr);
|
||||||
tmpresponse.Append(inventoryitemstr);
|
tmpresponse.Append(inventoryitemstr.Substring(6,inventoryitemstr.Length - 13));
|
||||||
}
|
}
|
||||||
|
|
||||||
//m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders));
|
//m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Bad folders {0}", string.Join(", ", bad_folders));
|
||||||
|
@ -236,16 +235,13 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
||||||
private LLSDInventoryDescendents ToLLSD(InventoryCollection inv, int descendents)
|
private LLSDInventoryFolderContents contentsToLLSD(InventoryCollection inv, int descendents)
|
||||||
{
|
{
|
||||||
LLSDInventoryDescendents reply = new LLSDInventoryDescendents();
|
|
||||||
LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents();
|
LLSDInventoryFolderContents contents = new LLSDInventoryFolderContents();
|
||||||
contents.agent_id = inv.OwnerID;
|
contents.agent_id = inv.OwnerID;
|
||||||
contents.owner_id = inv.OwnerID;
|
contents.owner_id = inv.OwnerID;
|
||||||
contents.folder_id = inv.FolderID;
|
contents.folder_id = inv.FolderID;
|
||||||
|
|
||||||
reply.folders.Array.Add(contents);
|
|
||||||
|
|
||||||
if (inv.Folders != null)
|
if (inv.Folders != null)
|
||||||
{
|
{
|
||||||
foreach (InventoryFolderBase invFolder in inv.Folders)
|
foreach (InventoryFolderBase invFolder in inv.Folders)
|
||||||
|
@ -267,7 +263,7 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
contents.descendents = descendents;
|
contents.descendents = descendents;
|
||||||
contents.version = inv.Version;
|
contents.version = inv.Version;
|
||||||
|
|
||||||
return reply;
|
return contents;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Old style. Soon to be deprecated.
|
/// Old style. Soon to be deprecated.
|
||||||
|
@ -424,110 +420,9 @@ namespace OpenSim.Capabilities.Handlers
|
||||||
itemsToReturn.Insert(0, linkedItem);
|
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
|
|
||||||
|
|
||||||
/* dont send contents of LinkFolders.
|
|
||||||
from docs seems this was never a spec
|
|
||||||
|
|
||||||
foreach (InventoryItemBase item in originalItems)
|
|
||||||
{
|
|
||||||
if (item.AssetType == (int)AssetType.LinkFolder)
|
|
||||||
{
|
|
||||||
InventoryCollection linkedFolderContents = m_InventoryService.GetFolderContent(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, containingFolder.Name);
|
|
||||||
|
|
||||||
InventoryItemBase linkedItem
|
|
||||||
= m_InventoryService.GetItem(new InventoryItemBase(link.AssetID));
|
|
||||||
|
|
||||||
if (linkedItem != null)
|
|
||||||
itemsToReturn.Insert(0, linkedItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
// foreach (InventoryItemBase item in contents.Items)
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat(
|
|
||||||
// "[WEB FETCH INV DESC HANDLER]: Returning item {0}, type {1}, parent {2} in {3} {4}",
|
|
||||||
// item.Name, (AssetType)item.AssetType, item.Folder, containingFolder.Name, containingFolder.ID);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// =====
|
|
||||||
|
|
||||||
//
|
|
||||||
// foreach (InventoryItemBase linkedItem in linkedItemsToAdd)
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat(
|
|
||||||
// "[WEB FETCH INV DESC HANDLER]: Inserted linked item {0} for link in folder {1} for agent {2}",
|
|
||||||
// linkedItem.Name, folderID, agentID);
|
|
||||||
//
|
|
||||||
// contents.Items.Add(linkedItem);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // If the folder requested contains links, then we need to send those folders first, otherwise the links
|
|
||||||
// // will be broken in the viewer.
|
|
||||||
// HashSet<UUID> linkedItemFolderIdsToSend = new HashSet<UUID>();
|
|
||||||
// foreach (InventoryItemBase item in contents.Items)
|
|
||||||
// {
|
|
||||||
// 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)
|
|
||||||
// {
|
|
||||||
// // We don't need to send the folder if source and destination of the link are in the same
|
|
||||||
// // folder.
|
|
||||||
// if (linkedItem.Folder != containingFolder.ID)
|
|
||||||
// linkedItemFolderIdsToSend.Add(linkedItem.Folder);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// foreach (UUID linkedItemFolderId in linkedItemFolderIdsToSend)
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat(
|
|
||||||
// "[WEB FETCH INV DESC HANDLER]: Recursively fetching folder {0} linked by item in folder {1} for agent {2}",
|
|
||||||
// linkedItemFolderId, folderID, agentID);
|
|
||||||
//
|
|
||||||
// int dummyVersion;
|
|
||||||
// InventoryCollection linkedCollection
|
|
||||||
// = Fetch(
|
|
||||||
// agentID, linkedItemFolderId, ownerID, fetchFolders, fetchItems, sortOrder, out dummyVersion);
|
|
||||||
//
|
|
||||||
// InventoryFolderBase linkedFolder = new InventoryFolderBase(linkedItemFolderId);
|
|
||||||
// linkedFolder.Owner = agentID;
|
|
||||||
// linkedFolder = m_InventoryService.GetFolder(linkedFolder);
|
|
||||||
//
|
|
||||||
//// contents.Folders.AddRange(linkedCollection.Folders);
|
|
||||||
//
|
|
||||||
// contents.Folders.Add(linkedFolder);
|
|
||||||
// contents.Items.AddRange(linkedCollection.Items);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Lost items don't really need a version
|
// Lost items don't really need a version
|
||||||
|
@ -696,42 +591,21 @@ from docs seems this was never a spec
|
||||||
|
|
||||||
if (freq.fetch_items && contents.Items != null)
|
if (freq.fetch_items && contents.Items != null)
|
||||||
{
|
{
|
||||||
List<InventoryItemBase> itemsToReturn = contents.Items;
|
// viewers are lasy and want a copy of the link item sent before the link to it
|
||||||
|
|
||||||
// descendents must only include the links, not the linked items we add
|
// descendents must only include the links, not the linked items we add
|
||||||
coll.Descendents = itemsToReturn.Count;
|
coll.Descendents = contents.Items.Count;
|
||||||
|
|
||||||
// Add target items for links in this folder before the links themselves.
|
// look for item links
|
||||||
List<UUID> itemIDs = new List<UUID>();
|
List<UUID> itemIDs = new List<UUID>();
|
||||||
List<UUID> folderIDs = new List<UUID>();
|
foreach (InventoryItemBase item in contents.Items)
|
||||||
foreach (InventoryItemBase item in itemsToReturn)
|
|
||||||
{
|
{
|
||||||
//m_log.DebugFormat("[XXX]: {0} {1}", item.Name, item.AssetType);
|
//m_log.DebugFormat("[XXX]: {0} {1}", item.Name, item.AssetType);
|
||||||
if (item.AssetType == (int)AssetType.Link)
|
if (item.AssetType == (int)AssetType.Link)
|
||||||
itemIDs.Add(item.AssetID);
|
itemIDs.Add(item.AssetID);
|
||||||
|
|
||||||
// else if (item.AssetType == (int)AssetType.LinkFolder)
|
|
||||||
// folderIDs.Add(item.AssetID);
|
|
||||||
}
|
|
||||||
|
|
||||||
//m_log.DebugFormat("[XXX]: folder {0} has {1} links and {2} linkfolders", contents.FolderID, itemIDs.Count, folderIDs.Count);
|
|
||||||
|
|
||||||
// Scan for folder links and insert the items they target and those links at the head of the return data
|
|
||||||
if (folderIDs.Count > 0)
|
|
||||||
{
|
|
||||||
InventoryCollection[] linkedFolders = m_InventoryService.GetMultipleFoldersContent(coll.Collection.OwnerID, folderIDs.ToArray());
|
|
||||||
foreach (InventoryCollection linkedFolderContents in linkedFolders)
|
|
||||||
{
|
|
||||||
if (linkedFolderContents == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
List<InventoryItemBase> links = linkedFolderContents.Items;
|
|
||||||
|
|
||||||
itemsToReturn.InsertRange(0, links);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get the linked if any
|
||||||
if (itemIDs.Count > 0)
|
if (itemIDs.Count > 0)
|
||||||
{
|
{
|
||||||
InventoryItemBase[] linked = m_InventoryService.GetMultipleItems(freq.owner_id, itemIDs.ToArray());
|
InventoryItemBase[] linked = m_InventoryService.GetMultipleItems(freq.owner_id, itemIDs.ToArray());
|
||||||
|
@ -747,12 +621,10 @@ from docs seems this was never a spec
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Processing folder {0}. Existing items:", freq.folder_id);
|
|
||||||
//foreach (InventoryItemBase item in itemsToReturn)
|
|
||||||
// m_log.DebugFormat("[XXX]: {0} {1} {2}", item.Name, item.AssetType, item.Folder);
|
|
||||||
|
|
||||||
if (linked != null)
|
if (linked != null)
|
||||||
{
|
{
|
||||||
|
List<InventoryItemBase> linkedItems = new List<InventoryItemBase>();
|
||||||
|
// check for broken
|
||||||
foreach (InventoryItemBase linkedItem in linked)
|
foreach (InventoryItemBase linkedItem in linked)
|
||||||
{
|
{
|
||||||
// Take care of genuinely broken links where the target doesn't exist
|
// Take care of genuinely broken links where the target doesn't exist
|
||||||
|
@ -761,14 +633,16 @@ from docs seems this was never a spec
|
||||||
// rather than having to keep track of every folder requested in the recursion.
|
// rather than having to keep track of every folder requested in the recursion.
|
||||||
if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link)
|
if (linkedItem != null && linkedItem.AssetType != (int)AssetType.Link)
|
||||||
{
|
{
|
||||||
itemsToReturn.Insert(0, linkedItem);
|
linkedItems.Add(linkedItem);
|
||||||
//m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Added {0} {1} {2}", linkedItem.Name, linkedItem.AssetType, linkedItem.Folder);
|
//m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Added {0} {1} {2}", linkedItem.Name, linkedItem.AssetType, linkedItem.Folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// insert them
|
||||||
|
if(linkedItems.Count > 0)
|
||||||
|
contents.Items.InsertRange(0,linkedItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue