james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [1/3] james-project git commit: JAMES-1945 Take into account the FetchType before composing with attachments
Date Mon, 20 Feb 2017 10:41:47 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 2dd366d2a -> 1f6b54942


JAMES-1945 Take into account the FetchType before composing with attachments


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

Branch: refs/heads/master
Commit: d0cbaf12580e914ceff2b2090e99eca206f18b5a
Parents: 2dd366d
Author: Benoit Tellier <btellier@linagora.com>
Authored: Mon Feb 20 08:22:05 2017 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Mon Feb 20 17:39:55 2017 +0700

----------------------------------------------------------------------
 .../cassandra/mail/CassandraMessageMapper.java  | 22 +++++++++++++-------
 1 file changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/d0cbaf12/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
index c36d9a0..c43f26b 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
@@ -162,14 +162,20 @@ public class CassandraMessageMapper implements MessageMapper {
     }
 
     private Stream<SimpleMailboxMessage> retrieveMessages(List<ComposedMessageIdWithMetaData>
messageIds, FetchType fetchType, Optional<Integer> limit) {
-        return messageDAO.retrieveMessages(messageIds, fetchType, limit).join()
-            .map(pair -> Pair.of(pair.getLeft(), new AttachmentLoader(attachmentMapper)
-                .getAttachments(pair.getRight()
-                    .collect(Guavate.toImmutableList()))))
-            .map(Throwing.function(pair -> pair.getLeft()
-                .toMailboxMessage(pair.getRight()
-                    .stream()
-                    .collect(Guavate.toImmutableList()))));
+        Stream<Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<CassandraMessageDAO.MessageAttachmentRepresentation>>>
+            messageRepresentions = messageDAO.retrieveMessages(messageIds, fetchType, limit).join();
+        if (fetchType == FetchType.Body || fetchType == FetchType.Full) {
+            return messageRepresentions
+                .map(pair -> Pair.of(pair.getLeft(), new AttachmentLoader(attachmentMapper)
+                    .getAttachments(pair.getRight()
+                        .collect(Guavate.toImmutableList()))))
+                .map(Throwing.function(pair -> pair.getLeft()
+                    .toMailboxMessage(pair.getRight()
+                        .stream()
+                        .collect(Guavate.toImmutableList()))));
+        } else {
+            return messageRepresentions.map(pair -> pair.getLeft().toMailboxMessage(ImmutableList.of()));
+        }
     }
 
     @Override


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