private static void DeleteSubFolder(Request req, UUID id, AISv3ResultData resultData) { var folders = new List <UUID>(); int index = 0; InventoryFolderContent content; while (index++ < folders.Count) { if (req.InventoryService.Folder.Content.TryGetValue(req.Agent.ID, id, out content)) { foreach (InventoryItem item in content.Items) { DeleteItem(req, item, resultData); } folders.Add(id); resultData.AddRemovedCategory(id); } } try { req.InventoryService.Folder.Delete(req.Agent.ID, id); } catch (InventoryFolderNotFoundException) { /* ignored */ } }
private static void FolderFolders_DeleteHandler(Request req, string[] elements) { InventoryFolder folder; var folderCache = new Dictionary <UUID, InventoryFolder>(); try { if (!TryFindFolder(req, elements[1], out folder, folderCache)) { ErrorResponse(req, HttpStatusCode.NotFound, AisErrorCode.NotFound, "Not Found"); return; } } catch (HttpResponse.ConnectionCloseException) { /* we need to pass it */ throw; } catch (Exception e) { m_Log.Debug("Exception occured", e); ErrorResponse(req, HttpStatusCode.InternalServerError, AisErrorCode.InternalError, "Internal Server Error"); return; } List <InventoryFolder> folders = req.InventoryService.Folder.GetFolders(req.Agent.ID, folder.ID); var result = new AISv3ResultData(); foreach (InventoryFolder subfolder in folders) { DeleteFolder(req, subfolder.ID, result); } SuccessResponse(req, result); }
private static void DeleteFolder(Request req, UUID id, AISv3ResultData resultData) { InventoryFolderContent content; InventoryFolder folderData; if (!req.InventoryService.Folder.TryGetValue(req.Agent.ID, id, out folderData) || !req.InventoryService.Folder.Content.TryGetValue(req.Agent.ID, id, out content)) { return; } foreach (InventoryFolder folder in content.Folders) { DeleteSubFolder(req, folder.ID, resultData); } foreach (InventoryItem item in content.Items) { DeleteItem(req, item, resultData); } try { req.InventoryService.Folder.Delete(req.Agent.ID, id); } catch (InventoryFolderNotFoundException) { /* intentionally ignored */ } if (req.InventoryService.Folder.TryGetValue(req.Agent.ID, folderData.ParentFolderID, out folderData)) { resultData.AddUpdatedCategory(folderData); } }
private static void DeleteItem(Request req, InventoryItem item, AISv3ResultData resultData) { try { req.InventoryService.Item.Delete(req.Agent.ID, item.ID); resultData.AddRemovedItem(item); } catch (InventoryItemNotFoundException) { /* ignored */ } }
private static void ItemHandler_Delete(Request req, string[] elements) { UUID itemid; if (!UUID.TryParse(elements[1], out itemid)) { ErrorResponse(req, HttpStatusCode.BadRequest, AisErrorCode.InvalidRequest, "Bad request"); return; } InventoryItem item; try { item = req.InventoryService.Item[req.Agent.ID, itemid]; } catch (KeyNotFoundException) { ErrorResponse(req, HttpStatusCode.Gone, AisErrorCode.Gone, "Gone"); return; } catch (HttpResponse.ConnectionCloseException) { /* we need to pass it */ throw; } catch (Exception e) { m_Log.Debug("Exception occured", e); ErrorResponse(req, HttpStatusCode.InternalServerError, AisErrorCode.InternalError, "Internal Server Error"); return; } var data = new AISv3ResultData(); try { DeleteItem(req, item, data); } catch (Exception e) { m_Log.Debug("Exception occured", e); ErrorResponse(req, HttpStatusCode.InternalServerError, AisErrorCode.InternalError, "Internal Server Error"); return; } SuccessResponse(req, data); }
private static void PurgeFolder(Request req, UUID id, AISv3ResultData resultData) { InventoryFolderContent content; if (!req.InventoryService.Folder.Content.TryGetValue(req.Agent.ID, id, out content)) { return; } foreach (InventoryFolder folder in content.Folders) { DeleteSubFolder(req, folder.ID, resultData); } foreach (InventoryItem item in content.Items) { DeleteItem(req, item, resultData); } InventoryFolder folderData; if (req.InventoryService.Folder.TryGetValue(req.Agent.ID, id, out folderData)) { resultData.AddUpdatedCategory(folderData); } }
private static void FolderHandler_Delete(Request req, string[] elements) { InventoryFolder folder; var folderCache = new Dictionary <UUID, InventoryFolder>(); try { if (!TryFindFolder(req, elements[1], out folder, folderCache)) { ErrorResponse(req, HttpStatusCode.NotFound, AisErrorCode.NotFound, "Not Found"); return; } } catch (HttpResponse.ConnectionCloseException) { /* we need to pass it */ throw; } catch (Exception e) { m_Log.Debug("Exception occured", e); ErrorResponse(req, HttpStatusCode.InternalServerError, AisErrorCode.InternalError, "Internal Server Error"); return; } if (!req.InventoryService.Folder.ContainsKey(req.Agent.ID, folder.ID)) { ErrorResponse(req, HttpStatusCode.Gone, AisErrorCode.Gone, "Category gone"); return; } var result = new AISv3ResultData(); DeleteFolder(req, folder.ID, result); SuccessResponse(req, result); }