aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDiva Canto2009-08-13 17:34:15 -0700
committerDiva Canto2009-08-13 17:34:15 -0700
commit034c9cf606373bfa9d3f8040cd787f789e0efbf2 (patch)
treef586e4a8247fdf92e730bb7a8c296559e144d0a8
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.
-rw-r--r--OpenSim/Framework/Communications/Tests/LoginServiceTests.cs5
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs15
-rw-r--r--OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs7
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs17
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs20
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs10
-rw-r--r--OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs12
-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
-rw-r--r--OpenSim/Tests/Common/Mock/TestInventoryService.cs5
15 files changed, 168 insertions, 44 deletions
diff --git a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
index 3161364..22dcef9 100644
--- a/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
+++ b/OpenSim/Framework/Communications/Tests/LoginServiceTests.cs
@@ -575,5 +575,10 @@ namespace OpenSim.Framework.Communications.Tests
575 root.ParentID = UUID.Zero; 575 root.ParentID = UUID.Zero;
576 return root; 576 return root;
577 } 577 }
578
579 public int GetAssetPermissions(UUID userID, UUID assetID)
580 {
581 return 1;
582 }
578 } 583 }
579} 584}
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index a3e275d..6dda5aa 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -2156,16 +2156,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2156 2156
2157 protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase) 2157 protected void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
2158 { 2158 {
2159 // XXX: Nasty temporary move that will be resolved shortly
2160 InventoryFolderImpl folder = (InventoryFolderImpl)folderBase;
2161
2162 // We will use the same transaction id for all the separate packets to be sent out in this update. 2159 // We will use the same transaction id for all the separate packets to be sent out in this update.
2163 UUID transactionId = UUID.Random(); 2160 UUID transactionId = UUID.Random();
2164 2161
2165 List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks 2162 List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
2166 = new List<BulkUpdateInventoryPacket.FolderDataBlock>(); 2163 = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
2167 2164
2168 SendBulkUpdateInventoryFolderRecursive(folder, ref folderDataBlocks, transactionId); 2165 SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
2169 2166
2170 if (folderDataBlocks.Count > 0) 2167 if (folderDataBlocks.Count > 0)
2171 { 2168 {
@@ -2191,17 +2188,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2191 /// <param name="folderDataBlocks"></param> 2188 /// <param name="folderDataBlocks"></param>
2192 /// <param name="transactionId"></param> 2189 /// <param name="transactionId"></param>
2193 private void SendBulkUpdateInventoryFolderRecursive( 2190 private void SendBulkUpdateInventoryFolderRecursive(
2194 InventoryFolderImpl folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks, 2191 InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
2195 UUID transactionId) 2192 UUID transactionId)
2196 { 2193 {
2197 folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder)); 2194 folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
2198 2195
2199 const int MAX_ITEMS_PER_PACKET = 5; 2196 const int MAX_ITEMS_PER_PACKET = 5;
2200 2197
2198 IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
2201 // If there are any items then we have to start sending them off in this packet - the next folder will have 2199 // If there are any items then we have to start sending them off in this packet - the next folder will have
2202 // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit 2200 // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
2203 // being used on the Linden grid at 20081203). 2201 // being used on the Linden grid at 20081203).
2204 List<InventoryItemBase> items = folder.RequestListOfItems(); 2202 InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
2203 List<InventoryItemBase> items = contents.Items;
2205 while (items.Count > 0) 2204 while (items.Count > 0)
2206 { 2205 {
2207 BulkUpdateInventoryPacket bulkUpdate 2206 BulkUpdateInventoryPacket bulkUpdate
@@ -2233,8 +2232,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2233 folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder)); 2232 folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
2234 } 2233 }
2235 2234
2236 List<InventoryFolderImpl> subFolders = folder.RequestListOfFolderImpls(); 2235 List<InventoryFolderBase> subFolders = contents.Folders;
2237 foreach (InventoryFolderImpl subFolder in subFolders) 2236 foreach (InventoryFolderBase subFolder in subFolders)
2238 { 2237 {
2239 SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId); 2238 SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
2240 } 2239 }
diff --git a/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs
index 956dd10..71ff28c 100644
--- a/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs
+++ b/OpenSim/Region/CoreModules/Agent/TextureDownload/TextureDownloadModule.cs
@@ -222,8 +222,12 @@ namespace OpenSim.Region.CoreModules.Agent.TextureDownload
222 if (invService.GetRootFolder(client.AgentId) == null) // Deny no inventory 222 if (invService.GetRootFolder(client.AgentId) == null) // Deny no inventory
223 return; 223 return;
224 224
225 if (profile.UserProfile.GodLevel < 200 && profile.RootFolder.FindAsset(e.RequestedAssetID) == null) // Deny if not owned 225 // Diva 2009-08-13: this test doesn't make any sense to many devs
226 return; 226 //if (profile.UserProfile.GodLevel < 200 && profile.RootFolder.FindAsset(e.RequestedAssetID) == null) // Deny if not owned
227 //{
228 // m_log.WarnFormat("[TEXTURE]: user {0} doesn't have permissions to texture {1}");
229 // return;
230 //}
227 231
228 m_log.Debug("Texture preview"); 232 m_log.Debug("Texture preview");
229 } 233 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
index 0526bc4..ef5ffe1 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/BaseInventoryConnector.cs
@@ -82,7 +82,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
82 /// </summary> 82 /// </summary>
83 /// <param name="userID"></param> 83 /// <param name="userID"></param>
84 /// <returns>null if no root folder was found</returns> 84 /// <returns>null if no root folder was found</returns>
85 public abstract InventoryFolderBase GetRootFolder(UUID userID); 85 public InventoryFolderBase GetRootFolder(UUID userID)
86 {
87 // Root folder is here as system type Folder.
88 return m_cache.GetFolderForType(userID, AssetType.Folder);
89 }
86 90
87 public abstract Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID); 91 public abstract Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID);
88 92
@@ -202,5 +206,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
202 /// <returns></returns> 206 /// <returns></returns>
203 public abstract List<InventoryItemBase> GetActiveGestures(UUID userId); 207 public abstract List<InventoryItemBase> GetActiveGestures(UUID userId);
204 208
209 public abstract int GetAssetPermissions(UUID userID, UUID assetID);
205 } 210 }
206} 211}
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
index db4e7f4..fd12a57 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs
@@ -263,6 +263,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
263 folders[(AssetType)folder.Type] = folder; 263 folders[(AssetType)folder.Type] = folder;
264 } 264 }
265 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: System folders count for {0}: {1}", userID, folders.Count); 265 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: System folders count for {0}: {1}", userID, folders.Count);
266 // Put the root folder there, as type Folder
267 folders[AssetType.Folder] = root;
266 return folders; 268 return folders;
267 } 269 }
268 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder content not found for {0}", userID); 270 m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder content not found for {0}", userID);
@@ -422,14 +424,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
422 return false; 424 return false;
423 } 425 }
424 426
425 public override InventoryFolderBase GetRootFolder(UUID userID) 427 public override List<InventoryItemBase> GetActiveGestures(UUID userId)
426 { 428 {
427 return null; 429 return new List<InventoryItemBase>();
428 } 430 }
429 431
430 public override List<InventoryItemBase> GetActiveGestures(UUID userId) 432 public override int GetAssetPermissions(UUID userID, UUID assetID)
431 { 433 {
432 return new List<InventoryItemBase>(); 434 if (IsLocalGridUser(userID))
435 return m_GridService.GetAssetPermissions(userID, assetID);
436 else
437 {
438 UUID sessionID = GetSessionID(userID);
439 string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
440 return m_HGService.GetAssetPermissions(uri, assetID, sessionID);
441 }
433 } 442 }
434 443
435 #endregion 444 #endregion
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
index ccf06d1..2fbc5fe 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs
@@ -201,8 +201,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
201 foreach (InventoryFolderBase folder in content.Folders) 201 foreach (InventoryFolderBase folder in content.Folders)
202 { 202 {
203 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown)) 203 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
204 {
205 m_log.InfoFormat("[INVENTORY CONNECTOR]: folder type {0} ", folder.Type);
204 folders[(AssetType)folder.Type] = folder; 206 folders[(AssetType)folder.Type] = folder;
207 }
205 } 208 }
209 // Put the root folder there, as type Folder
210 folders[AssetType.Folder] = root;
211 m_log.InfoFormat("[INVENTORY CONNECTOR]: root folder is type {0} ", root.Type);
212
206 return folders; 213 return folders;
207 } 214 }
208 } 215 }
@@ -312,19 +319,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
312 return m_InventoryService.HasInventoryForUser(userID); 319 return m_InventoryService.HasInventoryForUser(userID);
313 } 320 }
314 321
315 /// <summary> 322 public override List<InventoryItemBase> GetActiveGestures(UUID userId)
316 /// Retrieve the root inventory folder for the given user.
317 /// </summary>
318 /// <param name="userID"></param>
319 /// <returns>null if no root folder was found</returns>
320 public override InventoryFolderBase GetRootFolder(UUID userID)
321 { 323 {
322 return m_InventoryService.GetRootFolder(userID); 324 return m_InventoryService.GetActiveGestures(userId);
323 } 325 }
324 326
325 public override List<InventoryItemBase> GetActiveGestures(UUID userId) 327 public override int GetAssetPermissions(UUID userID, UUID assetID)
326 { 328 {
327 return m_InventoryService.GetActiveGestures(userId); 329 return m_InventoryService.GetAssetPermissions(userID, assetID);
328 } 330 }
329 #endregion IInventoryService 331 #endregion IInventoryService
330 } 332 }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
index 4f19573..e4bb865 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteInventoryServiceConnector.cs
@@ -296,16 +296,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
296 return false; 296 return false;
297 } 297 }
298 298
299 public override InventoryFolderBase GetRootFolder(UUID userID) 299 public override List<InventoryItemBase> GetActiveGestures(UUID userId)
300 { 300 {
301 return null; 301 return new List<InventoryItemBase>();
302 } 302 }
303 303
304 public override List<InventoryItemBase> GetActiveGestures(UUID userId) 304 public override int GetAssetPermissions(UUID userID, UUID assetID)
305 { 305 {
306 return new List<InventoryItemBase>(); 306 UUID sessionID = GetSessionID(userID);
307 return m_RemoteConnector.GetAssetPermissions(userID.ToString(), assetID, sessionID);
307 } 308 }
308 309
310
309 #endregion 311 #endregion
310 312
311 private UUID GetSessionID(UUID userID) 313 private UUID GetSessionID(UUID userID)
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
index 63cf034..30b3cae 100644
--- a/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/InventoryServerInConnector.cs
@@ -153,6 +153,11 @@ namespace OpenSim.Server.Handlers.Inventory
153 m_httpServer.AddStreamHandler( 153 m_httpServer.AddStreamHandler(
154 new RestDeserialiseTrustedHandler<Guid, List<InventoryFolderBase>> 154 new RestDeserialiseTrustedHandler<Guid, List<InventoryFolderBase>>
155 ("POST", "/RootFolders/", GetInventorySkeleton, CheckTrustSource)); 155 ("POST", "/RootFolders/", GetInventorySkeleton, CheckTrustSource));
156
157 m_httpServer.AddStreamHandler(
158 new RestDeserialiseTrustedHandler<InventoryItemBase, int>
159 ("POST", "/AssetPermissions/", GetAssetPermissions, CheckTrustSource));
160
156 } 161 }
157 162
158 #region Wrappers for converting the Guid parameter 163 #region Wrappers for converting the Guid parameter
@@ -185,6 +190,8 @@ namespace OpenSim.Server.Handlers.Inventory
185 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown)) 190 if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
186 folders[(AssetType)folder.Type] = folder; 191 folders[(AssetType)folder.Type] = folder;
187 } 192 }
193 // Put the root folder there, as type Folder
194 folders[AssetType.Folder] = root;
188 return folders; 195 return folders;
189 } 196 }
190 } 197 }
@@ -235,6 +242,11 @@ namespace OpenSim.Server.Handlers.Inventory
235 return m_InventoryService.GetInventorySkeleton(userID); 242 return m_InventoryService.GetInventorySkeleton(userID);
236 } 243 }
237 244
245 public int GetAssetPermissions(InventoryItemBase item)
246 {
247 return m_InventoryService.GetAssetPermissions(item.Owner, item.AssetID);
248 }
249
238 #endregion 250 #endregion
239 251
240 /// <summary> 252 /// <summary>
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>
diff --git a/OpenSim/Tests/Common/Mock/TestInventoryService.cs b/OpenSim/Tests/Common/Mock/TestInventoryService.cs
index 6576533..ba9cbe9 100644
--- a/OpenSim/Tests/Common/Mock/TestInventoryService.cs
+++ b/OpenSim/Tests/Common/Mock/TestInventoryService.cs
@@ -171,5 +171,10 @@ namespace OpenSim.Tests.Common.Mock
171 root.ParentID = UUID.Zero; 171 root.ParentID = UUID.Zero;
172 return root; 172 return root;
173 } 173 }
174
175 public int GetAssetPermissions(UUID userID, UUID assetID)
176 {
177 return 1;
178 }
174 } 179 }
175} 180}