コード例 #1
0
  private String deleteBucket()
      throws SignatureException, SSLSetupException, CommandException, IOException {
    try {
      getClient().deleteBucket(new DeleteBucketRequest(bucketName));
    } catch (final FailedRequestException e) {
      if (e.getStatusCode() == 409) { // BUCKET_NOT_EMPTY
        throw new CommandException(
            "Error: Tried to delete a non-empty bucket without the force delete objects flag.\nUse --force to delete all objects in the bucket");
      }
      throw new CommandException(
          "Error: Request failed with the following error: " + e.getMessage(), e);
    }

    return "Success: Deleted bucket '" + bucketName + "'.";
  }