use of com.amazonaws.services.s3.model.lifecycle.LifecycleFilterPredicate in project aws-sdk-android by aws-amplify.
the class BucketLifecycleSaxUnmarshallerTest method unmarshalls_filter_with_AndOperator_containing_prefixAndOneTag.
@Test
public void unmarshalls_filter_with_AndOperator_containing_prefixAndOneTag() throws Exception {
Rule rule = getRule(parseLifecycleConfiguration(UNKNOWN_STORAGE_CLASS_RESPONSE), 4);
LifecycleAndOperator predicate = (LifecycleAndOperator) rule.getFilter().getPredicate();
List<LifecycleFilterPredicate> operands = predicate.getOperands();
assertEquals(2, operands.size());
assertEquals("prefix", ((LifecyclePrefixPredicate) operands.get(0)).getPrefix());
Tag tag = ((LifecycleTagPredicate) operands.get(1)).getTag();
assertEquals("key1", tag.getKey());
assertEquals("value1", tag.getValue());
}
use of com.amazonaws.services.s3.model.lifecycle.LifecycleFilterPredicate in project aws-sdk-android by aws-amplify.
the class BucketLifecycleSaxUnmarshallerTest method lifecycleConfigurationUnmarshaller_unmarshalls_properly.
@Test
public void lifecycleConfigurationUnmarshaller_unmarshalls_properly() throws Exception {
Rule rule = getRule(parseLifecycleConfiguration(UNKNOWN_STORAGE_CLASS_RESPONSE), 0);
assertEquals("logs-rule", rule.getId());
assertEquals("logs/", rule.getPrefix());
assertEquals(BucketLifecycleConfiguration.ENABLED, rule.getStatus());
Transition transition = rule.getTransitions().get(0);
assertEquals(30, transition.getDays());
assertEquals(FUTURE_STORAGE_CLASS, transition.getStorageClassAsString());
assertEquals(365, rule.getExpirationInDays());
NoncurrentVersionTransition noncurrentVersionTransition = rule.getNoncurrentVersionTransitions().get(0);
assertEquals(7, noncurrentVersionTransition.getDays());
assertEquals(14, rule.getNoncurrentVersionExpirationInDays());
// Test Filter
LifecycleFilterPredicate predicate = rule.getFilter().getPredicate();
assertTrue(predicate instanceof LifecycleAndOperator);
List<LifecycleFilterPredicate> andOperands = ((LifecycleAndOperator) predicate).getOperands();
assertEquals("prefix", ((LifecyclePrefixPredicate) andOperands.get(0)).getPrefix());
assertEquals("key1", ((LifecycleTagPredicate) andOperands.get(1)).getTag().getKey());
assertEquals("value1", ((LifecycleTagPredicate) andOperands.get(1)).getTag().getValue());
assertEquals("key2", ((LifecycleTagPredicate) andOperands.get(2)).getTag().getKey());
assertEquals("value2", ((LifecycleTagPredicate) andOperands.get(2)).getTag().getValue());
}
use of com.amazonaws.services.s3.model.lifecycle.LifecycleFilterPredicate in project nexus-public by sonatype.
the class BucketManager method makeLifecycleConfiguration.
private BucketLifecycleConfiguration makeLifecycleConfiguration(final BucketLifecycleConfiguration existing, final BlobStoreConfiguration blobStoreConfiguration) {
String blobStoreName = blobStoreConfiguration.getName();
String bucketPrefix = getBucketPrefix(blobStoreConfiguration);
int expirationInDays = getConfiguredExpirationInDays(blobStoreConfiguration);
LifecycleFilterPredicate filterPredicate;
if (bucketPrefix.isEmpty()) {
filterPredicate = new LifecycleTagPredicate(S3BlobStore.DELETED_TAG);
} else {
filterPredicate = new LifecycleAndOperator(asList(new LifecyclePrefixPredicate(bucketPrefix), new LifecycleTagPredicate(S3BlobStore.DELETED_TAG)));
}
BucketLifecycleConfiguration.Rule rule = new BucketLifecycleConfiguration.Rule().withId(LIFECYCLE_EXPIRATION_RULE_ID_PREFIX + blobStoreName).withFilter(new LifecycleFilter(filterPredicate)).withExpirationInDays(expirationInDays).withStatus(BucketLifecycleConfiguration.ENABLED);
BucketLifecycleConfiguration newConfiguration = null;
if (existing != null && !existing.getRules().isEmpty()) {
List<Rule> rules = nonBlobstoreRules(existing, blobStoreName);
if (expirationInDays > 0) {
rules.add(rule);
}
if (!rules.isEmpty()) {
existing.setRules(rules);
newConfiguration = existing;
}
} else {
if (expirationInDays > 0) {
newConfiguration = new BucketLifecycleConfiguration().withRules(rule);
}
}
return newConfiguration;
}
use of com.amazonaws.services.s3.model.lifecycle.LifecycleFilterPredicate in project aws-sdk-android by aws-amplify.
the class BucketLifecycleSaxUnmarshallerTest method unmarshalls_filter_with_AndOperator_containing_multipleTags.
@Test
public void unmarshalls_filter_with_AndOperator_containing_multipleTags() throws Exception {
Rule rule = getRule(parseLifecycleConfiguration(UNKNOWN_STORAGE_CLASS_RESPONSE), 5);
LifecycleAndOperator predicate = (LifecycleAndOperator) rule.getFilter().getPredicate();
List<LifecycleFilterPredicate> operands = predicate.getOperands();
assertEquals(3, operands.size());
assertEquals("key0", ((LifecycleTagPredicate) operands.get(0)).getTag().getKey());
assertEquals("value0", ((LifecycleTagPredicate) operands.get(0)).getTag().getValue());
assertEquals("key1", ((LifecycleTagPredicate) operands.get(1)).getTag().getKey());
assertEquals("value1", ((LifecycleTagPredicate) operands.get(1)).getTag().getValue());
assertEquals("key2", ((LifecycleTagPredicate) operands.get(2)).getTag().getKey());
assertEquals("value2", ((LifecycleTagPredicate) operands.get(2)).getTag().getValue());
}
Aggregations