void deleteUser(String userUrl) throws IOException { log.info("Deleting user " + userUrl); Delete request = new Delete(userUrl, credentials); request.setAccept(APPLICATION_JSON); String result = request.executeAsString(); if (request.isBadRequest()) throw new ForbiddenException("Not authorized to delete user", userUrl); if (!request.isSuccessful()) throw new IOException("DELETE on " + userUrl + " 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); }
private String removeUris(DataSource dataSource, Set<String> uris) throws IOException { String xml = toXml(dataSource, uris, type); log.info(format("Removing URIs:%n%s", xml)); String dataSourcesUrl = getDataSourcesUrl(); Delete request = new Delete(dataSourcesUrl, getCredentials()); request.addFile("file", xml.getBytes(StandardCharsets.UTF_8)); request.setAccept(APPLICATION_JSON); String result = null; try { result = request.executeAsString(); log.info(format("Removed URIs with result:%n%s", result)); removeCount += uris.size(); } catch(Exception e) { log.severe(format("Cannot remove URIs: %s", e)); } return 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); }
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); } }