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 ma...@apache.org on 2016/07/25 08:33:52 UTC

[1/8] james-project git commit: MAILBOX-273 MessageSearchIndex doesn't have an Id parameter

Repository: james-project
Updated Branches:
  refs/heads/master 0ea95c34b -> e456c0733


MAILBOX-273 MessageSearchIndex doesn't have an Id parameter


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

Branch: refs/heads/master
Commit: 55b1476c4b6a288f16073a3e402b6a06cb9aca83
Parents: 0ea95c3
Author: Matthieu Baechler <ma...@linagora.com>
Authored: Mon Jul 18 13:21:01 2016 +0200
Committer: Raphael Ouazana <ra...@linagora.com>
Committed: Thu Jul 21 10:21:03 2016 +0200

----------------------------------------------------------------------
 .../org/apache/james/mailbox/store/search/MessageSearchIndex.java  | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/55b1476c/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
index 459af2c..c3ed9dd 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
@@ -32,8 +32,6 @@ import org.apache.james.mailbox.store.mail.model.Mailbox;
  * 
  * A developer should think of building an inverse-index for that.
  * 
- *
- * @param <Id>
  */
 public interface MessageSearchIndex {
     


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


[7/8] james-project git commit: MAILBOX-273 require multimailbox search capability for jmap

Posted by ma...@apache.org.
MAILBOX-273 require multimailbox search capability for jmap


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

Branch: refs/heads/master
Commit: 7a6a4c193d35b23ff2e4e326a858b9be237a44ef
Parents: 41cd544
Author: Matthieu Baechler <ma...@linagora.com>
Authored: Tue Jul 19 18:35:31 2016 +0200
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Mon Jul 25 10:13:31 2016 +0200

----------------------------------------------------------------------
 .../org/apache/james/mailbox/MailboxManager.java    |  6 ++++++
 .../ElasticSearchListeningMessageSearchIndex.java   |  7 +++++++
 .../lucene/search/LuceneMessageSearchIndex.java     |  8 ++++++++
 .../james/mailbox/store/StoreMailboxManager.java    |  6 ++++++
 .../store/search/LazyMessageSearchIndex.java        |  7 +++++++
 .../mailbox/store/search/MessageSearchIndex.java    |  4 ++++
 .../store/search/SimpleMessageSearchIndex.java      |  7 +++++++
 .../processor/base/MailboxEventAnalyserTest.java    |  5 +++++
 .../apache/james/JamesCapabilitiesServerTest.java   | 16 ++++++++++++++++
 .../main/java/org/apache/james/jmap/JMAPModule.java |  2 ++
 .../jmap/FirstUserConnectionFilterThreadTest.java   |  5 +++++
 11 files changed, 73 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/7a6a4c19/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
index 1d60bcf..8cc0ea6 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
@@ -88,7 +88,13 @@ public interface MailboxManager extends RequestAware, MailboxListenerSupport {
     }
 
     EnumSet<MessageCapabilities> getSupportedMessageCapabilities();
+
+    enum SearchCapabilities {
+        MultimailboxSearch
+    }
     
+    EnumSet<SearchCapabilities> getSupportedSearchCapabilities();
+
     
     /**
      * Return the delimiter to use for folders

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a6a4c19/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
index b967e7c..dc7e301 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.elasticsearch.events;
 import static org.elasticsearch.index.query.QueryBuilders.termQuery;
 
 import java.util.Collection;
+import java.util.EnumSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -29,6 +30,7 @@ import java.util.stream.Collectors;
 import javax.inject.Inject;
 
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MailboxManager.SearchCapabilities;
 import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
 import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
 import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
@@ -72,6 +74,11 @@ public class ElasticSearchListeningMessageSearchIndex extends ListeningMessageSe
     }
 
     @Override
+    public EnumSet<SearchCapabilities> getSupportedCapabilities() {
+        return EnumSet.of(SearchCapabilities.MultimailboxSearch);
+    }
+    
+    @Override
     public Iterator<Long> search(MailboxSession session, Mailbox mailbox, SearchQuery searchQuery) throws MailboxException {
         MailboxId mailboxId = mailbox.getMailboxId();
         return searcher

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a6a4c19/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
index 13ce4ac..9eb0388 100644
--- a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
+++ b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
@@ -28,6 +28,7 @@ import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collection;
 import java.util.Date;
+import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -39,6 +40,7 @@ import java.util.TimeZone;
 import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 
+import org.apache.james.mailbox.MailboxManager.SearchCapabilities;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.UnsupportedSearchException;
@@ -366,6 +368,12 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
         return ListenerType.EACH_NODE;
     }
 
+
+    @Override
+    public EnumSet<SearchCapabilities> getSupportedCapabilities() {
+        return EnumSet.noneOf(SearchCapabilities.class);
+    }
+    
     /**
      * Set the max count of results which will get returned from a query. The default is {@link #DEFAULT_MAX_QUERY_RESULTS}
      * 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a6a4c19/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
index 1d671af..84f24ae 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
@@ -209,6 +209,12 @@ public class StoreMailboxManager implements MailboxManager {
         return EnumSet.noneOf(MessageCapabilities.class);
     }
     
+    @Override
+    public EnumSet<SearchCapabilities> getSupportedSearchCapabilities() {
+        return index.getSupportedCapabilities();
+    }
+    
+
     /**
      * Return the {@link DelegatingMailboxListener} which is used by this {@link MailboxManager}
      *

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a6a4c19/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
index 82704f9..4096c8e 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
@@ -19,11 +19,13 @@
 package org.apache.james.mailbox.store.search;
 
 import java.util.Collection;
+import java.util.EnumSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
+import org.apache.james.mailbox.MailboxManager.SearchCapabilities;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.UnsupportedSearchException;
@@ -60,6 +62,11 @@ public class LazyMessageSearchIndex extends ListeningMessageSearchIndex {
     public ListenerType getType() {
         return index.getType();
     }
+    
+    @Override
+    public EnumSet<SearchCapabilities> getSupportedCapabilities() {
+        return EnumSet.noneOf(SearchCapabilities.class);
+    }
 
     @Override
     public void add(MailboxSession session, Mailbox mailbox, MailboxMessage message) throws MailboxException {

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a6a4c19/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
index b120b3a..3dcfcca 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
@@ -20,9 +20,11 @@
 package org.apache.james.mailbox.store.search;
 
 import java.util.Collection;
+import java.util.EnumSet;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxId;
@@ -49,4 +51,6 @@ public interface MessageSearchIndex {
      */
     Map<MailboxId, Collection<Long>> search(MailboxSession session, MultimailboxesSearchQuery searchQuery) throws MailboxException;
 
+    EnumSet<MailboxManager.SearchCapabilities> getSupportedCapabilities();
+
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a6a4c19/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
index e4712c2..4a2e8d1 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
@@ -19,6 +19,7 @@
 package org.apache.james.mailbox.store.search;
 
 import java.util.Collection;
+import java.util.EnumSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -27,6 +28,7 @@ import java.util.TreeSet;
 
 import javax.inject.Inject;
 
+import org.apache.james.mailbox.MailboxManager.SearchCapabilities;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.UnsupportedSearchException;
@@ -61,6 +63,11 @@ public class SimpleMessageSearchIndex implements MessageSearchIndex {
         this.factory = factory;
     }
     
+    @Override
+    public EnumSet<SearchCapabilities> getSupportedCapabilities() {
+        return EnumSet.noneOf(SearchCapabilities.class);
+    }
+    
     /**
      * Walks down the query tree's conjunctions to find a UidCriterion
      * @param crits - list of Criterion to search from

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a6a4c19/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
index 036ad33..29a6643 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
@@ -87,6 +87,11 @@ public class MailboxEventAnalyserTest {
             return EnumSet.noneOf(MessageCapabilities.class);
         }
         
+        @Override
+        public EnumSet<SearchCapabilities> getSupportedSearchCapabilities() {
+            return EnumSet.noneOf(SearchCapabilities.class);
+        }
+        
         public boolean hasCapability(MailboxCapabilities capability) {
             return false;
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a6a4c19/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
index b0f9feb..3eeeff8 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
@@ -106,6 +106,20 @@ public class JamesCapabilitiesServerTest {
 
         assertThatThrownBy(() -> server.start()).isInstanceOf(IllegalArgumentException.class);
     }
+    
+    @Test
+    public void startShouldFailWhenNoMultimailboxSearchCapability() throws Exception {
+        MailboxManager mailboxManager = mock(MailboxManager.class);
+        when(mailboxManager.getSupportedMailboxCapabilities())
+            .thenReturn(EnumSet.allOf(MailboxManager.MailboxCapabilities.class));
+        when(mailboxManager.getSupportedMessageCapabilities())
+            .thenReturn(EnumSet.allOf(MailboxManager.MessageCapabilities.class));
+        when(mailboxManager.getSupportedSearchCapabilities())
+            .thenReturn(EnumSet.noneOf(MailboxManager.SearchCapabilities.class));
+        server = createCassandraJamesServer(mailboxManager);
+
+        assertThatThrownBy(() -> server.start()).isInstanceOf(IllegalArgumentException.class);
+    }
 
     @Test
     public void startShouldSucceedWhenRequiredCapabilities() throws Exception {
@@ -113,6 +127,8 @@ public class JamesCapabilitiesServerTest {
         when(mailboxManager.hasCapability(MailboxManager.MailboxCapabilities.Move)).thenReturn(true);
         when(mailboxManager.getSupportedMessageCapabilities())
             .thenReturn(EnumSet.of(MailboxManager.MessageCapabilities.Attachment));
+        when(mailboxManager.getSupportedSearchCapabilities())
+            .thenReturn(EnumSet.of(MailboxManager.SearchCapabilities.MultimailboxSearch));
         server = createCassandraJamesServer(mailboxManager);
 
         server.start();

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a6a4c19/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java b/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java
index 247c70d..93bb11c 100644
--- a/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java
+++ b/server/container/guice/guice-common/src/main/java/org/apache/james/jmap/JMAPModule.java
@@ -106,6 +106,8 @@ public class JMAPModule extends AbstractModule {
                     "MOVE support in MailboxManager is required by JMAP Module");
             Preconditions.checkArgument(mailboxManager.getSupportedMessageCapabilities().contains(MailboxManager.MessageCapabilities.Attachment),
                     "Attachment support in MailboxManager is required by JMAP Module");
+            Preconditions.checkArgument(mailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.MultimailboxSearch),
+                    "Multimailbox search in MailboxManager is required by JMAP Module");
         }
 
         @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/7a6a4c19/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
index 8dc4628..8b4c273 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
@@ -92,6 +92,11 @@ public class FirstUserConnectionFilterThreadTest {
         }
 
         @Override
+        public EnumSet<SearchCapabilities> getSupportedSearchCapabilities() {
+            return EnumSet.noneOf(SearchCapabilities.class);
+        }
+        
+        @Override
         public void startProcessingRequest(MailboxSession session) {
         }
 


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


[3/8] james-project git commit: MAILBOX-273 reorder lucene dependencies

Posted by ma...@apache.org.
MAILBOX-273 reorder lucene dependencies


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

Branch: refs/heads/master
Commit: 72ace6a16b8f498dd6feef3d93e0b83d7b70e961
Parents: 73b2da0
Author: Matthieu Baechler <ma...@linagora.com>
Authored: Mon Jul 18 15:20:33 2016 +0200
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Mon Jul 25 10:13:29 2016 +0200

----------------------------------------------------------------------
 mailbox/lucene/pom.xml | 56 ++++++++++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/72ace6a1/mailbox/lucene/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/lucene/pom.xml b/mailbox/lucene/pom.xml
index 4a8cbc5..5edac5e 100644
--- a/mailbox/lucene/pom.xml
+++ b/mailbox/lucene/pom.xml
@@ -38,7 +38,24 @@
         </dependency>
         <dependency>
             <groupId>org.apache.james</groupId>
+            <artifactId>apache-james-mailbox-api</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>apache-james-mailbox-memory</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
+            <artifactId>apache-james-mailbox-store</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.james</groupId>
             <artifactId>apache-james-mailbox-store</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.james</groupId>
@@ -49,13 +66,22 @@
             <artifactId>apache-mime4j-dom</artifactId>
         </dependency>
         <dependency>
+            <groupId>${javax.mail.groupId}</groupId>
+            <artifactId>${javax.mail.artifactId}</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>org.apache.lucene</groupId>
-            <artifactId>lucene-core</artifactId>
+            <artifactId>lucene-analyzers</artifactId>
             <version>${lucene.version}</version>
         </dependency>
         <dependency>
             <groupId>org.apache.lucene</groupId>
-            <artifactId>lucene-analyzers</artifactId>
+            <artifactId>lucene-core</artifactId>
             <version>${lucene.version}</version>
         </dependency>
         <dependency>
@@ -73,32 +99,6 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
-        <dependency>
-            <groupId>${javax.mail.groupId}</groupId>
-            <artifactId>${javax.mail.artifactId}</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-james-mailbox-api</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-james-mailbox-memory</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.james</groupId>
-            <artifactId>apache-james-mailbox-store</artifactId>
-            <type>test-jar</type>
-            <scope>test</scope>
-        </dependency>
     </dependencies>
     <profiles>
         <profile>


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


[2/8] james-project git commit: MAILBOX-273 move MailboxId to mailbox-api project

Posted by ma...@apache.org.
MAILBOX-273 move MailboxId to mailbox-api project


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

Branch: refs/heads/master
Commit: 73b2da08b5239ace21b1a4b950945c4187c515fe
Parents: 55b1476
Author: Matthieu Baechler <ma...@linagora.com>
Authored: Mon Jul 18 14:13:11 2016 +0200
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Mon Jul 25 10:13:29 2016 +0200

----------------------------------------------------------------------
 .../apache/james/mailbox/model/MailboxId.java   | 23 ++++++++++++++++++++
 .../CachingMailboxSessionMapperFactory.java     |  2 +-
 .../guava/GuavaMailboxMetadataCache.java        |  2 +-
 .../james/mailbox/cassandra/CassandraId.java    |  2 +-
 .../CassandraMailboxSessionMapperFactory.java   |  2 +-
 .../org/apache/james/mailbox/hbase/HBaseId.java |  2 +-
 .../hbase/HBaseMailboxSessionMapperFactory.java |  2 +-
 .../org/apache/james/mailbox/jcr/JCRId.java     |  2 +-
 .../jcr/JCRMailboxSessionMapperFactory.java     |  2 +-
 .../org/apache/james/mailbox/jpa/JPAId.java     |  2 +-
 .../jpa/JPAMailboxSessionMapperFactory.java     |  2 +-
 .../apache/james/mailbox/maildir/MaildirId.java |  2 +-
 .../MaildirMailboxSessionMapperFactory.java     |  2 +-
 .../james/mailbox/inmemory/InMemoryId.java      |  2 +-
 .../InMemoryMailboxSessionMapperFactory.java    |  2 +-
 .../store/MailboxSessionMapperFactory.java      |  2 +-
 .../store/mail/model/DefaultMessageId.java      |  2 ++
 .../james/mailbox/store/mail/model/Mailbox.java |  1 +
 .../mailbox/store/mail/model/MailboxId.java     | 23 --------------------
 .../store/mail/model/MailboxIdDeserializer.java |  2 ++
 .../store/mail/model/MailboxMessage.java        |  2 ++
 .../store/mail/model/impl/SimpleMailbox.java    |  2 +-
 .../mail/model/impl/SimpleMailboxMessage.java   |  2 +-
 .../store/search/LazyMessageSearchIndex.java    |  2 +-
 .../StoreMailboxManagerAnnotationTest.java      |  2 +-
 .../org/apache/james/mailbox/store/TestId.java  |  2 +-
 .../store/mail/model/MapperProvider.java        |  1 +
 .../store/mail/model/MessageMapperTest.java     |  1 +
 .../store/mail/model/MessageMoveTest.java       |  1 +
 .../mailbox/store/mail/ZooUidProvider.java      |  2 +-
 .../mailbox/store/mail/ZooUidProviderTest.java  |  2 +-
 .../integration/GetMessageListMethodTest.java   |  2 +-
 .../methods/SetMessagesCreationProcessor.java   |  2 +-
 .../jmap/utils/SortToComparatorConvertor.java   |  2 +-
 .../james/jmap/utils/MailboxUtilsTest.java      |  2 +-
 35 files changed, 59 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxId.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxId.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxId.java
new file mode 100644
index 0000000..7410b4e
--- /dev/null
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxId.java
@@ -0,0 +1,23 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.mailbox.model;
+
+public interface MailboxId {
+    String serialize();
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java
index 2b9ee48..2c5d7b3 100644
--- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java
+++ b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java
@@ -4,13 +4,13 @@ import org.apache.commons.lang.NotImplementedException;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.SubscriptionException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapper;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.NoopAttachmentMapper;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java
----------------------------------------------------------------------
diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java
index 3a49878..3d539ad 100644
--- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java
+++ b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java
@@ -2,9 +2,9 @@ package org.apache.james.mailbox.caching.guava;
 
 import org.apache.james.mailbox.caching.MailboxMetadataCache;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 
 import com.google.common.cache.Cache;
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java
index c8d32ac..76088d8 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java
@@ -20,7 +20,7 @@ package org.apache.james.mailbox.cassandra;
 
 import java.util.UUID;
 
-import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxId;
 
 import com.datastax.driver.core.utils.UUIDs;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
index 639db36..0c099c7 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
@@ -29,13 +29,13 @@ import org.apache.james.mailbox.cassandra.mail.CassandraMailboxMapper;
 import org.apache.james.mailbox.cassandra.mail.CassandraMessageMapper;
 import org.apache.james.mailbox.cassandra.user.CassandraSubscriptionMapper;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapper;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.UidProvider;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 
 import com.datastax.driver.core.Session;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseId.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseId.java b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseId.java
index 7528187..586bec1 100644
--- a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseId.java
+++ b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseId.java
@@ -21,7 +21,7 @@ package org.apache.james.mailbox.hbase;
 import java.util.UUID;
 
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxId;
 
 public class HBaseId implements MailboxId {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java
index b2972a2..864b6a0 100644
--- a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java
+++ b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java
@@ -43,6 +43,7 @@ import org.apache.james.mailbox.exception.SubscriptionException;
 import org.apache.james.mailbox.hbase.mail.HBaseMailboxMapper;
 import org.apache.james.mailbox.hbase.mail.HBaseMessageMapper;
 import org.apache.james.mailbox.hbase.user.HBaseSubscriptionMapper;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapper;
@@ -51,7 +52,6 @@ import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.NoopAttachmentMapper;
 import org.apache.james.mailbox.store.mail.UidProvider;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRId.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRId.java b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRId.java
index 438068d..08851b0 100644
--- a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRId.java
+++ b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRId.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.james.mailbox.jcr;
 
-import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxId;
 
 public class JCRId implements MailboxId {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java
index 6fb5e43..030230f 100644
--- a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java
+++ b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java
@@ -25,6 +25,7 @@ import org.apache.james.mailbox.exception.SubscriptionException;
 import org.apache.james.mailbox.jcr.mail.JCRMailboxMapper;
 import org.apache.james.mailbox.jcr.mail.JCRMessageMapper;
 import org.apache.james.mailbox.jcr.user.JCRSubscriptionMapper;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapper;
@@ -33,7 +34,6 @@ import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.NoopAttachmentMapper;
 import org.apache.james.mailbox.store.mail.UidProvider;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAId.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAId.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAId.java
index 25696ad..8a5eb88 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAId.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAId.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.james.mailbox.jpa;
 
-import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxId;
 
 public class JPAId implements MailboxId {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java
index 9485ef5..1b64f43 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java
@@ -27,6 +27,7 @@ import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.jpa.mail.JPAMailboxMapper;
 import org.apache.james.mailbox.jpa.mail.JPAMessageMapper;
 import org.apache.james.mailbox.jpa.user.JPASubscriptionMapper;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapper;
@@ -35,7 +36,6 @@ import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.NoopAttachmentMapper;
 import org.apache.james.mailbox.store.mail.UidProvider;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirId.java
----------------------------------------------------------------------
diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirId.java b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirId.java
index d60b155..2142e18 100644
--- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirId.java
+++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirId.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.james.mailbox.maildir;
 
-import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxId;
 
 public class MaildirId implements MailboxId {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java
index b129071..cd3b3df 100644
--- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java
+++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java
@@ -25,13 +25,13 @@ import org.apache.james.mailbox.exception.SubscriptionException;
 import org.apache.james.mailbox.maildir.mail.MaildirMailboxMapper;
 import org.apache.james.mailbox.maildir.mail.MaildirMessageMapper;
 import org.apache.james.mailbox.maildir.user.MaildirSubscriptionMapper;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapper;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.NoopAttachmentMapper;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 
 public class MaildirMailboxSessionMapperFactory extends

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java
index 46cf277..51602d5 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.james.mailbox.inmemory;
 
-import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxId;
 
 public class InMemoryId implements MailboxId {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java
index fe70b1c..f3b0a9f 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java
@@ -28,12 +28,12 @@ import org.apache.james.mailbox.inmemory.mail.InMemoryMessageMapper;
 import org.apache.james.mailbox.inmemory.mail.InMemoryModSeqProvider;
 import org.apache.james.mailbox.inmemory.mail.InMemoryUidProvider;
 import org.apache.james.mailbox.inmemory.user.InMemorySubscriptionMapper;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapper;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.MessageMapper;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 
 public class InMemoryMailboxSessionMapperFactory extends MailboxSessionMapperFactory {

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/main/java/org/apache/james/mailbox/store/MailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/MailboxSessionMapperFactory.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/MailboxSessionMapperFactory.java
index 383c3a3..5c4659f 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/MailboxSessionMapperFactory.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/MailboxSessionMapperFactory.java
@@ -22,6 +22,7 @@ import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.RequestAware;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.SubscriptionException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapperFactory;
@@ -29,7 +30,6 @@ import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.MessageMapperFactory;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.transaction.Mapper;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 import org.apache.james.mailbox.store.user.SubscriptionMapperFactory;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DefaultMessageId.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DefaultMessageId.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DefaultMessageId.java
index 3453e44..46b65fc 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DefaultMessageId.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DefaultMessageId.java
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.james.mailbox.store.mail.model;
 
+import org.apache.james.mailbox.model.MailboxId;
+
 import com.google.common.base.Objects;
 import com.google.common.base.Preconditions;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Mailbox.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Mailbox.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Mailbox.java
index 5172841..e4c4092 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Mailbox.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Mailbox.java
@@ -19,6 +19,7 @@
 package org.apache.james.mailbox.store.mail.model;
 
 import org.apache.james.mailbox.model.MailboxACL;
+import org.apache.james.mailbox.model.MailboxId;
 
 /**
  * Models long term mailbox data.

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxId.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxId.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxId.java
deleted file mode 100644
index f3e27bb..0000000
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxId.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one   *
- * or more contributor license agreements.  See the NOTICE file *
- * distributed with this work for additional information        *
- * regarding copyright ownership.  The ASF licenses this file   *
- * to you under the Apache License, Version 2.0 (the            *
- * "License"); you may not use this file except in compliance   *
- * with the License.  You may obtain a copy of the License at   *
- *                                                              *
- *   http://www.apache.org/licenses/LICENSE-2.0                 *
- *                                                              *
- * Unless required by applicable law or agreed to in writing,   *
- * software distributed under the License is distributed on an  *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
- * KIND, either express or implied.  See the License for the    *
- * specific language governing permissions and limitations      *
- * under the License.                                           *
- ****************************************************************/
-package org.apache.james.mailbox.store.mail.model;
-
-public interface MailboxId {
-    String serialize();
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxIdDeserializer.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxIdDeserializer.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxIdDeserializer.java
index 5515f68..864be74 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxIdDeserializer.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxIdDeserializer.java
@@ -19,6 +19,8 @@
 
 package org.apache.james.mailbox.store.mail.model;
 
+import org.apache.james.mailbox.model.MailboxId;
+
 public interface MailboxIdDeserializer {
 
     MailboxId deserialize(String serializedMailboxId) throws MailboxIdDeserialisationException;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxMessage.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxMessage.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxMessage.java
index f572ce1..647de53 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxMessage.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxMessage.java
@@ -20,6 +20,8 @@ package org.apache.james.mailbox.store.mail.model;
 
 import javax.mail.Flags;
 
+import org.apache.james.mailbox.model.MailboxId;
+
 /**
  * A MIME message, consisting of meta-data (including MIME headers)
  * plus body content. In the case of multipart documents, this body content

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailbox.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailbox.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailbox.java
index 7d70bfd..686d6a7 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailbox.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailbox.java
@@ -19,10 +19,10 @@
 package org.apache.james.mailbox.store.mail.model.impl;
 
 import org.apache.james.mailbox.model.MailboxACL;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.SimpleMailboxACL;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 
 public class SimpleMailbox implements Mailbox {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
index f7c7c80..2eac432 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
@@ -29,8 +29,8 @@ import javax.mail.util.SharedByteArrayInputStream;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.DelegatingMailboxMessage;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.mail.model.MessageAttachment;
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
index 25031e9..3d5d1ae 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
@@ -24,12 +24,12 @@ import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.mail.MessageMapper.FetchType;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 
 /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
index 22efc19..f662dea 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerAnnotationTest.java
@@ -36,11 +36,11 @@ import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.acl.MailboxACLResolver;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxAnnotation;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestId.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestId.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestId.java
index 1ed9c87..aa097c7 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestId.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestId.java
@@ -18,7 +18,7 @@
  ****************************************************************/
 package org.apache.james.mailbox.store;
 
-import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxId;
 
 public class TestId implements MailboxId {
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MapperProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MapperProvider.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MapperProvider.java
index 72b7183..7105d74 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MapperProvider.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MapperProvider.java
@@ -20,6 +20,7 @@
 package org.apache.james.mailbox.store.mail.model;
 
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapper;
 import org.apache.james.mailbox.store.mail.MailboxMapper;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
index f93936d..3c22274 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMapperTest.java
@@ -33,6 +33,7 @@ import javax.mail.util.SharedByteArrayInputStream;
 import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.MessageManager.FlagsUpdateMode;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.MessageRange;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMoveTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMoveTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMoveTest.java
index e394d1f..8d9de5c 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMoveTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageMoveTest.java
@@ -27,6 +27,7 @@ import javax.mail.Flags;
 import javax.mail.util.SharedByteArrayInputStream;
 
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.MessageRange;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/zoo-seq-provider/src/main/java/org/apache/james/mailbox/store/mail/ZooUidProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/zoo-seq-provider/src/main/java/org/apache/james/mailbox/store/mail/ZooUidProvider.java b/mailbox/zoo-seq-provider/src/main/java/org/apache/james/mailbox/store/mail/ZooUidProvider.java
index bdabe05..2720ae3 100644
--- a/mailbox/zoo-seq-provider/src/main/java/org/apache/james/mailbox/store/mail/ZooUidProvider.java
+++ b/mailbox/zoo-seq-provider/src/main/java/org/apache/james/mailbox/store/mail/ZooUidProvider.java
@@ -20,8 +20,8 @@ package org.apache.james.mailbox.store.mail;
 
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 
 import com.google.common.base.Preconditions;
 import com.netflix.curator.RetryPolicy;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/mailbox/zoo-seq-provider/src/test/java/org/apache/james/mailbox/store/mail/ZooUidProviderTest.java
----------------------------------------------------------------------
diff --git a/mailbox/zoo-seq-provider/src/test/java/org/apache/james/mailbox/store/mail/ZooUidProviderTest.java b/mailbox/zoo-seq-provider/src/test/java/org/apache/james/mailbox/store/mail/ZooUidProviderTest.java
index 046ee4f..2671c6a 100644
--- a/mailbox/zoo-seq-provider/src/test/java/org/apache/james/mailbox/store/mail/ZooUidProviderTest.java
+++ b/mailbox/zoo-seq-provider/src/test/java/org/apache/james/mailbox/store/mail/ZooUidProviderTest.java
@@ -22,8 +22,8 @@ import static org.junit.Assert.assertEquals;
 
 import java.util.UUID;
 
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.junit.After;
 import org.junit.Before;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
index 60408ab..8a9eca5 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java
@@ -40,8 +40,8 @@ import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.JmapAuthentication;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
index 3e3eaff..4ffd308 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
@@ -61,6 +61,7 @@ import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.AttachmentNotFoundException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.AttachmentMapper;
@@ -68,7 +69,6 @@ import org.apache.james.mailbox.store.mail.AttachmentMapperFactory;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.model.AttachmentId;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.mail.model.MessageAttachment;
 import org.apache.james.mailbox.store.mail.model.impl.Cid;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortToComparatorConvertor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortToComparatorConvertor.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortToComparatorConvertor.java
index 9ba867b..a523293 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortToComparatorConvertor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/SortToComparatorConvertor.java
@@ -24,7 +24,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.function.Function;
 
-import org.apache.james.mailbox.store.mail.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 
 import com.google.common.base.Preconditions;

http://git-wip-us.apache.org/repos/asf/james-project/blob/73b2da08/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
index a229b9d..4f10a04 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/MailboxUtilsTest.java
@@ -28,9 +28,9 @@ import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;


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


[5/8] james-project git commit: MAILBOX-273 update LuceneMailboxMessageSearchIndexTest to match new standards

Posted by ma...@apache.org.
MAILBOX-273 update LuceneMailboxMessageSearchIndexTest to match new standards


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

Branch: refs/heads/master
Commit: eff623d6e756e1c66297bb3c7cf5298e65fe4077
Parents: 72ace6a
Author: Matthieu Baechler <ma...@linagora.com>
Authored: Mon Jul 18 16:45:00 2016 +0200
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Mon Jul 25 10:13:30 2016 +0200

----------------------------------------------------------------------
 .../LuceneMailboxMessageSearchIndexTest.java    | 674 +++++++------------
 1 file changed, 261 insertions(+), 413 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/eff623d6/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
index f116bfb..f9d5158 100644
--- a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
+++ b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
@@ -18,9 +18,7 @@
  ****************************************************************/
 package org.apache.james.mailbox.lucene.search;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.assertj.core.api.Assertions.assertThat;
 
 import java.nio.charset.Charset;
 import java.util.Arrays;
@@ -126,580 +124,436 @@ public class LuceneMailboxMessageSearchIndexTest {
 
 
     @Test
-    public void testBodyShouldMatchPhraseInBody() throws Exception {
+    public void bodySearchShouldMatchPhraseInBody() throws Exception {
         SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.bodyContains(CUSTARD));
         Iterator<Long> result = index.search(null, mailbox3, query);
-        assertEquals(10L, result.next().longValue());
-        assertFalse(result.hasNext());
-        
-        
-        query = new SearchQuery();
-        query.andCriteria(SearchQuery.bodyContains(CUSTARD + CUSTARD));
-        result = index.search(null, mailbox3, query);
-        assertFalse(result.hasNext());
+        assertThat(result).containsExactly(10L);
     }
 
     @Test
-    public void testBodyMatchShouldBeCaseInsensitive() throws Exception {
+    public void bodySearchShouldNotMatchAbsentPhraseInBody() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.bodyContains(CUSTARD + CUSTARD));
+        Iterator<Long> result = index.search(null, mailbox3, query);
+        assertThat(result).isEmpty();
+    }
+    
+    @Test
+    public void bodySearchShouldBeCaseInsensitive() throws Exception {
         SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.bodyContains(RHUBARD));
         Iterator<Long> result = index.search(null, mailbox3, query);
-        assertEquals(10L, result.next().longValue());
-        assertFalse(result.hasNext());
+        assertThat(result).containsExactly(10L);
     }
 
     @Test
-    public void testBodyShouldNotMatchPhraseOnlyInHeader() throws Exception {
+    public void bodySearchNotMatchPhraseOnlyInFrom() throws Exception {
         SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.bodyContains(FROM_ADDRESS));
         Iterator<Long> result = index.search(null, mailbox3, query);
-        assertFalse(result.hasNext());
-        
-        query = new SearchQuery();
+        assertThat(result).isEmpty();
+    }
+
+    @Test
+    public void bodySearchShouldNotMatchPhraseOnlyInSubject() throws Exception {
+        SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.bodyContains(SUBJECT_PART));
-        result = index.search(null, mailbox3, query);
-        assertFalse(result.hasNext());
+        Iterator<Long> result = index.search(null, mailbox3, query);
+        assertThat(result).isEmpty();
     }
 
     @Test
-    public void testTextShouldMatchPhraseInBody() throws Exception {
+    public void textSearchShouldMatchPhraseInBody() throws Exception {
         SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.mailContains(CUSTARD));
         Iterator<Long> result = index.search(null, mailbox3, query);
-        assertEquals(10L, result.next().longValue());
-        assertFalse(result.hasNext());
-        
-        query = new SearchQuery();
-        query.andCriteria(SearchQuery.mailContains(CUSTARD + CUSTARD));
-        result = index.search(null, mailbox3, query);
-        assertFalse(result.hasNext());
+        assertThat(result).containsExactly(10L);
     }
 
     @Test
-    public void testTextMatchShouldBeCaseInsensitive() throws Exception {
+    public void textSearchShouldNotAbsentMatchPhraseInBody() throws Exception {
         SearchQuery query = new SearchQuery();
-        query.andCriteria(SearchQuery.mailContains(RHUBARD));
+        query.andCriteria(SearchQuery.mailContains(CUSTARD + CUSTARD));
         Iterator<Long> result = index.search(null, mailbox3, query);
-        assertEquals(10L, result.next().longValue());
-        assertFalse(result.hasNext());
-        
+        assertThat(result).isEmpty();
+    }
+
+    @Test
+    public void textSearchMatchShouldBeCaseInsensitive() throws Exception {
+        SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.mailContains(RHUBARD.toLowerCase(Locale.US)));
-        result = index.search(null, mailbox3, query);
-        assertEquals(10L, result.next().longValue());
-        assertFalse(result.hasNext());
+        Iterator<Long> result = index.search(null, mailbox3, query);
+        assertThat(result).containsExactly(10L);
     }
 
     @Test
-    public void testSearchAddress() throws Exception {
-        
+    public void addressSearchShouldMatchToFullAddress() throws Exception {
         SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.address(AddressType.To,FROM_ADDRESS));
         Iterator<Long> result = index.search(null, mailbox3, query);
-        assertEquals(10L, result.next().longValue());
-        assertFalse(result.hasNext());
-        
-        query = new SearchQuery();
+        assertThat(result).containsExactly(10L);
+    }
+
+    @Test
+    public void addressSearchShouldMatchToDisplayName() throws Exception {
+        SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.address(AddressType.To,"Harry"));
-        result = index.search(null, mailbox3, query);
-        assertEquals(10L, result.next().longValue());
-        assertFalse(result.hasNext());
-        
-        query = new SearchQuery();
+        Iterator<Long> result = index.search(null, mailbox3, query);
+        assertThat(result).containsExactly(10L);
+    }
+    
+    @Test
+    public void addressSearchShouldMatchToEmail() throws Exception {
+        SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.address(AddressType.To,"Harry@example.org"));
-        result = index.search(null, mailbox3, query);
-        assertEquals(10L, result.next().longValue());
-        assertFalse(result.hasNext());
+        Iterator<Long> result = index.search(null, mailbox3, query);
+        assertThat(result).containsExactly(10L);
     }
     
     @Test
-    public void testSearchAddressFrom() throws Exception {
-        
+    public void addressSearchShouldMatchFrom() throws Exception {
         SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.address(AddressType.From,"ser-from@domain.or"));
         Iterator<Long> result = index.search(null, mailbox3, query);
-        assertEquals(10L, result.next().longValue());
-        assertFalse(result.hasNext());
-        
-       
+        assertThat(result).containsExactly(10L);
     }
+
     @Test
-    public void testBodyShouldMatchPhraseOnlyInHeader() throws Exception {
-        
+    public void textSearchShouldMatchPhraseOnlyInToHeader() throws Exception {
         SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.mailContains(FROM_ADDRESS));
         Iterator<Long> result = index.search(null, mailbox3, query);
-        assertEquals(10L, result.next().longValue());
-        assertFalse(result.hasNext());
-        
+        assertThat(result).containsExactly(10L);
+    }
+    
+    @Test
+    public void textSearchShouldMatchPhraseOnlyInSubjectHeader() throws Exception {
+        SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.mailContains(SUBJECT_PART));
-        result = index.search(null, mailbox3, query);
-        assertEquals(10L, result.next().longValue());
-        assertFalse(result.hasNext());
+        Iterator<Long> result = index.search(null, mailbox3, query);
+        assertThat(result).containsExactly(10L);
     }
     
     @Test
-    public void testSearchAll() throws Exception {
+    public void searchAllShouldMatchAllMailboxEmails() throws Exception {
         SearchQuery query = new SearchQuery();
         query.andCriteria(SearchQuery.all());
-        Iterator<Long> it2 = index.search(null, mailbox2, query);
-        assertTrue(it2.hasNext());
-        assertEquals(1L, it2.next().longValue());
-        assertFalse(it2.hasNext());
+        Iterator<Long> result = index.search(null, mailbox2, query);
+        assertThat(result).containsExactly(1L);
     }
     
     @Test
-    public void testSearchFlag() throws Exception {
-
-        SearchQuery q = new SearchQuery();
-        q.andCriteria(SearchQuery.flagIsSet(Flag.DELETED));
-        Iterator<Long> it3 = index.search(null, mailbox, q);
-        assertEquals(2L, it3.next().longValue());
-        assertEquals(3L, it3.next().longValue());
-        assertFalse(it3.hasNext());
+    public void flagSearchShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.flagIsSet(Flag.DELETED));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 3L);
     }
     
     @Test
-    public void testSearchBody() throws Exception {    
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.bodyContains("body"));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void bodySearchShouldMatchSeveralEmails() throws Exception {    
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.bodyContains("body"));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 2L, 3L);
     }
     
     @Test
-    public void testSearchMail() throws Exception {    
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.mailContains("body"));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void textSearchShouldMatchSeveralEmails() throws Exception {    
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.mailContains("body"));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 2L, 3L);
     }
     
     @Test
-    public void testSearchHeaderContains() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.headerContains("Subject", "test"));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void headerSearchShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.headerContains("Subject", "test"));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 3L);
     }
     
     @Test
-    public void testSearchHeaderExists() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.headerExists("Subject"));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void headerExistsShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.headerExists("Subject"));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 3L);
     }
     
     @Test
-    public void testSearchFlagUnset() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.flagIsUnSet(Flag.DRAFT));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void flagUnsetShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.flagIsUnSet(Flag.DRAFT));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 2L, 3L);
     }
     
-    
     @Test
-    public void testSearchInternalDateBefore() throws Exception {
-        SearchQuery q2 = new SearchQuery();
+    public void internalDateBeforeShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
         Calendar cal = Calendar.getInstance();
         cal.setTime(new Date());
-        q2.andCriteria(SearchQuery.internalDateBefore(cal.getTime(), DateResolution.Day));
+        query.andCriteria(SearchQuery.internalDateBefore(cal.getTime(), DateResolution.Day));
         
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(2L, it4.next().longValue());
-        assertFalse(it4.hasNext());
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L);
     }
     
     
     @Test
-    public void testSearchInternalDateAfter() throws Exception {
-        SearchQuery q2 = new SearchQuery();
+    public void internalDateAfterShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
         Calendar cal = Calendar.getInstance();
         cal.setTime(new Date());
-        q2.andCriteria(SearchQuery.internalDateAfter(cal.getTime(), DateResolution.Day));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(3L, it4.next().longValue());
-        assertFalse(it4.hasNext());
+        query.andCriteria(SearchQuery.internalDateAfter(cal.getTime(), DateResolution.Day));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(3L);
     }
     
     
     
     @Test
-    public void testSearchInternalDateOn() throws Exception {
-        SearchQuery q2 = new SearchQuery();
+    public void internalDateOnShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
         Calendar cal = Calendar.getInstance();
         cal.setTime(new Date());
-        q2.andCriteria(SearchQuery.internalDateOn(cal.getTime(), DateResolution.Day));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertFalse(it4.hasNext());
+        query.andCriteria(SearchQuery.internalDateOn(cal.getTime(), DateResolution.Day));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L);
     }
     
     @Test
-    public void testSearchUidMatch() throws Exception {
-        SearchQuery q2 = new SearchQuery();
+    public void uidSearchShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
         Calendar cal = Calendar.getInstance();
         cal.setTime(new Date());
-        q2.andCriteria(SearchQuery.uid(new SearchQuery.NumericRange[] {new SearchQuery.NumericRange(1)}));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertFalse(it4.hasNext());
+        query.andCriteria(SearchQuery.uid(new SearchQuery.NumericRange[] {new SearchQuery.NumericRange(1)}));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L);
     }
     
-    
     @Test
-    public void testSearchUidRange() throws Exception {
-        SearchQuery q2 = new SearchQuery();
+    public void uidRangeSearchShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
         Calendar cal = Calendar.getInstance();
         cal.setTime(new Date());
-        q2.andCriteria(SearchQuery.uid(new SearchQuery.NumericRange[] {new SearchQuery.NumericRange(1), new SearchQuery.NumericRange(2,3)}));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+        query.andCriteria(SearchQuery.uid(new SearchQuery.NumericRange[] {new SearchQuery.NumericRange(1), new SearchQuery.NumericRange(2,3)}));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 2L, 3L);
     }
     
-    
-    
     @Test
-    public void testSearchSizeEquals() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.sizeEquals(200));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void sizeEqualsShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.sizeEquals(200));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L);
     }
     
     @Test
-    public void testSearchSizeLessThan() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.sizeLessThan(200));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void sizeLessThanShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.sizeLessThan(200));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 3L);
     }
     
-    
     @Test
-    public void testSearchSizeGreaterThan() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.sizeGreaterThan(6));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void sizeGreaterThanShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.sizeGreaterThan(6));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 2L, 3L);
     }
     
     @Test
-    public void testSortUid() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-        assertFalse(it4.hasNext());
+    public void uidShouldBeSorted() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 2L, 3L);
     }
     
     @Test
-    public void testSortUidReverse() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.Uid, true)));
-        q2.andCriteria(SearchQuery.all());
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-        assertFalse(it4.hasNext());
+    public void uidReverseSortShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.Uid, true)));
+        query.andCriteria(SearchQuery.all());
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(3L, 2L, 1L);
     }
     
     @Test
-    public void testSortSentDate() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.SentDate, false)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void sortOnSentDateShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.SentDate, false)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 3L, 1L);
     }
     
     @Test
-    public void testSortSentDateReverse() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.SentDate, true)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertFalse(it4.hasNext());
+    public void reverseSortOnSentDateShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.SentDate, true)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 3L, 2L);
     }
-    @Test
-    public void testSortBaseSubject() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.BaseSubject, false)));
 
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    @Test
+    public void sortOnSubjectShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.BaseSubject, false)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 1L, 3L);
     }
     
     @Test
-    public void testSortBaseSubjectReverse() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.BaseSubject, true)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertFalse(it4.hasNext());
+    public void reverseSortOnSubjectShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.BaseSubject, true)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(3L, 1L, 2L);
     }
     
     @Test
-    public void testSortMailboxFrom() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxFrom, false)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void sortOnMailboxFromShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxFrom, false)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 3L, 1L);
     }
     
     @Test
-    public void  testSortMailboxFromReverse() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxFrom, true)));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void reverseSortOnMailboxFromShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxFrom, true)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 3L, 2L);
     }
     
-    
     @Test
-    public void testSortMailboxCc() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxCc, false)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void sortOnMailboxCCShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxCc, false)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 2L, 3L);
     }
     
     @Test
-    public void  testSortMailboxCcReverse() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxCc, true)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertEquals(1L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void reverseSortOnMailboxCCShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxCc, true)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 3L, 1L);
     }
     
     @Test
-    public void testSortMailboxTo() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxTo, false)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void sortOnMailboxToShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxTo, false)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(3L, 1L, 2L);
     }
     
     @Test
-    public void  testSortMailboxToReverse() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxTo, true)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void reverseSortOnMailboxToShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.MailboxTo, true)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 1L, 3L);
     }
     
     @Test
-    public void testSortDisplayTo() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.DisplayTo, false)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void sortOnDisplayToShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.DisplayTo, false)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(3L, 1L, 2L);
     }
     
     @Test
-    public void  testSortDisplayToReverse() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.DisplayTo, true)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void reverseSortOnDisplayToShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.DisplayTo, true)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 1L, 3L);
     }
     
-    
     @Test
-    public void testSortDisplayFrom() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.DisplayFrom, false)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void sortOnDisplayFromShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.DisplayFrom, false)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 3L, 1L);
     }
     
     @Test
-    public void  testSortDisplayFromReverse() throws Exception {
-       
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.DisplayFrom, true)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void reverseSortOnDisplayFromShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.DisplayFrom, true)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 3L, 2L);
     }
     
     @Test
-    public void testSortArrival() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.Arrival, false)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void sortOnArrivalDateShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.Arrival, false)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 1L, 3L);
     }
     
     @Test
-    public void testSortArrivalReverse() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.Arrival, true)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertFalse(it4.hasNext());
+    public void reverseSortOnArrivalDateShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.Arrival, true)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(3L, 1L, 2L);
     }
+    
     @Test
-    public void testSortSize() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.Size, false)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-        assertEquals(1L, it4.next().longValue());
-
-        assertFalse(it4.hasNext());
+    public void sortOnSizeShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.Size, false)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 3L, 1L);
     }
     
     @Test
-    public void testSortSizeReverse() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.all());
-        q2.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.Size, true)));
-
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(1L, it4.next().longValue());
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-        assertFalse(it4.hasNext());
+    public void reverseSortOnSizeShouldReturnWellOrderedResults() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        query.setSorts(Arrays.asList(new SearchQuery.Sort(SortClause.Size, true)));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(1L, 2L, 3L);
     }
     
     @Test
-    public void testNot() throws Exception {
-        SearchQuery q2 = new SearchQuery();
-        q2.andCriteria(SearchQuery.not(SearchQuery.uid(new SearchQuery.NumericRange[] { new SearchQuery.NumericRange(1)})));
-        Iterator<Long> it4 = index.search(null, mailbox, q2);
-        assertEquals(2L, it4.next().longValue());
-        assertEquals(3L, it4.next().longValue());
-        assertFalse(it4.hasNext());
+    public void notOperatorShouldReverseMatching() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.not(SearchQuery.uid(new SearchQuery.NumericRange[] { new SearchQuery.NumericRange(1)})));
+        Iterator<Long> result = index.search(null, mailbox, query);
+        assertThat(result).containsExactly(2L, 3L);
     }
     
     private final class SimpleMailbox implements Mailbox {
@@ -742,17 +596,11 @@ public class LuceneMailboxMessageSearchIndexTest {
             return 0;
         }
 
-        /* (non-Javadoc)
-         * @see org.apache.james.mailbox.store.mail.model.Mailbox#getACL()
-         */
         @Override
         public MailboxACL getACL() {
             return SimpleMailboxACL.OWNER_FULL_ACL;
         }
 
-        /* (non-Javadoc)
-         * @see org.apache.james.mailbox.store.mail.model.Mailbox#setACL(org.apache.james.mailbox.MailboxACL)
-         */
         @Override
         public void setACL(MailboxACL acl) {
             throw new UnsupportedOperationException("Not supported");


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


[8/8] james-project git commit: MAILBOX-273 Add partial multimailbox support for simple search backend

Posted by ma...@apache.org.
MAILBOX-273 Add partial multimailbox support for simple search backend


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

Branch: refs/heads/master
Commit: e456c07333db5735599cc7a93cbe05476c6b7a40
Parents: 7a6a4c1
Author: Raphael Ouazana <ra...@linagora.com>
Authored: Thu Jul 21 14:45:16 2016 +0200
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Mon Jul 25 10:13:31 2016 +0200

----------------------------------------------------------------------
 .../search/SimpleMessageSearchIndexTest.java    | 19 +-----
 .../mailbox/store/StoreMailboxManager.java      |  2 +-
 .../store/search/SimpleMessageSearchIndex.java  | 64 ++++++++++++++++----
 3 files changed, 56 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/e456c073/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
index f034769..b974db9 100644
--- a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
+++ b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
@@ -39,7 +39,7 @@ public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest
     @Override
     protected void initializeMailboxManager() throws Exception {
         MailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
-        messageSearchIndex = new SimpleMessageSearchIndex(mapperFactory);
+        messageSearchIndex = new SimpleMessageSearchIndex(mapperFactory, mapperFactory);
         storeMailboxManager = new InMemoryMailboxManager(
             mapperFactory,
             new MockAuthenticator(),
@@ -214,29 +214,14 @@ public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest
     @Override
     public void sortShouldOrderMessages() throws Exception {
     }
-    
-    @Ignore
-    @Override
-    public void multimailboxSearchShouldReturnUidOfMessageMarkedAsSeenInTwoMailboxes() throws MailboxException {
-    }
 
     @Ignore
     @Override
-    public void multimailboxSearchShouldReturnUidOfMessageMarkedAsSeenInAllMailboxes() throws MailboxException {
-    }
-    
-    @Ignore
-    @Override
     public void multimailboxSearchShouldReturnUidOfMessageWithExpectedFromInTwoMailboxes() throws MailboxException {
     }
-    
+
     @Ignore
     @Override
     public void multimailboxSearchShouldReturnUidOfMessageWithExpectedFromInAllMailboxes() throws MailboxException {
     }
-    
-    @Ignore
-    @Override
-    public void multimailboxSearchShouldReturnUidOfMessageMarkedAsSeenInOneMailbox() throws MailboxException {
-    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/e456c073/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
index 84f24ae..7f5bd28 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
@@ -173,7 +173,7 @@ public class StoreMailboxManager implements MailboxManager {
         dispatcher = new MailboxEventDispatcher(getDelegationListener());
 
         if (index == null) {
-            index = new SimpleMessageSearchIndex(mailboxSessionMapperFactory);
+            index = new SimpleMessageSearchIndex(mailboxSessionMapperFactory, mailboxSessionMapperFactory);
         }
         if (index instanceof ListeningMessageSearchIndex) {
             this.addGlobalListener((MailboxListener) index, null);

http://git-wip-us.apache.org/repos/asf/james-project/blob/e456c073/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
index 4a2e8d1..7d05a49 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
@@ -18,6 +18,7 @@
  ****************************************************************/
 package org.apache.james.mailbox.store.search;
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.EnumSet;
 import java.util.Iterator;
@@ -31,8 +32,8 @@ import javax.inject.Inject;
 import org.apache.james.mailbox.MailboxManager.SearchCapabilities;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.exception.UnsupportedSearchException;
 import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
 import org.apache.james.mailbox.model.SearchQuery;
@@ -40,12 +41,18 @@ import org.apache.james.mailbox.model.SearchQuery.ConjunctionCriterion;
 import org.apache.james.mailbox.model.SearchQuery.Criterion;
 import org.apache.james.mailbox.model.SearchQuery.NumericRange;
 import org.apache.james.mailbox.model.SearchQuery.UidCriterion;
+import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.MessageMapper.FetchType;
 import org.apache.james.mailbox.store.mail.MessageMapperFactory;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.ImmutableMultimap.Builder;
+import com.google.common.collect.Multimap;
+
 /**
  * {@link MessageSearchIndex} which just fetch {@link MailboxMessage}'s from the {@link MessageMapper} and use {@link MessageSearcher}
  * to match them against the {@link SearchQuery}.
@@ -55,17 +62,20 @@ import org.apache.james.mailbox.store.mail.model.MailboxMessage;
  *
  */
 public class SimpleMessageSearchIndex implements MessageSearchIndex {
+    private static final String WILDCARD = "%";
 
-    private final MessageMapperFactory factory;
+    private final MessageMapperFactory messageMapperFactory;
+    private final MailboxMapperFactory mailboxMapperFactory;
     
     @Inject
-    public SimpleMessageSearchIndex(MessageMapperFactory factory) {
-        this.factory = factory;
+    public SimpleMessageSearchIndex(MessageMapperFactory messageMapperFactory, MailboxMapperFactory mailboxMapperFactory) {
+        this.messageMapperFactory = messageMapperFactory;
+        this.mailboxMapperFactory = mailboxMapperFactory;
     }
     
     @Override
     public EnumSet<SearchCapabilities> getSupportedCapabilities() {
-        return EnumSet.noneOf(SearchCapabilities.class);
+        return EnumSet.of(SearchCapabilities.MultimailboxSearch);
     }
     
     /**
@@ -89,7 +99,22 @@ public class SimpleMessageSearchIndex implements MessageSearchIndex {
     
     @Override
     public Iterator<Long> search(MailboxSession session, Mailbox mailbox, SearchQuery query) throws MailboxException {
-        MessageMapper mapper = factory.getMessageMapper(session);
+        return searchMultimap(session, ImmutableList.of(mailbox), query)
+                .get(mailbox.getMailboxId())
+                .iterator();
+    }
+    
+    private Multimap<MailboxId, Long> searchMultimap(MailboxSession session, List<Mailbox> mailboxes, SearchQuery query) throws MailboxException {
+        Builder<MailboxId, Long> multimap = ImmutableMultimap.builder();
+        for (Mailbox mailbox: mailboxes) {
+            multimap.putAll(searchMultimap(session, mailbox, query));
+        }
+        return multimap.build();
+
+    }
+    
+    private Multimap<MailboxId, Long> searchMultimap(MailboxSession session, Mailbox mailbox, SearchQuery query) throws MailboxException {
+        MessageMapper mapper = messageMapperFactory.getMessageMapper(session);
 
         final SortedSet<MailboxMessage> hitSet = new TreeSet<MailboxMessage>();
 
@@ -115,15 +140,32 @@ public class SimpleMessageSearchIndex implements MessageSearchIndex {
         
         // MessageSearches does the filtering for us
         if (session == null) {
-			return new MessageSearches(hitSet.iterator(), query).iterator();
-		} else {
-			return new MessageSearches(hitSet.iterator(), query, session.getLog()).iterator();
-		}
+            return ImmutableMultimap.<MailboxId, Long>builder()
+                        .putAll(mailbox.getMailboxId(), ImmutableList.copyOf(new MessageSearches(hitSet.iterator(), query).iterator()))
+                        .build();
+        } else {
+            return ImmutableMultimap.<MailboxId, Long>builder()
+                        .putAll(mailbox.getMailboxId(), ImmutableList.copyOf(new MessageSearches(hitSet.iterator(), query, session.getLog()).iterator()))
+                        .build();
+        }
     }
 
     @Override
     public Map<MailboxId, Collection<Long>> search(MailboxSession session, MultimailboxesSearchQuery searchQuery) throws MailboxException {
-        throw new UnsupportedSearchException();
+        List<Mailbox> allUserMailboxes = mailboxMapperFactory.getMailboxMapper(session)
+                .findMailboxWithPathLike(new MailboxPath(session.getPersonalSpace(), session.getUser().getUserName(), WILDCARD));
+        if (searchQuery.getMailboxIds().isEmpty()) {
+            return searchMultimap(session, allUserMailboxes, searchQuery.getSearchQuery())
+                    .asMap();
+        }
+        List<Mailbox> queriedMailboxes = new ArrayList<Mailbox>();
+        for (Mailbox mailbox: allUserMailboxes) {
+            if (searchQuery.getMailboxIds().contains(mailbox.getMailboxId())) {
+                queriedMailboxes.add(mailbox);
+            }
+        }
+        return searchMultimap(session, queriedMailboxes, searchQuery.getSearchQuery())
+                .asMap();
     }
 
 }


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


[6/8] james-project git commit: MAILBOX-273 implement cross-mailboxes search in ElasticSearch

Posted by ma...@apache.org.
MAILBOX-273 implement cross-mailboxes search in ElasticSearch


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

Branch: refs/heads/master
Commit: 085cf65e9dbb1dfe5b3fbe4a00c7d9a36ea334be
Parents: eff623d
Author: Matthieu Baechler <ma...@linagora.com>
Authored: Tue Jul 19 18:12:07 2016 +0200
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Mon Jul 25 10:13:30 2016 +0200

----------------------------------------------------------------------
 .../apache/james/mailbox/model/MailboxId.java   |   5 +
 .../model/MultimailboxesSearchQuery.java        |  72 ++++++++++++
 .../model/MultimailboxesSearchQueryTest.java    |  92 +++++++++++++++
 .../james/mailbox/cassandra/CassandraId.java    |   7 ++
 mailbox/elasticsearch/pom.xml                   |   5 +
 ...lasticSearchListeningMessageSearchIndex.java |  17 ++-
 .../elasticsearch/query/QueryConverter.java     |  26 +++--
 .../search/ElasticSearchSearcher.java           |  51 ++++----
 .../ElasticSearchIntegrationTest.java           |   3 +-
 .../lucene/search/LuceneMessageSearchIndex.java | 108 ++++++++++++-----
 .../LuceneMailboxMessageSearchIndexTest.java    |  34 +++++-
 .../search/LuceneMessageSearchIndexTest.java    |  15 ++-
 .../james/mailbox/inmemory/InMemoryId.java      |   8 ++
 .../search/SimpleMessageSearchIndexTest.java    |  25 ++++
 .../store/search/LazyMessageSearchIndex.java    |  10 ++
 .../store/search/MessageSearchIndex.java        |  15 ++-
 .../store/search/SimpleMessageSearchIndex.java  |  10 ++
 .../org/apache/james/mailbox/store/TestId.java  |   8 ++
 .../search/AbstractMessageSearchIndexTest.java  | 116 ++++++++++++++++---
 .../imap/scripts/UidSearchAtomsIndexer.test     |  37 +++++-
 .../host/ElasticSearchHostSystem.java           |   3 +-
 .../modules/mailbox/CassandraMailboxModule.java |   4 +
 22 files changed, 583 insertions(+), 88 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxId.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxId.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxId.java
index 7410b4e..3e263fc 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxId.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxId.java
@@ -19,5 +19,10 @@
 package org.apache.james.mailbox.model;
 
 public interface MailboxId {
+    
+    interface Factory {
+        MailboxId fromString(String serialized);
+    }
+    
     String serialize();
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/api/src/main/java/org/apache/james/mailbox/model/MultimailboxesSearchQuery.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MultimailboxesSearchQuery.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MultimailboxesSearchQuery.java
new file mode 100644
index 0000000..f979a79
--- /dev/null
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MultimailboxesSearchQuery.java
@@ -0,0 +1,72 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mailbox.model;
+
+import java.util.Arrays;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableSet;
+
+public class MultimailboxesSearchQuery {
+
+    public static Builder from(SearchQuery searchQuery) {
+        return new Builder(searchQuery);
+    }
+    
+    public static class Builder {
+        
+        private final SearchQuery searchQuery;
+        private ImmutableSet.Builder<MailboxId> mailboxIds;
+
+        private Builder(SearchQuery searchQuery) {
+            Preconditions.checkNotNull(searchQuery);
+            this.searchQuery = searchQuery;
+            this.mailboxIds = ImmutableSet.builder();
+        }
+        
+        public Builder inMailboxes(MailboxId... mailboxIds) {
+            this.mailboxIds.addAll(Arrays.asList(mailboxIds));
+            return this;
+        }
+        
+        public MultimailboxesSearchQuery build() {
+            return new MultimailboxesSearchQuery(searchQuery, mailboxIds.build());
+        }
+        
+    }
+
+    private final SearchQuery searchQuery;
+    private final ImmutableSet<MailboxId> mailboxIds;
+
+    @VisibleForTesting
+    MultimailboxesSearchQuery(SearchQuery searchQuery, ImmutableSet<MailboxId> mailboxIds) {
+        this.searchQuery = searchQuery;
+        this.mailboxIds = mailboxIds;
+    }
+
+    public ImmutableSet<MailboxId> getMailboxIds() {
+        return mailboxIds;
+    }
+    
+    public SearchQuery getSearchQuery() {
+        return searchQuery;
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/api/src/test/java/org/apache/james/mailbox/model/MultimailboxesSearchQueryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MultimailboxesSearchQueryTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MultimailboxesSearchQueryTest.java
new file mode 100644
index 0000000..92a77a2
--- /dev/null
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MultimailboxesSearchQueryTest.java
@@ -0,0 +1,92 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.mailbox.model;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.junit.Test;
+
+import com.google.common.collect.ImmutableSet;
+
+public class MultimailboxesSearchQueryTest {
+
+    private static final SearchQuery EMPTY_QUERY = new SearchQuery();
+
+    @Test(expected=NullPointerException.class)
+    public void buildShouldThrowWhenQueryIsNull() {
+        MultimailboxesSearchQuery.from(null);
+    }
+
+    @Test
+    public void buildShouldBuildWhenNoMailboxes() {
+        MultimailboxesSearchQuery expected = new MultimailboxesSearchQuery(EMPTY_QUERY, ImmutableSet.<MailboxId>of());
+        MultimailboxesSearchQuery actual = MultimailboxesSearchQuery.from(EMPTY_QUERY).build();
+        assertThat(actual).isEqualToComparingFieldByField(expected);
+    }
+
+    @Test
+    public void buildShouldBuildWhenEmptyMailboxes() {
+        MultimailboxesSearchQuery expected = new MultimailboxesSearchQuery(EMPTY_QUERY, ImmutableSet.<MailboxId>of());
+        MultimailboxesSearchQuery actual = MultimailboxesSearchQuery.from(EMPTY_QUERY).inMailboxes().build();
+        assertThat(actual).isEqualToComparingFieldByField(expected);
+    }
+
+    @Test
+    public void buildShouldBuildWhenOneMailbox() {
+        MultimailboxesSearchQuery expected = new MultimailboxesSearchQuery(EMPTY_QUERY, ImmutableSet.<MailboxId>of(TestId.of(("id1"))));
+        MultimailboxesSearchQuery actual = MultimailboxesSearchQuery.from(EMPTY_QUERY).inMailboxes(TestId.of("id1")).build();
+        assertThat(actual).isEqualToComparingFieldByField(expected);
+    }
+
+    @Test
+    public void buildShouldBuildWhenTwoMailboxes() {
+        MultimailboxesSearchQuery expected = new MultimailboxesSearchQuery(EMPTY_QUERY, ImmutableSet.<MailboxId>of(TestId.of("id1"), TestId.of("id2")));
+        MultimailboxesSearchQuery actual = MultimailboxesSearchQuery.from(EMPTY_QUERY).inMailboxes(TestId.of("id1"), TestId.of("id2")).build();
+        assertThat(actual).isEqualToComparingFieldByField(expected);
+    }
+
+    private static class TestId implements MailboxId {
+        private final String id;
+
+        public TestId(String id) {
+            this.id = id;
+        }
+
+        public static TestId of(String id) {
+            return new TestId(id);
+        }
+        
+        @Override
+        public String serialize() {
+            return id;
+        }
+        
+        @Override
+        public boolean equals(Object other) {
+            return other instanceof TestId
+                    && id.equals(((TestId)other).id);
+        }
+        
+        @Override
+        public int hashCode() {
+            return id.hashCode();
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java
index 76088d8..7553d6d 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java
@@ -26,6 +26,13 @@ import com.datastax.driver.core.utils.UUIDs;
 
 public class CassandraId implements MailboxId {
 
+    public static class Factory implements MailboxId.Factory {
+        @Override
+        public MailboxId fromString(String serialized) {
+            return of(UUID.fromString(serialized));
+        }
+    }
+    
     private final UUID id;
 
     public static CassandraId timeBased() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/pom.xml b/mailbox/elasticsearch/pom.xml
index 793a05d..864a95f 100644
--- a/mailbox/elasticsearch/pom.xml
+++ b/mailbox/elasticsearch/pom.xml
@@ -190,6 +190,11 @@
                     <artifactId>jackson-datatype-jdk8</artifactId>
                 </dependency>
                 <dependency>
+                    <groupId>com.github.steveash.guavate</groupId>
+                    <artifactId>guavate</artifactId>
+                    <version>1.0.0</version>
+                </dependency>
+                <dependency>
                     <groupId>com.google.guava</groupId>
                     <artifactId>guava</artifactId>
                 </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
index ef053b5..b967e7c 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
@@ -20,8 +20,10 @@ package org.apache.james.mailbox.elasticsearch.events;
 
 import static org.elasticsearch.index.query.QueryBuilders.termQuery;
 
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 import javax.inject.Inject;
@@ -32,6 +34,8 @@ import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
 import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.mail.MessageMapperFactory;
@@ -42,6 +46,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
+import com.google.common.collect.ImmutableList;
 
 public class ElasticSearchListeningMessageSearchIndex extends ListeningMessageSearchIndex {
 
@@ -68,7 +73,17 @@ public class ElasticSearchListeningMessageSearchIndex extends ListeningMessageSe
 
     @Override
     public Iterator<Long> search(MailboxSession session, Mailbox mailbox, SearchQuery searchQuery) throws MailboxException {
-        return searcher.search(mailbox, searchQuery);
+        MailboxId mailboxId = mailbox.getMailboxId();
+        return searcher
+                .search(ImmutableList.of(mailboxId), searchQuery)
+                .get(mailboxId)
+                .iterator();
+    }
+    
+    @Override
+    public Map<MailboxId, Collection<Long>> search(MailboxSession session, MultimailboxesSearchQuery searchQuery)
+            throws MailboxException {
+        return searcher.search(searchQuery.getMailboxIds(), searchQuery.getSearchQuery()).asMap();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/QueryConverter.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/QueryConverter.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/QueryConverter.java
index b0a5346..762522f 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/QueryConverter.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/QueryConverter.java
@@ -20,17 +20,21 @@
 package org.apache.james.mailbox.elasticsearch.query;
 
 import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
-import static org.elasticsearch.index.query.QueryBuilders.termQuery;
+import static org.elasticsearch.index.query.QueryBuilders.termsQuery;
 
+import java.util.Collection;
 import java.util.List;
-import java.util.stream.Stream;
 
 import javax.inject.Inject;
 
 import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.elasticsearch.index.query.QueryBuilder;
 
+import com.github.steveash.guavate.Guavate;
+import com.google.common.collect.ImmutableList;
+
 public class QueryConverter {
 
 
@@ -41,11 +45,9 @@ public class QueryConverter {
         this.criterionConverter = criterionConverter;
     }
 
-    public QueryBuilder from(SearchQuery searchQuery, String mailboxUUID) {
-        return Stream.of(generateQueryBuilder(searchQuery))
-            .map((rep) -> addMailboxFilters(rep, mailboxUUID))
-            .findAny()
-            .get();
+    public QueryBuilder from(SearchQuery searchQuery, Collection<MailboxId> mailboxIds) {
+        QueryBuilder queryBuilder = generateQueryBuilder(searchQuery);
+        return addMailboxFilters(queryBuilder, mailboxIds);
     }
 
     private QueryBuilder generateQueryBuilder(SearchQuery searchQuery) {
@@ -59,9 +61,15 @@ public class QueryConverter {
         }
     }
 
-    private QueryBuilder addMailboxFilters(QueryBuilder queryBuilder, String mailboxUUID) {
+    private QueryBuilder addMailboxFilters(QueryBuilder queryBuilder, Collection<MailboxId> mailboxIds) {
+        if (mailboxIds.isEmpty()) {
+            return queryBuilder;
+        }
+        ImmutableList<String> ids = mailboxIds.stream()
+                .map(MailboxId::serialize)
+                .collect(Guavate.toImmutableList());
         return boolQuery().must(queryBuilder)
-            .filter(termQuery(JsonMessageConstants.MAILBOX_ID, mailboxUUID));
+            .filter(termsQuery(JsonMessageConstants.MAILBOX_ID, ids));
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
index 1042ec8..8a9a1d8 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
@@ -19,28 +19,34 @@
 
 package org.apache.james.mailbox.elasticsearch.search;
 
-import java.util.Iterator;
+import java.util.Collection;
 import java.util.Optional;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 
 import javax.inject.Inject;
 
+import org.apache.commons.lang3.tuple.Pair;
 import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
 import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
 import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
 import org.apache.james.mailbox.elasticsearch.query.SortConverter;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxId.Factory;
 import org.apache.james.mailbox.model.SearchQuery;
-import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.elasticsearch.action.search.SearchRequestBuilder;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.client.Client;
 import org.elasticsearch.common.unit.TimeValue;
 import org.elasticsearch.search.SearchHit;
+import org.elasticsearch.search.SearchHitField;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.github.steveash.guavate.Guavate;
+import com.google.common.collect.Multimap;
+
 public class ElasticSearchSearcher {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchSearcher.class);
@@ -50,50 +56,55 @@ public class ElasticSearchSearcher {
     private final Client client;
     private final QueryConverter queryConverter;
     private final int size;
+    private final Factory mailboxIdFactory;
 
     @Inject
-    public ElasticSearchSearcher(Client client, QueryConverter queryConverter) {
-        this(client, queryConverter, DEFAULT_SIZE);
+    public ElasticSearchSearcher(Client client, QueryConverter queryConverter, MailboxId.Factory mailboxIdFactory) {
+        this(client, queryConverter, DEFAULT_SIZE, mailboxIdFactory);
     }
 
-    public ElasticSearchSearcher(Client client, QueryConverter queryConverter, int size) {
+    public ElasticSearchSearcher(Client client, QueryConverter queryConverter, int size, MailboxId.Factory mailboxIdFactory) {
         this.client = client;
         this.queryConverter = queryConverter;
         this.size = size;
+        this.mailboxIdFactory = mailboxIdFactory;
     }
-
-    public Iterator<Long> search(Mailbox mailbox, SearchQuery searchQuery) throws MailboxException {
-        return new ScrollIterable(client, getSearchRequestBuilder(client, mailbox, searchQuery)).stream()
+    
+    public Multimap<MailboxId, Long> search(Collection<MailboxId> mailboxIds, SearchQuery searchQuery) throws MailboxException {
+        return new ScrollIterable(client, getSearchRequestBuilder(client, mailboxIds, searchQuery)).stream()
             .flatMap(this::transformResponseToUidStream)
-            .iterator();
+            .collect(Guavate.toImmutableListMultimap(Pair::getLeft, Pair::getRight));
     }
-
-    private SearchRequestBuilder getSearchRequestBuilder(Client client, Mailbox mailbox, SearchQuery searchQuery) {
+    
+    private SearchRequestBuilder getSearchRequestBuilder(Client client, Collection<MailboxId> mailboxIds, SearchQuery searchQuery) {
         return searchQuery.getSorts()
             .stream()
             .reduce(
                 client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
                     .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
                     .setScroll(TIMEOUT)
-                    .setFetchSource(JsonMessageConstants.ID, "")
-                    .setQuery(queryConverter.from(searchQuery, mailbox.getMailboxId().serialize()))
+                    .addFields(JsonMessageConstants.ID, JsonMessageConstants.MAILBOX_ID)
+                    .setQuery(queryConverter.from(searchQuery, mailboxIds))
                     .setSize(size),
                 (searchBuilder, sort) -> searchBuilder.addSort(SortConverter.convertSort(sort)),
                 (partialResult1, partialResult2) -> partialResult1);
     }
 
-    private Stream<Long> transformResponseToUidStream(SearchResponse searchResponse) {
+    private Stream<Pair<MailboxId, Long>> transformResponseToUidStream(SearchResponse searchResponse) {
         return StreamSupport.stream(searchResponse.getHits().spliterator(), false)
-            .map(this::extractUidFromHit)
+            .map(this::extractContentFromHit)
             .filter(Optional::isPresent)
             .map(Optional::get);
     }
 
-    private Optional<Long> extractUidFromHit(SearchHit hit) {
-        try {
-            return Optional.of(((Number) hit.getSource().get(JsonMessageConstants.ID)).longValue());
-        } catch (Exception exception) {
-            LOGGER.warn("Can not extract UID for search result " + hit.getId(), exception);
+    private Optional<Pair<MailboxId, Long>> extractContentFromHit(SearchHit hit) {
+        SearchHitField mailboxId = hit.field(JsonMessageConstants.MAILBOX_ID);
+        SearchHitField uid = hit.field(JsonMessageConstants.ID);
+        if (mailboxId != null && uid != null) {
+            Number uidAsNumber = uid.getValue();
+            return Optional.of(Pair.of(mailboxIdFactory.fromString(mailboxId.getValue()), uidAsNumber.longValue()));
+        } else {
+            LOGGER.warn("Can not extract UID and/or MailboxId for search result " + hit.getId());
             return Optional.empty();
         }
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
index 8467afd..5d55b63 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
@@ -30,6 +30,7 @@ import org.apache.james.mailbox.elasticsearch.query.CriterionConverter;
 import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
 import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
@@ -67,7 +68,7 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
         MailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
         messageSearchIndex = new ElasticSearchListeningMessageSearchIndex(mapperFactory,
             new ElasticSearchIndexer(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor(), BATCH_SIZE)),
-            new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), SEARCH_SIZE),
+            new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), SEARCH_SIZE, new InMemoryId.Factory()),
             new MessageToElasticSearchJson(new DefaultTextExtractor(), ZoneId.of("Europe/Paris")));
         storeMailboxManager = new InMemoryMailboxManager(
             mapperFactory,

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
index c9585b5..13ce4ac 100644
--- a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
+++ b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
@@ -30,9 +30,9 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Set;
 import java.util.TimeZone;
 
@@ -42,7 +42,10 @@ import javax.mail.Flags.Flag;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.UnsupportedSearchException;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxId.Factory;
 import org.apache.james.mailbox.model.MessageRange;
+import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.model.SearchQuery.AllCriterion;
 import org.apache.james.mailbox.model.SearchQuery.ContainsOperator;
@@ -94,6 +97,7 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.search.BooleanClause;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.IndexSearcher;
+import org.apache.lucene.search.MatchAllDocsQuery;
 import org.apache.lucene.search.NumericRangeQuery;
 import org.apache.lucene.search.PrefixQuery;
 import org.apache.lucene.search.Query;
@@ -109,6 +113,10 @@ import org.apache.lucene.store.LockObtainFailedException;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.Version;
 
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.Multimap;
+
 /**
  * Lucene based {@link ListeningMessageSearchIndex} which offers message searching via a Lucene index
  * 
@@ -296,12 +304,6 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
     private final static String MEDIA_TYPE_MESSAGE = "message"; 
     private final static String DEFAULT_ENCODING = "US-ASCII";
     
-    private final IndexWriter writer;
-    
-    private int maxQueryResults = DEFAULT_MAX_QUERY_RESULTS;
-
-    private boolean suffixMatch = false;
-    
     private final static SortField UID_SORT = new SortField(UID_FIELD, SortField.LONG);
     private final static SortField UID_SORT_REVERSE = new SortField(UID_FIELD, SortField.LONG, true);
 
@@ -332,21 +334,30 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
 
     private final static SortField FIRST_FROM_MAILBOX_DISPLAY_SORT = new SortField(FIRST_FROM_MAILBOX_DISPLAY_FIELD, SortField.STRING);
     private final static SortField FIRST_FROM_MAILBOX_DISPLAY_SORT_REVERSE = new SortField(FIRST_FROM_MAILBOX_DISPLAY_FIELD, SortField.STRING, true);
+    
+    private final Factory mailboxIdFactory;
+    private final IndexWriter writer;
+    
+    private int maxQueryResults = DEFAULT_MAX_QUERY_RESULTS;
+
+    private boolean suffixMatch = false;
 
     
-    public LuceneMessageSearchIndex(MessageMapperFactory factory, Directory directory) throws CorruptIndexException, LockObtainFailedException, IOException {
-        this(factory, directory, false, true);
+    public LuceneMessageSearchIndex(MessageMapperFactory factory, MailboxId.Factory mailboxIdFactory, Directory directory) throws CorruptIndexException, LockObtainFailedException, IOException {
+        this(factory, mailboxIdFactory, directory, false, true);
     }
     
     
-    public LuceneMessageSearchIndex(MessageMapperFactory factory, Directory directory, boolean dropIndexOnStart, boolean lenient) throws CorruptIndexException, LockObtainFailedException, IOException {
+    public LuceneMessageSearchIndex(MessageMapperFactory factory, MailboxId.Factory mailboxIdFactory, Directory directory, boolean dropIndexOnStart, boolean lenient) throws CorruptIndexException, LockObtainFailedException, IOException {
         super(factory);
+        this.mailboxIdFactory = mailboxIdFactory;
         this.writer = new IndexWriter(directory,  createConfig(createAnalyzer(lenient), dropIndexOnStart));
     }
     
     
-    public LuceneMessageSearchIndex(MessageMapperFactory factory, IndexWriter writer) {
+    public LuceneMessageSearchIndex(MessageMapperFactory factory, MailboxId.Factory mailboxIdFactory, IndexWriter writer) {
         super(factory);
+        this.mailboxIdFactory = mailboxIdFactory;
         this.writer = writer;
     }
 
@@ -409,26 +420,47 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
      * @see org.apache.james.mailbox.store.search.MessageSearchIndex#search(org.apache.james.mailbox.MailboxSession, org.apache.james.mailbox.store.mail.model.Mailbox, org.apache.james.mailbox.model.SearchQuery)
      */
     public Iterator<Long> search(MailboxSession session, Mailbox mailbox, SearchQuery searchQuery) throws MailboxException {
-        Set<Long> uids = new LinkedHashSet<Long>();
+        MailboxId mailboxId = mailbox.getMailboxId();
+        Multimap<MailboxId, Long> results = 
+                searchMultimap(
+                    session, 
+                    MultimailboxesSearchQuery
+                        .from(searchQuery)
+                        .inMailboxes(mailboxId)
+                        .build());
+        return results.get(mailboxId).iterator();
+    }
+
+    @Override
+    public Map<MailboxId, Collection<Long>> search(MailboxSession session, MultimailboxesSearchQuery searchQuery) throws MailboxException {
+        return searchMultimap(session, searchQuery).asMap();
+    }
+    
+    private Multimap<MailboxId, Long> searchMultimap(MailboxSession session, MultimailboxesSearchQuery searchQuery) throws MailboxException {
+        Multimap<MailboxId, Long> results = LinkedHashMultimap.create();
         IndexSearcher searcher = null;
 
+        Query inMailboxes = buildQueryFromMailboxes(searchQuery.getMailboxIds());
+        
         try {
             searcher = new IndexSearcher(IndexReader.open(writer, true));
             BooleanQuery query = new BooleanQuery();
-            query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().serialize())), BooleanClause.Occur.MUST);
+            query.add(inMailboxes, BooleanClause.Occur.MUST);
             // Not return flags documents
             query.add(new PrefixQuery(new Term(FLAGS_FIELD, "")), BooleanClause.Occur.MUST_NOT);
-            List<Criterion> crits = searchQuery.getCriterias();
+            List<Criterion> crits = searchQuery.getSearchQuery().getCriterias();
             for (Criterion crit : crits) {
-                query.add(createQuery(crit, mailbox, searchQuery.getRecentMessageUids()), BooleanClause.Occur.MUST);
+                query.add(createQuery(crit, inMailboxes, searchQuery.getSearchQuery().getRecentMessageUids()), BooleanClause.Occur.MUST);
             }
 
             // query for all the documents sorted as specified in the SearchQuery
-            TopDocs docs = searcher.search(query, null, maxQueryResults, createSort(searchQuery.getSorts()));
+            TopDocs docs = searcher.search(query, null, maxQueryResults, createSort(searchQuery.getSearchQuery().getSorts()));
             ScoreDoc[] sDocs = docs.scoreDocs;
             for (ScoreDoc sDoc : sDocs) {
-                long uid = Long.valueOf(searcher.doc(sDoc.doc).get(UID_FIELD));
-                uids.add(uid);
+                Document doc = searcher.doc(sDoc.doc);
+                long uid = Long.valueOf(doc.get(UID_FIELD));
+                MailboxId mailboxId = mailboxIdFactory.fromString(doc.get(MAILBOX_ID_FIELD));
+                results.put(mailboxId, uid);
             }
         } catch (IOException e) {
             throw new MailboxException("Unable to search the mailbox", e);
@@ -441,10 +473,22 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
                 }
             }
         }
-        return uids.iterator();
+        return results;
     }
-
    
+    private Query buildQueryFromMailboxes(ImmutableSet<MailboxId> mailboxIds) {
+        if (mailboxIds.isEmpty()) {
+            return new MatchAllDocsQuery();
+        }
+        BooleanQuery query = new BooleanQuery();
+        for (MailboxId id: mailboxIds) {
+            String idAsString = id.serialize();
+            query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, idAsString)), BooleanClause.Occur.SHOULD);
+        }
+        return query;
+    }
+
+
     /**
      * Create a new {@link Document} for the given {@link MailboxMessage}. This Document does not contain any flags data. The {@link Flags} are stored in a seperate Document.
      * 
@@ -885,7 +929,7 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
      * @return query
      * @throws UnsupportedSearchException
      */
-    private Query createFlagQuery(String flag, boolean isSet, Mailbox mailbox, Collection<Long> recentUids) throws MailboxException, UnsupportedSearchException {
+    private Query createFlagQuery(String flag, boolean isSet, Query inMailboxes, Collection<Long> recentUids) throws MailboxException, UnsupportedSearchException {
         BooleanQuery query = new BooleanQuery();
         
         if (isSet) {   
@@ -898,7 +942,7 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
             
             query.add(bQuery, BooleanClause.Occur.MUST);
         }
-        query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().serialize())), BooleanClause.Occur.MUST);
+        query.add(inMailboxes, BooleanClause.Occur.MUST);
         
         
         IndexSearcher searcher = null;
@@ -932,7 +976,7 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
             }
             return createUidQuery((UidCriterion) SearchQuery.uid(nRanges));
         } catch (IOException e) {
-            throw new MailboxException("Unable to search mailbox " + mailbox, e);
+            throw new MailboxException("Unable to search mailbox " + inMailboxes, e);
         } finally {
             if (searcher != null) {
                 try {
@@ -1114,26 +1158,26 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
      * @return query
      * @throws UnsupportedSearchException
      */
-    private Query createConjunctionQuery(SearchQuery.ConjunctionCriterion crit, Mailbox mailbox, Collection<Long> recentUids) throws UnsupportedSearchException, MailboxException {
+    private Query createConjunctionQuery(SearchQuery.ConjunctionCriterion crit, Query inMailboxes, Collection<Long> recentUids) throws UnsupportedSearchException, MailboxException {
         List<Criterion> crits = crit.getCriteria();
         BooleanQuery conQuery = new BooleanQuery();
         switch (crit.getType()) {
         case AND:
             for (Criterion criterion : crits) {
-                conQuery.add(createQuery(criterion, mailbox, recentUids), BooleanClause.Occur.MUST);
+                conQuery.add(createQuery(criterion, inMailboxes, recentUids), BooleanClause.Occur.MUST);
             }
             return conQuery;
         case OR:
             for (Criterion criterion : crits) {
-                conQuery.add(createQuery(criterion, mailbox, recentUids), BooleanClause.Occur.SHOULD);
+                conQuery.add(createQuery(criterion, inMailboxes, recentUids), BooleanClause.Occur.SHOULD);
             }
             return conQuery;
         case NOR:
             BooleanQuery nor = new BooleanQuery();
             for (Criterion criterion : crits) {
-                conQuery.add(createQuery(criterion, mailbox, recentUids), BooleanClause.Occur.SHOULD);
+                conQuery.add(createQuery(criterion, inMailboxes, recentUids), BooleanClause.Occur.SHOULD);
             }
-            nor.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().serialize())), BooleanClause.Occur.MUST);
+            nor.add(inMailboxes, BooleanClause.Occur.MUST);
 
             nor.add(conQuery, BooleanClause.Occur.MUST_NOT);
             return nor;
@@ -1150,7 +1194,7 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
      * @return query
      * @throws UnsupportedSearchException
      */
-    private Query createQuery(Criterion criterion, Mailbox mailbox, Collection<Long> recentUids) throws UnsupportedSearchException, MailboxException {
+    private Query createQuery(Criterion criterion, Query inMailboxes, Collection<Long> recentUids) throws UnsupportedSearchException, MailboxException {
         if (criterion instanceof SearchQuery.InternalDateCriterion) {
             SearchQuery.InternalDateCriterion crit = (SearchQuery.InternalDateCriterion) criterion;
             return createInternalDateQuery(crit);
@@ -1165,10 +1209,10 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
             return createUidQuery(crit);
         } else if (criterion instanceof SearchQuery.FlagCriterion) {
             FlagCriterion crit = (FlagCriterion) criterion;
-            return createFlagQuery(toString(crit.getFlag()), crit.getOperator().isSet(), mailbox, recentUids);
+            return createFlagQuery(toString(crit.getFlag()), crit.getOperator().isSet(), inMailboxes, recentUids);
         } else if (criterion instanceof SearchQuery.CustomFlagCriterion) {
             CustomFlagCriterion crit = (CustomFlagCriterion) criterion;
-            return createFlagQuery(crit.getFlag(), crit.getOperator().isSet(), mailbox, recentUids);
+            return createFlagQuery(crit.getFlag(), crit.getOperator().isSet(), inMailboxes, recentUids);
         } else if (criterion instanceof SearchQuery.TextCriterion) {
             SearchQuery.TextCriterion crit = (SearchQuery.TextCriterion) criterion;
             return createTextQuery(crit);
@@ -1176,7 +1220,7 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
             return createAllQuery((AllCriterion) criterion);
         } else if (criterion instanceof SearchQuery.ConjunctionCriterion) {
             SearchQuery.ConjunctionCriterion crit = (SearchQuery.ConjunctionCriterion) criterion;
-            return createConjunctionQuery(crit, mailbox, recentUids);
+            return createConjunctionQuery(crit, inMailboxes, recentUids);
         } else if (criterion instanceof SearchQuery.ModSeqCriterion) {
             return createModSeqQuery((SearchQuery.ModSeqCriterion) criterion);
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
index f9d5158..9b1417a 100644
--- a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
+++ b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import java.nio.charset.Charset;
 import java.util.Arrays;
 import java.util.Calendar;
+import java.util.Collection;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -33,6 +34,8 @@ import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 
 import org.apache.james.mailbox.model.MailboxACL;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.model.SearchQuery.AddressType;
 import org.apache.james.mailbox.model.SearchQuery.DateResolution;
@@ -73,7 +76,7 @@ public class LuceneMailboxMessageSearchIndexTest {
     
     @Before
     public void setUp() throws Exception {
-        index = new LuceneMessageSearchIndex(null, new RAMDirectory(), true, useLenient());
+        index = new LuceneMessageSearchIndex(null, new TestId.Factory(), new RAMDirectory(), true, useLenient());
         index.setEnableSuffixMatch(true);
         Map<String, String> headersSubject = new HashMap<String, String>();
         headersSubject.put("Subject", "test (fwd)");
@@ -242,6 +245,35 @@ public class LuceneMailboxMessageSearchIndexTest {
         Iterator<Long> result = index.search(null, mailbox2, query);
         assertThat(result).containsExactly(1L);
     }
+
+    @Test
+    public void searchBodyInAllMailboxesShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.bodyContains("My Body"));
+        Map<MailboxId, Collection<Long>> result = index.search(null, MultimailboxesSearchQuery.from(query).build());
+        assertThat(result).hasSize(2);
+        assertThat(result.get(mailbox.id)).containsExactly(1L);
+        assertThat(result.get(mailbox2.id)).containsExactly(1L);
+    }
+
+    @Test
+    public void searchBodyInSpecificMailboxesShouldMatch() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.bodyContains("My Body"));
+        Map<MailboxId, Collection<Long>> result = index.search(null, 
+                MultimailboxesSearchQuery.from(query).inMailboxes(mailbox.id, mailbox3.id).build());
+        assertThat(result).hasSize(1);
+        assertThat(result.get(mailbox.id)).containsExactly(1L);
+    }
+
+
+    @Test
+    public void searchAllShouldMatchAllUserEmails() throws Exception {
+        SearchQuery query = new SearchQuery();
+        query.andCriteria(SearchQuery.all());
+        Map<MailboxId, Collection<Long>> result = index.search(null, MultimailboxesSearchQuery.from(query).build());
+        assertThat(result).hasSize(3);
+    }
     
     @Test
     public void flagSearchShouldMatch() throws Exception {

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
index db25e07..51f5ae7 100644
--- a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
+++ b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
@@ -22,6 +22,7 @@ package org.apache.james.mailbox.lucene.search;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.JVMMailboxPathLocker;
@@ -41,7 +42,7 @@ public class LuceneMessageSearchIndexTest extends AbstractMessageSearchIndexTest
     @Override
     protected void initializeMailboxManager() throws Exception {
         MailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
-        messageSearchIndex = new LuceneMessageSearchIndex(mapperFactory, new RAMDirectory());
+        messageSearchIndex = new LuceneMessageSearchIndex(mapperFactory, new InMemoryId.Factory(), new RAMDirectory());
         storeMailboxManager = new InMemoryMailboxManager(
             mapperFactory,
             new MockAuthenticator(),
@@ -56,7 +57,7 @@ public class LuceneMessageSearchIndexTest extends AbstractMessageSearchIndexTest
     /**
      * 15 tests out of 54 are failing
      */
-
+    
     @Ignore
     @Override
     public void uidShouldreturnEveryThing() throws Exception {
@@ -131,4 +132,14 @@ public class LuceneMessageSearchIndexTest extends AbstractMessageSearchIndexTest
     @Override
     public void modSeqEqualsShouldReturnUidsOfMessageHavingAGivenModSeq() throws Exception {
     }
+
+    @Ignore
+    @Override
+    public void multimailboxSearchShouldReturnUidOfMessageMarkedAsSeenInTwoMailboxes() throws MailboxException {
+    }
+
+    @Ignore
+    @Override
+    public void multimailboxSearchShouldReturnUidOfMessageMarkedAsSeenInAllMailboxes() throws MailboxException {
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java
index 51602d5..c5139fc 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java
@@ -22,6 +22,14 @@ import org.apache.james.mailbox.model.MailboxId;
 
 public class InMemoryId implements MailboxId {
 
+    public static class Factory implements MailboxId.Factory {
+        
+        @Override
+        public MailboxId fromString(String serialized) {
+            return of(Long.valueOf(serialized));
+        }
+    }
+    
     public static InMemoryId of(long value) {
         return new InMemoryId(value);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
index c484c64..f034769 100644
--- a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
+++ b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
@@ -214,4 +214,29 @@ public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest
     @Override
     public void sortShouldOrderMessages() throws Exception {
     }
+    
+    @Ignore
+    @Override
+    public void multimailboxSearchShouldReturnUidOfMessageMarkedAsSeenInTwoMailboxes() throws MailboxException {
+    }
+
+    @Ignore
+    @Override
+    public void multimailboxSearchShouldReturnUidOfMessageMarkedAsSeenInAllMailboxes() throws MailboxException {
+    }
+    
+    @Ignore
+    @Override
+    public void multimailboxSearchShouldReturnUidOfMessageWithExpectedFromInTwoMailboxes() throws MailboxException {
+    }
+    
+    @Ignore
+    @Override
+    public void multimailboxSearchShouldReturnUidOfMessageWithExpectedFromInAllMailboxes() throws MailboxException {
+    }
+    
+    @Ignore
+    @Override
+    public void multimailboxSearchShouldReturnUidOfMessageMarkedAsSeenInOneMailbox() throws MailboxException {
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
index 3d5d1ae..82704f9 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
@@ -18,14 +18,18 @@
  ****************************************************************/
 package org.apache.james.mailbox.store.search;
 
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.exception.UnsupportedSearchException;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageRange;
+import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.mail.MessageMapper.FetchType;
@@ -110,4 +114,10 @@ public class LazyMessageSearchIndex extends ListeningMessageSearchIndex {
     public void update(MailboxSession session, Mailbox mailbox, List<UpdatedFlags> updatedFlagsList) throws MailboxException {
         index.update(session, mailbox, updatedFlagsList);
     }
+    
+
+    @Override
+    public Map<MailboxId, Collection<Long>> search(MailboxSession session, MultimailboxesSearchQuery searchQuery) throws MailboxException {
+        throw new UnsupportedSearchException();
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
index c3ed9dd..b120b3a 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
@@ -19,10 +19,14 @@
 
 package org.apache.james.mailbox.store.search;
 
+import java.util.Collection;
 import java.util.Iterator;
+import java.util.Map;
 
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
@@ -37,11 +41,12 @@ public interface MessageSearchIndex {
     
     /**
      * Return all uids of the previous indexed {@link Mailbox}'s which match the {@link SearchQuery}
-     * 
-     * @param mailbox
-     * @param searchQuery
-     * @return Iterator on found uids
-     * @throws MailboxException
      */
     Iterator<Long> search(MailboxSession session, Mailbox mailbox, SearchQuery searchQuery) throws MailboxException;
+
+    /**
+     * Return all uids of all {@link Mailbox}'s the current user has access to which match the {@link SearchQuery}
+     */
+    Map<MailboxId, Collection<Long>> search(MailboxSession session, MultimailboxesSearchQuery searchQuery) throws MailboxException;
+
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
index 99d38f6..e4712c2 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
@@ -18,8 +18,10 @@
  ****************************************************************/
 package org.apache.james.mailbox.store.search;
 
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
@@ -27,7 +29,10 @@ import javax.inject.Inject;
 
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.exception.UnsupportedSearchException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageRange;
+import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.model.SearchQuery.ConjunctionCriterion;
 import org.apache.james.mailbox.model.SearchQuery.Criterion;
@@ -109,4 +114,9 @@ public class SimpleMessageSearchIndex implements MessageSearchIndex {
 		}
     }
 
+    @Override
+    public Map<MailboxId, Collection<Long>> search(MailboxSession session, MultimailboxesSearchQuery searchQuery) throws MailboxException {
+        throw new UnsupportedSearchException();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestId.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestId.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestId.java
index aa097c7..31b695c 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestId.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestId.java
@@ -22,6 +22,14 @@ import org.apache.james.mailbox.model.MailboxId;
 
 public class TestId implements MailboxId {
 
+    public static class Factory implements MailboxId.Factory {
+        
+        @Override
+        public MailboxId fromString(String serialized) {
+            return TestId.of(Long.valueOf(serialized));
+        }
+    }
+    
     public static TestId of(long id) {
         return new TestId(id);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
index d52cbfe..d2ab3d8 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
@@ -19,16 +19,19 @@
 
 package org.apache.james.mailbox.store.search;
 
-import static org.assertj.core.api.Assertions.assertThat;
-
+import java.util.Collection;
 import java.util.Date;
+import java.util.Map;
 
 import javax.mail.Flags;
 
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
 import org.apache.james.mailbox.model.SearchQuery;
+import org.apache.james.mailbox.model.SearchQuery.AddressType;
 import org.apache.james.mailbox.store.StoreMailboxManager;
 import org.apache.james.mailbox.store.StoreMessageManager;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
@@ -39,6 +42,8 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.Lists;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
 public abstract class AbstractMessageSearchIndexTest {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(AbstractMessageSearchIndexTest.class);
@@ -46,6 +51,7 @@ public abstract class AbstractMessageSearchIndexTest {
     protected MessageSearchIndex messageSearchIndex;
     protected StoreMailboxManager storeMailboxManager;
     private Mailbox mailbox;
+    private Mailbox mailbox2;
     private MailboxSession session;
 
     @Before
@@ -54,13 +60,18 @@ public abstract class AbstractMessageSearchIndexTest {
 
         session = storeMailboxManager.createSystemSession("benwa", LOGGER);
 
-        storeMailboxManager.createMailbox(new MailboxPath("#private", "benwa", "INBOX"), session);
-        StoreMessageManager messageManager = (StoreMessageManager) storeMailboxManager.getMailbox(new MailboxPath("#private", "benwa", "INBOX"), session);
-        mailbox = messageManager.getMailboxEntity();
+        MailboxPath inboxPath = new MailboxPath("#private", "benwa", "INBOX");
+        storeMailboxManager.createMailbox(inboxPath, session);
+        StoreMessageManager inboxMessageManager = (StoreMessageManager) storeMailboxManager.getMailbox(inboxPath, session);
+        MailboxPath myFolderPath = new MailboxPath("#private", "benwa", "MyFolder");
+        storeMailboxManager.createMailbox(myFolderPath, session);
+        StoreMessageManager myFolderMessageManager = (StoreMessageManager) storeMailboxManager.getMailbox(myFolderPath, session);
+        mailbox = inboxMessageManager.getMailboxEntity();
+        mailbox2 = myFolderMessageManager.getMailboxEntity();
 
         // sentDate: Wed, 3 Jun 2015 09:05:46 +0000
         // Internal date : 2014/01/02 00:00:00.000
-        messageManager.appendMessage(
+        inboxMessageManager.appendMessage(
             ClassLoader.getSystemResourceAsStream("eml/spamMail.eml"),
             new Date(1388617200000L),
             session,
@@ -68,7 +79,7 @@ public abstract class AbstractMessageSearchIndexTest {
             new Flags(Flags.Flag.DELETED));
         // sentDate: Thu, 4 Jun 2015 09:23:37 +0000
         // Internal date : 2014/02/02 00:00:00.000
-        messageManager.appendMessage(
+        inboxMessageManager.appendMessage(
             ClassLoader.getSystemResourceAsStream("eml/mail1.eml"),
             new Date(1391295600000L),
             session,
@@ -76,7 +87,7 @@ public abstract class AbstractMessageSearchIndexTest {
             new Flags(Flags.Flag.ANSWERED));
         // sentDate: Thu, 4 Jun 2015 09:27:37 +0000
         // Internal date : 2014/03/02 00:00:00.000
-        messageManager.appendMessage(
+        inboxMessageManager.appendMessage(
             ClassLoader.getSystemResourceAsStream("eml/mail2.eml"),
             new Date(1393714800000L),
             session,
@@ -84,7 +95,7 @@ public abstract class AbstractMessageSearchIndexTest {
             new Flags(Flags.Flag.DRAFT));
         // sentDate: Tue, 2 Jun 2015 08:16:19 +0000
         // Internal date : 2014/05/02 00:00:00.000
-        messageManager.appendMessage(
+        inboxMessageManager.appendMessage(
             ClassLoader.getSystemResourceAsStream("eml/mail3.eml"),
             new Date(1398981600000L),
             session,
@@ -92,7 +103,7 @@ public abstract class AbstractMessageSearchIndexTest {
             new Flags(Flags.Flag.RECENT));
         // sentDate: Fri, 15 May 2015 06:35:59 +0000
         // Internal date : 2014/04/02 00:00:00.000
-        messageManager.appendMessage(
+        inboxMessageManager.appendMessage(
             ClassLoader.getSystemResourceAsStream("eml/mail4.eml"),
             new Date(1396389600000L),
             session,
@@ -100,7 +111,7 @@ public abstract class AbstractMessageSearchIndexTest {
             new Flags(Flags.Flag.FLAGGED));
         // sentDate: Wed, 03 Jun 2015 19:14:32 +0000
         // Internal date : 2014/06/02 00:00:00.000
-        messageManager.appendMessage(
+        inboxMessageManager.appendMessage(
             ClassLoader.getSystemResourceAsStream("eml/pgpSignedMail.eml"),
             new Date(1401660000000L),
             session,
@@ -108,7 +119,7 @@ public abstract class AbstractMessageSearchIndexTest {
             new Flags(Flags.Flag.SEEN));
         // sentDate: Thu, 04 Jun 2015 07:36:08 +0000
         // Internal date : 2014/07/02 00:00:00.000
-        messageManager.appendMessage(
+        inboxMessageManager.appendMessage(
             ClassLoader.getSystemResourceAsStream("eml/htmlMail.eml"),
             new Date(1404252000000L),
             session,
@@ -116,21 +127,28 @@ public abstract class AbstractMessageSearchIndexTest {
             new Flags());
         // sentDate: Thu, 4 Jun 2015 06:08:41 +0200
         // Internal date : 2014/08/02 00:00:00.000
-        messageManager.appendMessage(
+        inboxMessageManager.appendMessage(
             ClassLoader.getSystemResourceAsStream("eml/mail.eml"),
             new Date(1406930400000L),
             session,
             true,
             new Flags("Hello"));
+        // sentDate: Thu, 4 Jun 2015 06:08:41 +0200
+        // Internal date : 2014/08/02 00:00:00.000
+        myFolderMessageManager.appendMessage(
+            ClassLoader.getSystemResourceAsStream("eml/mail.eml"),
+            new Date(1406930400000L),
+            session,
+            true,
+            new Flags(Flags.Flag.SEEN));
         // sentDate: Tue, 2 Jun 2015 12:00:55 +0200
         // Internal date : 2014/09/02 00:00:00.000
-        messageManager.appendMessage(
+        inboxMessageManager.appendMessage(
             ClassLoader.getSystemResourceAsStream("eml/frnog.eml"),
             new Date(1409608800000L),
             session,
             true,
             new Flags("Hello you"));
-
         await();
     }
 
@@ -224,8 +242,76 @@ public abstract class AbstractMessageSearchIndexTest {
         assertThat(messageSearchIndex.search(session, mailbox, searchQuery))
             .containsOnly(6L);
     }
+    
+    @Test
+    public void multimailboxSearchShouldReturnUidOfMessageMarkedAsSeenInAllMailboxes() throws MailboxException {
+        SearchQuery searchQuery = new SearchQuery();
+        searchQuery.andCriteria(SearchQuery.flagIsSet(Flags.Flag.SEEN));
+        Map<MailboxId, Collection<Long>> actual = messageSearchIndex.search(session, MultimailboxesSearchQuery.from(searchQuery).build());
+        assertThat(actual.entrySet()).hasSize(2);
+        assertThat(actual.get(mailbox.getMailboxId())).containsExactly(6L);
+        assertThat(actual.get(mailbox2.getMailboxId())).containsExactly(1L);
+    }
 
     @Test
+    public void multimailboxSearchShouldReturnUidOfMessageMarkedAsSeenInOneMailbox() throws MailboxException {
+        SearchQuery searchQuery = new SearchQuery();
+        searchQuery.andCriteria(SearchQuery.flagIsSet(Flags.Flag.SEEN));
+        MultimailboxesSearchQuery query = 
+                MultimailboxesSearchQuery
+                    .from(searchQuery)
+                    .inMailboxes(mailbox.getMailboxId())
+                    .build();
+        Map<MailboxId, Collection<Long>> actual = messageSearchIndex.search(session, query);
+        assertThat(actual.entrySet()).hasSize(1);
+        assertThat(actual.get(mailbox.getMailboxId())).containsExactly(6L);
+    }
+
+    @Test
+    public void multimailboxSearchShouldReturnUidOfMessageWithExpectedFromInTwoMailboxes() throws MailboxException {
+        SearchQuery searchQuery = new SearchQuery();
+        searchQuery.andCriteria(SearchQuery.address(AddressType.From, "murari"));
+        MultimailboxesSearchQuery query = 
+                MultimailboxesSearchQuery
+                    .from(searchQuery)
+                    .inMailboxes(mailbox.getMailboxId(), mailbox2.getMailboxId())
+                    .build();
+        Map<MailboxId, Collection<Long>> actual = messageSearchIndex.search(session, query);
+        assertThat(actual.entrySet()).hasSize(2);
+        assertThat(actual.get(mailbox.getMailboxId())).containsExactly(8L);
+        assertThat(actual.get(mailbox2.getMailboxId())).containsExactly(1L);
+    }
+
+    @Test
+    public void multimailboxSearchShouldReturnUidOfMessageWithExpectedFromInAllMailboxes() throws MailboxException {
+        SearchQuery searchQuery = new SearchQuery();
+        searchQuery.andCriteria(SearchQuery.address(AddressType.From, "murari"));
+        MultimailboxesSearchQuery query = 
+                MultimailboxesSearchQuery
+                    .from(searchQuery)
+                    .build();
+        Map<MailboxId, Collection<Long>> actual = messageSearchIndex.search(session, query);
+        assertThat(actual.entrySet()).hasSize(2);
+        assertThat(actual.get(mailbox.getMailboxId())).containsExactly(8L);
+        assertThat(actual.get(mailbox2.getMailboxId())).containsExactly(1L);
+    }
+
+    @Test
+    public void multimailboxSearchShouldReturnUidOfMessageMarkedAsSeenInTwoMailboxes() throws MailboxException {
+        SearchQuery searchQuery = new SearchQuery();
+        searchQuery.andCriteria(SearchQuery.flagIsSet(Flags.Flag.SEEN));
+        MultimailboxesSearchQuery query = 
+                MultimailboxesSearchQuery
+                    .from(searchQuery)
+                    .inMailboxes(mailbox.getMailboxId(), mailbox2.getMailboxId())
+                    .build();
+        Map<MailboxId, Collection<Long>> actual = messageSearchIndex.search(session, query);
+        assertThat(actual.entrySet()).hasSize(2);
+        assertThat(actual.get(mailbox.getMailboxId())).containsExactly(6L);
+        assertThat(actual.get(mailbox2.getMailboxId())).containsExactly(1L);
+    }
+    
+    @Test
     public void flagIsSetShouldReturnUidsOfMessageContainingAGivenUserFlag() throws MailboxException {
         SearchQuery searchQuery = new SearchQuery();
         searchQuery.andCriteria(SearchQuery.flagIsSet("Hello"));

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/UidSearchAtomsIndexer.test
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/UidSearchAtomsIndexer.test b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/UidSearchAtomsIndexer.test
index 39bd1e3..320cbe9 100644
--- a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/UidSearchAtomsIndexer.test
+++ b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/UidSearchAtomsIndexer.test
@@ -2211,4 +2211,39 @@ S: A135 OK SEARCH completed\.
 
 # C: A139 UID SEARCH NEW
 # S: \* SEARCH 23 24 28 29 33 34 38 39
-# S: A139 OK SEARCH completed\.
\ No newline at end of file
+# S: A139 OK SEARCH completed\.
+
+C: A200 CREATE secondmailbox
+S: A200 OK CREATE completed\.
+
+C: A201 SELECT secondmailbox
+S: \* FLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\Seen\)
+S: \* 0 EXISTS
+S: \* 0 RECENT
+S: \* OK \[UIDVALIDITY (.)*
+S: \* OK \[PERMANENTFLAGS \(\\Answered \\Deleted \\Draft \\Flagged \\\Seen( \\\*)?\)\](.)*
+S: \* OK \[HIGHESTMODSEQ \d+\].*
+S: \* OK \[UIDNEXT 1\].*
+S: A201 OK \[READ-WRITE\] SELECT completed\.
+
+C: A202 APPEND secondmailbox {185+}
+C: From: Timothy Tayler <ti...@example.org>
+C: To: Samual Smith <sa...@example.org>
+C: Date: Thu, 14 Feb 2008 12:00:00 +0000 (GMT)
+C: Subject: A Simple Email
+C: 
+C: This is a very simple email.
+C: 
+S: \* 1 EXISTS
+S: \* 1 RECENT
+S: A202 OK (\[.+\] )?APPEND completed\.
+
+LOG INFO Waiting for ElasticSearch to index data
+
+WAIT 1000
+
+LOG INFO Performing tests about search
+
+C: A203 UID SEARCH FROM "Timothy"
+S: \* SEARCH 1
+S: A203 OK SEARCH completed\.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
index 6aaf843..b354514 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
@@ -44,6 +44,7 @@ import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
 import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.MockAuthenticator;
@@ -105,7 +106,7 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
         ElasticSearchListeningMessageSearchIndex searchIndex = new ElasticSearchListeningMessageSearchIndex(
             factory,
             new ElasticSearchIndexer(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor())),
-            new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter())),
+            new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), new InMemoryId.Factory()),
             new MessageToElasticSearchJson(new DefaultTextExtractor()));
 
         MailboxACLResolver aclResolver = new UnionMailboxACLResolver();

http://git-wip-us.apache.org/repos/asf/james-project/blob/085cf65e/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
index 853ce0b..7d358f3 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
@@ -25,12 +25,14 @@ import org.apache.james.backends.cassandra.components.CassandraModule;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxPathLocker;
 import org.apache.james.mailbox.SubscriptionManager;
+import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.cassandra.CassandraMailboxManager;
 import org.apache.james.mailbox.cassandra.CassandraMailboxSessionMapperFactory;
 import org.apache.james.mailbox.cassandra.CassandraSubscriptionManager;
 import org.apache.james.mailbox.cassandra.mail.CassandraModSeqProvider;
 import org.apache.james.mailbox.cassandra.mail.CassandraUidProvider;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.Authenticator;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.NoMailboxPathLocker;
@@ -60,6 +62,7 @@ public class CassandraMailboxModule extends AbstractModule {
         bind(CassandraModSeqProvider.class).in(Scopes.SINGLETON);
         bind(CassandraUidProvider.class).in(Scopes.SINGLETON);
         bind(UserRepositoryAuthenticator.class).in(Scopes.SINGLETON);
+        bind(CassandraId.Factory.class).in(Scopes.SINGLETON);
 
         bind(MessageMapperFactory.class).to(CassandraMailboxSessionMapperFactory.class);
         bind(MailboxMapperFactory.class).to(CassandraMailboxSessionMapperFactory.class);
@@ -72,6 +75,7 @@ public class CassandraMailboxModule extends AbstractModule {
         bind(MailboxPathLocker.class).to(NoMailboxPathLocker.class);
         bind(Authenticator.class).to(UserRepositoryAuthenticator.class);
         bind(MailboxManager.class).to(CassandraMailboxManager.class);
+        bind(MailboxId.Factory.class).to(CassandraId.Factory.class);
 
         Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(), CassandraModule.class);
         cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraAclModule.class);


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


[4/8] james-project git commit: MAILBOX-273 reorder MailboxCapabilities alphabetically

Posted by ma...@apache.org.
MAILBOX-273 reorder MailboxCapabilities alphabetically


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

Branch: refs/heads/master
Commit: 41cd5448bbdb78f039c3cbf04e96880894bc1d15
Parents: 085cf65
Author: Matthieu Baechler <ma...@linagora.com>
Authored: Tue Jul 19 18:15:02 2016 +0200
Committer: Matthieu Baechler <ma...@linagora.com>
Committed: Mon Jul 25 10:13:30 2016 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/james/mailbox/MailboxManager.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/41cd5448/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
index cfbdc15..1d60bcf 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
@@ -73,10 +73,10 @@ import org.slf4j.Logger;
 public interface MailboxManager extends RequestAware, MailboxListenerSupport {
 
     enum MailboxCapabilities {
+        Annotation,
         Move,
-        UserFlag,
         Namespace,
-        Annotation
+        UserFlag
     }
 
     EnumSet<MailboxCapabilities> getSupportedMailboxCapabilities();


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