From 8a8c89a0f32b528bd588715bdbfc875c852e7187 Mon Sep 17 00:00:00 2001 From: Brian McBee Date: Sat, 15 Dec 2007 04:57:14 +0000 Subject: Grid Inventory feature upgrade: renaming folders should now be correct, subfolders work, moving folders works. Tested only in MYSQL, but may work in MSSQL and sqlite. Probably not working in standalone mode. --- .../Grid/InventoryServer/GridInventoryService.cs | 59 ++++++++++++++++++---- OpenSim/Grid/InventoryServer/Main.cs | 4 ++ 2 files changed, 54 insertions(+), 9 deletions(-) (limited to 'OpenSim/Grid') diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs index 8756ecb..6ae1d82 100644 --- a/OpenSim/Grid/InventoryServer/GridInventoryService.cs +++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs @@ -45,22 +45,33 @@ namespace OpenSim.Grid.InventoryServer private bool TryGetUsersInventory(LLUUID userID, out List folderList, out List itemsList) { - List folders = RequestFirstLevelFolders(userID); + List rootFolders = RequestFirstLevelFolders(userID); List allItems = new List(); + List allFolders = new List(); - if (folders != null) + if (rootFolders != null) { - foreach (InventoryFolderBase folder in folders) + allFolders.InsertRange(0, rootFolders); + foreach (InventoryFolderBase subfolder in rootFolders) { - List items = RequestFolderItems(folder.folderID); - if (items != null) + List subFolders = GetAllFolders(subfolder.folderID); + if (subFolders != null) { - allItems.InsertRange(0, items); + allFolders.InsertRange(0, subFolders); } } } - - folderList = folders; + + foreach (InventoryFolderBase folder in allFolders) + { + List items = RequestFolderItems(folder.folderID); + if (items != null) + { + allItems.InsertRange(0, items); + } + } + + folderList = allFolders; itemsList = allItems; if (folderList != null) { @@ -72,6 +83,26 @@ namespace OpenSim.Grid.InventoryServer } } + private List GetAllFolders(LLUUID folder) + { + List allFolders = new List(); + List folders = RequestSubFolders(folder); + if (folders != null) + { + allFolders.InsertRange(0, folders); + foreach (InventoryFolderBase subfolder in folders) + { + List subFolders = GetAllFolders(subfolder.folderID); + if (subFolders != null) + { + allFolders.InsertRange(0, subFolders); + } + } + } + return allFolders; + } + + public InventoryCollection GetUserInventory(Guid rawUserID) { Console.WriteLine("Request for Inventory for " + rawUserID.ToString()); @@ -104,6 +135,11 @@ namespace OpenSim.Grid.InventoryServer AddFolder(folder); } + public override void MoveExistingInventoryFolder(InventoryFolderBase folder) + { + MoveFolder(folder); + } + public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) { AddItem(item); @@ -111,11 +147,16 @@ namespace OpenSim.Grid.InventoryServer public bool AddInventoryFolder( InventoryFolderBase folder) { - Console.WriteLine("creating new folder for " + folder.agentID.ToString()); AddNewInventoryFolder(folder.agentID, folder); return true; } + public bool MoveInventoryFolder(InventoryFolderBase folder) + { + MoveExistingInventoryFolder(folder); + return true; + } + public bool AddInventoryItem( InventoryItemBase item) { Console.WriteLine("creating new item for " + item.avatarID.ToString()); diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index 58b63f4..df854f9 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs @@ -88,6 +88,10 @@ namespace OpenSim.Grid.InventoryServer m_inventoryService.AddInventoryFolder)); httpServer.AddStreamHandler( + new RestDeserialisehandler("POST", "/MoveFolder/", + m_inventoryService.MoveInventoryFolder)); + + httpServer.AddStreamHandler( new RestDeserialisehandler("POST", "/NewItem/", m_inventoryService.AddInventoryItem)); httpServer.AddStreamHandler( -- cgit v1.1