@Test void fromShouldThrowWhenBlobStoreImplIsNull() { PropertiesConfiguration configuration = new PropertiesConfiguration(); configuration.addProperty("implementation", null); assertThatThrownBy(() -> BlobStoreConfiguration.from(configuration)) .isInstanceOf(IllegalStateException.class) .hasMessage("implementation property is missing please use one of supported values in: cassandra, s3"); }
static BlobStoreConfiguration from(Configuration configuration) { BlobStoreImplName blobStoreImplName = Optional.ofNullable(configuration.getString(BLOBSTORE_IMPLEMENTATION_PROPERTY)) .filter(StringUtils::isNotBlank) .map(StringUtils::trim) .map(BlobStoreImplName::from) .orElseThrow(() -> new IllegalStateException(String.format("%s property is missing please use one of " + "supported values in: %s", BLOBSTORE_IMPLEMENTATION_PROPERTY, BlobStoreImplName.supportedImplNames()))); boolean cacheEnabled = configuration.getBoolean(CACHE_ENABLE_PROPERTY, false); boolean deduplicationEnabled = Try.ofCallable(() -> configuration.getBoolean(DEDUPLICATION_ENABLE_PROPERTY)) .getOrElseThrow(() -> new IllegalStateException("deduplication.enable property is missing please use one of the supported values in: true, false\n" + "If you choose to enable deduplication, the mails with the same content will be stored only once.\n" + "Warning: Once this feature is enabled, there is no turning back as turning it off will lead to the deletion of all\n" + "the mails sharing the same content once one is deleted.\n" + "Upgrade note: If you are upgrading from James 3.5 or older, the deduplication was enabled.")); if (deduplicationEnabled) { return new BlobStoreConfiguration(blobStoreImplName, cacheEnabled, StorageStrategy.DEDUPLICATION); } else { return new BlobStoreConfiguration(blobStoreImplName, cacheEnabled, StorageStrategy.PASSTHROUGH); } }
BlobStoreConfiguration { static BlobStoreConfiguration from(Configuration configuration) { BlobStoreImplName blobStoreImplName = Optional.ofNullable(configuration.getString(BLOBSTORE_IMPLEMENTATION_PROPERTY)) .filter(StringUtils::isNotBlank) .map(StringUtils::trim) .map(BlobStoreImplName::from) .orElseThrow(() -> new IllegalStateException(String.format("%s property is missing please use one of " + "supported values in: %s", BLOBSTORE_IMPLEMENTATION_PROPERTY, BlobStoreImplName.supportedImplNames()))); boolean cacheEnabled = configuration.getBoolean(CACHE_ENABLE_PROPERTY, false); boolean deduplicationEnabled = Try.ofCallable(() -> configuration.getBoolean(DEDUPLICATION_ENABLE_PROPERTY)) .getOrElseThrow(() -> new IllegalStateException("deduplication.enable property is missing please use one of the supported values in: true, false\n" + "If you choose to enable deduplication, the mails with the same content will be stored only once.\n" + "Warning: Once this feature is enabled, there is no turning back as turning it off will lead to the deletion of all\n" + "the mails sharing the same content once one is deleted.\n" + "Upgrade note: If you are upgrading from James 3.5 or older, the deduplication was enabled.")); if (deduplicationEnabled) { return new BlobStoreConfiguration(blobStoreImplName, cacheEnabled, StorageStrategy.DEDUPLICATION); } else { return new BlobStoreConfiguration(blobStoreImplName, cacheEnabled, StorageStrategy.PASSTHROUGH); } } }
BlobStoreConfiguration { static BlobStoreConfiguration from(Configuration configuration) { BlobStoreImplName blobStoreImplName = Optional.ofNullable(configuration.getString(BLOBSTORE_IMPLEMENTATION_PROPERTY)) .filter(StringUtils::isNotBlank) .map(StringUtils::trim) .map(BlobStoreImplName::from) .orElseThrow(() -> new IllegalStateException(String.format("%s property is missing please use one of " + "supported values in: %s", BLOBSTORE_IMPLEMENTATION_PROPERTY, BlobStoreImplName.supportedImplNames()))); boolean cacheEnabled = configuration.getBoolean(CACHE_ENABLE_PROPERTY, false); boolean deduplicationEnabled = Try.ofCallable(() -> configuration.getBoolean(DEDUPLICATION_ENABLE_PROPERTY)) .getOrElseThrow(() -> new IllegalStateException("deduplication.enable property is missing please use one of the supported values in: true, false\n" + "If you choose to enable deduplication, the mails with the same content will be stored only once.\n" + "Warning: Once this feature is enabled, there is no turning back as turning it off will lead to the deletion of all\n" + "the mails sharing the same content once one is deleted.\n" + "Upgrade note: If you are upgrading from James 3.5 or older, the deduplication was enabled.")); if (deduplicationEnabled) { return new BlobStoreConfiguration(blobStoreImplName, cacheEnabled, StorageStrategy.DEDUPLICATION); } else { return new BlobStoreConfiguration(blobStoreImplName, cacheEnabled, StorageStrategy.PASSTHROUGH); } } BlobStoreConfiguration(BlobStoreImplName implementation, boolean cacheEnabled, StorageStrategy storageStrategy); }
BlobStoreConfiguration { static BlobStoreConfiguration from(Configuration configuration) { BlobStoreImplName blobStoreImplName = Optional.ofNullable(configuration.getString(BLOBSTORE_IMPLEMENTATION_PROPERTY)) .filter(StringUtils::isNotBlank) .map(StringUtils::trim) .map(BlobStoreImplName::from) .orElseThrow(() -> new IllegalStateException(String.format("%s property is missing please use one of " + "supported values in: %s", BLOBSTORE_IMPLEMENTATION_PROPERTY, BlobStoreImplName.supportedImplNames()))); boolean cacheEnabled = configuration.getBoolean(CACHE_ENABLE_PROPERTY, false); boolean deduplicationEnabled = Try.ofCallable(() -> configuration.getBoolean(DEDUPLICATION_ENABLE_PROPERTY)) .getOrElseThrow(() -> new IllegalStateException("deduplication.enable property is missing please use one of the supported values in: true, false\n" + "If you choose to enable deduplication, the mails with the same content will be stored only once.\n" + "Warning: Once this feature is enabled, there is no turning back as turning it off will lead to the deletion of all\n" + "the mails sharing the same content once one is deleted.\n" + "Upgrade note: If you are upgrading from James 3.5 or older, the deduplication was enabled.")); if (deduplicationEnabled) { return new BlobStoreConfiguration(blobStoreImplName, cacheEnabled, StorageStrategy.DEDUPLICATION); } else { return new BlobStoreConfiguration(blobStoreImplName, cacheEnabled, StorageStrategy.PASSTHROUGH); } } BlobStoreConfiguration(BlobStoreImplName implementation, boolean cacheEnabled, StorageStrategy storageStrategy); static RequireImplementation builder(); static BlobStoreConfiguration parse(org.apache.james.server.core.configuration.Configuration configuration); static BlobStoreConfiguration parse(PropertiesProvider propertiesProvider); @VisibleForTesting static RequireStoringStrategy cassandra(); static RequireCache s3(); boolean cacheEnabled(); StorageStrategy storageStrategy(); @Override final boolean equals(Object o); @Override final int hashCode(); @Override String toString(); }
BlobStoreConfiguration { static BlobStoreConfiguration from(Configuration configuration) { BlobStoreImplName blobStoreImplName = Optional.ofNullable(configuration.getString(BLOBSTORE_IMPLEMENTATION_PROPERTY)) .filter(StringUtils::isNotBlank) .map(StringUtils::trim) .map(BlobStoreImplName::from) .orElseThrow(() -> new IllegalStateException(String.format("%s property is missing please use one of " + "supported values in: %s", BLOBSTORE_IMPLEMENTATION_PROPERTY, BlobStoreImplName.supportedImplNames()))); boolean cacheEnabled = configuration.getBoolean(CACHE_ENABLE_PROPERTY, false); boolean deduplicationEnabled = Try.ofCallable(() -> configuration.getBoolean(DEDUPLICATION_ENABLE_PROPERTY)) .getOrElseThrow(() -> new IllegalStateException("deduplication.enable property is missing please use one of the supported values in: true, false\n" + "If you choose to enable deduplication, the mails with the same content will be stored only once.\n" + "Warning: Once this feature is enabled, there is no turning back as turning it off will lead to the deletion of all\n" + "the mails sharing the same content once one is deleted.\n" + "Upgrade note: If you are upgrading from James 3.5 or older, the deduplication was enabled.")); if (deduplicationEnabled) { return new BlobStoreConfiguration(blobStoreImplName, cacheEnabled, StorageStrategy.DEDUPLICATION); } else { return new BlobStoreConfiguration(blobStoreImplName, cacheEnabled, StorageStrategy.PASSTHROUGH); } } BlobStoreConfiguration(BlobStoreImplName implementation, boolean cacheEnabled, StorageStrategy storageStrategy); static RequireImplementation builder(); static BlobStoreConfiguration parse(org.apache.james.server.core.configuration.Configuration configuration); static BlobStoreConfiguration parse(PropertiesProvider propertiesProvider); @VisibleForTesting static RequireStoringStrategy cassandra(); static RequireCache s3(); boolean cacheEnabled(); StorageStrategy storageStrategy(); @Override final boolean equals(Object o); @Override final int hashCode(); @Override String toString();  }