Example usage for com.amazonaws.services.s3 AmazonS3 getBucketVersioningConfiguration

List of usage examples for com.amazonaws.services.s3 AmazonS3 getBucketVersioningConfiguration

Introduction

In this page you can find the example usage for com.amazonaws.services.s3 AmazonS3 getBucketVersioningConfiguration.

Prototype

public BucketVersioningConfiguration getBucketVersioningConfiguration(
        GetBucketVersioningConfigurationRequest getBucketVersioningConfigurationRequest)
        throws SdkClientException, AmazonServiceException;

Source Link

Document

Returns the versioning configuration for the specified bucket.

Usage

From source file:cloudExplorer.BucketClass.java

License:Open Source License

Boolean VersioningStatus(String access_key, String secret_key, String bucket, String endpoint, String region,
        Boolean enable) {/*  w  w w. ja  va  2s. c om*/
    String message = null;
    boolean result = false;
    AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key);
    AmazonS3 s3Client = new AmazonS3Client(credentials,
            new ClientConfiguration().withSignerOverride("S3SignerType"));
    s3Client.setEndpoint(endpoint);
    try {
        message = s3Client.getBucketVersioningConfiguration(bucket).getStatus().toString();
        if (message.contains("Enabled") || message.contains("Suspended")) {
            result = true;
        } else {
            result = false;
        }
    } catch (Exception versioning) {
    }

    return result;
}