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 ma...@apache.org on 2017/09/11 08:56:37 UTC
[14/18] james-project git commit: MAILBOX-304
s/DAOAttachmentModel/DAOAttachment/
MAILBOX-304 s/DAOAttachmentModel/DAOAttachment/
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/c3e5598c
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/c3e5598c
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/c3e5598c
Branch: refs/heads/master
Commit: c3e5598c7bc3552d2d8d4b1fd5a196c45aeda33d
Parents: e93e9e2
Author: benwa <bt...@linagora.com>
Authored: Fri Sep 8 09:12:46 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Fri Sep 8 09:12:46 2017 +0700
----------------------------------------------------------------------
.../mail/CassandraAttachmentDAOV2.java | 20 ++++++++++----------
.../mail/CassandraAttachmentMapper.java | 12 ++++++------
.../mail/CassandraAttachmentDAOV2Test.java | 12 ++++++------
3 files changed, 22 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/c3e5598c/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2.java
index 96dd8ae..34a654c 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2.java
@@ -48,13 +48,13 @@ import com.datastax.driver.core.Session;
import com.google.common.base.Preconditions;
public class CassandraAttachmentDAOV2 {
- public static class DAOAttachmentModel {
+ public static class DAOAttachment {
private final AttachmentId attachmentId;
private final BlobId blobId;
private final String type;
private final long size;
- private DAOAttachmentModel(AttachmentId attachmentId, BlobId blobId, String type, long size) {
+ private DAOAttachment(AttachmentId attachmentId, BlobId blobId, String type, long size) {
this.attachmentId = attachmentId;
this.blobId = blobId;
this.type = type;
@@ -87,8 +87,8 @@ public class CassandraAttachmentDAOV2 {
@Override
public final boolean equals(Object o) {
- if (o instanceof DAOAttachmentModel) {
- DAOAttachmentModel that = (DAOAttachmentModel) o;
+ if (o instanceof DAOAttachment) {
+ DAOAttachment that = (DAOAttachment) o;
return Objects.equals(this.size, that.size)
&& Objects.equals(this.attachmentId, that.attachmentId)
@@ -104,16 +104,16 @@ public class CassandraAttachmentDAOV2 {
}
}
- public static DAOAttachmentModel from(Attachment attachment, BlobId blobId) {
- return new DAOAttachmentModel(
+ public static DAOAttachment from(Attachment attachment, BlobId blobId) {
+ return new DAOAttachment(
attachment.getAttachmentId(),
blobId,
attachment.getType(),
attachment.getSize());
}
- private static DAOAttachmentModel fromRow(Row row) {
- return new DAOAttachmentModel(
+ private static DAOAttachment fromRow(Row row) {
+ return new DAOAttachment(
AttachmentId.from(row.getString(ID)),
BlobId.from(row.getString(BLOB_ID)),
row.getString(TYPE),
@@ -148,7 +148,7 @@ public class CassandraAttachmentDAOV2 {
.where(eq(ID_AS_UUID, bindMarker(ID_AS_UUID))));
}
- public CompletableFuture<Optional<DAOAttachmentModel>> getAttachment(AttachmentId attachmentId) {
+ public CompletableFuture<Optional<DAOAttachment>> getAttachment(AttachmentId attachmentId) {
Preconditions.checkArgument(attachmentId != null);
return cassandraAsyncExecutor.executeSingleRow(
selectStatement.bind()
@@ -156,7 +156,7 @@ public class CassandraAttachmentDAOV2 {
.thenApply(row -> row.map(CassandraAttachmentDAOV2::fromRow));
}
- public CompletableFuture<Void> storeAttachment(DAOAttachmentModel attachment) {
+ public CompletableFuture<Void> storeAttachment(DAOAttachment attachment) {
return cassandraAsyncExecutor.executeVoid(
insertStatement.bind()
.setUUID(ID_AS_UUID, attachment.getAttachmentId().asUUID())
http://git-wip-us.apache.org/repos/asf/james-project/blob/c3e5598c/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java
index 46db802..ee2e5d1 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentMapper.java
@@ -28,7 +28,7 @@ import java.util.stream.Stream;
import javax.inject.Inject;
-import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentDAOV2.DAOAttachmentModel;
+import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentDAOV2.DAOAttachment;
import org.apache.james.mailbox.exception.AttachmentNotFoundException;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.Attachment;
@@ -75,13 +75,13 @@ public class CassandraAttachmentMapper implements AttachmentMapper {
}
@Nullable
- private CompletionStage<Optional<Attachment>> retrievePayload(Optional<DAOAttachmentModel> optionalModel) {
- if (!optionalModel.isPresent()) {
+ private CompletionStage<Optional<Attachment>> retrievePayload(Optional<DAOAttachment> daoAttachmentOptional) {
+ if (!daoAttachmentOptional.isPresent()) {
return CompletableFuture.completedFuture(Optional.empty());
}
- DAOAttachmentModel model = optionalModel.get();
- return blobsDAO.read(model.getBlobId())
- .thenApply(bytes -> Optional.of(model.toAttachment(bytes)));
+ DAOAttachment daoAttachment = daoAttachmentOptional.get();
+ return blobsDAO.read(daoAttachment.getBlobId())
+ .thenApply(bytes -> Optional.of(daoAttachment.toAttachment(bytes)));
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/c3e5598c/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2Test.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2Test.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2Test.java
index 82b66e0..84e19bc 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2Test.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraAttachmentDAOV2Test.java
@@ -27,7 +27,7 @@ import java.util.Optional;
import org.apache.james.backends.cassandra.CassandraCluster;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.mailbox.cassandra.ids.BlobId;
-import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentDAOV2.DAOAttachmentModel;
+import org.apache.james.mailbox.cassandra.mail.CassandraAttachmentDAOV2.DAOAttachment;
import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
import org.apache.james.mailbox.model.Attachment;
import org.apache.james.mailbox.model.AttachmentId;
@@ -63,7 +63,7 @@ public class CassandraAttachmentDAOV2Test {
@Test
public void getAttachmentShouldReturnEmptyWhenAbsent() {
- Optional<DAOAttachmentModel> attachment = testee.getAttachment(ATTACHMENT_ID).join();
+ Optional<DAOAttachment> attachment = testee.getAttachment(ATTACHMENT_ID).join();
assertThat(attachment).isEmpty();
}
@@ -76,11 +76,11 @@ public class CassandraAttachmentDAOV2Test {
.bytes("{\"property\":`\"value\"}".getBytes(StandardCharsets.UTF_8))
.build();
BlobId blobId = BlobId.from("blobId");
- DAOAttachmentModel model = CassandraAttachmentDAOV2.from(attachment, blobId);
- testee.storeAttachment(model).join();
+ DAOAttachment daoAttachment = CassandraAttachmentDAOV2.from(attachment, blobId);
+ testee.storeAttachment(daoAttachment).join();
- Optional<DAOAttachmentModel> actual = testee.getAttachment(ATTACHMENT_ID).join();
+ Optional<DAOAttachment> actual = testee.getAttachment(ATTACHMENT_ID).join();
- assertThat(actual).contains(model);
+ assertThat(actual).contains(daoAttachment);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org