boolean isExpirationLifecycleConfigurationPresent(BucketLifecycleConfiguration lifecycleConfiguration) { return lifecycleConfiguration != null && lifecycleConfiguration.getRules() != null && lifecycleConfiguration.getRules().stream() .filter(r -> r.getExpirationInDays() == getConfiguredExpirationInDays()) .filter(r -> { LifecycleFilterPredicate predicate = r.getFilter().getPredicate(); if (predicate instanceof LifecycleTagPredicate) { LifecycleTagPredicate tagPredicate = (LifecycleTagPredicate) predicate; return DELETED_TAG.equals(tagPredicate.getTag()); } return false; }) .findAny().isPresent(); }
BucketLifecycleConfiguration makeLifecycleConfiguration(BucketLifecycleConfiguration existing, int expirationInDays) { BucketLifecycleConfiguration.Rule rule = new BucketLifecycleConfiguration.Rule() .withId(LIFECYCLE_EXPIRATION_RULE_ID) .withFilter(new LifecycleFilter( new LifecycleTagPredicate(DELETED_TAG))) .withExpirationInDays(expirationInDays) .withStatus(BucketLifecycleConfiguration.ENABLED.toString()); if (existing != null) { existing.getRules().add(rule); return existing; } else { return new BucketLifecycleConfiguration().withRules(rule); } }
boolean isExpirationLifecycleConfigurationPresent(BucketLifecycleConfiguration lifecycleConfiguration) { return lifecycleConfiguration != null && lifecycleConfiguration.getRules() != null && lifecycleConfiguration.getRules().stream() .filter(r -> r.getExpirationInDays() == getConfiguredExpirationInDays()) .anyMatch(r -> { LifecycleFilterPredicate predicate = r.getFilter().getPredicate(); if (predicate instanceof LifecycleTagPredicate) { LifecycleTagPredicate tagPredicate = (LifecycleTagPredicate) predicate; return DELETED_TAG.equals(tagPredicate.getTag()); } return false; }); }
BucketLifecycleConfiguration makeLifecycleConfiguration(BucketLifecycleConfiguration existing, int expirationInDays) { BucketLifecycleConfiguration.Rule rule = new BucketLifecycleConfiguration.Rule() .withId(LIFECYCLE_EXPIRATION_RULE_ID) .withFilter(new LifecycleFilter( new LifecycleTagPredicate(DELETED_TAG))) .withExpirationInDays(expirationInDays) .withStatus(BucketLifecycleConfiguration.ENABLED); if (existing != null) { existing.getRules().add(rule); return existing; } else { return new BucketLifecycleConfiguration().withRules(rule); } }
@Override public void visit(LifecycleTagPredicate lifecycleTagPredicate) { writeTag(xml, lifecycleTagPredicate.getTag()); }