private void deleteKeyVersions(AmazonS3Client s3Client,String s3BucketName,List<DeleteObjectsRequest.KeyVersion> keyVersions){
  DeleteObjectsRequest multiObjectDeleteRequest=new DeleteObjectsRequest(s3BucketName);
  for (int i=0; i < keyVersions.size() / MAX_KEYS_PER_DELETE_REQUEST + 1; i++) {
    List<DeleteObjectsRequest.KeyVersion> keysSubList=keyVersions.subList(i * MAX_KEYS_PER_DELETE_REQUEST,Math.min(keyVersions.size(),(i + 1) * MAX_KEYS_PER_DELETE_REQUEST));
    multiObjectDeleteRequest.setKeys(keysSubList);
    try {
      s3Operations.deleteObjects(multiObjectDeleteRequest,s3Client);
    }
 catch (    MultiObjectDeleteException multiObjectDeleteException) {
      logMultiObjectDeleteException(multiObjectDeleteException);
      throw multiObjectDeleteException;
    }
    LOGGER.info("Successfully requested the deletion of the listed below keys/key versions from the S3 bucket. s3KeyCount={} s3BucketName=\"{}\"",keysSubList.size(),s3BucketName);
    for (    DeleteObjectsRequest.KeyVersion keyVersion : keysSubList) {
      LOGGER.info("s3Key=\"{}\" s3VersionId=\"{}\"",keyVersion.getKey(),keyVersion.getVersion());
    }
  }
}

private void deleteKeyVersions ( AmazonS3Client s3Client , String s3BucketName , List < DeleteObjectsRequest . KeyVersion > keyVersions ) { DeleteObjectsRequest multiObjectDeleteRequest = new DeleteObjectsRequest ( s3BucketName ) ; for ( int i = 0 ; i < keyVersions . size ( ) / MAX_KEYS_PER_DELETE_REQUEST + 1 ; i ++ ) { List < DeleteObjectsRequest . KeyVersion > keysSubList = keyVersions . subList ( i * MAX_KEYS_PER_DELETE_REQUEST , Math . min ( keyVersions . size ( ) , ( i + 1 ) * MAX_KEYS_PER_DELETE_REQUEST ) ) ; multiObjectDeleteRequest . setKeys ( keysSubList ) ; try { s3Operations . deleteObjects ( multiObjectDeleteRequest , s3Client ) ; } catch ( MultiObjectDeleteException multiObjectDeleteException ) { logMultiObjectDeleteException ( multiObjectDeleteException ) ; throw multiObjectDeleteException ; } LOGGER . info ( "Successfully requested the deletion of the listed below keys/key versions from the S3 bucket. s3KeyCount={} s3BucketName=\"{}\"" , keysSubList . size ( ) , s3BucketName ) ; for ( DeleteObjectsRequest . KeyVersion keyVersion : keysSubList ) { LOGGER . info ( "s3Key=\"{}\" s3VersionId=\"{}\"" , keyVersion . getKey ( ) , keyVersion . getVersion ( ) ) ; } } }
deletes a list of keys / key versions from the specified s3 bucket .
