com.amazonaws.services.s3.model.lifecycle.LifecycleTagPredicate Java Examples

The following examples show how to use com.amazonaws.services.s3.model.lifecycle.LifecycleTagPredicate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: S3BlobStore.java    From nexus-blobstore-s3 with Eclipse Public License 1.0 5 votes vote down vote up
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();
}
 
Example #2
Source File: S3BlobStore.java    From nexus-blobstore-s3 with Eclipse Public License 1.0 5 votes vote down vote up
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);
  }
}
 
Example #3
Source File: BucketManager.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private boolean isDeletedTagPredicate(final LifecycleFilterPredicate filterPredicate, final String bucketPrefix) {
  if (filterPredicate instanceof LifecycleTagPredicate) {
    LifecycleTagPredicate tagPredicate = (LifecycleTagPredicate) filterPredicate;
    return S3BlobStore.DELETED_TAG.equals(tagPredicate.getTag());
  }
  else if (filterPredicate instanceof LifecycleAndOperator) {
    LifecycleAndOperator andOperator = (LifecycleAndOperator) filterPredicate;
    return
        andOperator.getOperands().stream().anyMatch(op -> isDeletedTagPredicate(op, bucketPrefix)) &&
        andOperator.getOperands().stream().anyMatch(op -> isBucketPrefixPredicate(op, bucketPrefix));
  }
  else {
    return false;
  }
}