james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [2/3] james-project git commit: JAMES-1945 Also take FetchType into account for attachments into CassandraMessageIdMapper
Date Mon, 20 Feb 2017 10:41:48 GMT
JAMES-1945 Also take FetchType into account for attachments into CassandraMessageIdMapper


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

Branch: refs/heads/master
Commit: 124749a37f8ceb3d7ae41941234a1f6b3ef490ad
Parents: d0cbaf1
Author: Benoit Tellier <btellier@linagora.com>
Authored: Mon Feb 20 09:00:47 2017 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Mon Feb 20 17:40:00 2017 +0700

----------------------------------------------------------------------
 .../cassandra/mail/CassandraMessageIdMapper.java    | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/124749a3/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
index 61045d1..eec9340 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
@@ -98,7 +98,7 @@ public class CassandraMessageIdMapper implements MessageIdMapper {
             .collect(Guavate.toImmutableList());
         return messageDAO.retrieveMessages(composedMessageIds, fetchType, Optional.empty()).join()
             .filter(pair -> mailboxExists(pair.getLeft()))
-            .map(loadAttachments())
+            .map(loadAttachments(fetchType))
             .map(toMailboxMessages())
             .sorted(Comparator.comparing(MailboxMessage::getUid));
     }
@@ -113,11 +113,15 @@ public class CassandraMessageIdMapper implements MessageIdMapper {
         }
     }
 
-    private Function<Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<CassandraMessageDAO.MessageAttachmentRepresentation>>,
Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<MessageAttachment>>>
loadAttachments() {
-        return pair -> Pair.of(pair.getLeft(),
-            new AttachmentLoader(attachmentMapper)
-                .getAttachments(pair.getRight().collect(Guavate.toImmutableList()))
-                .stream());
+    private Function<Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<CassandraMessageDAO.MessageAttachmentRepresentation>>,
Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<MessageAttachment>>>
loadAttachments(FetchType fetchType) {
+        if (fetchType == FetchType.Full || fetchType == FetchType.Body) {
+            return pair -> Pair.of(pair.getLeft(),
+                new AttachmentLoader(attachmentMapper)
+                    .getAttachments(pair.getRight().collect(Guavate.toImmutableList()))
+                    .stream());
+        } else {
+            return pair -> Pair.of(pair.getLeft(), Stream.of());
+        }
     }
 
     private FunctionChainer<Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<MessageAttachment>>,
SimpleMailboxMessage> toMailboxMessages() {


---------------------------------------------------------------------
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