You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/07/05 07:00:50 UTC
[james-project] 02/12: JAMES-2806 Replace ContainerName by
BucketName in ObjectStorage Guice
This is an automated email from the ASF dual-hosted git repository.
btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit ae932171dfd9635c3248115fd9b3f4041bd3f539
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Tue Jun 25 15:58:17 2019 +0700
JAMES-2806 Replace ContainerName by BucketName in ObjectStorage Guice
---
.../ObjectStorageBlobConfiguration.java | 20 ++++++++++----------
.../ObjectStorageDependenciesModule.java | 2 +-
.../objectstorage/swift/SwiftObjectStorage.java | 8 ++++----
.../objectstorage/aws/s3/DockerAwsS3TestRule.java | 6 +++---
.../objectstorage/swift/DockerSwiftTestRule.java | 6 +++---
.../swift/ObjectStorageBlobConfigurationTest.java | 8 ++++----
.../swift/ObjectStorageBlobStoreModuleTest.java | 11 +++++------
.../objectstorage/swift/SwiftObjectStorageTest.java | 14 +++++++-------
8 files changed, 37 insertions(+), 38 deletions(-)
diff --git a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageBlobConfiguration.java b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageBlobConfiguration.java
index 06520d8..f1fb395 100644
--- a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageBlobConfiguration.java
+++ b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageBlobConfiguration.java
@@ -25,7 +25,7 @@ import java.util.Optional;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.blob.objectstorage.ContainerName;
+import org.apache.james.blob.api.BucketName;
import org.apache.james.blob.objectstorage.PayloadCodec;
import org.apache.james.blob.objectstorage.SpecificAuthConfiguration;
import org.apache.james.modules.objectstorage.aws.s3.AwsS3ConfigurationReader;
@@ -70,7 +70,7 @@ public class ObjectStorageBlobConfiguration {
return builder()
.codec(payloadCodecFactory)
.provider(ObjectStorageProvider.from(provider))
- .container(ContainerName.of(namespace))
+ .bucketName(BucketName.of(namespace))
.authConfiguration(authConfiguration(provider, configuration))
.aesSalt(aesSalt)
.aesPassword(aesPassword)
@@ -104,7 +104,7 @@ public class ObjectStorageBlobConfiguration {
@FunctionalInterface
interface RequireContainerName {
- RequireAuthConfiguration container(ContainerName container);
+ RequireAuthConfiguration bucketName(BucketName bucketName);
}
@FunctionalInterface
@@ -116,7 +116,7 @@ public class ObjectStorageBlobConfiguration {
private final PayloadCodecFactory payloadCodecFactory;
private final ObjectStorageProvider provider;
- private final ContainerName container;
+ private final BucketName bucketName;
private final SpecificAuthConfiguration specificAuthConfiguration;
private Optional<String> aesSalt;
@@ -124,13 +124,13 @@ public class ObjectStorageBlobConfiguration {
public ReadyToBuild(PayloadCodecFactory payloadCodecFactory,
ObjectStorageProvider provider,
- ContainerName container,
+ BucketName bucketName,
SpecificAuthConfiguration specificAuthConfiguration) {
this.aesSalt = Optional.empty();
this.aesPassword = Optional.empty();
this.payloadCodecFactory = payloadCodecFactory;
this.provider = provider;
- this.container = container;
+ this.bucketName = bucketName;
this.specificAuthConfiguration = specificAuthConfiguration;
}
@@ -160,7 +160,7 @@ public class ObjectStorageBlobConfiguration {
.orElseThrow(() -> new IllegalStateException("AES code requires an non-empty password parameter"));
}
- return new ObjectStorageBlobConfiguration(payloadCodecFactory, provider, container, specificAuthConfiguration, aesSalt, aesPassword);
+ return new ObjectStorageBlobConfiguration(payloadCodecFactory, provider, bucketName, specificAuthConfiguration, aesSalt, aesPassword);
}
}
@@ -168,7 +168,7 @@ public class ObjectStorageBlobConfiguration {
}
private final PayloadCodecFactory payloadCodec;
- private final ContainerName namespace;
+ private final BucketName namespace;
private final ObjectStorageProvider provider;
private final SpecificAuthConfiguration specificAuthConfiguration;
private Optional<String> aesSalt;
@@ -176,7 +176,7 @@ public class ObjectStorageBlobConfiguration {
@VisibleForTesting
ObjectStorageBlobConfiguration(PayloadCodecFactory payloadCodec, ObjectStorageProvider provider,
- ContainerName namespace,
+ BucketName namespace,
SpecificAuthConfiguration specificAuthConfiguration,
Optional<String> aesSalt,
Optional<char[]> aesPassword) {
@@ -188,7 +188,7 @@ public class ObjectStorageBlobConfiguration {
this.aesPassword = aesPassword;
}
- public ContainerName getNamespace() {
+ public BucketName getNamespace() {
return namespace;
}
diff --git a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
index a2b3953..7f11da9 100644
--- a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
+++ b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/ObjectStorageDependenciesModule.java
@@ -76,7 +76,7 @@ public class ObjectStorageDependenciesModule extends AbstractModule {
return dao;
}
- private ObjectStorageBlobsDAOBuilder.RequireContainerName selectDaoBuilder(ObjectStorageBlobConfiguration configuration) {
+ private ObjectStorageBlobsDAOBuilder.RequireBucketName selectDaoBuilder(ObjectStorageBlobConfiguration configuration) {
switch (configuration.getProvider()) {
case SWIFT:
return SwiftObjectStorage.builder(configuration);
diff --git a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/swift/SwiftObjectStorage.java b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/swift/SwiftObjectStorage.java
index bf5c9da..6cc6a44 100644
--- a/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/swift/SwiftObjectStorage.java
+++ b/server/container/guice/blob-objectstorage-guice/src/main/java/org/apache/james/modules/objectstorage/swift/SwiftObjectStorage.java
@@ -29,7 +29,7 @@ import org.apache.james.modules.objectstorage.ObjectStorageProvider;
public class SwiftObjectStorage {
- public static ObjectStorageBlobsDAOBuilder.RequireContainerName builder(ObjectStorageBlobConfiguration configuration) {
+ public static ObjectStorageBlobsDAOBuilder.RequireBucketName builder(ObjectStorageBlobConfiguration configuration) {
if (configuration.getProvider() != ObjectStorageProvider.SWIFT) {
throw new IllegalArgumentException("unknown provider " + configuration.getProvider());
}
@@ -52,15 +52,15 @@ public class SwiftObjectStorage {
}
}
- public static ObjectStorageBlobsDAOBuilder.RequireContainerName builder(SwiftTempAuthObjectStorage.Configuration testConfig) {
+ public static ObjectStorageBlobsDAOBuilder.RequireBucketName builder(SwiftTempAuthObjectStorage.Configuration testConfig) {
return SwiftTempAuthObjectStorage.daoBuilder(testConfig);
}
- public static ObjectStorageBlobsDAOBuilder.RequireContainerName builder(SwiftKeystone2ObjectStorage.Configuration testConfig) {
+ public static ObjectStorageBlobsDAOBuilder.RequireBucketName builder(SwiftKeystone2ObjectStorage.Configuration testConfig) {
return SwiftKeystone2ObjectStorage.daoBuilder(testConfig);
}
- public static ObjectStorageBlobsDAOBuilder.RequireContainerName builder(SwiftKeystone3ObjectStorage.Configuration testConfig) {
+ public static ObjectStorageBlobsDAOBuilder.RequireBucketName builder(SwiftKeystone3ObjectStorage.Configuration testConfig) {
return SwiftKeystone3ObjectStorage.daoBuilder(testConfig);
}
}
diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/aws/s3/DockerAwsS3TestRule.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/aws/s3/DockerAwsS3TestRule.java
index 78c1ebf..3dca764 100644
--- a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/aws/s3/DockerAwsS3TestRule.java
+++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/aws/s3/DockerAwsS3TestRule.java
@@ -25,7 +25,7 @@ import javax.inject.Inject;
import org.apache.james.CleanupTasksPerformer;
import org.apache.james.GuiceModuleTestRule;
-import org.apache.james.blob.objectstorage.ContainerName;
+import org.apache.james.blob.api.BucketName;
import org.apache.james.blob.objectstorage.DockerAwsS3Singleton;
import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAO;
import org.apache.james.blob.objectstorage.PayloadCodec;
@@ -105,7 +105,7 @@ public class DockerAwsS3TestRule implements GuiceModuleTestRule {
@Override
public Module getModule() {
- ContainerName containerName = ContainerName.of(UUID.randomUUID().toString());
+ BucketName bucketName = BucketName.of(UUID.randomUUID().toString());
AwsS3AuthConfiguration authConfiguration = AwsS3AuthConfiguration.builder()
.endpoint(DockerAwsS3Singleton.singleton.getEndpoint())
.accessKeyId(DockerAwsS3Container.ACCESS_KEY_ID)
@@ -115,7 +115,7 @@ public class DockerAwsS3TestRule implements GuiceModuleTestRule {
ObjectStorageBlobConfiguration configuration = ObjectStorageBlobConfiguration.builder()
.codec(payloadCodecFactory)
.provider(ObjectStorageProvider.AWSS3)
- .container(containerName)
+ .bucketName(bucketName)
.authConfiguration(authConfiguration)
.aesSalt("c603a7327ee3dcbc031d8d34b1096c605feca5e1")
.aesPassword("dockerAwsS3Encryption".toCharArray())
diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/DockerSwiftTestRule.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/DockerSwiftTestRule.java
index 67a2a53..b0c041b 100644
--- a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/DockerSwiftTestRule.java
+++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/DockerSwiftTestRule.java
@@ -26,7 +26,7 @@ import javax.inject.Inject;
import org.apache.james.CleanupTasksPerformer;
import org.apache.james.GuiceModuleTestRule;
-import org.apache.james.blob.objectstorage.ContainerName;
+import org.apache.james.blob.api.BucketName;
import org.apache.james.blob.objectstorage.DockerSwiftRule;
import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAO;
import org.apache.james.blob.objectstorage.PayloadCodec;
@@ -106,11 +106,11 @@ public class DockerSwiftTestRule implements GuiceModuleTestRule {
.endpoint(swiftContainer.dockerSwift().keystoneV2Endpoint())
.build();
- ContainerName containerName = ContainerName.of(UUID.randomUUID().toString());
+ BucketName bucketName = BucketName.of(UUID.randomUUID().toString());
ObjectStorageBlobConfiguration configuration = ObjectStorageBlobConfiguration.builder()
.codec(payloadCodecFactory)
.provider(ObjectStorageProvider.SWIFT)
- .container(containerName)
+ .bucketName(bucketName)
.authConfiguration(new SwiftAuthConfiguration(SwiftKeystone2ObjectStorage.AUTH_API_NAME,
Optional.empty(),
Optional.of(authConfiguration),
diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobConfigurationTest.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobConfigurationTest.java
index 901bb1f..6e159b9 100644
--- a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobConfigurationTest.java
+++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobConfigurationTest.java
@@ -26,7 +26,7 @@ import java.util.Optional;
import java.util.stream.Stream;
import org.apache.commons.configuration.ConfigurationException;
-import org.apache.james.blob.objectstorage.ContainerName;
+import org.apache.james.blob.api.BucketName;
import org.apache.james.blob.objectstorage.swift.Credentials;
import org.apache.james.blob.objectstorage.swift.DomainName;
import org.apache.james.blob.objectstorage.swift.IdentityV3;
@@ -97,7 +97,7 @@ class ObjectStorageBlobConfigurationTest {
ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(ContainerName.of("foo"))
+ .bucketName(BucketName.of("foo"))
.authConfiguration(new SwiftAuthConfiguration(SwiftTempAuthObjectStorage.AUTH_API_NAME,
Optional.of(SwiftTempAuthObjectStorage.configBuilder()
.endpoint(URI.create("http://swift/endpoint"))
@@ -130,7 +130,7 @@ class ObjectStorageBlobConfigurationTest {
ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(ContainerName.of("foo"))
+ .bucketName(BucketName.of("foo"))
.authConfiguration(new SwiftAuthConfiguration(SwiftKeystone2ObjectStorage.AUTH_API_NAME,
Optional.empty(),
Optional.of(SwiftKeystone2ObjectStorage.configBuilder()
@@ -162,7 +162,7 @@ class ObjectStorageBlobConfigurationTest {
ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(ContainerName.of("foo"))
+ .bucketName(BucketName.of("foo"))
.authConfiguration(new SwiftAuthConfiguration(SwiftKeystone3ObjectStorage.AUTH_API_NAME,
Optional.empty(),
Optional.empty(),
diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobStoreModuleTest.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobStoreModuleTest.java
index a99e704..503b3d1 100644
--- a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobStoreModuleTest.java
+++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/ObjectStorageBlobStoreModuleTest.java
@@ -28,7 +28,6 @@ import java.util.stream.Stream;
import org.apache.james.blob.api.BlobStore;
import org.apache.james.blob.api.BucketName;
import org.apache.james.blob.api.MetricableBlobStore;
-import org.apache.james.blob.objectstorage.ContainerName;
import org.apache.james.blob.objectstorage.DockerSwift;
import org.apache.james.blob.objectstorage.DockerSwiftExtension;
import org.apache.james.blob.objectstorage.ObjectStorageBlobsDAO;
@@ -80,7 +79,7 @@ class ObjectStorageBlobStoreModuleTest {
ObjectStorageBlobConfiguration tmpAuth = ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(generateContainerName())
+ .bucketName(generateBucketName())
.authConfiguration(new SwiftAuthConfiguration(SwiftTempAuthObjectStorage.AUTH_API_NAME,
Optional.of(SwiftTempAuthObjectStorage.configBuilder()
.endpoint(dockerSwift.swiftEndpoint())
@@ -96,7 +95,7 @@ class ObjectStorageBlobStoreModuleTest {
ObjectStorageBlobConfiguration keystone2 = ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(generateContainerName())
+ .bucketName(generateBucketName())
.authConfiguration(new SwiftAuthConfiguration(SwiftKeystone2ObjectStorage.AUTH_API_NAME,
Optional.empty(),
Optional.of(SwiftKeystone2ObjectStorage.configBuilder()
@@ -110,7 +109,7 @@ class ObjectStorageBlobStoreModuleTest {
ObjectStorageBlobConfiguration keystone3 = ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(generateContainerName())
+ .bucketName(generateBucketName())
.authConfiguration(new SwiftAuthConfiguration(SwiftKeystone3ObjectStorage.AUTH_API_NAME,
Optional.empty(),
Optional.empty(),
@@ -125,8 +124,8 @@ class ObjectStorageBlobStoreModuleTest {
}
}
- private static ContainerName generateContainerName() {
- return ContainerName.of(UUID.randomUUID().toString());
+ private static BucketName generateBucketName() {
+ return BucketName.of(UUID.randomUUID().toString());
}
@ParameterizedTest
diff --git a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/SwiftObjectStorageTest.java b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/SwiftObjectStorageTest.java
index 262019a..12411c3 100644
--- a/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/SwiftObjectStorageTest.java
+++ b/server/container/guice/blob-objectstorage-guice/src/test/java/org/apache/james/modules/objectstorage/swift/SwiftObjectStorageTest.java
@@ -24,7 +24,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.Optional;
import org.apache.commons.configuration.PropertiesConfiguration;
-import org.apache.james.blob.objectstorage.ContainerName;
+import org.apache.james.blob.api.BucketName;
import org.apache.james.modules.objectstorage.ObjectStorageBlobConfiguration;
import org.apache.james.modules.objectstorage.ObjectStorageProvider;
import org.apache.james.modules.objectstorage.PayloadCodecFactory;
@@ -37,7 +37,7 @@ class SwiftObjectStorageTest {
ObjectStorageBlobConfiguration objectStorageBlobConfiguration = ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(ContainerName.of("myContainer"))
+ .bucketName(BucketName.of("myContainer"))
.authConfiguration(new SwiftAuthConfiguration("tmpauth", Optional.empty(), Optional.empty(), Optional.empty()))
.build();
assertThatThrownBy(() -> SwiftObjectStorage.builder(objectStorageBlobConfiguration))
@@ -57,7 +57,7 @@ class SwiftObjectStorageTest {
ObjectStorageBlobConfiguration objectStorageBlobConfiguration = ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(ContainerName.of("myContainer"))
+ .bucketName(BucketName.of("myContainer"))
.authConfiguration(SwiftAuthConfiguration.from(configuration))
.build();
SwiftObjectStorage.builder(objectStorageBlobConfiguration);
@@ -68,7 +68,7 @@ class SwiftObjectStorageTest {
ObjectStorageBlobConfiguration objectStorageBlobConfiguration = ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(ContainerName.of("myContainer"))
+ .bucketName(BucketName.of("myContainer"))
.authConfiguration(new SwiftAuthConfiguration("keystone2", Optional.empty(), Optional.empty(), Optional.empty()))
.build();
assertThatThrownBy(() -> SwiftObjectStorage.builder(objectStorageBlobConfiguration))
@@ -88,7 +88,7 @@ class SwiftObjectStorageTest {
ObjectStorageBlobConfiguration objectStorageBlobConfiguration = ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(ContainerName.of("myContainer"))
+ .bucketName(BucketName.of("myContainer"))
.authConfiguration(SwiftAuthConfiguration.from(configuration))
.build();
SwiftObjectStorage.builder(objectStorageBlobConfiguration);
@@ -99,7 +99,7 @@ class SwiftObjectStorageTest {
ObjectStorageBlobConfiguration objectStorageBlobConfiguration = ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(ContainerName.of("myContainer"))
+ .bucketName(BucketName.of("myContainer"))
.authConfiguration(new SwiftAuthConfiguration("keystone3", Optional.empty(), Optional.empty(), Optional.empty()))
.build();
assertThatThrownBy(() -> SwiftObjectStorage.builder(objectStorageBlobConfiguration))
@@ -119,7 +119,7 @@ class SwiftObjectStorageTest {
ObjectStorageBlobConfiguration objectStorageBlobConfiguration = ObjectStorageBlobConfiguration.builder()
.codec(PayloadCodecFactory.DEFAULT)
.provider(ObjectStorageProvider.SWIFT)
- .container(ContainerName.of("myContainer"))
+ .bucketName(BucketName.of("myContainer"))
.authConfiguration(SwiftAuthConfiguration.from(configuration))
.build();
SwiftObjectStorage.builder(objectStorageBlobConfiguration);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org