@Override public boolean deleteContainerIfEmpty(String container) { return delegate().deleteContainerIfEmpty(container) && writeStore.deleteContainerIfEmpty(container); }
private static void handleContainerDelete(HttpServletResponse response, BlobStore blobStore, String containerName) throws IOException, S3Exception { if (!blobStore.containerExists(containerName)) { throw new S3Exception(S3ErrorCode.NO_SUCH_BUCKET); } String blobStoreType = getBlobStoreType(blobStore); if (blobStoreType.equals("b2")) { // S3 allows deleting a container with in-progress MPU while B2 does // not. Explicitly cancel uploads for B2. for (MultipartUpload mpu : blobStore.listMultipartUploads( containerName)) { blobStore.abortMultipartUpload(mpu); } } if (!blobStore.deleteContainerIfEmpty(containerName)) { throw new S3Exception(S3ErrorCode.BUCKET_NOT_EMPTY); } response.setStatus(HttpServletResponse.SC_NO_CONTENT); }
@Override public boolean deleteContainerIfEmpty(String container) { return delegate().deleteContainerIfEmpty(container) && writeStore.deleteContainerIfEmpty(container); }
@Override public boolean deleteContainerIfEmpty(String container) { return delegate().deleteContainerIfEmpty(container) && writeStore.deleteContainerIfEmpty(container); }
@Override public boolean deleteContainerIfEmpty(String container) { return delegate().deleteContainerIfEmpty(container); }
@Override public boolean deleteContainerIfEmpty(String container) { return delegate().deleteContainerIfEmpty(container); }
@Override public boolean deleteContainerIfEmpty(String container) { return delegate().deleteContainerIfEmpty(container); }
@Override public boolean deleteContainerIfEmpty(String container) { return delegate().deleteContainerIfEmpty(container); }
@DELETE public Response deleteContainer(@NotNull @PathParam("container") String container, @HeaderParam("X-Auth-Token") String authToken) { BlobStore store = getBlobStore(authToken).get(container); if (!store.containerExists(container)) { return Response.status(Response.Status.NOT_FOUND).build(); } if (store.deleteContainerIfEmpty(container)) { return Response.noContent().build(); } else { return Response.status(Response.Status.CONFLICT) .entity("<html><h1>Conflict</h1><p>There was a conflict when trying to complete your request.</p></html>") .build(); } }
private static void handleContainerDelete(HttpServletResponse response, BlobStore blobStore, String containerName) throws IOException, S3Exception { if (!blobStore.containerExists(containerName)) { throw new S3Exception(S3ErrorCode.NO_SUCH_BUCKET); } String blobStoreType = getBlobStoreType(blobStore); if (blobStoreType.equals("b2")) { // S3 allows deleting a container with in-progress MPU while B2 does // not. Explicitly cancel uploads for B2. for (MultipartUpload mpu : blobStore.listMultipartUploads( containerName)) { blobStore.abortMultipartUpload(mpu); } } if (!blobStore.deleteContainerIfEmpty(containerName)) { throw new S3Exception(S3ErrorCode.BUCKET_NOT_EMPTY); } response.setStatus(HttpServletResponse.SC_NO_CONTENT); }
private static void handleContainerDelete(HttpServletResponse response, BlobStore blobStore, String containerName) throws IOException, S3Exception { if (!blobStore.containerExists(containerName)) { throw new S3Exception(S3ErrorCode.NO_SUCH_BUCKET); } String blobStoreType = getBlobStoreType(blobStore); if (blobStoreType.equals("b2")) { // S3 allows deleting a container with in-progress MPU while B2 does // not. Explicitly cancel uploads for B2. for (MultipartUpload mpu : blobStore.listMultipartUploads( containerName)) { blobStore.abortMultipartUpload(mpu); } } if (!blobStore.deleteContainerIfEmpty(containerName)) { throw new S3Exception(S3ErrorCode.BUCKET_NOT_EMPTY); } response.setStatus(HttpServletResponse.SC_NO_CONTENT); }
@Test(groups = { "integration", "live" }) public void deleteContainerIfEmptyWithoutContents() throws InterruptedException { final String containerName = getContainerName(); try { assertTrue(view.getBlobStore().deleteContainerIfEmpty(containerName)); awaitConsistency(); assertNotExists(containerName); // verify that true is returned even if the container does not exist assertTrue(view.getBlobStore().deleteContainerIfEmpty(containerName)); } finally { // this container is now deleted, so we can't reuse it directly recycleContainerAndAddToPool(containerName); } }
@Test(groups = { "integration", "live" }) public void deleteContainerIfEmptyWithContents() throws InterruptedException { String containerName = getContainerName(); try { addBlobToContainer(containerName, "test"); awaitConsistency(); assertFalse(view.getBlobStore().deleteContainerIfEmpty(containerName)); awaitConsistency(); assertTrue(view.getBlobStore().containerExists(containerName)); } finally { recycleContainerAndAddToPool(containerName); } }