Added http handlers for the two new inventory operations.

arthursv
Diva Canto 2009-08-11 12:30:28 -07:00
parent dc897b2288
commit e3dbd0e049
2 changed files with 46 additions and 4 deletions

View File

@ -84,6 +84,14 @@ namespace OpenSim.Server.Handlers.Inventory
new RestDeserialiseSecureHandler<Guid, InventoryCollection>( new RestDeserialiseSecureHandler<Guid, InventoryCollection>(
"POST", "/GetInventory/", GetUserInventory, CheckAuthSession)); "POST", "/GetInventory/", GetUserInventory, CheckAuthSession));
m_httpServer.AddStreamHandler(
new RestDeserialiseSecureHandler<Guid, Dictionary<AssetType, InventoryFolderBase>>(
"GET", "/SystemFolders/", GetSystemFolders, CheckAuthSession));
m_httpServer.AddStreamHandler(
new RestDeserialiseSecureHandler<Guid, InventoryCollection>(
"POST", "/GetFolderContent/", GetFolderContent, CheckAuthSession));
m_httpServer.AddStreamHandler( m_httpServer.AddStreamHandler(
new RestDeserialiseSecureHandler<InventoryFolderBase, bool>( new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
"POST", "/UpdateFolder/", m_InventoryService.UpdateFolder, CheckAuthSession)); "POST", "/UpdateFolder/", m_InventoryService.UpdateFolder, CheckAuthSession));
@ -155,6 +163,40 @@ namespace OpenSim.Server.Handlers.Inventory
return m_InventoryService.GetUserInventory(userID); return m_InventoryService.GetUserInventory(userID);
} }
public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(Guid guid)
{
UUID userID = new UUID(guid);
return GetSystemFolders(userID);
}
// This shouldn't be here, it should be in the inventory service.
// But I don't want to deal with types and dependencies for now.
private Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
{
InventoryFolderBase root = m_InventoryService.GetRootFolder(userID);
if (root != null)
{
InventoryCollection content = m_InventoryService.GetFolderContent(userID, root.ID);
if (content != null)
{
Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
foreach (InventoryFolderBase folder in content.Folders)
{
if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
folders[(AssetType)folder.Type] = folder;
}
return folders;
}
}
m_log.WarnFormat("[INVENTORY SERVICE]: System folders for {0} not found", userID);
return new Dictionary<AssetType, InventoryFolderBase>();
}
public InventoryCollection GetFolderContent(Guid guid)
{
return m_InventoryService.GetFolderContent(UUID.Zero, new UUID(guid));
}
public List<InventoryItemBase> GetFolderItems(Guid folderID) public List<InventoryItemBase> GetFolderItems(Guid folderID)
{ {
List<InventoryItemBase> allItems = new List<InventoryItemBase>(); List<InventoryItemBase> allItems = new List<InventoryItemBase>();

View File

@ -165,8 +165,8 @@ namespace OpenSim.Services.Connectors
{ {
try try
{ {
return SynchronousRestSessionObjectPoster<string, Dictionary<AssetType, InventoryFolderBase>>.BeginPostObject( return SynchronousRestSessionObjectPoster<Guid, Dictionary<AssetType, InventoryFolderBase>>.BeginPostObject(
"GET", m_ServerURI + "/SystemFolders/", userID, sessionID.ToString(), userID.ToString()); "GET", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString());
} }
catch (Exception e) catch (Exception e)
{ {
@ -187,8 +187,8 @@ namespace OpenSim.Services.Connectors
{ {
try try
{ {
return SynchronousRestSessionObjectPoster<UUID, InventoryCollection>.BeginPostObject( return SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject(
"GET", m_ServerURI + "/GetFolderContents/", folderID, sessionID.ToString(), userID.ToString()); "POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString());
} }
catch (Exception e) catch (Exception e)
{ {