@Test public void downloadsFromS3WhenUploadOnlyFalse() throws StorageException { Map<String, String> s3Properties = getS3Properties(); s3Properties.put(MpfConstants.S3_UPLOAD_ONLY_PROPERTY, "false"); assertTrue(S3StorageBackend.requiresS3MediaDownload(s3Properties::get)); }
public static boolean requiresS3MediaDownload(Function<String, String> properties) throws StorageException { boolean uploadOnly = Boolean.parseBoolean(properties.apply(MpfConstants.S3_UPLOAD_ONLY_PROPERTY)); if (uploadOnly) { return false; } boolean hasAccessKey = StringUtils.isNotBlank(properties.apply(MpfConstants.S3_ACCESS_KEY_PROPERTY)); boolean hasSecretKey = StringUtils.isNotBlank(properties.apply(MpfConstants.S3_SECRET_KEY_PROPERTY)); if (hasAccessKey && hasSecretKey) { return true; } if (!hasAccessKey && !hasSecretKey) { return false; } String presentProperty; String missingProperty; if (hasAccessKey) { presentProperty = MpfConstants.S3_ACCESS_KEY_PROPERTY; missingProperty = MpfConstants.S3_SECRET_KEY_PROPERTY; } else { presentProperty = MpfConstants.S3_SECRET_KEY_PROPERTY; missingProperty = MpfConstants.S3_ACCESS_KEY_PROPERTY; } throw new StorageException(String.format("The %s property was set, but the %s property was not.", presentProperty, missingProperty)); }
S3StorageBackend implements StorageBackend { public static boolean requiresS3MediaDownload(Function<String, String> properties) throws StorageException { boolean uploadOnly = Boolean.parseBoolean(properties.apply(MpfConstants.S3_UPLOAD_ONLY_PROPERTY)); if (uploadOnly) { return false; } boolean hasAccessKey = StringUtils.isNotBlank(properties.apply(MpfConstants.S3_ACCESS_KEY_PROPERTY)); boolean hasSecretKey = StringUtils.isNotBlank(properties.apply(MpfConstants.S3_SECRET_KEY_PROPERTY)); if (hasAccessKey && hasSecretKey) { return true; } if (!hasAccessKey && !hasSecretKey) { return false; } String presentProperty; String missingProperty; if (hasAccessKey) { presentProperty = MpfConstants.S3_ACCESS_KEY_PROPERTY; missingProperty = MpfConstants.S3_SECRET_KEY_PROPERTY; } else { presentProperty = MpfConstants.S3_SECRET_KEY_PROPERTY; missingProperty = MpfConstants.S3_ACCESS_KEY_PROPERTY; } throw new StorageException(String.format("The %s property was set, but the %s property was not.", presentProperty, missingProperty)); } }
S3StorageBackend implements StorageBackend { public static boolean requiresS3MediaDownload(Function<String, String> properties) throws StorageException { boolean uploadOnly = Boolean.parseBoolean(properties.apply(MpfConstants.S3_UPLOAD_ONLY_PROPERTY)); if (uploadOnly) { return false; } boolean hasAccessKey = StringUtils.isNotBlank(properties.apply(MpfConstants.S3_ACCESS_KEY_PROPERTY)); boolean hasSecretKey = StringUtils.isNotBlank(properties.apply(MpfConstants.S3_SECRET_KEY_PROPERTY)); if (hasAccessKey && hasSecretKey) { return true; } if (!hasAccessKey && !hasSecretKey) { return false; } String presentProperty; String missingProperty; if (hasAccessKey) { presentProperty = MpfConstants.S3_ACCESS_KEY_PROPERTY; missingProperty = MpfConstants.S3_SECRET_KEY_PROPERTY; } else { presentProperty = MpfConstants.S3_SECRET_KEY_PROPERTY; missingProperty = MpfConstants.S3_ACCESS_KEY_PROPERTY; } throw new StorageException(String.format("The %s property was set, but the %s property was not.", presentProperty, missingProperty)); } @Inject  S3StorageBackend(PropertiesUtil propertiesUtil,
                            LocalStorageBackend localStorageBackend,
                            InProgressBatchJobsService inProgressBatchJobsService,
                            AggregateJobPropertiesUtil aggregateJobPropertiesUtil); }
S3StorageBackend implements StorageBackend { public static boolean requiresS3MediaDownload(Function<String, String> properties) throws StorageException { boolean uploadOnly = Boolean.parseBoolean(properties.apply(MpfConstants.S3_UPLOAD_ONLY_PROPERTY)); if (uploadOnly) { return false; } boolean hasAccessKey = StringUtils.isNotBlank(properties.apply(MpfConstants.S3_ACCESS_KEY_PROPERTY)); boolean hasSecretKey = StringUtils.isNotBlank(properties.apply(MpfConstants.S3_SECRET_KEY_PROPERTY)); if (hasAccessKey && hasSecretKey) { return true; } if (!hasAccessKey && !hasSecretKey) { return false; } String presentProperty; String missingProperty; if (hasAccessKey) { presentProperty = MpfConstants.S3_ACCESS_KEY_PROPERTY; missingProperty = MpfConstants.S3_SECRET_KEY_PROPERTY; } else { presentProperty = MpfConstants.S3_SECRET_KEY_PROPERTY; missingProperty = MpfConstants.S3_ACCESS_KEY_PROPERTY; } throw new StorageException(String.format("The %s property was set, but the %s property was not.", presentProperty, missingProperty)); } @Inject  S3StorageBackend(PropertiesUtil propertiesUtil,
                            LocalStorageBackend localStorageBackend,
                            InProgressBatchJobsService inProgressBatchJobsService,
                            AggregateJobPropertiesUtil aggregateJobPropertiesUtil); @Override boolean canStore(JsonOutputObject outputObject); @Override URI store(JsonOutputObject outputObject); @Override boolean canStore(ArtifactExtractionRequest request); @Override Table<Integer, Integer, URI> storeArtifacts(ArtifactExtractionRequest request); @Override boolean canStore(MarkupResult markupResult); @Override void store(MarkupResult markupResult); static void validateS3Properties(Function<String, String> properties); static boolean requiresS3MediaDownload(Function<String, String> properties); static boolean requiresS3ResultUpload(Function<String, String> properties); void downloadFromS3(Media media, Function<String, String> combinedProperties); S3Object getFromS3(String uri, Function<String, String> properties); }
S3StorageBackend implements StorageBackend { public static boolean requiresS3MediaDownload(Function<String, String> properties) throws StorageException { boolean uploadOnly = Boolean.parseBoolean(properties.apply(MpfConstants.S3_UPLOAD_ONLY_PROPERTY)); if (uploadOnly) { return false; } boolean hasAccessKey = StringUtils.isNotBlank(properties.apply(MpfConstants.S3_ACCESS_KEY_PROPERTY)); boolean hasSecretKey = StringUtils.isNotBlank(properties.apply(MpfConstants.S3_SECRET_KEY_PROPERTY)); if (hasAccessKey && hasSecretKey) { return true; } if (!hasAccessKey && !hasSecretKey) { return false; } String presentProperty; String missingProperty; if (hasAccessKey) { presentProperty = MpfConstants.S3_ACCESS_KEY_PROPERTY; missingProperty = MpfConstants.S3_SECRET_KEY_PROPERTY; } else { presentProperty = MpfConstants.S3_SECRET_KEY_PROPERTY; missingProperty = MpfConstants.S3_ACCESS_KEY_PROPERTY; } throw new StorageException(String.format("The %s property was set, but the %s property was not.", presentProperty, missingProperty)); } @Inject  S3StorageBackend(PropertiesUtil propertiesUtil,
                            LocalStorageBackend localStorageBackend,
                            InProgressBatchJobsService inProgressBatchJobsService,
                            AggregateJobPropertiesUtil aggregateJobPropertiesUtil); @Override boolean canStore(JsonOutputObject outputObject); @Override URI store(JsonOutputObject outputObject); @Override boolean canStore(ArtifactExtractionRequest request); @Override Table<Integer, Integer, URI> storeArtifacts(ArtifactExtractionRequest request); @Override boolean canStore(MarkupResult markupResult); @Override void store(MarkupResult markupResult); static void validateS3Properties(Function<String, String> properties); static boolean requiresS3MediaDownload(Function<String, String> properties); static boolean requiresS3ResultUpload(Function<String, String> properties); void downloadFromS3(Media media, Function<String, String> combinedProperties); S3Object getFromS3(String uri, Function<String, String> properties);  }