diff options
author | Teravus Ovares (Dan Olivares) | 2009-08-19 14:43:18 -0400 |
---|---|---|
committer | Teravus Ovares (Dan Olivares) | 2009-08-19 14:43:18 -0400 |
commit | 289439c8329d992251769aa83e3d7809f651de26 (patch) | |
tree | 8a1e596190f197fa5f70f21a8c968d2c55004cde /OpenSim/Services | |
parent | Add Border (a virtual border management class) (diff) | |
parent | Added MoveItems, which is most useful upon viewer-delete inventory operation.... (diff) | |
download | opensim-SC-289439c8329d992251769aa83e3d7809f651de26.zip opensim-SC-289439c8329d992251769aa83e3d7809f651de26.tar.gz opensim-SC-289439c8329d992251769aa83e3d7809f651de26.tar.bz2 opensim-SC-289439c8329d992251769aa83e3d7809f651de26.tar.xz |
Merge branch 'master' of ssh://MyConnection/var/git/opensim
Diffstat (limited to 'OpenSim/Services')
6 files changed, 139 insertions, 12 deletions
diff --git a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs index 94b4ad9..45e921a 100644 --- a/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/HGInventoryServiceConnector.cs | |||
@@ -214,6 +214,19 @@ namespace OpenSim.Services.Connectors.Inventory | |||
214 | return false; | 214 | return false; |
215 | } | 215 | } |
216 | 216 | ||
217 | public List<InventoryItemBase> GetFolderItems(string id, UUID folderID, UUID sessionID) | ||
218 | { | ||
219 | string url = string.Empty; | ||
220 | string userID = string.Empty; | ||
221 | |||
222 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
223 | { | ||
224 | ISessionAuthInventoryService connector = GetConnector(url); | ||
225 | return connector.GetFolderItems(userID, folderID, sessionID); | ||
226 | } | ||
227 | return new List<InventoryItemBase>(); | ||
228 | } | ||
229 | |||
217 | public bool AddItem(string id, InventoryItemBase item, UUID sessionID) | 230 | public bool AddItem(string id, InventoryItemBase item, UUID sessionID) |
218 | { | 231 | { |
219 | string url = string.Empty; | 232 | string url = string.Empty; |
@@ -240,7 +253,7 @@ namespace OpenSim.Services.Connectors.Inventory | |||
240 | return false; | 253 | return false; |
241 | } | 254 | } |
242 | 255 | ||
243 | public bool DeleteItem(string id, InventoryItemBase item, UUID sessionID) | 256 | public bool MoveItems(string id, List<InventoryItemBase> items, UUID sessionID) |
244 | { | 257 | { |
245 | string url = string.Empty; | 258 | string url = string.Empty; |
246 | string userID = string.Empty; | 259 | string userID = string.Empty; |
@@ -248,7 +261,20 @@ namespace OpenSim.Services.Connectors.Inventory | |||
248 | if (StringToUrlAndUserID(id, out url, out userID)) | 261 | if (StringToUrlAndUserID(id, out url, out userID)) |
249 | { | 262 | { |
250 | ISessionAuthInventoryService connector = GetConnector(url); | 263 | ISessionAuthInventoryService connector = GetConnector(url); |
251 | return connector.UpdateItem(userID, item, sessionID); | 264 | return connector.MoveItems(userID, items, sessionID); |
265 | } | ||
266 | return false; | ||
267 | } | ||
268 | |||
269 | public bool DeleteItems(string id, List<UUID> itemIDs, UUID sessionID) | ||
270 | { | ||
271 | string url = string.Empty; | ||
272 | string userID = string.Empty; | ||
273 | |||
274 | if (StringToUrlAndUserID(id, out url, out userID)) | ||
275 | { | ||
276 | ISessionAuthInventoryService connector = GetConnector(url); | ||
277 | return connector.DeleteItems(userID, itemIDs, sessionID); | ||
252 | } | 278 | } |
253 | return false; | 279 | return false; |
254 | } | 280 | } |
diff --git a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs index f50bcf5..c89c9b7 100644 --- a/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs +++ b/OpenSim/Services/Connectors/Inventory/ISessionAuthInventoryService.cs | |||
@@ -96,6 +96,13 @@ namespace OpenSim.Services.Connectors | |||
96 | bool PurgeFolder(string userID, InventoryFolderBase folder, UUID session_id); | 96 | bool PurgeFolder(string userID, InventoryFolderBase folder, UUID session_id); |
97 | 97 | ||
98 | /// <summary> | 98 | /// <summary> |
99 | /// Get items from a folder. | ||
100 | /// </summary> | ||
101 | /// <param name="folder"></param> | ||
102 | /// <returns>true if the folder was successfully purged</returns> | ||
103 | List<InventoryItemBase> GetFolderItems(string userID, UUID folderID, UUID session_id); | ||
104 | |||
105 | /// <summary> | ||
99 | /// Add a new item to the user's inventory | 106 | /// Add a new item to the user's inventory |
100 | /// </summary> | 107 | /// </summary> |
101 | /// <param name="item"></param> | 108 | /// <param name="item"></param> |
@@ -109,12 +116,14 @@ namespace OpenSim.Services.Connectors | |||
109 | /// <returns>true if the item was successfully updated</returns> | 116 | /// <returns>true if the item was successfully updated</returns> |
110 | bool UpdateItem(string userID, InventoryItemBase item, UUID session_id); | 117 | bool UpdateItem(string userID, InventoryItemBase item, UUID session_id); |
111 | 118 | ||
119 | bool MoveItems(string userID, List<InventoryItemBase> items, UUID session_id); | ||
120 | |||
112 | /// <summary> | 121 | /// <summary> |
113 | /// Delete an item from the user's inventory | 122 | /// Delete an item from the user's inventory |
114 | /// </summary> | 123 | /// </summary> |
115 | /// <param name="item"></param> | 124 | /// <param name="item"></param> |
116 | /// <returns>true if the item was successfully deleted</returns> | 125 | /// <returns>true if the item was successfully deleted</returns> |
117 | bool DeleteItem(string userID, InventoryItemBase item, UUID session_id); | 126 | bool DeleteItems(string userID, List<UUID> itemIDs, UUID session_id); |
118 | 127 | ||
119 | InventoryItemBase QueryItem(string userID, InventoryItemBase item, UUID session_id); | 128 | InventoryItemBase QueryItem(string userID, InventoryItemBase item, UUID session_id); |
120 | 129 | ||
diff --git a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs index 5d94eac..bcf9d87 100644 --- a/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/InventoryServiceConnector.cs | |||
@@ -334,6 +334,23 @@ namespace OpenSim.Services.Connectors | |||
334 | return false; | 334 | return false; |
335 | } | 335 | } |
336 | 336 | ||
337 | public List<InventoryItemBase> GetFolderItems(string userID, UUID folderID, UUID sessionID) | ||
338 | { | ||
339 | try | ||
340 | { | ||
341 | InventoryFolderBase folder = new InventoryFolderBase(folderID, new UUID(userID)); | ||
342 | return SynchronousRestSessionObjectPoster<InventoryFolderBase, List<InventoryItemBase>>.BeginPostObject( | ||
343 | "POST", m_ServerURI + "/GetItems/", folder, sessionID.ToString(), userID); | ||
344 | } | ||
345 | catch (Exception e) | ||
346 | { | ||
347 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: Get folder items operation failed, {0} {1}", | ||
348 | e.Source, e.Message); | ||
349 | } | ||
350 | |||
351 | return null; | ||
352 | } | ||
353 | |||
337 | public bool AddItem(string userID, InventoryItemBase item, UUID sessionID) | 354 | public bool AddItem(string userID, InventoryItemBase item, UUID sessionID) |
338 | { | 355 | { |
339 | try | 356 | try |
@@ -366,12 +383,57 @@ namespace OpenSim.Services.Connectors | |||
366 | return false; | 383 | return false; |
367 | } | 384 | } |
368 | 385 | ||
369 | public bool DeleteItem(string userID, InventoryItemBase item, UUID sessionID) | 386 | /** |
387 | * MoveItems Async group | ||
388 | */ | ||
389 | |||
390 | delegate void MoveItemsDelegate(string userID, List<InventoryItemBase> items, UUID sessionID); | ||
391 | |||
392 | private void MoveItemsAsync(string userID, List<InventoryItemBase> items, UUID sessionID) | ||
370 | { | 393 | { |
371 | try | 394 | try |
372 | { | 395 | { |
373 | return SynchronousRestSessionObjectPoster<InventoryItemBase, bool>.BeginPostObject( | 396 | SynchronousRestSessionObjectPoster<List<InventoryItemBase>, bool>.BeginPostObject( |
374 | "POST", m_ServerURI + "/DeleteItem/", item, sessionID.ToString(), item.Owner.ToString()); | 397 | "POST", m_ServerURI + "/MoveItems/", items, sessionID.ToString(), userID.ToString()); |
398 | |||
399 | // Success | ||
400 | return; | ||
401 | } | ||
402 | catch (Exception e) | ||
403 | { | ||
404 | m_log.ErrorFormat("[INVENTORY CONNECTOR]: Move inventory items operation failed, {0} {1} (old server?). Trying slow way.", | ||
405 | e.Source, e.Message); | ||
406 | } | ||
407 | |||
408 | foreach (InventoryItemBase item in items) | ||
409 | { | ||
410 | InventoryItemBase itm = this.QueryItem(userID, item, sessionID); | ||
411 | itm.Name = item.Name; | ||
412 | itm.Folder = item.Folder; | ||
413 | this.UpdateItem(userID, itm, sessionID); | ||
414 | } | ||
415 | } | ||
416 | |||
417 | private void MoveItemsCompleted(IAsyncResult iar) | ||
418 | { | ||
419 | } | ||
420 | |||
421 | public bool MoveItems(string userID, List<InventoryItemBase> items, UUID sessionID) | ||
422 | { | ||
423 | MoveItemsDelegate d = MoveItemsAsync; | ||
424 | d.BeginInvoke(userID, items, sessionID, MoveItemsCompleted, d); | ||
425 | return true; | ||
426 | } | ||
427 | |||
428 | public bool DeleteItems(string userID, List<UUID> items, UUID sessionID) | ||
429 | { | ||
430 | try | ||
431 | { | ||
432 | List<Guid> guids = new List<Guid>(); | ||
433 | foreach (UUID u in items) | ||
434 | guids.Add(u.Guid); | ||
435 | return SynchronousRestSessionObjectPoster<List<Guid>, bool>.BeginPostObject( | ||
436 | "POST", m_ServerURI + "/DeleteItem/", guids, sessionID.ToString(), userID); | ||
375 | } | 437 | } |
376 | catch (Exception e) | 438 | catch (Exception e) |
377 | { | 439 | { |
diff --git a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs index 5cbd307..cd283ff 100644 --- a/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/QuickAndDirtyInventoryServiceConnector.cs | |||
@@ -151,7 +151,12 @@ namespace OpenSim.Services.Connectors | |||
151 | return false; | 151 | return false; |
152 | } | 152 | } |
153 | 153 | ||
154 | public bool DeleteItem(InventoryItemBase item) | 154 | public bool MoveItems(UUID ownerID, List<InventoryItemBase> items) |
155 | { | ||
156 | return false; | ||
157 | } | ||
158 | |||
159 | public bool DeleteItems(UUID owner, List<UUID> itemIDs) | ||
155 | { | 160 | { |
156 | return false; | 161 | return false; |
157 | } | 162 | } |
diff --git a/OpenSim/Services/Interfaces/IInventoryService.cs b/OpenSim/Services/Interfaces/IInventoryService.cs index a89a238..ebdb09a 100644 --- a/OpenSim/Services/Interfaces/IInventoryService.cs +++ b/OpenSim/Services/Interfaces/IInventoryService.cs | |||
@@ -142,12 +142,15 @@ namespace OpenSim.Services.Interfaces | |||
142 | /// <returns>true if the item was successfully updated</returns> | 142 | /// <returns>true if the item was successfully updated</returns> |
143 | bool UpdateItem(InventoryItemBase item); | 143 | bool UpdateItem(InventoryItemBase item); |
144 | 144 | ||
145 | bool MoveItems(UUID ownerID, List<InventoryItemBase> items); | ||
146 | |||
145 | /// <summary> | 147 | /// <summary> |
146 | /// Delete an item from the user's inventory | 148 | /// Delete an item from the user's inventory |
147 | /// </summary> | 149 | /// </summary> |
148 | /// <param name="item"></param> | 150 | /// <param name="item"></param> |
149 | /// <returns>true if the item was successfully deleted</returns> | 151 | /// <returns>true if the item was successfully deleted</returns> |
150 | bool DeleteItem(InventoryItemBase item); | 152 | //bool DeleteItem(InventoryItemBase item); |
153 | bool DeleteItems(UUID userID, List<UUID> itemIDs); | ||
151 | 154 | ||
152 | /// <summary> | 155 | /// <summary> |
153 | /// Get an item, given by its UUID | 156 | /// Get an item, given by its UUID |
diff --git a/OpenSim/Services/InventoryService/InventoryService.cs b/OpenSim/Services/InventoryService/InventoryService.cs index 65c2d96..e0217f6 100644 --- a/OpenSim/Services/InventoryService/InventoryService.cs +++ b/OpenSim/Services/InventoryService/InventoryService.cs | |||
@@ -386,13 +386,33 @@ namespace OpenSim.Services.InventoryService | |||
386 | return true; | 386 | return true; |
387 | } | 387 | } |
388 | 388 | ||
389 | public virtual bool MoveItems(UUID ownerID, List<InventoryItemBase> items) | ||
390 | { | ||
391 | m_log.InfoFormat( | ||
392 | "[INVENTORY SERVICE]: Moving {0} items from user {1}", items.Count, ownerID); | ||
393 | |||
394 | InventoryItemBase itm = null; | ||
395 | foreach (InventoryItemBase item in items) | ||
396 | { | ||
397 | itm = GetInventoryItem(item.ID); | ||
398 | itm.Folder = item.Folder; | ||
399 | if ((item.Name != null) && !item.Name.Equals(string.Empty)) | ||
400 | itm.Name = item.Name; | ||
401 | m_Database.updateInventoryItem(itm); | ||
402 | } | ||
403 | |||
404 | return true; | ||
405 | } | ||
406 | |||
389 | // See IInventoryServices | 407 | // See IInventoryServices |
390 | public virtual bool DeleteItem(InventoryItemBase item) | 408 | public virtual bool DeleteItems(UUID owner, List<UUID> itemIDs) |
391 | { | 409 | { |
392 | m_log.InfoFormat( | 410 | m_log.InfoFormat( |
393 | "[INVENTORY SERVICE]: Deleting item {0} {1} from folder {2}", item.Name, item.ID, item.Folder); | 411 | "[INVENTORY SERVICE]: Deleting {0} items from user {1}", itemIDs.Count, owner); |
394 | 412 | ||
395 | m_Database.deleteInventoryItem(item.ID); | 413 | // uhh..... |
414 | foreach (UUID uuid in itemIDs) | ||
415 | m_Database.deleteInventoryItem(uuid); | ||
396 | 416 | ||
397 | // FIXME: Should return false on failure | 417 | // FIXME: Should return false on failure |
398 | return true; | 418 | return true; |
@@ -439,10 +459,12 @@ namespace OpenSim.Services.InventoryService | |||
439 | 459 | ||
440 | List<InventoryItemBase> items = GetFolderItems(folder.Owner, folder.ID); | 460 | List<InventoryItemBase> items = GetFolderItems(folder.Owner, folder.ID); |
441 | 461 | ||
462 | List<UUID> uuids = new List<UUID>(); | ||
442 | foreach (InventoryItemBase item in items) | 463 | foreach (InventoryItemBase item in items) |
443 | { | 464 | { |
444 | DeleteItem(item); | 465 | uuids.Add(item.ID); |
445 | } | 466 | } |
467 | DeleteItems(folder.Owner, uuids); | ||
446 | 468 | ||
447 | // FIXME: Should return false on failure | 469 | // FIXME: Should return false on failure |
448 | return true; | 470 | return true; |