From 5b4fe23f7f1877a150ed50dd63beaac762fe8674 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Nov 2011 23:43:57 +0000 Subject: Resolve error where an unknown asset type would cause the fetch inventory descendents cap to fail. Introduced just a few commits ago in 0688861 --- .../WebFetchInvDescHandler.cs | 83 +++++++++++----------- 1 file changed, 43 insertions(+), 40 deletions(-) (limited to 'OpenSim/Capabilities') diff --git a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs index 04fa55c..08570bc 100644 --- a/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs +++ b/OpenSim/Capabilities/Handlers/WebFetchInventoryDescendents/WebFetchInvDescHandler.cs @@ -42,7 +42,6 @@ using Caps = OpenSim.Framework.Capabilities.Caps; namespace OpenSim.Capabilities.Handlers { - public class WebFetchInvDescHandler { private static readonly ILog m_log = @@ -60,39 +59,40 @@ namespace OpenSim.Capabilities.Handlers public string FetchInventoryDescendentsRequest(string request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { -// m_log.DebugFormat("[WEB FETCH INV DESC HANDLER]: Received request"); - - // nasty temporary hack here, the linden client falsely - // identifies the uuid 00000000-0000-0000-0000-000000000000 - // as a string which breaks us - // - // correctly mark it as a uuid - // - request = request.Replace("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000"); - - // another hack 1 results in a - // System.ArgumentException: Object type System.Int32 cannot - // be converted to target type: System.Boolean - // - request = request.Replace("fetch_folders0", "fetch_folders0"); - request = request.Replace("fetch_folders1", "fetch_folders1"); - - Hashtable hash = new Hashtable(); - try - { - hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); - } - catch (LLSD.LLSDParseException pe) - { - m_log.Error("[AGENT INVENTORY]: Fetch error: " + pe.Message); - m_log.Error("Request: " + request.ToString()); - } - - ArrayList foldersrequested = (ArrayList)hash["folders"]; - - string response = ""; 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 + // as a string which breaks us + // + // correctly mark it as a uuid + // + request = request.Replace("00000000-0000-0000-0000-000000000000", "00000000-0000-0000-0000-000000000000"); + + // another hack 1 results in a + // System.ArgumentException: Object type System.Int32 cannot + // be converted to target type: System.Boolean + // + request = request.Replace("fetch_folders0", "fetch_folders0"); + request = request.Replace("fetch_folders1", "fetch_folders1"); + + Hashtable hash = new Hashtable(); + try + { + hash = (Hashtable)LLSD.LLSDDeserialize(Utils.StringToBytes(request)); + } + catch (LLSD.LLSDParseException e) + { + m_log.ErrorFormat("[WEB FETCH INV DESC HANDLER]: Fetch error: {0}{1}" + e.Message, e.StackTrace); + m_log.Error("Request: " + request); + } + + ArrayList foldersrequested = (ArrayList)hash["folders"]; + + string response = ""; + for (int i = 0; i < foldersrequested.Count; i++) { string inventoryitemstr = ""; @@ -106,7 +106,7 @@ namespace OpenSim.Capabilities.Handlers } catch (Exception e) { - m_log.Debug("[CAPS]: caught exception doing OSD deserialize" + e); + m_log.Debug("[WEB FETCH INV DESC HANDLER]: caught exception doing OSD deserialize" + e); } LLSDInventoryDescendents reply = FetchInventoryReply(llsdRequest); @@ -130,12 +130,12 @@ namespace OpenSim.Capabilities.Handlers response = "folders" + response + ""; } - //m_log.DebugFormat("[CAPS]: Replying to CAPS fetch inventory request with following xml"); - //m_log.Debug("[CAPS] "+response); +// 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; } - - return response; } /// @@ -184,8 +184,9 @@ namespace OpenSim.Capabilities.Handlers return reply; } - public InventoryCollection Fetch(UUID agentID, UUID folderID, UUID ownerID, - bool fetchFolders, bool fetchItems, int sortOrder, out int version) + public InventoryCollection Fetch( + UUID agentID, UUID folderID, UUID ownerID, + bool fetchFolders, bool fetchItems, int sortOrder, out int version) { m_log.DebugFormat( "[WEB FETCH INV DESC HANDLER]: Fetching folders ({0}), items ({1}) from {2} for agent {3}", @@ -194,6 +195,7 @@ namespace OpenSim.Capabilities.Handlers version = 0; InventoryFolderImpl fold; if (m_LibraryService != null && m_LibraryService.LibraryRootFolder != null && agentID == m_LibraryService.LibraryRootFolder.Owner) + { if ((fold = m_LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) { InventoryCollection ret = new InventoryCollection(); @@ -202,6 +204,7 @@ namespace OpenSim.Capabilities.Handlers return ret; } + } InventoryCollection contents = new InventoryCollection(); @@ -236,7 +239,7 @@ namespace OpenSim.Capabilities.Handlers llsdFolder.parent_id = invFolder.ParentID; llsdFolder.name = invFolder.Name; - if (!Enum.IsDefined(typeof(AssetType), invFolder.Type)) + if (invFolder.Type == (short)AssetType.Unknown || !Enum.IsDefined(typeof(AssetType), (sbyte)invFolder.Type)) llsdFolder.type = "-1"; else llsdFolder.type = Utils.AssetTypeToString((AssetType)invFolder.Type); -- cgit v1.1