예제 #1
0
  private String clearObjects() throws SignatureException, SSLSetupException, CommandException {
    // TODO when the multi object delete command has been added to DS3
    // Get the list of objects from the bucket
    LOG.debug("Deleting objects in bucket first");
    final Ds3Client client = getClient();
    final Ds3ClientHelpers helper = Ds3ClientHelpers.wrap(client);

    try {
      final Iterable<Contents> fileList = helper.listObjects(bucketName);
      client.deleteObjects(new DeleteObjectsRequest(bucketName, fileList));

      LOG.debug("Deleting bucket");
      getClient().deleteBucket(new DeleteBucketRequest(bucketName));

    } catch (final IOException e) {
      throw new CommandException(
          "Error: Request failed with the following error: " + e.getMessage(), e);
    }

    return "Success: Deleted " + bucketName + " and all the objects contained in it.";
  }