diff options
Diffstat (limited to 'OpenSim/Services')
6 files changed, 170 insertions, 23 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..5d94eac 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs | |||
@@ -163,21 +163,48 @@ 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 | List<InventoryFolderBase> folders = null; |
167 | //try | 167 | Dictionary<AssetType, InventoryFolderBase> dFolders = new Dictionary<AssetType, InventoryFolderBase>(); |
168 | //{ | 168 | try |
169 | // List<InventoryFolderBase> folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject( | 169 | { |
170 | // "POST", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString()); | 170 | folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject( |
171 | // Dictionary<AssetType, InventoryFolderBase> dFolders = new Dictionary<AssetType, InventoryFolderBase>(); | 171 | "POST", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString()); |
172 | // foreach (InventoryFolderBase f in folders) | 172 | |
173 | // dFolders[(AssetType)f.Type] = f; | 173 | foreach (InventoryFolderBase f in folders) |
174 | // return dFolders; | 174 | dFolders[(AssetType)f.Type] = f; |
175 | //} | 175 | |
176 | //catch (Exception e) | 176 | return dFolders; |
177 | //{ | 177 | } |
178 | // m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1}", | 178 | catch (Exception e) |
179 | // e.Source, e.Message); | 179 | { |
180 | //} | 180 | // Maybe we're talking to an old inventory server. Try this other thing. |
181 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1}. Trying RootFolders.", | ||
182 | e.Source, e.Message); | ||
183 | |||
184 | try | ||
185 | { | ||
186 | folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject( | ||
187 | "POST", m_ServerURI + "/RootFolders/", new Guid(userID), sessionID.ToString(), userID.ToString()); | ||
188 | } | ||
189 | catch (Exception ex) | ||
190 | { | ||
191 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: RootFolders operation also failed, {0} {1}. Give up.", | ||
192 | e.Source, ex.Message); | ||
193 | } | ||
194 | |||
195 | if ((folders != null) && (folders.Count > 0)) | ||
196 | { | ||
197 | dFolders[AssetType.Folder] = folders[0]; // Root folder is the first one | ||
198 | folders.RemoveAt(0); | ||
199 | foreach (InventoryFolderBase f in folders) | ||
200 | { | ||
201 | if ((f.Type != (short)AssetType.Folder) && (f.Type != (short)AssetType.Unknown)) | ||
202 | dFolders[(AssetType)f.Type] = f; | ||
203 | } | ||
204 | |||
205 | return dFolders; | ||
206 | } | ||
207 | } | ||
181 | 208 | ||
182 | return new Dictionary<AssetType, InventoryFolderBase>(); | 209 | return new Dictionary<AssetType, InventoryFolderBase>(); |
183 | } | 210 | } |
@@ -192,13 +219,52 @@ namespace OpenSim.Services.Connectors | |||
192 | { | 219 | { |
193 | try | 220 | try |
194 | { | 221 | { |
222 | // normal case | ||
195 | return SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject( | 223 | return SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject( |
196 | "POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString()); | 224 | "POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString()); |
197 | } | 225 | } |
198 | catch (Exception e) | 226 | catch (Exception e) |
199 | { | 227 | { |
200 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}", | 228 | // Maybe we're talking to an old inventory server. Try this other thing. |
229 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}. Trying RootFolders and GetItems.", | ||
201 | e.Source, e.Message); | 230 | e.Source, e.Message); |
231 | |||
232 | List<InventoryFolderBase> folders = null; | ||
233 | try | ||
234 | { | ||
235 | folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject( | ||
236 | "POST", m_ServerURI + "/RootFolders/", new Guid(userID), sessionID.ToString(), userID.ToString()); | ||
237 | } | ||
238 | catch (Exception ex) | ||
239 | { | ||
240 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: RootFolders operation also failed, {0} {1}. Give up.", | ||
241 | e.Source, ex.Message); | ||
242 | } | ||
243 | |||
244 | if ((folders != null) && (folders.Count > 0)) | ||
245 | { | ||
246 | folders = folders.FindAll(delegate (InventoryFolderBase f) { return f.ParentID == folderID ; }); | ||
247 | |||
248 | try | ||
249 | { | ||
250 | List<InventoryItemBase> items = SynchronousRestSessionObjectPoster<Guid, List<InventoryItemBase>>.BeginPostObject( | ||
251 | "POST", m_ServerURI + "/GetItems/", folderID.Guid, sessionID.ToString(), userID.ToString()); | ||
252 | |||
253 | if (items != null) | ||
254 | { | ||
255 | InventoryCollection result = new InventoryCollection(); | ||
256 | result.Folders = folders; | ||
257 | result.Items = items; | ||
258 | result.UserID = new UUID(userID); | ||
259 | return result; | ||
260 | } | ||
261 | } | ||
262 | catch (Exception ex) | ||
263 | { | ||
264 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: QueryFolder and GetItems operation failed, {0} {1}. Give up.", | ||
265 | e.Source, ex.Message); | ||
266 | } | ||
267 | } | ||
202 | } | 268 | } |
203 | 269 | ||
204 | return null; | 270 | return null; |
@@ -348,6 +414,25 @@ namespace OpenSim.Services.Connectors | |||
348 | return null; | 414 | return null; |
349 | } | 415 | } |
350 | 416 | ||
417 | public int GetAssetPermissions(string userID, UUID assetID, UUID sessionID) | ||
418 | { | ||
419 | try | ||
420 | { | ||
421 | InventoryItemBase item = new InventoryItemBase(); | ||
422 | item.Owner = new UUID(userID); | ||
423 | item.AssetID = assetID; | ||
424 | return SynchronousRestSessionObjectPoster<InventoryItemBase, int>.BeginPostObject( | ||
425 | "POST", m_ServerURI + "/AssetPermissions/", item, sessionID.ToString(), userID); | ||
426 | } | ||
427 | catch (Exception e) | ||
428 | { | ||
429 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: AssetPermissions operation failed, {0} {1}", | ||
430 | e.Source, e.Message); | ||
431 | } | ||
432 | |||
433 | return 0; | ||
434 | } | ||
435 | |||
351 | #endregion | 436 | #endregion |
352 | 437 | ||
353 | /// <summary> | 438 | /// <summary> |
diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs index 22289aa..5cbd307 100644 --- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs | |||
@@ -156,12 +156,12 @@ namespace OpenSim.Services.Connectors | |||
156 | return false; | 156 | return false; |
157 | } | 157 | } |
158 | 158 | ||
159 | public InventoryItemBase QueryItem(InventoryItemBase item) | 159 | public InventoryItemBase GetItem(InventoryItemBase item) |
160 | { | 160 | { |
161 | return null; | 161 | return null; |
162 | } | 162 | } |
163 | 163 | ||
164 | public InventoryFolderBase QueryFolder(InventoryFolderBase folder) | 164 | public InventoryFolderBase GetFolder(InventoryFolderBase folder) |
165 | { | 165 | { |
166 | return null; | 166 | return null; |
167 | } | 167 | } |
@@ -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 8058aa7..a89a238 100644 --- a/OpenSim/Services/Interfaces/IInventoryService.cs +++ b/OpenSim/Services/Interfaces/IInventoryService.cs | |||
@@ -149,9 +149,19 @@ 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 | InventoryItemBase QueryItem(InventoryItemBase item); | 152 | /// <summary> |
153 | /// Get an item, given by its UUID | ||
154 | /// </summary> | ||
155 | /// <param name="item"></param> | ||
156 | /// <returns></returns> | ||
157 | InventoryItemBase GetItem(InventoryItemBase item); | ||
153 | 158 | ||
154 | InventoryFolderBase QueryFolder(InventoryFolderBase folder); | 159 | /// <summary> |
160 | /// Get a folder, given by its UUID | ||
161 | /// </summary> | ||
162 | /// <param name="folder"></param> | ||
163 | /// <returns></returns> | ||
164 | InventoryFolderBase GetFolder(InventoryFolderBase folder); | ||
155 | 165 | ||
156 | /// <summary> | 166 | /// <summary> |
157 | /// Does the given user have an inventory structure? | 167 | /// Does the given user have an inventory structure? |
@@ -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 a9ecda4..65c2d96 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs | |||
@@ -398,7 +398,7 @@ namespace OpenSim.Services.InventoryService | |||
398 | return true; | 398 | return true; |
399 | } | 399 | } |
400 | 400 | ||
401 | public virtual InventoryItemBase QueryItem(InventoryItemBase item) | 401 | public virtual InventoryItemBase GetItem(InventoryItemBase item) |
402 | { | 402 | { |
403 | InventoryItemBase result = m_Database.queryInventoryItem(item.ID); | 403 | InventoryItemBase result = m_Database.queryInventoryItem(item.ID); |
404 | if (result != null) | 404 | if (result != null) |
@@ -407,7 +407,7 @@ namespace OpenSim.Services.InventoryService | |||
407 | return null; | 407 | return null; |
408 | } | 408 | } |
409 | 409 | ||
410 | public virtual InventoryFolderBase QueryFolder(InventoryFolderBase item) | 410 | public virtual InventoryFolderBase GetFolder(InventoryFolderBase item) |
411 | { | 411 | { |
412 | InventoryFolderBase result = m_Database.queryInventoryFolder(item.ID); | 412 | InventoryFolderBase result = m_Database.queryInventoryFolder(item.ID); |
413 | if (result != null) | 413 | if (result != null) |
@@ -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> |