james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject james-project git commit: MAILBOX-270: MailboxMapper has to be unique on mapper factory
Date Thu, 08 Sep 2016 07:43:35 GMT
Repository: james-project
Updated Branches:
  refs/heads/master baae24e23 -> f88464d77


MAILBOX-270: MailboxMapper has to be unique on mapper factory


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

Branch: refs/heads/master
Commit: f88464d775a5927d5a6bbd6650daf3435630eeef
Parents: baae24e
Author: Quynh Nguyen <qnguyen@linagora.com>
Authored: Tue Aug 30 15:49:38 2016 +0700
Committer: Quynh Nguyen <qnguyen@linagora.com>
Committed: Thu Sep 8 12:14:32 2016 +0700

----------------------------------------------------------------------
 .../CachingMailboxSessionMapperFactory.java     |   2 +-
 .../CassandraMailboxSessionMapperFactory.java   |   4 +-
 .../mail/CassandraAnnotationMapper.java         |  51 +++++----
 .../cassandra/mail/CassandraMapperProvider.java |   2 +-
 .../hbase/HBaseMailboxSessionMapperFactory.java |   3 +-
 .../jcr/JCRMailboxSessionMapperFactory.java     |   2 +-
 .../jpa/JPAMailboxSessionMapperFactory.java     |   2 +-
 .../MaildirMailboxSessionMapperFactory.java     |   2 +-
 .../InMemoryMailboxSessionMapperFactory.java    |   6 +-
 .../inmemory/mail/InMemoryAnnotationMapper.java |  27 +++--
 .../inmemory/mail/InMemoryMapperProvider.java   |   3 +-
 .../store/MailboxSessionMapperFactory.java      |   6 +-
 .../mailbox/store/StoreMailboxManager.java      |  39 +++----
 .../mailbox/store/mail/AnnotationMapper.java    |  42 ++++---
 .../StoreMailboxManagerAnnotationTest.java      |  20 ++--
 .../store/mail/model/AnnotationMapperTest.java  | 111 ++++++++++---------
 16 files changed, 169 insertions(+), 153 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/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 2c5d7b3..d3fe572 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
@@ -56,7 +56,7 @@ public class CachingMailboxSessionMapperFactory extends
     }
 
     @Override
-    public AnnotationMapper createAnnotationMapper(MailboxId mailboxId, MailboxSession session)
+    public AnnotationMapper createAnnotationMapper(MailboxSession session)
             throws MailboxException {
         throw new NotImplementedException();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/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 0c099c7..2350e1b 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
@@ -99,8 +99,8 @@ public class CassandraMailboxSessionMapperFactory extends MailboxSessionMapperFa
     }
 
     @Override
-    public AnnotationMapper createAnnotationMapper(MailboxId mailboxId, MailboxSession mailboxSession)
+    public AnnotationMapper createAnnotationMapper(MailboxSession mailboxSession)
             throws MailboxException {
-        return new CassandraAnnotationMapper((CassandraId)mailboxId, session);
+        return new CassandraAnnotationMapper(session);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapper.java
index 995795a..3984ac7 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraAnnotationMapper.java
@@ -39,6 +39,7 @@ import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.cassandra.table.CassandraAnnotationTable;
 import org.apache.james.mailbox.model.MailboxAnnotation;
 import org.apache.james.mailbox.model.MailboxAnnotationKey;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.apache.james.mailbox.store.transaction.NonTransactionalMapper;
 
@@ -49,48 +50,50 @@ import com.google.common.base.Preconditions;
 
 public class CassandraAnnotationMapper extends NonTransactionalMapper implements AnnotationMapper {
 
-    private final CassandraId mailboxId;
     private final Session session;
 
-    public CassandraAnnotationMapper(CassandraId mailboxId, Session session) {
-        this.mailboxId = mailboxId;
+    public CassandraAnnotationMapper(Session session) {
         this.session = session;
     }
 
-    public List<MailboxAnnotation> getAllAnnotations() {
-        return CassandraUtils.convertToStream(session.execute(getStoredAnnotationsQuery()))
+    public List<MailboxAnnotation> getAllAnnotations(MailboxId mailboxId) {
+        CassandraId cassandraId = (CassandraId)mailboxId;
+        return CassandraUtils.convertToStream(session.execute(getStoredAnnotationsQuery(cassandraId)))
             .map(this::toAnnotation)
             .collect(Collectors.toList());
     }
 
-    public List<MailboxAnnotation> getAnnotationsByKeys(Set<MailboxAnnotationKey> keys) {
-        return CassandraUtils.convertToStream(session.execute(getStoredAnnotationsQueryForKeys(keys)))
+    public List<MailboxAnnotation> getAnnotationsByKeys(MailboxId mailboxId, Set<MailboxAnnotationKey> keys) {
+        CassandraId cassandraId = (CassandraId)mailboxId;
+        return CassandraUtils.convertToStream(session.execute(getStoredAnnotationsQueryForKeys(cassandraId, keys)))
             .map(this::toAnnotation)
             .collect(Collectors.toList());
     }
 
-    public List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(Set<MailboxAnnotationKey> keys) {
+    public List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxId mailboxId, Set<MailboxAnnotationKey> keys) {
+        CassandraId cassandraId = (CassandraId)mailboxId;
         return keys.stream()
-            .flatMap(this::getAnnotationsByKeyWithOneDepth)
+            .flatMap(annotation -> getAnnotationsByKeyWithOneDepth(cassandraId, annotation))
             .collect(Guavate.toImmutableList());
     }
 
-    public List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(Set<MailboxAnnotationKey> keys) {
+    public List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxId mailboxId, Set<MailboxAnnotationKey> keys) {
+        CassandraId cassandraId = (CassandraId)mailboxId;
         return keys.stream()
-            .flatMap(this::getAnnotationsByKeyWithAllDepth)
+            .flatMap(annotation -> getAnnotationsByKeyWithAllDepth(cassandraId, annotation))
             .collect(Guavate.toImmutableList());
     }
 
-    public void deleteAnnotation(MailboxAnnotationKey key) {
+    public void deleteAnnotation(MailboxId mailboxId, MailboxAnnotationKey key) {
         session.execute(delete().from(CassandraAnnotationTable.TABLE_NAME)
-            .where(eq(CassandraAnnotationTable.MAILBOX_ID, mailboxId.asUuid()))
+            .where(eq(CassandraAnnotationTable.MAILBOX_ID, ((CassandraId) mailboxId).asUuid()))
             .and(eq(CassandraAnnotationTable.KEY, key.asString())));
     }
 
-    public void insertAnnotation(MailboxAnnotation mailboxAnnotation) {
+    public void insertAnnotation(MailboxId mailboxId, MailboxAnnotation mailboxAnnotation) {
         Preconditions.checkArgument(!mailboxAnnotation.isNil());
         session.execute(insertInto(CassandraAnnotationTable.TABLE_NAME)
-            .value(CassandraAnnotationTable.MAILBOX_ID, mailboxId.asUuid())
+            .value(CassandraAnnotationTable.MAILBOX_ID, ((CassandraId) mailboxId).asUuid())
             .value(CassandraAnnotationTable.KEY, mailboxAnnotation.getKey().asString())
             .value(CassandraAnnotationTable.VALUE, mailboxAnnotation.getValue().get()));
     }
@@ -100,20 +103,20 @@ public class CassandraAnnotationMapper extends NonTransactionalMapper implements
             row.getString(CassandraAnnotationTable.VALUE));
     }
 
-    private Select.Where getStoredAnnotationsQuery() {
+    private Select.Where getStoredAnnotationsQuery(CassandraId mailboxId) {
         return select(CassandraAnnotationTable.SELECT_FIELDS)
             .from(CassandraAnnotationTable.TABLE_NAME)
             .where(eq(CassandraAnnotationTable.MAILBOX_ID, mailboxId.asUuid()));
     }
 
-    private Select.Where getStoredAnnotationsQueryForKeys(Set<MailboxAnnotationKey> keys) {
-        return getStoredAnnotationsQuery().and(in(CassandraAnnotationTable.KEY, keys.stream()
+    private Select.Where getStoredAnnotationsQueryForKeys(CassandraId mailboxId, Set<MailboxAnnotationKey> keys) {
+        return getStoredAnnotationsQuery(mailboxId).and(in(CassandraAnnotationTable.KEY, keys.stream()
             .map(MailboxAnnotationKey::asString)
             .collect(Guavate.toImmutableList())));
     }
 
-    private Select.Where getStoredAnnotationsQueryLikeKey(String key) {
-        return getStoredAnnotationsQuery()
+    private Select.Where getStoredAnnotationsQueryLikeKey(CassandraId mailboxId, String key) {
+        return getStoredAnnotationsQuery(mailboxId)
             .and(gte(CassandraAnnotationTable.KEY, key))
             .and(lte(CassandraAnnotationTable.KEY, buildNextKey(key)));
     }
@@ -122,13 +125,13 @@ public class CassandraAnnotationMapper extends NonTransactionalMapper implements
         return key + MailboxAnnotationKey.SLASH_CHARACTER + Ascii.MAX;
     }
 
-    private Stream<MailboxAnnotation> getAnnotationsByKeyWithAllDepth(MailboxAnnotationKey key) {
-        return CassandraUtils.convertToStream(session.execute(getStoredAnnotationsQueryLikeKey(key.asString())))
+    private Stream<MailboxAnnotation> getAnnotationsByKeyWithAllDepth(CassandraId mailboxId, MailboxAnnotationKey key) {
+        return CassandraUtils.convertToStream(session.execute(getStoredAnnotationsQueryLikeKey(mailboxId, key.asString())))
             .map(this::toAnnotation);
     }
 
-    private Stream<MailboxAnnotation> getAnnotationsByKeyWithOneDepth(MailboxAnnotationKey key) {
-        return CassandraUtils.convertToStream(session.execute(getStoredAnnotationsQueryLikeKey(key.asString())))
+    private Stream<MailboxAnnotation> getAnnotationsByKeyWithOneDepth(CassandraId mailboxId, MailboxAnnotationKey key) {
+        return CassandraUtils.convertToStream(session.execute(getStoredAnnotationsQueryLikeKey(mailboxId, key.asString())))
             .map(this::toAnnotation)
             .filter(annotation -> isChild(key, annotation));
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
index af504f6..ae3c1eb 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
@@ -107,6 +107,6 @@ public class CassandraMapperProvider implements MapperProvider {
                 new CassandraModSeqProvider(cassandra.getConf()),
                 cassandra.getConf(),
                 cassandra.getTypesProvider()
-            ).getAnnotationMapper(CassandraId.timeBased(), new MockMailboxSession("benwa"));
+            ).getAnnotationMapper(new MockMailboxSession("benwa"));
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/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 864b6a0..be5fdb9 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,7 +43,6 @@ 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;
@@ -175,7 +174,7 @@ public class HBaseMailboxSessionMapperFactory extends MailboxSessionMapperFactor
     }
 
     @Override
-    public AnnotationMapper createAnnotationMapper(MailboxId mailboxId, MailboxSession session)
+    public AnnotationMapper createAnnotationMapper(MailboxSession session)
             throws MailboxException {
         throw new NotImplementedException();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/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 030230f..40d31bd 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
@@ -87,7 +87,7 @@ public class JCRMailboxSessionMapperFactory extends MailboxSessionMapperFactory
     }
 
     @Override
-    public AnnotationMapper createAnnotationMapper(MailboxId mailboxId, MailboxSession session)
+    public AnnotationMapper createAnnotationMapper(MailboxSession session)
             throws MailboxException {
         throw new NotImplementedException();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/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 1b64f43..2f71f2e 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
@@ -85,7 +85,7 @@ public class JPAMailboxSessionMapperFactory extends MailboxSessionMapperFactory
     }
 
     @Override
-    public AnnotationMapper createAnnotationMapper(MailboxId mailboxId, MailboxSession session)
+    public AnnotationMapper createAnnotationMapper(MailboxSession session)
             throws MailboxException {
         throw new NotImplementedException();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/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 cd3b3df..9f83f44 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
@@ -71,7 +71,7 @@ public class MaildirMailboxSessionMapperFactory extends
 
 
     @Override
-    public AnnotationMapper createAnnotationMapper(MailboxId mailboxId, MailboxSession session)
+    public AnnotationMapper createAnnotationMapper(MailboxSession session)
             throws MailboxException {
         throw new NotImplementedException();
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/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 f3b0a9f..3f8c36c 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
@@ -42,12 +42,14 @@ public class InMemoryMailboxSessionMapperFactory extends MailboxSessionMapperFac
     private final MessageMapper messageMapper;
     private final SubscriptionMapper subscriptionMapper;
     private final AttachmentMapper attachmentMapper;
+    private final AnnotationMapper annotationMapper;
     
     public InMemoryMailboxSessionMapperFactory() {
         mailboxMapper = new InMemoryMailboxMapper();
         messageMapper = new InMemoryMessageMapper(null, new InMemoryUidProvider(), new InMemoryModSeqProvider());
         subscriptionMapper = new InMemorySubscriptionMapper();
         attachmentMapper = new InMemoryAttachmentMapper();
+        annotationMapper = new InMemoryAnnotationMapper();
     }
     
     @Override
@@ -77,9 +79,9 @@ public class InMemoryMailboxSessionMapperFactory extends MailboxSessionMapperFac
     }
 
     @Override
-    public AnnotationMapper createAnnotationMapper(MailboxId mailboxId, MailboxSession session)
+    public AnnotationMapper createAnnotationMapper(MailboxSession session)
             throws MailboxException {
-        return new InMemoryAnnotationMapper((InMemoryId)mailboxId);
+        return annotationMapper;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java
index e433603..52a166b 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryAnnotationMapper.java
@@ -31,6 +31,7 @@ import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.model.MailboxAnnotation;
 import org.apache.james.mailbox.model.MailboxAnnotationKey;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 
 import com.google.common.base.Function;
@@ -42,12 +43,10 @@ import com.google.common.collect.Iterables;
 import com.google.common.collect.Table;
 
 public class InMemoryAnnotationMapper implements AnnotationMapper {
-    private final InMemoryId mailboxId;
     private final Table<InMemoryId, String, String> mailboxesAnnotations;
     private final ReadWriteLock lock = new ReentrantReadWriteLock();
 
-    public InMemoryAnnotationMapper(InMemoryId mailboxId) {
-        this.mailboxId = mailboxId;
+    public InMemoryAnnotationMapper() {
         mailboxesAnnotations = HashBasedTable.create();
     }
 
@@ -78,14 +77,14 @@ public class InMemoryAnnotationMapper implements AnnotationMapper {
     }
     
     @Override
-    public List<MailboxAnnotation> getAllAnnotations() {
-        return ImmutableList.copyOf(retrieveAllAnnotations(mailboxId));
+    public List<MailboxAnnotation> getAllAnnotations(MailboxId mailboxId) {
+        return ImmutableList.copyOf(retrieveAllAnnotations((InMemoryId)mailboxId));
     }
 
     @Override
-    public List<MailboxAnnotation> getAnnotationsByKeys(final Set<MailboxAnnotationKey> keys) {
+    public List<MailboxAnnotation> getAnnotationsByKeys(MailboxId mailboxId, final Set<MailboxAnnotationKey> keys) {
         return ImmutableList.copyOf(
-            Iterables.filter(retrieveAllAnnotations(mailboxId),
+            Iterables.filter(retrieveAllAnnotations((InMemoryId)mailboxId),
                 new Predicate<MailboxAnnotation>() {
                     @Override
                     public boolean apply(MailboxAnnotation input) {
@@ -95,13 +94,13 @@ public class InMemoryAnnotationMapper implements AnnotationMapper {
     }
 
     @Override
-    public List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(final Set<MailboxAnnotationKey> keys) {
-        return ImmutableList.copyOf(Iterables.filter(retrieveAllAnnotations(mailboxId), getPredicateFilterByAll(keys)));
+    public List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxId mailboxId, final Set<MailboxAnnotationKey> keys) {
+        return ImmutableList.copyOf(Iterables.filter(retrieveAllAnnotations((InMemoryId)mailboxId), getPredicateFilterByAll(keys)));
     }
 
     @Override
-    public List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(final Set<MailboxAnnotationKey> keys) {
-        return ImmutableList.copyOf(Iterables.filter(getAnnotationsByKeysWithAllDepth(keys), getPredicateFilterByOne(keys)));
+    public List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxId mailboxId, final Set<MailboxAnnotationKey> keys) {
+        return ImmutableList.copyOf(Iterables.filter(getAnnotationsByKeysWithAllDepth(mailboxId, keys), getPredicateFilterByOne(keys)));
     }
 
     private Predicate<MailboxAnnotation> getPredicateFilterByAll(final Set<MailboxAnnotationKey> keys) {
@@ -141,18 +140,18 @@ public class InMemoryAnnotationMapper implements AnnotationMapper {
     }
 
     @Override
-    public void insertAnnotation(MailboxAnnotation mailboxAnnotation) {
+    public void insertAnnotation(MailboxId mailboxId, MailboxAnnotation mailboxAnnotation) {
         Preconditions.checkArgument(!mailboxAnnotation.isNil());
         lock.writeLock().lock();
         try {
-            mailboxesAnnotations.put(mailboxId, mailboxAnnotation.getKey().asString(), mailboxAnnotation.getValue().get());
+            mailboxesAnnotations.put((InMemoryId)mailboxId, mailboxAnnotation.getKey().asString(), mailboxAnnotation.getValue().get());
         } finally {
             lock.writeLock().unlock();
         }
     }
 
     @Override
-    public void deleteAnnotation(MailboxAnnotationKey key) {
+    public void deleteAnnotation(MailboxId mailboxId, MailboxAnnotationKey key) {
         lock.writeLock().lock();
         try {
             mailboxesAnnotations.remove(mailboxId, key.asString());

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java
index b489e6f..cc50512 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMapperProvider.java
@@ -57,7 +57,6 @@ public class InMemoryMapperProvider implements MapperProvider {
 
     @Override
     public AnnotationMapper createAnnotationMapper() throws MailboxException {
-        return new InMemoryMailboxSessionMapperFactory().createAnnotationMapper(InMemoryId.of(random.nextInt()), 
-            new MockMailboxSession("user"));
+        return new InMemoryMailboxSessionMapperFactory().createAnnotationMapper(new MockMailboxSession("user"));
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/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 5c4659f..0e2a0f6 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
@@ -68,16 +68,16 @@ public abstract class MailboxSessionMapperFactory implements RequestAware, Mailb
         return mapper;
     }
 
-    public AnnotationMapper getAnnotationMapper(MailboxId mailboxId, MailboxSession session) throws MailboxException {
+    public AnnotationMapper getAnnotationMapper(MailboxSession session) throws MailboxException {
         AnnotationMapper mapper = (AnnotationMapper)session.getAttributes().get(ANNOTATIONMAPPER);
         if (mapper == null) {
-            mapper = createAnnotationMapper(mailboxId, session);
+            mapper = createAnnotationMapper(session);
             session.getAttributes().put(ANNOTATIONMAPPER, mapper);
         }
         return mapper;
     }
 
-    public abstract AnnotationMapper createAnnotationMapper(MailboxId mailboxId, MailboxSession session) throws MailboxException;
+    public abstract AnnotationMapper createAnnotationMapper(MailboxSession session) throws MailboxException;
 
     /**
      * Create a {@link MessageMapper} instance which will get reused during the whole {@link MailboxSession}

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/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 09bba85..1f46c77 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
@@ -750,36 +750,33 @@ public class StoreMailboxManager implements MailboxManager {
         );
     }
 
-    private AnnotationMapper getAnnotationMapper(MailboxPath mailboxPath, MailboxSession session)
-            throws MailboxException, MailboxNotFoundException {
-        MailboxMapper mailboxMapper = mailboxSessionMapperFactory.getMailboxMapper(session);
-        Mailbox mailbox = mailboxMapper.findMailboxByPath(mailboxPath);
-        AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(mailbox.getMailboxId(), session);
-        return annotationMapper;
-    }
-    
     @Override
     public List<MailboxAnnotation> getAllAnnotations(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-        AnnotationMapper annotationMapper = getAnnotationMapper(mailboxPath, session);
-        return annotationMapper.getAllAnnotations();
+        AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
+        MailboxId mailboxId = getMailbox(mailboxPath, session).getId();
+
+        return annotationMapper.getAllAnnotations(mailboxId);
     }
 
     @Override
     public List<MailboxAnnotation> getAnnotationsByKeys(MailboxPath mailboxPath, MailboxSession session, Set<MailboxAnnotationKey> keys)
             throws MailboxException {
-        AnnotationMapper annotationMapper = getAnnotationMapper(mailboxPath, session);
-        return annotationMapper.getAnnotationsByKeys(keys);
+        AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
+        MailboxId mailboxId = getMailbox(mailboxPath, session).getId();
+
+        return annotationMapper.getAnnotationsByKeys(mailboxId, keys);
     }
 
     @Override
     public void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, List<MailboxAnnotation> mailboxAnnotations) 
             throws MailboxException {
-        AnnotationMapper annotationMapper = getAnnotationMapper(mailboxPath, session);
+        AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
+        MailboxId mailboxId = getMailbox(mailboxPath, session).getId();
         for (MailboxAnnotation annotation : mailboxAnnotations) {
             if (annotation.isNil()) {
-                annotationMapper.deleteAnnotation(annotation.getKey());
+                annotationMapper.deleteAnnotation(mailboxId, annotation.getKey());
             } else {
-                annotationMapper.insertAnnotation(annotation);
+                annotationMapper.insertAnnotation(mailboxId, annotation);
             }
         }
     }
@@ -792,15 +789,19 @@ public class StoreMailboxManager implements MailboxManager {
     @Override
     public List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxPath mailboxPath, MailboxSession session,
             Set<MailboxAnnotationKey> keys) throws MailboxException {
-        AnnotationMapper annotationMapper = getAnnotationMapper(mailboxPath, session);
-        return annotationMapper.getAnnotationsByKeysWithOneDepth(keys);
+        AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
+        MailboxId mailboxId = getMailbox(mailboxPath, session).getId();
+
+        return annotationMapper.getAnnotationsByKeysWithOneDepth(mailboxId, keys);
     }
 
     @Override
     public List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxPath mailboxPath, MailboxSession session,
             Set<MailboxAnnotationKey> keys) throws MailboxException {
-        AnnotationMapper annotationMapper = getAnnotationMapper(mailboxPath, session);
-        return annotationMapper.getAnnotationsByKeysWithAllDepth(keys);
+        AnnotationMapper annotationMapper = mailboxSessionMapperFactory.getAnnotationMapper(session);
+        MailboxId mailboxId = getMailbox(mailboxPath, session).getId();
+
+        return annotationMapper.getAnnotationsByKeysWithAllDepth(mailboxId, keys);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/AnnotationMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/AnnotationMapper.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/AnnotationMapper.java
index 468a708..4617ed4 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/AnnotationMapper.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/AnnotationMapper.java
@@ -24,58 +24,64 @@ import java.util.Set;
 
 import org.apache.james.mailbox.model.MailboxAnnotation;
 import org.apache.james.mailbox.model.MailboxAnnotationKey;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.transaction.Mapper;
 
 public interface AnnotationMapper extends Mapper {
-
     /**
-     * Return all <code>MailboxAnnotation</code>.
+     * Return all <code>MailboxAnnotation</code> of specific mailbox.
      * The result is not ordered and should not contain duplicate by key
-     * 
+     *
+     * @param mailboxId the selected mailbox
      * @return List<MailboxAnnotation>
      */
-    List<MailboxAnnotation> getAllAnnotations();
+    List<MailboxAnnotation> getAllAnnotations(MailboxId mailboxId);
 
     /**
-     * Search all the <code>MailboxAnnotation</code> by the set of annotation's keys. The result is not ordered and should not
+     * Search all the <code>MailboxAnnotation</code> of selected mailbox by the set of annotation's keys. The result is not ordered and should not
      * contain duplicate by key
-     * 
+     *
+     * @param mailboxId the selected mailbox
      * @param keys the set of the key should be filtered
      * @return List<MailboxAnnotation>
      */
-    List<MailboxAnnotation> getAnnotationsByKeys(Set<MailboxAnnotationKey> keys);
+    List<MailboxAnnotation> getAnnotationsByKeys(MailboxId mailboxId, Set<MailboxAnnotationKey> keys);
 
     /**
-     * Search all the <code>MailboxAnnotation</code> by the set of annotation's keys as well as its children entries 
+     * Search all the <code>MailboxAnnotation</code> of selected mailbox by the set of annotation's keys as well as its children entries
      * The result is not ordered and should not contain duplicate by key
-     * 
+     *
+     * @param mailboxId the selected mailbox
      * @param keys the set of the key should be filtered
      * @return List<MailboxAnnotation>
      */
-    List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(Set<MailboxAnnotationKey> keys);
+    List<MailboxAnnotation> getAnnotationsByKeysWithOneDepth(MailboxId mailboxId, Set<MailboxAnnotationKey> keys);
 
     /**
-     * Search all the <code>MailboxAnnotation</code> by the set of annotation's keys and entries below the keys 
+     * Search all the <code>MailboxAnnotation</code> of selected mailbox by the set of annotation's keys and entries below the keys
      * The result is not ordered and should not contain duplicate by key
-     * 
+     *
+     * @param mailboxId the selected mailbox
      * @param keys the set of the key should be filtered
      * @return List<MailboxAnnotation>
      */
-    List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(Set<MailboxAnnotationKey> keys);
+    List<MailboxAnnotation> getAnnotationsByKeysWithAllDepth(MailboxId mailboxId, Set<MailboxAnnotationKey> keys);
 
     /**
-     * Delete the annotation by its key.
-     * 
+     * Delete the annotation of selected mailbox by its key.
+     *
+     * @param mailboxId the selected mailbox
      * @param key the key of annotation should be deleted
      */
-    void deleteAnnotation(MailboxAnnotationKey key);
+    void deleteAnnotation(MailboxId mailboxId, MailboxAnnotationKey key);
 
     /**
      * - Insert new annotation if it does not exist on store
      * - Update the new value for existed annotation
-     * 
+     *
+     * @param mailboxId the selected mailbox
      * @param mailboxAnnotation the selected annotation
      */
-    void insertAnnotation(MailboxAnnotation mailboxAnnotation);
+    void insertAnnotation(MailboxId mailboxId, MailboxAnnotation mailboxAnnotation);
 
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/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 6b3007f..c28a6a9 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
@@ -35,6 +35,7 @@ import org.apache.james.mailbox.MailboxSession;
 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.mock.MockMailboxSession;
 import org.apache.james.mailbox.model.MailboxAnnotation;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxAnnotationKey;
@@ -62,13 +63,13 @@ public class StoreMailboxManagerAnnotationTest {
 
     private static final List<MailboxAnnotation> ANNOTATIONS = ImmutableList.of(PRIVATE_ANNOTATION, SHARED_ANNOTATION);
     private static final List<MailboxAnnotation> ANNOTATIONS_WITH_NIL_ENTRY = ImmutableList.of(PRIVATE_ANNOTATION, MailboxAnnotation.nil(SHARED_KEY));
+    private static final MailboxSession session = new MockMailboxSession("userName");
 
     @Mock private MailboxSessionMapperFactory mailboxSessionMapperFactory;
     @Mock private Authenticator authenticator;
     @Mock private MailboxACLResolver aclResolver;
     @Mock private GroupMembershipResolver groupMembershipResolver;
-    
-    @Mock private MailboxSession session;
+
     @Mock private MailboxMapper mailboxMapper;
     @Mock private AnnotationMapper annotationMapper;
     @Mock private MailboxPath mailboxPath;
@@ -84,8 +85,9 @@ public class StoreMailboxManagerAnnotationTest {
         MockitoAnnotations.initMocks(this);
 
         when(mailboxSessionMapperFactory.getMailboxMapper(eq(session))).thenReturn(mailboxMapper);
+        when(mailboxSessionMapperFactory.getAnnotationMapper(eq(session))).thenReturn(annotationMapper);
         when(mailbox.getMailboxId()).thenReturn(mailboxId);
-        when(mailboxSessionMapperFactory.getAnnotationMapper(eq(mailboxId), eq(session))).thenReturn(annotationMapper);
+        when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
 
         storeMailboxManager = new StoreMailboxManager(mailboxSessionMapperFactory, authenticator, aclResolver, groupMembershipResolver, messageParser);
     }
@@ -101,7 +103,7 @@ public class StoreMailboxManagerAnnotationTest {
         when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
         storeMailboxManager.updateAnnotations(mailboxPath, session, ANNOTATIONS);
 
-        verify(annotationMapper, times(2)).insertAnnotation(any(MailboxAnnotation.class));
+        verify(annotationMapper, times(2)).insertAnnotation(eq(mailboxId), any(MailboxAnnotation.class));
     }
 
     @Test
@@ -109,8 +111,8 @@ public class StoreMailboxManagerAnnotationTest {
         when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
         storeMailboxManager.updateAnnotations(mailboxPath, session, ANNOTATIONS_WITH_NIL_ENTRY);
 
-        verify(annotationMapper, times(1)).insertAnnotation(eq(PRIVATE_ANNOTATION));
-        verify(annotationMapper, times(1)).deleteAnnotation(eq(SHARED_KEY));
+        verify(annotationMapper, times(1)).insertAnnotation(eq(mailboxId), eq(PRIVATE_ANNOTATION));
+        verify(annotationMapper, times(1)).deleteAnnotation(eq(mailboxId), eq(SHARED_KEY));
     }
 
     @Test(expected = MailboxException.class)
@@ -122,7 +124,7 @@ public class StoreMailboxManagerAnnotationTest {
     @Test
     public void getAllAnnotationsShouldReturnEmptyForNonStoredAnnotation() throws Exception {
         when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
-        when(annotationMapper.getAllAnnotations()).thenReturn(Collections.<MailboxAnnotation> emptyList());
+        when(annotationMapper.getAllAnnotations(eq(mailboxId))).thenReturn(Collections.<MailboxAnnotation> emptyList());
 
         assertThat(storeMailboxManager.getAllAnnotations(mailboxPath, session)).isEmpty();
     }
@@ -130,7 +132,7 @@ public class StoreMailboxManagerAnnotationTest {
     @Test
     public void getAllAnnotationsShouldReturnStoredAnnotation() throws Exception {
         when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
-        when(annotationMapper.getAllAnnotations()).thenReturn(ANNOTATIONS);
+        when(annotationMapper.getAllAnnotations(eq(mailboxId))).thenReturn(ANNOTATIONS);
 
         assertThat(storeMailboxManager.getAllAnnotations(mailboxPath, session)).isEqualTo(ANNOTATIONS);
     }
@@ -144,7 +146,7 @@ public class StoreMailboxManagerAnnotationTest {
     @Test
     public void getAnnotationsByKeysShouldRetrieveStoreAnnotationsByKey() throws Exception {
         when(mailboxMapper.findMailboxByPath(eq(mailboxPath))).thenReturn(mailbox);
-        when(annotationMapper.getAnnotationsByKeys(KEYS)).thenReturn(ANNOTATIONS);
+        when(annotationMapper.getAnnotationsByKeys(eq(mailboxId), eq(KEYS))).thenReturn(ANNOTATIONS);
 
         assertThat(storeMailboxManager.getAnnotationsByKeys(mailboxPath, session, KEYS)).isEqualTo(ANNOTATIONS);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/f88464d7/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AnnotationMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AnnotationMapperTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AnnotationMapperTest.java
index a48a6e2..ae0e305 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AnnotationMapperTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/AnnotationMapperTest.java
@@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxAnnotation;
 import org.apache.james.mailbox.model.MailboxAnnotationKey;
+import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
 import org.junit.After;
 import org.junit.Rule;
@@ -55,14 +56,18 @@ public class AnnotationMapperTest<T extends MapperProvider> {
 
     private IProducer<T> producer;
     private AnnotationMapper annotationMapper;
+    private MailboxId mailboxId;
 
     @Rule
     public ExpectedException expected = ExpectedException.none();
 
     @Contract.Inject
     public final void setProducer(IProducer<T> producer) throws MailboxException {
+        T newInstance = producer.newInstance();
+
         this.producer = producer;
-        this.annotationMapper = producer.newInstance().createAnnotationMapper();
+        this.annotationMapper = newInstance.createAnnotationMapper();
+        this.mailboxId = newInstance.generateId();
     }
 
     @After
@@ -73,131 +78,131 @@ public class AnnotationMapperTest<T extends MapperProvider> {
     @ContractTest
     public void insertAnnotationShouldThrowExceptionWithNilData() {
         expected.expect(IllegalArgumentException.class);
-        annotationMapper.insertAnnotation(MailboxAnnotation.nil(PRIVATE_KEY));
+        annotationMapper.insertAnnotation(mailboxId, MailboxAnnotation.nil(PRIVATE_KEY));
     }
 
     @ContractTest
     public void insertAnnotationShouldCreateNewAnnotation() throws MailboxException {
-        annotationMapper.insertAnnotation(PRIVATE_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION);
 
-        assertThat(annotationMapper.getAllAnnotations()).containsExactly(PRIVATE_ANNOTATION);
+        assertThat(annotationMapper.getAllAnnotations(mailboxId)).containsExactly(PRIVATE_ANNOTATION);
     }
 
     @ContractTest
     public void insertAnnotationShouldUpdateExistedAnnotation() throws MailboxException {
-        annotationMapper.insertAnnotation(PRIVATE_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_ANNOTATION_UPDATE);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION_UPDATE);
 
-        assertThat(annotationMapper.getAllAnnotations()).containsExactly(PRIVATE_ANNOTATION_UPDATE);
+        assertThat(annotationMapper.getAllAnnotations(mailboxId)).containsExactly(PRIVATE_ANNOTATION_UPDATE);
     }
 
     @ContractTest
     public void deleteAnnotationShouldDeleteStoredAnnotation() throws MailboxException {
-        annotationMapper.insertAnnotation(PRIVATE_ANNOTATION);
-        annotationMapper.deleteAnnotation(PRIVATE_KEY);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION);
+        annotationMapper.deleteAnnotation(mailboxId, PRIVATE_KEY);
 
-        assertThat(annotationMapper.getAllAnnotations()).isEmpty();
+        assertThat(annotationMapper.getAllAnnotations(mailboxId)).isEmpty();
     }
 
     @ContractTest
     public void getEmptyAnnotationsWithNonStoredAnnotations() throws MailboxException {
-        assertThat(annotationMapper.getAllAnnotations()).isEmpty();
+        assertThat(annotationMapper.getAllAnnotations(mailboxId)).isEmpty();
     }
 
     @ContractTest
     public void getAllAnnotationsShouldRetrieveStoredAnnotations() throws MailboxException {
-        annotationMapper.insertAnnotation(PRIVATE_ANNOTATION);
-        annotationMapper.insertAnnotation(SHARED_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, SHARED_ANNOTATION);
 
-        assertThat(annotationMapper.getAllAnnotations()).contains(PRIVATE_ANNOTATION, SHARED_ANNOTATION);
+        assertThat(annotationMapper.getAllAnnotations(mailboxId)).contains(PRIVATE_ANNOTATION, SHARED_ANNOTATION);
     }
 
     @ContractTest
     public void getAnnotationsByKeysShouldReturnStoredAnnotationWithFilter() throws MailboxException {
-        annotationMapper.insertAnnotation(PRIVATE_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_CHILD_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION);
 
-        assertThat(annotationMapper.getAnnotationsByKeys(ImmutableSet.of(PRIVATE_KEY)))
+        assertThat(annotationMapper.getAnnotationsByKeys(mailboxId, ImmutableSet.of(PRIVATE_KEY)))
             .containsOnly(PRIVATE_ANNOTATION);
     }
 
     @ContractTest
     public void getAnnotationsByKeysWithOneDepthShouldReturnThatEntryAndItsChildren() throws MailboxException {
-        annotationMapper.insertAnnotation(PRIVATE_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_CHILD_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_GRANDCHILD_ANNOTATION);
-        annotationMapper.insertAnnotation(SHARED_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_USER_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_GRANDCHILD_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, SHARED_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_USER_ANNOTATION);
 
-        assertThat(annotationMapper.getAnnotationsByKeysWithOneDepth(ImmutableSet.of(PRIVATE_KEY)))
+        assertThat(annotationMapper.getAnnotationsByKeysWithOneDepth(mailboxId, ImmutableSet.of(PRIVATE_KEY)))
             .contains(PRIVATE_ANNOTATION, PRIVATE_CHILD_ANNOTATION);
     }
 
     @ContractTest
     public void getAnnotationsByKeysWithAllDepthShouldReturnThatEntryAndAllBelowEntries() throws MailboxException {
-        annotationMapper.insertAnnotation(PRIVATE_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_CHILD_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_GRANDCHILD_ANNOTATION);
-        annotationMapper.insertAnnotation(SHARED_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_USER_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_GRANDCHILD_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, SHARED_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_USER_ANNOTATION);
 
-        assertThat(annotationMapper.getAnnotationsByKeysWithAllDepth(ImmutableSet.of(PRIVATE_KEY)))
+        assertThat(annotationMapper.getAnnotationsByKeysWithAllDepth(mailboxId, ImmutableSet.of(PRIVATE_KEY)))
             .contains(PRIVATE_ANNOTATION, PRIVATE_CHILD_ANNOTATION, PRIVATE_GRANDCHILD_ANNOTATION);
     }
 
     @ContractTest
     public void getAnnotationsByKeysWithOneDepthShouldReturnTheChildrenEntriesEvenItDoesNotExist() throws Exception {
-        annotationMapper.insertAnnotation(PRIVATE_CHILD_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_GRANDCHILD_ANNOTATION);
-        annotationMapper.insertAnnotation(SHARED_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_USER_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_GRANDCHILD_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, SHARED_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_USER_ANNOTATION);
 
-        assertThat(annotationMapper.getAnnotationsByKeysWithOneDepth(ImmutableSet.of(PRIVATE_KEY)))
+        assertThat(annotationMapper.getAnnotationsByKeysWithOneDepth(mailboxId, ImmutableSet.of(PRIVATE_KEY)))
             .contains(PRIVATE_CHILD_ANNOTATION);
     }
 
     @ContractTest
     public void getAnnotationsByKeysWithAllDepthShouldReturnTheChildrenEntriesEvenItDoesNotExist() throws Exception {
-        annotationMapper.insertAnnotation(PRIVATE_CHILD_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_GRANDCHILD_ANNOTATION);
-        annotationMapper.insertAnnotation(SHARED_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_USER_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_GRANDCHILD_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, SHARED_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_USER_ANNOTATION);
 
-        assertThat(annotationMapper.getAnnotationsByKeysWithAllDepth(ImmutableSet.of(PRIVATE_KEY)))
+        assertThat(annotationMapper.getAnnotationsByKeysWithAllDepth(mailboxId, ImmutableSet.of(PRIVATE_KEY)))
             .contains(PRIVATE_CHILD_ANNOTATION, PRIVATE_GRANDCHILD_ANNOTATION);
     }
 
     @ContractTest
     public void getAnnotationsByKeysWithOneDepthShouldReturnEmptyWithEmptyInputKeys() throws Exception {
-        annotationMapper.insertAnnotation(PRIVATE_CHILD_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_GRANDCHILD_ANNOTATION);
-        annotationMapper.insertAnnotation(SHARED_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_USER_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_CHILD_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_GRANDCHILD_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, SHARED_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_USER_ANNOTATION);
 
-        assertThat(annotationMapper.getAnnotationsByKeysWithOneDepth(ImmutableSet.<MailboxAnnotationKey>of())).isEmpty();
+        assertThat(annotationMapper.getAnnotationsByKeysWithOneDepth(mailboxId, ImmutableSet.<MailboxAnnotationKey>of())).isEmpty();
     }
 
     @ContractTest
     public void getAnnotationsByKeysWithOneDepthShouldReturnEmptyIfDoNotFind() throws Exception {
-        annotationMapper.insertAnnotation(SHARED_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_USER_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, SHARED_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_USER_ANNOTATION);
 
-        assertThat(annotationMapper.getAnnotationsByKeysWithOneDepth(ImmutableSet.of(PRIVATE_KEY))).isEmpty();
+        assertThat(annotationMapper.getAnnotationsByKeysWithOneDepth(mailboxId, ImmutableSet.of(PRIVATE_KEY))).isEmpty();
     }
 
     @ContractTest
     public void getAnnotationsByKeysWithAllDepthShouldReturnEmptyIfDoNotFind() throws Exception {
-        annotationMapper.insertAnnotation(SHARED_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_USER_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, SHARED_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_USER_ANNOTATION);
 
-        assertThat(annotationMapper.getAnnotationsByKeysWithAllDepth(ImmutableSet.of(PRIVATE_KEY))).isEmpty();
+        assertThat(annotationMapper.getAnnotationsByKeysWithAllDepth(mailboxId, ImmutableSet.of(PRIVATE_KEY))).isEmpty();
     }
 
     @ContractTest
     public void annotationShouldBeCaseInsentive() throws Exception {
-        annotationMapper.insertAnnotation(PRIVATE_ANNOTATION);
-        annotationMapper.insertAnnotation(PRIVATE_ANNOTATION_WITH_KEY_UPPER);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION);
+        annotationMapper.insertAnnotation(mailboxId, PRIVATE_ANNOTATION_WITH_KEY_UPPER);
 
-        assertThat(annotationMapper.getAllAnnotations()).containsOnly(PRIVATE_ANNOTATION_WITH_KEY_UPPER);
+        assertThat(annotationMapper.getAllAnnotations(mailboxId)).containsOnly(PRIVATE_ANNOTATION_WITH_KEY_UPPER);
     }
 }


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


Mime
View raw message