From 3a3f9d5abbdd25511b1bb2cd7476ba68761a0d12 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 17 Aug 2009 14:14:22 -0700 Subject: Added some padding to the remote inventory connector so that it tries to operate with the old Grid.InventoryServer.exe. Untested, but it should work -- slow. --- .../Inventory/InventoryServiceConnector.cs | 74 ++++++++++++++++++++-- 1 file changed, 70 insertions(+), 4 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 4907015..5d94eac 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs @@ -163,20 +163,47 @@ namespace OpenSim.Services.Connectors /// public Dictionary GetSystemFolders(string userID, UUID sessionID) { + List folders = null; + Dictionary dFolders = new Dictionary(); try { - List folders = SynchronousRestSessionObjectPoster>.BeginPostObject( + folders = SynchronousRestSessionObjectPoster>.BeginPostObject( "POST", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString()); - Dictionary dFolders = new Dictionary(); foreach (InventoryFolderBase f in folders) dFolders[(AssetType)f.Type] = f; + return dFolders; } catch (Exception e) { - m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1}", + // Maybe we're talking to an old inventory server. Try this other thing. + m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1}. Trying RootFolders.", e.Source, e.Message); + + try + { + folders = SynchronousRestSessionObjectPoster>.BeginPostObject( + "POST", m_ServerURI + "/RootFolders/", new Guid(userID), sessionID.ToString(), userID.ToString()); + } + catch (Exception ex) + { + m_log.ErrorFormat("[INVENTORY CONNECTOR]: RootFolders operation also failed, {0} {1}. Give up.", + e.Source, ex.Message); + } + + if ((folders != null) && (folders.Count > 0)) + { + dFolders[AssetType.Folder] = folders[0]; // Root folder is the first one + folders.RemoveAt(0); + foreach (InventoryFolderBase f in folders) + { + if ((f.Type != (short)AssetType.Folder) && (f.Type != (short)AssetType.Unknown)) + dFolders[(AssetType)f.Type] = f; + } + + return dFolders; + } } return new Dictionary(); @@ -192,13 +219,52 @@ namespace OpenSim.Services.Connectors { try { + // normal case return SynchronousRestSessionObjectPoster.BeginPostObject( "POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString()); } catch (Exception e) { - m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}", + // Maybe we're talking to an old inventory server. Try this other thing. + m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}. Trying RootFolders and GetItems.", e.Source, e.Message); + + List folders = null; + try + { + folders = SynchronousRestSessionObjectPoster>.BeginPostObject( + "POST", m_ServerURI + "/RootFolders/", new Guid(userID), sessionID.ToString(), userID.ToString()); + } + catch (Exception ex) + { + m_log.ErrorFormat("[INVENTORY CONNECTOR]: RootFolders operation also failed, {0} {1}. Give up.", + e.Source, ex.Message); + } + + if ((folders != null) && (folders.Count > 0)) + { + folders = folders.FindAll(delegate (InventoryFolderBase f) { return f.ParentID == folderID ; }); + + try + { + List items = SynchronousRestSessionObjectPoster>.BeginPostObject( + "POST", m_ServerURI + "/GetItems/", folderID.Guid, sessionID.ToString(), userID.ToString()); + + if (items != null) + { + InventoryCollection result = new InventoryCollection(); + result.Folders = folders; + result.Items = items; + result.UserID = new UUID(userID); + return result; + } + } + catch (Exception ex) + { + m_log.ErrorFormat("[INVENTORY CONNECTOR]: QueryFolder and GetItems operation failed, {0} {1}. Give up.", + e.Source, ex.Message); + } + } } return null; -- cgit v1.1