aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorDiva Canto2009-08-13 17:34:15 -0700
committerDiva Canto2009-08-13 17:34:15 -0700
commit034c9cf606373bfa9d3f8040cd787f789e0efbf2 (patch)
treef586e4a8247fdf92e730bb7a8c296559e144d0a8 /OpenSim/Services
parentRenamed QueryItem/QueryFolder to GetItem/GetFolder. The word 'query' starting... (diff)
downloadopensim-SC_OLD-034c9cf606373bfa9d3f8040cd787f789e0efbf2.zip
opensim-SC_OLD-034c9cf606373bfa9d3f8040cd787f789e0efbf2.tar.gz
opensim-SC_OLD-034c9cf606373bfa9d3f8040cd787f789e0efbf2.tar.bz2
opensim-SC_OLD-034c9cf606373bfa9d3f8040cd787f789e0efbf2.tar.xz
Added GetAssetPermissions. Few last bugs nixed. This is ready for testing.
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs14
-rw-r--r--OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs2
-rw-r--r--OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs49
-rw-r--r--OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs5
-rw-r--r--OpenSim/Services/Interfaces/IInventoryService.cs20
-rw-r--r--OpenSim/Services/InventoryService/InventoryService.cs23
6 files changed, 97 insertions, 16 deletions
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
149 /// <returns></returns> 149 /// <returns></returns>
150 public InventoryCollection GetFolderContent(string id, UUID folderID, UUID sessionID) 150 public InventoryCollection GetFolderContent(string id, UUID folderID, UUID sessionID)
151 { 151 {
152 m_log.Debug("[HGInventory]: GetSystemFolders " + id); 152 m_log.Debug("[HGInventory]: GetFolderContent " + id);
153 string url = string.Empty; 153 string url = string.Empty;
154 string userID = string.Empty; 154 string userID = string.Empty;
155 155
@@ -279,5 +279,17 @@ namespace OpenSim.Services.Connectors.Inventory
279 return null; 279 return null;
280 } 280 }
281 281
282 public int GetAssetPermissions(string id, UUID assetID, UUID sessionID)
283 {
284 string url = string.Empty;
285 string userID = string.Empty;
286
287 if (StringToUrlAndUserID(id, out url, out userID))
288 {
289 ISessionAuthInventoryService connector = GetConnector(url);
290 return connector.GetAssetPermissions(userID, assetID, sessionID);
291 }
292 return 0;
293 }
282 } 294 }
283} 295}
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
120 120
121 InventoryFolderBase QueryFolder(string userID, InventoryFolderBase item, UUID session_id); 121 InventoryFolderBase QueryFolder(string userID, InventoryFolderBase item, UUID session_id);
122 122
123 int GetAssetPermissions(string userID, UUID assetID, UUID session_id);
124
123 } 125 }
124} 126}
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
163 /// <returns></returns> 163 /// <returns></returns>
164 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID sessionID) 164 public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID sessionID)
165 { 165 {
166 // !!! Not just yet. 166 try
167 //try 167 {
168 //{ 168 List<InventoryFolderBase> folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject(
169 // List<InventoryFolderBase> folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject( 169 "POST", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString());
170 // "POST", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString()); 170
171 // Dictionary<AssetType, InventoryFolderBase> dFolders = new Dictionary<AssetType, InventoryFolderBase>(); 171 Dictionary<AssetType, InventoryFolderBase> dFolders = new Dictionary<AssetType, InventoryFolderBase>();
172 // foreach (InventoryFolderBase f in folders) 172 foreach (InventoryFolderBase f in folders)
173 // dFolders[(AssetType)f.Type] = f; 173 dFolders[(AssetType)f.Type] = f;
174 // return dFolders; 174 return dFolders;
175 //} 175 }
176 //catch (Exception e) 176 catch (Exception e)
177 //{ 177 {
178 // m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1}", 178 m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1}",
179 // e.Source, e.Message); 179 e.Source, e.Message);
180 //} 180 }
181 181
182 return new Dictionary<AssetType, InventoryFolderBase>(); 182 return new Dictionary<AssetType, InventoryFolderBase>();
183 } 183 }
@@ -348,6 +348,25 @@ namespace OpenSim.Services.Connectors
348 return null; 348 return null;
349 } 349 }
350 350
351 public int GetAssetPermissions(string userID, UUID assetID, UUID sessionID)
352 {
353 try
354 {
355 InventoryItemBase item = new InventoryItemBase();
356 item.Owner = new UUID(userID);
357 item.AssetID = assetID;
358 return SynchronousRestSessionObjectPoster<InventoryItemBase, int>.BeginPostObject(
359 "POST", m_ServerURI + "/AssetPermissions/", item, sessionID.ToString(), userID);
360 }
361 catch (Exception e)
362 {
363 m_log.ErrorFormat("[INVENTORY CONNECTOR]: AssetPermissions operation failed, {0} {1}",
364 e.Source, e.Message);
365 }
366
367 return 0;
368 }
369
351 #endregion 370 #endregion
352 371
353 /// <summary> 372 /// <summary>
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
176 return null; 176 return null;
177 } 177 }
178 178
179 public int GetAssetPermissions(UUID userID, UUID assetID)
180 {
181 return 0;
182 }
183
179 } 184 }
180} 185}
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
149 /// <returns>true if the item was successfully deleted</returns> 149 /// <returns>true if the item was successfully deleted</returns>
150 bool DeleteItem(InventoryItemBase item); 150 bool DeleteItem(InventoryItemBase item);
151 151
152 /// <summary>
153 /// Get an item, given by its UUID
154 /// </summary>
155 /// <param name="item"></param>
156 /// <returns></returns>
152 InventoryItemBase GetItem(InventoryItemBase item); 157 InventoryItemBase GetItem(InventoryItemBase item);
153 158
159 /// <summary>
160 /// Get a folder, given by its UUID
161 /// </summary>
162 /// <param name="folder"></param>
163 /// <returns></returns>
154 InventoryFolderBase GetFolder(InventoryFolderBase folder); 164 InventoryFolderBase GetFolder(InventoryFolderBase folder);
155 165
156 /// <summary> 166 /// <summary>
@@ -166,5 +176,15 @@ namespace OpenSim.Services.Interfaces
166 /// <param name="userId"></param> 176 /// <param name="userId"></param>
167 /// <returns></returns> 177 /// <returns></returns>
168 List<InventoryItemBase> GetActiveGestures(UUID userId); 178 List<InventoryItemBase> GetActiveGestures(UUID userId);
179
180 /// <summary>
181 /// Get the union of permissions of all inventory items
182 /// that hold the given assetID.
183 /// </summary>
184 /// <param name="userID"></param>
185 /// <param name="assetID"></param>
186 /// <returns>The permissions or 0 if no such asset is found in
187 /// the user's inventory</returns>
188 int GetAssetPermissions(UUID userID, UUID assetID);
169 } 189 }
170} 190}
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
465 return null; 465 return null;
466 } 466 }
467 467
468 public int GetAssetPermissions(UUID userID, UUID assetID)
469 {
470 InventoryFolderBase parent = GetRootFolder(userID);
471 return FindAssetPerms(parent, assetID);
472 }
473
474 private int FindAssetPerms(InventoryFolderBase folder, UUID assetID)
475 {
476 InventoryCollection contents = GetFolderContent(folder.Owner, folder.ID);
477
478 int perms = 0;
479 foreach (InventoryItemBase item in contents.Items)
480 {
481 if (item.AssetID == assetID)
482 perms = (int)item.CurrentPermissions | perms;
483 }
484
485 foreach (InventoryFolderBase subfolder in contents.Folders)
486 perms = perms | FindAssetPerms(subfolder, assetID);
487
488 return perms;
489 }
490
468 /// <summary> 491 /// <summary>
469 /// Used to create a new user inventory. 492 /// Used to create a new user inventory.
470 /// </summary> 493 /// </summary>