james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [19/41] james-project git commit: JAMES-2082 Extract UDT generation for readability in CassandraMessageDAOV2
Date Mon, 10 Jul 2017 17:54:31 GMT
JAMES-2082 Extract UDT generation for readability in CassandraMessageDAOV2


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e5a1a355
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e5a1a355
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e5a1a355

Branch: refs/heads/master
Commit: e5a1a355cbede74da43b84bbbe8a97198cb30286
Parents: 9c46faa
Author: benwa <btellier@linagora.com>
Authored: Fri Jul 7 08:24:42 2017 +0700
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Mon Jul 10 14:23:57 2017 +0200

----------------------------------------------------------------------
 .../cassandra/mail/CassandraMessageDAOV2.java   | 29 +++++++++++++-------
 1 file changed, 19 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e5a1a355/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
index ad126fc..14d1d08 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
@@ -84,6 +84,7 @@ import com.datastax.driver.core.UDTValue;
 import com.datastax.driver.core.querybuilder.QueryBuilder;
 import com.github.steveash.guavate.Guavate;
 import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableList;
 import com.google.common.primitives.Bytes;
 
 public class CassandraMessageDAOV2 {
@@ -180,16 +181,24 @@ public class CassandraMessageDAOV2 {
             .setString(BODY_CONTENT, pair.getLeft().map(BlobId::getId).orElse(DEFAULT_OBJECT_VALUE))
             .setString(HEADER_CONTENT, pair.getRight().map(BlobId::getId).orElse(DEFAULT_OBJECT_VALUE))
             .setLong(TEXTUAL_LINE_COUNT, Optional.ofNullable(message.getTextualLineCount()).orElse(DEFAULT_LONG_VALUE))
-            .setList(PROPERTIES, message.getProperties().stream()
-                .map(x -> typesProvider.getDefinedUserType(PROPERTIES)
-                    .newValue()
-                    .setString(Properties.NAMESPACE, x.getNamespace())
-                    .setString(Properties.NAME, x.getLocalName())
-                    .setString(Properties.VALUE, x.getValue()))
-                .collect(Collectors.toList()))
-            .setList(ATTACHMENTS, message.getAttachments().stream()
-                .map(this::toUDT)
-                .collect(Guavate.toImmutableList()));
+            .setList(PROPERTIES, buildPropertiesUdt(message))
+            .setList(ATTACHMENTS, buildAttachmentUdt(message));
+    }
+
+    private ImmutableList<UDTValue> buildAttachmentUdt(MailboxMessage message) {
+        return message.getAttachments().stream()
+            .map(this::toUDT)
+            .collect(Guavate.toImmutableList());
+    }
+
+    private List<UDTValue> buildPropertiesUdt(MailboxMessage message) {
+        return message.getProperties().stream()
+            .map(x -> typesProvider.getDefinedUserType(PROPERTIES)
+                .newValue()
+                .setString(Properties.NAMESPACE, x.getNamespace())
+                .setString(Properties.NAME, x.getLocalName())
+                .setString(Properties.VALUE, x.getValue()))
+            .collect(Guavate.toImmutableList());
     }
 
     private UDTValue toUDT(MessageAttachment messageAttachment) {


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message