void deleteFile(String fileUrl) throws IOException { log.info(format("Adding file %s", fileUrl)); Delete request = new Delete(fileUrl, credentials); String result = request.executeAsString(); if (request.isUnAuthorized()) throw new UnAuthorizedException("Not authorized to delete file", fileUrl); if (request.isForbidden()) throw new ForbiddenException("Forbidden to delete file", fileUrl); if (request.isNotFound()) throw new NotFoundException("File not found", fileUrl); if (request.isBadRequest()) throw new NotOwnerException("Not owner of file to delete", fileUrl); if (!request.isSuccessful()) throw new IOException("DELETE on " + fileUrl + " not successful: " + result); } }
void deleteCategory(String categoryUrl) throws IOException { log.info(format("Deleting category %s", categoryUrl)); Delete request = new Delete(categoryUrl, credentials); request.setAccept(APPLICATION_JSON); String result = request.executeAsString(); if (request.isUnAuthorized()) throw new UnAuthorizedException("Not authorized to delete category", categoryUrl); if (request.isForbidden()) throw new ForbiddenException("Forbidden to delete category", categoryUrl); if (request.isNotFound()) throw new NotFoundException("Category not found", categoryUrl); if (request.isBadRequest()) throw new NotOwnerException("Not owner of category to delete", categoryUrl); if (!request.isSuccessful()) throw new IOException("DELETE on " + categoryUrl + " not successful: " + result); }
void deleteRoute(String routeUrl) throws IOException { log.info(format("Deleting route %s", routeUrl)); Delete request = new Delete(routeUrl, credentials); request.setAccept(APPLICATION_JSON); String result = request.executeAsString(); if (request.isUnAuthorized()) throw new UnAuthorizedException("Not authorized to delete route", routeUrl); if (request.isForbidden()) throw new ForbiddenException("Forbidden to delete route", routeUrl); if (request.isNotFound()) throw new NotFoundException("Route not found", routeUrl); if (request.isBadRequest()) throw new NotOwnerException("Not owner of route to delete", routeUrl); if (!request.isSuccessful()) throw new IOException("DELETE on " + routeUrl + " not successful: " + result); }