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/11/28 02:12:40 UTC

[james-project] 23/23: JAMES-2988 Use the smallest fetch group possible upon GetMessages

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 e8c2f63ac4ce7414db349cee066a2ea00511d23c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Wed Nov 27 03:16:04 2019 +0100

    JAMES-2988 Use the smallest fetch group possible upon GetMessages
---
 .../james/jmap/draft/methods/GetMessagesMethod.java      |  3 +--
 .../apache/james/jmap/draft/model/MessageProperties.java | 16 ++++++++++++----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessagesMethod.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessagesMethod.java
index 01c2c25..f4a8315 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessagesMethod.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessagesMethod.java
@@ -39,7 +39,6 @@ import org.apache.james.jmap.draft.model.message.view.MetaMessageViewFactory;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageIdManager;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.model.FetchGroup;
 import org.apache.james.mailbox.model.MessageResult;
 import org.apache.james.metrics.api.MetricFactory;
 import org.apache.james.util.MDCBuilder;
@@ -128,7 +127,7 @@ public class GetMessagesMethod implements Method {
 
             return GetMessagesResponse.builder()
                 .messages(
-                    messageIdManager.getMessages(getMessagesRequest.getIds(), FetchGroup.FULL_CONTENT, mailboxSession)
+                    messageIdManager.getMessages(getMessagesRequest.getIds(), readProfile.getFetchGroup(), mailboxSession)
                         .stream()
                         .collect(Guavate.toImmutableListMultimap(MessageResult::getMessageId))
                         .asMap()
diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/MessageProperties.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/MessageProperties.java
index b2cadee..12fa16a 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/MessageProperties.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/model/MessageProperties.java
@@ -24,6 +24,8 @@ import java.util.Objects;
 import java.util.Optional;
 import java.util.stream.Stream;
 
+import org.apache.james.mailbox.model.FetchGroup;
+
 import com.github.steveash.guavate.Guavate;
 import com.google.common.base.MoreObjects;
 import com.google.common.base.Preconditions;
@@ -213,9 +215,9 @@ public class MessageProperties {
     }
 
     public enum ReadProfile {
-        Metadata(0),
-        Header(1),
-        Full(2);
+        Metadata(0, FetchGroup.MINIMAL),
+        Header(1, FetchGroup.HEADERS),
+        Full(2, FetchGroup.FULL_CONTENT);
 
         static ReadProfile combine(ReadProfile readProfile1, ReadProfile readProfile2) {
             if (readProfile1.priority > readProfile2.priority) {
@@ -225,9 +227,15 @@ public class MessageProperties {
         }
 
         private final int priority;
+        private final FetchGroup fetchGroup;
 
-        ReadProfile(int priority) {
+        ReadProfile(int priority, FetchGroup fetchGroup) {
             this.priority = priority;
+            this.fetchGroup = fetchGroup;
+        }
+
+        public FetchGroup getFetchGroup() {
+            return fetchGroup;
         }
     }
 


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