org.jclouds.blobstore.BlobStore.deleteContainerIfEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.4k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中org.jclouds.blobstore.BlobStore.deleteContainerIfEmpty()方法的一些代码示例,展示了BlobStore.deleteContainerIfEmpty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlobStore.deleteContainerIfEmpty()方法的具体详情如下:
包路径:org.jclouds.blobstore.BlobStore
类名称:BlobStore
方法名:deleteContainerIfEmpty

BlobStore.deleteContainerIfEmpty介绍

[英]Deletes a container if it is empty.
[中]如果容器为空,则删除该容器。

代码示例

代码示例来源:origin: gaul/s3proxy

@Override
public boolean deleteContainerIfEmpty(String container) {
  return delegate().deleteContainerIfEmpty(container) &&
      writeStore.deleteContainerIfEmpty(container);
}

代码示例来源:origin: gaul/s3proxy

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);
}

代码示例来源:origin: Nextdoor/bender

@Override
public boolean deleteContainerIfEmpty(String container) {
  return delegate().deleteContainerIfEmpty(container) &&
      writeStore.deleteContainerIfEmpty(container);
}

代码示例来源:origin: org.gaul/s3proxy

@Override
public boolean deleteContainerIfEmpty(String container) {
  return delegate().deleteContainerIfEmpty(container) &&
      writeStore.deleteContainerIfEmpty(container);
}

代码示例来源:origin: Nextdoor/bender

@Override
public boolean deleteContainerIfEmpty(String container) {
 return delegate().deleteContainerIfEmpty(container);
}

代码示例来源:origin: org.apache.jclouds/jclouds-blobstore

@Override
public boolean deleteContainerIfEmpty(String container) {
 return delegate().deleteContainerIfEmpty(container);
}

代码示例来源:origin: com.amysta.jclouds/jclouds-blobstore

@Override
public boolean deleteContainerIfEmpty(String container) {
 return delegate().deleteContainerIfEmpty(container);
}

代码示例来源:origin: apache/jclouds

@Override
public boolean deleteContainerIfEmpty(String container) {
 return delegate().deleteContainerIfEmpty(container);
}

代码示例来源:origin: bouncestorage/swiftproxy

@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();
  }
}

代码示例来源:origin: org.gaul/s3proxy

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);
}

代码示例来源:origin: Nextdoor/bender

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);
}

代码示例来源:origin: apache/jclouds

@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);
 }
}

代码示例来源:origin: apache/jclouds

@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);
 }
}

相关文章