@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());
}