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

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

Introduction

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

Prototype

public BucketLifecycleConfiguration getBucketLifecycleConfiguration(
        GetBucketLifecycleConfigurationRequest getBucketLifecycleConfigurationRequest);

Source Link

Document

Gets the lifecycle configuration for the specified bucket, or null if the specified bucket does not exist or if no configuration has been established.

Usage

From source file:c3.ops.priam.aws.S3FileSystem.java

License:Apache License

/**
 * Note: Current limitation allows only 100 object expiration rules to be
 * set. Removes the rule is set to 0.//from ww w  .  j a v a2s . c  om
 */
@Override
public void cleanup() {
    AmazonS3 s3Client = getS3Client();
    String clusterPath = pathProvider.get().clusterPrefix("");
    BucketLifecycleConfiguration lifeConfig = s3Client
            .getBucketLifecycleConfiguration(config.getBackupPrefix());
    if (lifeConfig == null) {
        lifeConfig = new BucketLifecycleConfiguration();
        List<Rule> rules = Lists.newArrayList();
        lifeConfig.setRules(rules);
    }
    List<Rule> rules = lifeConfig.getRules();
    if (updateLifecycleRule(rules, clusterPath)) {
        if (rules.size() > 0) {
            lifeConfig.setRules(rules);
            s3Client.setBucketLifecycleConfiguration(config.getBackupPrefix(), lifeConfig);
        } else
            s3Client.deleteBucketLifecycleConfiguration(config.getBackupPrefix());
    }
}

From source file:cloudExplorer.BucketClass.java

License:Open Source License

Boolean LifeCycleStatus(String access_key, String secret_key, String bucket, String endpoint, String region,
        Boolean enable) {// w  w  w . jav  a2 s.co m
    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.getBucketLifecycleConfiguration(bucket).getRules().toString();
        if (message == null) {
            result = false;
        } else {
            result = true;
        }
    } catch (Exception lifecyclestatus) {
    }

    return result;
}