Class AwsUtils

java.lang.Object
org.craftercms.commons.aws.AwsUtils

public final class AwsUtils extends Object
Provides utility methods for AWS services
  • Field Details

  • Constructor Details

    • AwsUtils

      public AwsUtils()
  • Method Details

    • buildTransferManager

      public static software.amazon.awssdk.transfer.s3.S3TransferManager buildTransferManager(software.amazon.awssdk.services.s3.S3AsyncClient client)
      Builds the S3TransferManager using the shared ExecutorService
    • buildTransferManager

      public static software.amazon.awssdk.transfer.s3.S3TransferManager buildTransferManager(software.amazon.awssdk.services.s3.S3AsyncClient client, ThreadPoolExecutor threadPoolExecutor)
      Builds the S3TransferManager using the provided ThreadPoolExecutor
      Parameters:
      client - the S3AsyncClient client
      threadPoolExecutor - the thread pool executor
    • copyObjects

      public static void copyObjects(software.amazon.awssdk.services.s3.S3AsyncClient client, ThreadPoolExecutor threadPoolExecutor, String sourceBucket, String sourceBaseKey, String targetBucket, String targetBaseKey, List<String> paths, Consumer<Throwable> errorHandler)
      Copy a list of objects from a source bucket to a target bucket
      Parameters:
      client - The S3AsyncClient client
      threadPoolExecutor - The thread pool executor
      sourceBucket - The source bucket
      sourceBaseKey - The base key in the source bucket (i.e. prefix for all paths)
      targetBucket - The target bucket
      targetBaseKey - The base key in the target bucket (i.e. prefix for all paths)
      paths - The list of paths to copy
      errorHandler - The error handler to be called on copy errors. This handler will receive the cause exception and can return a CompletionException to propagate the error or handle it in any other way
    • ignoreMissingObject

      public static Consumer<Throwable> ignoreMissingObject()
      Convenience handler to ignore NoSuchKeyException. It will throw a CompletionException for any other exception type
      Returns:
      handler that ignores NoSuchKeyException
    • s3KeyFromPath

      public static String s3KeyFromPath(String baseKey, String path)
      Form a S3 key from a base key and a path
      Parameters:
      baseKey - the base key
      path - the path
      Returns:
      s3 key format