From 034c9cf606373bfa9d3f8040cd787f789e0efbf2 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Thu, 13 Aug 2009 17:34:15 -0700
Subject: Added GetAssetPermissions. Few last bugs nixed. This is ready for
testing.
---
.../Inventory/HGInventoryServiceConnector.cs | 14 ++++++-
.../Inventory/ISessionAuthInventoryService.cs | 2 +
.../Inventory/InventoryServiceConnector.cs | 49 +++++++++++++++-------
.../QuickAndDirtyInventoryServiceConnector.cs | 5 +++
OpenSim/Services/Interfaces/IInventoryService.cs | 20 +++++++++
.../Services/InventoryService/InventoryService.cs | 23 ++++++++++
6 files changed, 97 insertions(+), 16 deletions(-)
(limited to 'OpenSim/Services')
diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
index f6d1500..94b4ad9 100644
--- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs
@@ -149,7 +149,7 @@ namespace OpenSim.Services.Connectors.Inventory
///
public InventoryCollection GetFolderContent(string id, UUID folderID, UUID sessionID)
{
- m_log.Debug("[HGInventory]: GetSystemFolders " + id);
+ m_log.Debug("[HGInventory]: GetFolderContent " + id);
string url = string.Empty;
string userID = string.Empty;
@@ -279,5 +279,17 @@ namespace OpenSim.Services.Connectors.Inventory
return null;
}
+ public int GetAssetPermissions(string id, UUID assetID, UUID sessionID)
+ {
+ string url = string.Empty;
+ string userID = string.Empty;
+
+ if (StringToUrlAndUserID(id, out url, out userID))
+ {
+ ISessionAuthInventoryService connector = GetConnector(url);
+ return connector.GetAssetPermissions(userID, assetID, sessionID);
+ }
+ return 0;
+ }
}
}
diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
index 973cb0a..f50bcf5 100644
--- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
+++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs
@@ -120,5 +120,7 @@ namespace OpenSim.Services.Connectors
InventoryFolderBase QueryFolder(string userID, InventoryFolderBase item, UUID session_id);
+ int GetAssetPermissions(string userID, UUID assetID, UUID session_id);
+
}
}
diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
index e41b427..4907015 100644
--- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs
@@ -163,21 +163,21 @@ namespace OpenSim.Services.Connectors
///
public Dictionary GetSystemFolders(string userID, UUID sessionID)
{
- // !!! Not just yet.
- //try
- //{
- // List 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}",
- // e.Source, e.Message);
- //}
+ try
+ {
+ List 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}",
+ e.Source, e.Message);
+ }
return new Dictionary();
}
@@ -348,6 +348,25 @@ namespace OpenSim.Services.Connectors
return null;
}
+ public int GetAssetPermissions(string userID, UUID assetID, UUID sessionID)
+ {
+ try
+ {
+ InventoryItemBase item = new InventoryItemBase();
+ item.Owner = new UUID(userID);
+ item.AssetID = assetID;
+ return SynchronousRestSessionObjectPoster.BeginPostObject(
+ "POST", m_ServerURI + "/AssetPermissions/", item, sessionID.ToString(), userID);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat("[INVENTORY CONNECTOR]: AssetPermissions operation failed, {0} {1}",
+ e.Source, e.Message);
+ }
+
+ return 0;
+ }
+
#endregion
///
diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
index 41aacd0..5cbd307 100644
--- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs
@@ -176,5 +176,10 @@ namespace OpenSim.Services.Connectors
return null;
}
+ public int GetAssetPermissions(UUID userID, UUID assetID)
+ {
+ return 0;
+ }
+
}
}
diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs
index 6256c32..a89a238 100644
--- a/OpenSim/Services/Interfaces/IInventoryService.cs
+++ b/OpenSim/Services/Interfaces/IInventoryService.cs
@@ -149,8 +149,18 @@ namespace OpenSim.Services.Interfaces
/// true if the item was successfully deleted
bool DeleteItem(InventoryItemBase item);
+ ///
+ /// Get an item, given by its UUID
+ ///
+ ///
+ ///
InventoryItemBase GetItem(InventoryItemBase item);
+ ///
+ /// Get a folder, given by its UUID
+ ///
+ ///
+ ///
InventoryFolderBase GetFolder(InventoryFolderBase folder);
///
@@ -166,5 +176,15 @@ namespace OpenSim.Services.Interfaces
///
///
List GetActiveGestures(UUID userId);
+
+ ///
+ /// Get the union of permissions of all inventory items
+ /// that hold the given assetID.
+ ///
+ ///
+ ///
+ /// The permissions or 0 if no such asset is found in
+ /// the user's inventory
+ int GetAssetPermissions(UUID userID, UUID assetID);
}
}
diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs
index 3d706dc..65c2d96 100644
--- a/OpenSim/Services/InventoryService/InventoryService.cs
+++ b/OpenSim/Services/InventoryService/InventoryService.cs
@@ -465,6 +465,29 @@ namespace OpenSim.Services.InventoryService
return null;
}
+ public int GetAssetPermissions(UUID userID, UUID assetID)
+ {
+ InventoryFolderBase parent = GetRootFolder(userID);
+ return FindAssetPerms(parent, assetID);
+ }
+
+ private int FindAssetPerms(InventoryFolderBase folder, UUID assetID)
+ {
+ InventoryCollection contents = GetFolderContent(folder.Owner, folder.ID);
+
+ int perms = 0;
+ foreach (InventoryItemBase item in contents.Items)
+ {
+ if (item.AssetID == assetID)
+ perms = (int)item.CurrentPermissions | perms;
+ }
+
+ foreach (InventoryFolderBase subfolder in contents.Folders)
+ perms = perms | FindAssetPerms(subfolder, assetID);
+
+ return perms;
+ }
+
///
/// Used to create a new user inventory.
///
--
cgit v1.1