james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [19/22] james-project git commit: JAMES-1894 Let backend care about sorting by default
Date Wed, 11 Jan 2017 16:45:46 GMT
JAMES-1894 Let backend care about sorting by default


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

Branch: refs/heads/master
Commit: 0606d2ee1e6ae46e8fe2296c61cc5013d043e549
Parents: f6bc8be
Author: Benoit Tellier <btellier@linagora.com>
Authored: Fri Dec 23 17:57:38 2016 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Mon Jan 9 22:01:07 2017 +0700

----------------------------------------------------------------------
 .../org/apache/james/jmap/methods/GetMessageListMethod.java  | 5 ++++-
 .../main/java/org/apache/james/jmap/utils/SortConverter.java | 8 +-------
 .../java/org/apache/james/jmap/utils/SortConverterTest.java  | 4 ++--
 3 files changed, 7 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0606d2ee/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
index ee2593c..1d48e93 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
@@ -118,7 +118,10 @@ public class GetMessageListMethod implements Method {
                 .orElse(new SearchQuery());
         Set<MailboxId> inMailboxes = buildFilterMailboxesSet(messageListRequest.getFilter(),
FilterCondition::getInMailboxes);
         Set<MailboxId> notInMailboxes = buildFilterMailboxesSet(messageListRequest.getFilter(),
FilterCondition::getNotInMailboxes);
-        searchQuery.setSorts(SortConverter.convertToSorts(messageListRequest.getSort()));
+        List<SearchQuery.Sort> sorts = SortConverter.convertToSorts(messageListRequest.getSort());
+        if (!sorts.isEmpty()) {
+            searchQuery.setSorts(sorts);
+        }
         return MultimailboxesSearchQuery
                 .from(searchQuery)
                 .inMailboxes(inMailboxes)

http://git-wip-us.apache.org/repos/asf/james-project/blob/0606d2ee/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortConverter.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortConverter.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortConverter.java
index 74ad6a6..f9e2020 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortConverter.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortConverter.java
@@ -38,19 +38,13 @@ public class SortConverter {
     private static final Map<String, SearchQuery.Sort.SortClause> SORT_CLAUSE_MAP =
ImmutableMap.of(
         "date", SearchQuery.Sort.SortClause.Arrival,
         "id", SearchQuery.Sort.SortClause.Id);
-    public static final boolean REVERSE = true;
-    public static final SearchQuery.Sort DEFAULT_SORT = new SearchQuery.Sort(SearchQuery.Sort.SortClause.Arrival,
REVERSE);
 
 
     public static List<SearchQuery.Sort> convertToSorts(List<String> jmapSorts)
{
         Preconditions.checkNotNull(jmapSorts);
-        ImmutableList<SearchQuery.Sort> result = jmapSorts.stream()
+        return jmapSorts.stream()
             .map(SortConverter::toSort)
             .collect(Guavate.toImmutableList());
-        if (result.isEmpty()) {
-            return ImmutableList.of(DEFAULT_SORT);
-        }
-        return result;
     }
 
     private static SearchQuery.Sort toSort(String jmapSort) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/0606d2ee/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortConverterTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortConverterTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortConverterTest.java
index bcd48ae..eb79e61 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortConverterTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortConverterTest.java
@@ -45,9 +45,9 @@ public class SortConverterTest {
     }
 
     @Test
-    public void convertToSortsShouldReturnDefaultSortOnEmptyEntry() {
+    public void convertToSortsShouldReturnEmptyOnEmptyEntry() {
         assertThat(SortConverter.convertToSorts(ImmutableList.of()))
-            .containsOnly(new SearchQuery.Sort(SearchQuery.Sort.SortClause.Arrival, REVERSE));
+            .isEmpty();
     }
 
     @Test


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