You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2020/11/20 02:18:13 UTC

[james-project] 07/18: [Refactoring] Fix indent in GetMessageListMethod

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 9dff3ba90a9aaca95fbf2147870e7b689f66c90a
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Nov 17 11:34:19 2020 +0700

    [Refactoring] Fix indent in GetMessageListMethod
---
 .../jmap/draft/methods/GetMessageListMethod.java   | 81 +++++++++++-----------
 1 file changed, 40 insertions(+), 41 deletions(-)

diff --git a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessageListMethod.java b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessageListMethod.java
index 5935b79..69d64d5e 100644
--- a/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessageListMethod.java
+++ b/server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/GetMessageListMethod.java
@@ -64,7 +64,6 @@ import reactor.core.publisher.Mono;
 import reactor.core.scheduler.Schedulers;
 
 public class GetMessageListMethod implements Method {
-
     private static final long DEFAULT_POSITION = 0;
     public static final String MAXIMUM_LIMIT = "maximumLimit";
     public static final long DEFAULT_MAXIMUM_LIMIT = 256;
@@ -137,28 +136,28 @@ public class GetMessageListMethod implements Method {
 
     private Flux<JmapResponse> process(MethodCallId methodCallId, MailboxSession mailboxSession, GetMessageListRequest messageListRequest) {
         return getMessageListResponse(messageListRequest, mailboxSession)
-                .flatMapMany(messageListResponse -> Flux.concat(
-                    Mono.just(JmapResponse.builder().methodCallId(methodCallId)
-                        .response(messageListResponse)
-                        .responseName(RESPONSE_NAME)
-                        .build()),
-                    processGetMessages(messageListRequest, messageListResponse, methodCallId, mailboxSession)))
-                .onErrorResume(NotImplementedException.class, e -> Mono.just(JmapResponse.builder()
-                    .methodCallId(methodCallId)
-                    .responseName(RESPONSE_NAME)
-                    .error(ErrorResponse.builder()
-                        .type("invalidArguments")
-                        .description(e.getMessage())
-                        .build())
-                    .build()))
-                .onErrorResume(Filter.TooDeepFilterHierarchyException.class, e -> Mono.just(JmapResponse.builder()
-                    .methodCallId(methodCallId)
+            .flatMapMany(messageListResponse -> Flux.concat(
+                Mono.just(JmapResponse.builder().methodCallId(methodCallId)
+                    .response(messageListResponse)
                     .responseName(RESPONSE_NAME)
-                    .error(ErrorResponse.builder()
-                        .type("invalidArguments")
-                        .description(e.getMessage())
-                        .build())
-                    .build()));
+                    .build()),
+                processGetMessages(messageListRequest, messageListResponse, methodCallId, mailboxSession)))
+            .onErrorResume(NotImplementedException.class, e -> Mono.just(JmapResponse.builder()
+                .methodCallId(methodCallId)
+                .responseName(RESPONSE_NAME)
+                .error(ErrorResponse.builder()
+                    .type("invalidArguments")
+                    .description(e.getMessage())
+                    .build())
+                .build()))
+            .onErrorResume(Filter.TooDeepFilterHierarchyException.class, e -> Mono.just(JmapResponse.builder()
+                .methodCallId(methodCallId)
+                .responseName(RESPONSE_NAME)
+                .error(ErrorResponse.builder()
+                    .type("invalidArguments")
+                    .description(e.getMessage())
+                    .build())
+                .build()));
     }
 
     private Mono<GetMessageListResponse> getMessageListResponse(GetMessageListRequest messageListRequest, MailboxSession mailboxSession) {
@@ -232,9 +231,9 @@ public class GetMessageListMethod implements Method {
 
         SearchQuery.Builder searchQueryBuilder = SearchQuery.builder();
 
-            messageListRequest.getFilter()
-                .map(filter -> new FilterToCriteria().convert(filter).collect(Guavate.toImmutableList()))
-                .ifPresent(searchQueryBuilder::andCriteria);
+        messageListRequest.getFilter()
+            .map(filter -> new FilterToCriteria().convert(filter).collect(Guavate.toImmutableList()))
+            .ifPresent(searchQueryBuilder::andCriteria);
         Set<MailboxId> inMailboxes = buildFilterMailboxesSet(messageListRequest.getFilter(), FilterCondition::getInMailboxes);
         Set<MailboxId> notInMailboxes = buildFilterMailboxesSet(messageListRequest.getFilter(), FilterCondition::getNotInMailboxes);
         List<SearchQuery.Sort> sorts = SortConverter.convertToSorts(messageListRequest.getSort());
@@ -242,10 +241,10 @@ public class GetMessageListMethod implements Method {
             searchQueryBuilder.sorts(sorts);
         }
         return MultimailboxesSearchQuery
-                .from(searchQueryBuilder.build())
-                .inMailboxes(inMailboxes)
-                .notInMailboxes(notInMailboxes)
-                .build();
+            .from(searchQueryBuilder.build())
+            .inMailboxes(inMailboxes)
+            .notInMailboxes(notInMailboxes)
+            .build();
     }
 
     private boolean containsNestedMailboxFilters(Filter filter) {
@@ -276,28 +275,28 @@ public class GetMessageListMethod implements Method {
     
     private Stream<FilterCondition> filterToFilterCondition(Optional<Filter> maybeCondition) {
         return Guavate.stream(maybeCondition)
-                .flatMap(c -> {
-                    if (c instanceof FilterCondition) {
-                        return Stream.of((FilterCondition)c);
-                    }
-                    return Stream.of();
-                });
+            .flatMap(c -> {
+                if (c instanceof FilterCondition) {
+                    return Stream.of((FilterCondition)c);
+                }
+                return Stream.of();
+            });
     }
-    
+
     private Flux<JmapResponse> processGetMessages(GetMessageListRequest messageListRequest, GetMessageListResponse messageListResponse, MethodCallId methodCallId, MailboxSession mailboxSession) {
         if (shouldChainToGetMessages(messageListRequest)) {
             GetMessagesRequest getMessagesRequest = GetMessagesRequest.builder()
-                    .ids(messageListResponse.getMessageIds())
-                    .properties(messageListRequest.getFetchMessageProperties())
-                    .build();
+                .ids(messageListResponse.getMessageIds())
+                .properties(messageListRequest.getFetchMessageProperties())
+                .build();
             return getMessagesMethod.process(getMessagesRequest, methodCallId, mailboxSession);
         }
         return Flux.empty();
     }
 
     private boolean shouldChainToGetMessages(GetMessageListRequest messageListRequest) {
-        return messageListRequest.isFetchMessages().orElse(false) 
-                && !messageListRequest.isFetchThreads().orElse(false);
+        return messageListRequest.isFetchMessages().orElse(false)
+            && !messageListRequest.isFetchThreads().orElse(false);
     }
 
 }


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