james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [6/7] james-project git commit: JAMES-1948 use CassandraDeletedMessageDAO to speed up exchange
Date Thu, 02 Mar 2017 13:44:48 GMT
JAMES-1948 use CassandraDeletedMessageDAO to speed up exchange


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

Branch: refs/heads/master
Commit: 8dba0425b27622bebb41f140e492f0c51b000e65
Parents: 01d21eb
Author: Luc DUZAN <lduzan@linagora.com>
Authored: Fri Feb 24 19:08:56 2017 +0100
Committer: Luc DUZAN <lduzan@linagora.com>
Committed: Thu Mar 2 12:31:25 2017 +0100

----------------------------------------------------------------------
 .../CassandraMailboxSessionMapperFactory.java   |  51 ++++--
 .../mail/CassandraIndexTableHandler.java        |  33 +++-
 .../cassandra/mail/CassandraMessageMapper.java  |  66 +++++---
 .../cassandra/CassandraMailboxManagerTest.java  |   7 +-
 .../CassandraSubscriptionManagerTest.java       |   6 +-
 .../cassandra/CassandraTestSystemFixture.java   |   7 +-
 .../mail/CassandraIndexTableHandlerTest.java    | 156 ++++++++++++++++++-
 .../CassandraMailboxManagerAttachmentTest.java  |   6 +-
 .../cassandra/mail/CassandraMapperProvider.java |   8 +-
 .../cassandra/host/CassandraHostSystem.java     |  23 ++-
 .../modules/mailbox/CassandraMailboxModule.java |   6 +-
 11 files changed, 320 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/8dba0425/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 9ee5f19..36f536a 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
@@ -40,6 +40,7 @@ import org.apache.james.mailbox.cassandra.mail.CassandraMessageIdToImapUidDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraMessageMapper;
 import org.apache.james.mailbox.cassandra.mail.CassandraModSeqProvider;
 import org.apache.james.mailbox.cassandra.mail.CassandraUidProvider;
+import org.apache.james.mailbox.cassandra.mail.*;
 import org.apache.james.mailbox.cassandra.user.CassandraSubscriptionMapper;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
@@ -73,6 +74,7 @@ public class CassandraMailboxSessionMapperFactory extends MailboxSessionMapperFa
     private final CassandraMailboxPathDAO mailboxPathDAO;
     private final CassandraFirstUnseenDAO firstUnseenDAO;
     private final CassandraApplicableFlagDAO applicableFlagDAO;
+    private final CassandraDeletedMessageDAO deletedMessageDAO;
     private int maxRetry;
 
     @Inject
@@ -80,7 +82,7 @@ public class CassandraMailboxSessionMapperFactory extends MailboxSessionMapperFa
                                                 CassandraMessageDAO messageDAO, CassandraMessageIdDAO messageIdDAO, CassandraMessageIdToImapUidDAO imapUidDAO,
                                                 CassandraMailboxCounterDAO mailboxCounterDAO, CassandraMailboxRecentsDAO mailboxRecentsDAO, CassandraMailboxDAO mailboxDAO,
                                                 CassandraMailboxPathDAO mailboxPathDAO, CassandraFirstUnseenDAO firstUnseenDAO, CassandraApplicableFlagDAO applicableFlagDAO,
-                                                @Named(CassandraMailboxDAO.MAX_ACL_RETRY) Integer maxRetry) {
+                                                CassandraDeletedMessageDAO deletedMessageDAO, @Named(CassandraMailboxDAO.MAX_ACL_RETRY) Integer maxRetry) {
         this.uidProvider = uidProvider;
         this.modSeqProvider = modSeqProvider;
         this.session = session;
@@ -92,24 +94,53 @@ public class CassandraMailboxSessionMapperFactory extends MailboxSessionMapperFa
         this.mailboxDAO = mailboxDAO;
         this.mailboxPathDAO = mailboxPathDAO;
         this.firstUnseenDAO = firstUnseenDAO;
+        this.deletedMessageDAO = deletedMessageDAO;
         this.applicableFlagDAO = applicableFlagDAO;
-        this.indexTableHandler = new CassandraIndexTableHandler(mailboxRecentsDAO, mailboxCounterDAO, this.firstUnseenDAO, applicableFlagDAO);
+        this.indexTableHandler = new CassandraIndexTableHandler(
+            mailboxRecentsDAO,
+            mailboxCounterDAO,
+            firstUnseenDAO,
+            applicableFlagDAO,
+            deletedMessageDAO);
         this.maxRetry = maxRetry;
     }
 
-    public CassandraMailboxSessionMapperFactory(CassandraUidProvider uidProvider, CassandraModSeqProvider modSeqProvider, Session session,
-                                                CassandraMessageDAO messageDAO, CassandraMessageIdDAO messageIdDAO, CassandraMessageIdToImapUidDAO imapUidDAO,
-                                                CassandraMailboxCounterDAO mailboxCounterDAO, CassandraMailboxRecentsDAO mailboxRecentsDAO, CassandraMailboxDAO mailboxDAO,
-                                                CassandraMailboxPathDAO mailboxPathDAO, CassandraFirstUnseenDAO firstUnseenDAO, CassandraApplicableFlagDAO applicableFlagDAO) {
+    public CassandraMailboxSessionMapperFactory(
+        CassandraUidProvider uidProvider,
+        CassandraModSeqProvider modSeqProvider,
+        Session session,
+        CassandraMessageDAO messageDAO,
+        CassandraMessageIdDAO messageIdDAO,
+        CassandraMessageIdToImapUidDAO imapUidDAO,
+        CassandraMailboxCounterDAO mailboxCounterDAO,
+        CassandraMailboxRecentsDAO mailboxRecentsDAO,
+        CassandraMailboxDAO mailboxDAO,
+        CassandraMailboxPathDAO mailboxPathDAO,
+        CassandraFirstUnseenDAO firstUnseenDAO,
+        CassandraApplicableFlagDAO applicableFlagDAO,
+        CassandraDeletedMessageDAO deletedMesageDAO) {
+
         this(uidProvider, modSeqProvider, session, messageDAO, messageIdDAO, imapUidDAO, mailboxCounterDAO,
-            mailboxRecentsDAO, mailboxDAO, mailboxPathDAO, firstUnseenDAO, applicableFlagDAO, DEFAULT_MAX_RETRY);
+             mailboxRecentsDAO, mailboxDAO, mailboxPathDAO, firstUnseenDAO, applicableFlagDAO, deletedMesageDAO, DEFAULT_MAX_RETRY);
     }
 
     @Override
     public CassandraMessageMapper createMessageMapper(MailboxSession mailboxSession) {
-        return new CassandraMessageMapper(uidProvider, modSeqProvider, null, maxRetry,
-                (CassandraAttachmentMapper) createAttachmentMapper(mailboxSession),
-                messageDAO, messageIdDAO, imapUidDAO, mailboxCounterDAO, mailboxRecentsDAO, applicableFlagDAO, indexTableHandler, firstUnseenDAO);
+        return new CassandraMessageMapper(
+                                          uidProvider,
+                                          modSeqProvider,
+                                          null,
+                                          maxRetry,
+                                          (CassandraAttachmentMapper) createAttachmentMapper(mailboxSession),
+                                          messageDAO,
+                                          messageIdDAO,
+                                          imapUidDAO,
+                                          mailboxCounterDAO,
+                                          mailboxRecentsDAO,
+                                          applicableFlagDAO,
+                                          indexTableHandler,
+                                          firstUnseenDAO,
+                                          deletedMessageDAO);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/8dba0425/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandler.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandler.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandler.java
index 5ef6b85..b99e91d 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandler.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandler.java
@@ -36,23 +36,28 @@ public class CassandraIndexTableHandler {
     private final CassandraMailboxCounterDAO mailboxCounterDAO;
     private final CassandraFirstUnseenDAO firstUnseenDAO;
     private final CassandraApplicableFlagDAO applicableFlagDAO;
+    private final CassandraDeletedMessageDAO deletedMessageDAO;
 
     @Inject
     public CassandraIndexTableHandler(CassandraMailboxRecentsDAO mailboxRecentDAO,
                                       CassandraMailboxCounterDAO mailboxCounterDAO,
                                       CassandraFirstUnseenDAO firstUnseenDAO,
-                                      CassandraApplicableFlagDAO applicableFlagDAO) {
+                                      CassandraApplicableFlagDAO applicableFlagDAO,
+                                      CassandraDeletedMessageDAO deletedMessageDAO) {
         this.mailboxRecentDAO = mailboxRecentDAO;
         this.mailboxCounterDAO = mailboxCounterDAO;
         this.firstUnseenDAO = firstUnseenDAO;
         this.applicableFlagDAO = applicableFlagDAO;
+        this.deletedMessageDAO = deletedMessageDAO;
     }
 
     public CompletableFuture<Void> updateIndexOnDelete(ComposedMessageIdWithMetaData composedMessageIdWithMetaData, CassandraId mailboxId) {
+        MessageUid uid = composedMessageIdWithMetaData.getComposedMessageId().getUid();
         return CompletableFuture.allOf(
             updateFirstUnseenOnDelete(mailboxId, composedMessageIdWithMetaData.getFlags(), composedMessageIdWithMetaData.getComposedMessageId().getUid()),
             mailboxRecentDAO.removeFromRecent(mailboxId, composedMessageIdWithMetaData.getComposedMessageId().getUid()),
             mailboxCounterDAO.decrementCount(mailboxId),
+            deletedMessageDAO.removeDeleted(mailboxId, uid),
             decrementUnseenOnDelete(mailboxId, composedMessageIdWithMetaData.getFlags()));
     }
 
@@ -60,6 +65,7 @@ public class CassandraIndexTableHandler {
         Flags flags = message.createFlags();
 
         return CompletableFuture.allOf(
+            checkDeletedOnAdd(mailboxId, message.createFlags(), message.getUid()),
             updateFirstUnseenOnAdd(mailboxId, message.createFlags(), message.getUid()),
             addRecentOnSave(mailboxId, message),
             incrementUnseenOnSave(mailboxId, flags),
@@ -69,9 +75,20 @@ public class CassandraIndexTableHandler {
 
     public CompletableFuture<Void> updateIndexOnFlagsUpdate(CassandraId mailboxId, UpdatedFlags updatedFlags) {
         return CompletableFuture.allOf(manageUnseenMessageCountsOnFlagsUpdate(mailboxId, updatedFlags),
-            manageRecentOnFlagsUpdate(mailboxId, updatedFlags),
-            updateFirstUnseenOnFlagsUpdate(mailboxId, updatedFlags),
-            applicableFlagDAO.updateApplicableFlags(mailboxId, updatedFlags.getNewFlags()));
+                                       manageRecentOnFlagsUpdate(mailboxId, updatedFlags),
+                                       updateFirstUnseenOnFlagsUpdate(mailboxId, updatedFlags),
+                                       applicableFlagDAO.updateApplicableFlags(mailboxId, updatedFlags.getNewFlags()),
+                                       updateDeletedOnFlagsUpdate(mailboxId, updatedFlags));
+    }
+
+    private CompletableFuture<Void> updateDeletedOnFlagsUpdate(CassandraId mailboxId, UpdatedFlags updatedFlags) {
+        if (updatedFlags.isModifiedToSet(Flags.Flag.DELETED)) {
+            return deletedMessageDAO.addDeleted(mailboxId, updatedFlags.getUid());
+        } else if (updatedFlags.isModifiedToUnset(Flags.Flag.DELETED)) {
+            return deletedMessageDAO.removeDeleted(mailboxId, updatedFlags.getUid());
+        } else {
+            return CompletableFuture.completedFuture(null);
+        }
     }
 
     private CompletableFuture<Void> decrementUnseenOnDelete(CassandraId mailboxId, Flags flags) {
@@ -122,6 +139,14 @@ public class CassandraIndexTableHandler {
         return firstUnseenDAO.addUnread(mailboxId, uid);
     }
 
+    private CompletableFuture<Void> checkDeletedOnAdd(CassandraId mailboxId, Flags flags, MessageUid uid) {
+        if (flags.contains(Flags.Flag.DELETED)) {
+            return deletedMessageDAO.addDeleted(mailboxId, uid);
+        }
+
+        return CompletableFuture.completedFuture(null);
+    }
+
     private CompletableFuture<Void> updateFirstUnseenOnDelete(CassandraId mailboxId, Flags flags, MessageUid uid) {
         if (flags.contains(Flags.Flag.SEEN)) {
             return CompletableFuture.completedFuture(null);

http://git-wip-us.apache.org/repos/asf/james-project/blob/8dba0425/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
index 639d6ed..11161e5 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
@@ -54,6 +54,7 @@ import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailboxMessage;
 import org.apache.james.util.CompletableFutureUtil;
+import org.apache.james.util.OptionalConverter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -82,12 +83,13 @@ public class CassandraMessageMapper implements MessageMapper {
     private final CassandraIndexTableHandler indexTableHandler;
     private final CassandraFirstUnseenDAO firstUnseenDAO;
     private final AttachmentLoader attachmentLoader;
+    private final CassandraDeletedMessageDAO deletedMessageDAO;
 
     public CassandraMessageMapper(CassandraUidProvider uidProvider, CassandraModSeqProvider modSeqProvider,
                                   MailboxSession mailboxSession, int maxRetries, CassandraAttachmentMapper attachmentMapper,
                                   CassandraMessageDAO messageDAO, CassandraMessageIdDAO messageIdDAO, CassandraMessageIdToImapUidDAO imapUidDAO,
                                   CassandraMailboxCounterDAO mailboxCounterDAO, CassandraMailboxRecentsDAO mailboxRecentDAO, CassandraApplicableFlagDAO applicableFlagDAO,
-                                  CassandraIndexTableHandler indexTableHandler, CassandraFirstUnseenDAO firstUnseenDAO) {
+                                  CassandraIndexTableHandler indexTableHandler, CassandraFirstUnseenDAO firstUnseenDAO, CassandraDeletedMessageDAO deletedMessageDAO) {
         this.uidProvider = uidProvider;
         this.modSeqProvider = modSeqProvider;
         this.mailboxSession = mailboxSession;
@@ -101,6 +103,7 @@ public class CassandraMessageMapper implements MessageMapper {
         this.firstUnseenDAO = firstUnseenDAO;
         this.attachmentLoader = new AttachmentLoader(attachmentMapper);
         this.applicableFlagDAO = applicableFlagDAO;
+        this.deletedMessageDAO = deletedMessageDAO;
     }
 
     @Override
@@ -128,12 +131,17 @@ public class CassandraMessageMapper implements MessageMapper {
     public void delete(Mailbox mailbox, MailboxMessage message) {
         CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
 
-        messageIdDAO.retrieve(mailboxId, message.getUid())
-            .thenCompose(optional -> optional.map(this::deleteUsingMailboxId)
-                .orElse(CompletableFuture.completedFuture(null)))
+        deleteAsFuture(message, mailboxId)
             .join();
     }
 
+    private CompletableFuture<Void> deleteAsFuture(MailboxMessage message, CassandraId mailboxId) {
+        return messageIdDAO.retrieve(mailboxId, message.getUid())
+            .thenCompose(optional -> optional
+                .map(this::deleteUsingMailboxId)
+                .orElse(CompletableFuture.completedFuture(null)));
+    }
+
     private CompletableFuture<Void> deleteUsingMailboxId(ComposedMessageIdWithMetaData composedMessageIdWithMetaData) {
         ComposedMessageId composedMessageId = composedMessageIdWithMetaData.getComposedMessageId();
         CassandraMessageId messageId = (CassandraMessageId) composedMessageId.getMessageId();
@@ -153,6 +161,7 @@ public class CassandraMessageMapper implements MessageMapper {
     public Iterator<MailboxMessage> findInMailbox(Mailbox mailbox, MessageRange messageRange, FetchType ftype, int max) throws MailboxException {
         CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
         return retrieveMessages(retrieveMessageIds(mailboxId, messageRange), ftype, Optional.of(max))
+                .join()
                 .map(SimpleMailboxMessage -> (MailboxMessage) SimpleMailboxMessage)
                 .sorted(Comparator.comparing(MailboxMessage::getUid))
                 .iterator();
@@ -164,21 +173,23 @@ public class CassandraMessageMapper implements MessageMapper {
                 .collect(Guavate.toImmutableList());
     }
 
-    private Stream<SimpleMailboxMessage> retrieveMessages(List<ComposedMessageIdWithMetaData> messageIds, FetchType fetchType, Optional<Integer> limit) {
-        Stream<Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<CassandraMessageDAO.MessageAttachmentRepresentation>>>
-            messageRepresentions = messageDAO.retrieveMessages(messageIds, fetchType, limit).join();
+    private CompletableFuture<Stream<SimpleMailboxMessage>> retrieveMessages(List<ComposedMessageIdWithMetaData> messageIds, FetchType fetchType, Optional<Integer> limit) {
+        CompletableFuture<Stream<Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<CassandraMessageDAO.MessageAttachmentRepresentation>>>>
+            messageRepresentations = messageDAO.retrieveMessages(messageIds, fetchType, limit);
         if (fetchType == FetchType.Body || fetchType == FetchType.Full) {
-            return CompletableFutureUtil.allOf(messageRepresentions
-                .map((Pair<CassandraMessageDAO.MessageWithoutAttachment, Stream<CassandraMessageDAO.MessageAttachmentRepresentation>> pair) -> 
-                    attachmentLoader.getAttachments(pair.getRight().collect(Guavate.toImmutableList()))
-                        .thenApply(attachments -> Pair.of(pair.getLeft(), attachments))))
-                .join()
-                .map(Throwing.function(pair -> pair.getLeft()
+            return messageRepresentations
+                .thenCompose(stream -> CompletableFutureUtil.allOf(
+                    stream.map(pair -> attachmentLoader.getAttachments(pair.getRight().collect(Guavate.toImmutableList()))
+                        .thenApply(attachments -> Pair.of(pair.getLeft(), attachments)))
+                ))
+                .thenApply(stream -> stream.map(Throwing.function(pair -> pair.getLeft()
                     .toMailboxMessage(pair.getRight()
                         .stream()
-                        .collect(Guavate.toImmutableList()))));
+                        .collect(Guavate.toImmutableList())))));
         } else {
-            return messageRepresentions.map(pair -> pair.getLeft().toMailboxMessage(ImmutableList.of()));
+            return messageRepresentations.thenApply(
+                stream -> stream.map(pair ->
+                pair.getLeft().toMailboxMessage(ImmutableList.of())));
         }
     }
 
@@ -198,14 +209,26 @@ public class CassandraMessageMapper implements MessageMapper {
     }
 
     @Override
-    public Map<MessageUid, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox mailbox, MessageRange set) throws MailboxException {
+    public Map<MessageUid, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox mailbox, MessageRange messageRange) throws MailboxException {
         CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
-        return retrieveMessages(retrieveMessageIds(mailboxId, set), FetchType.Metadata, Optional.empty())
-                .filter(MailboxMessage::isDeleted)
-                .peek(message -> delete(mailbox, message))
-                .collect(Collectors.toMap(MailboxMessage::getUid, SimpleMessageMetaData::new));
-    }
 
+        CompletableFuture<Stream<SimpleMailboxMessage>> messagesToDelete =
+            CompletableFutureUtil.flatMapOnAll(
+                deletedMessageDAO.retrieveDeletedMessage(mailboxId, messageRange),
+                messageId ->
+                    messageIdDAO.retrieve(mailboxId, messageId))
+
+            .thenApply(ids -> ids
+                .flatMap(OptionalConverter::toStream)
+                .collect(Guavate.toImmutableList()))
+
+            .thenCompose(ids -> retrieveMessages(ids, FetchType.Metadata, Optional.empty()));
+
+        return CompletableFutureUtil.performOnAll(messagesToDelete, message ->
+                deleteAsFuture(message, mailboxId))
+            .join()
+            .collect(Guavate.toImmutableMap(MailboxMessage::getUid, SimpleMessageMetaData::new));
+    }
     @Override
     public MessageMetaData move(Mailbox destinationMailbox, MailboxMessage original) throws MailboxException {
         CassandraId originalMailboxId = (CassandraId) original.getMailboxId();
@@ -249,6 +272,7 @@ public class CassandraMessageMapper implements MessageMapper {
     public Iterator<UpdatedFlags> updateFlags(Mailbox mailbox, FlagsUpdateCalculator flagUpdateCalculator, MessageRange set) throws MailboxException {
         CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
         return retrieveMessages(retrieveMessageIds(mailboxId, set), FetchType.Metadata, Optional.empty())
+                .join()
                 .flatMap(message -> updateFlagsOnMessage(mailbox, flagUpdateCalculator, message))
                 .map((UpdatedFlags updatedFlags) -> indexTableHandler.updateIndexOnFlagsUpdate(mailboxId, updatedFlags)
                     .thenApply(voidValue -> updatedFlags))

http://git-wip-us.apache.org/repos/asf/james-project/blob/8dba0425/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
index 25f3134..2c5b99b 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerTest.java
@@ -24,6 +24,7 @@ import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.acl.MailboxACLResolver;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
+import org.apache.james.mailbox.cassandra.mail.CassandraDeletedMessageDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraFirstUnseenDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraApplicableFlagDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraMailboxCounterDAO;
@@ -38,6 +39,7 @@ import org.apache.james.mailbox.cassandra.mail.CassandraUidProvider;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
@@ -77,6 +79,7 @@ public class CassandraMailboxManagerTest {
         new CassandraModSeqModule(),
         new CassandraSubscriptionModule(),
         new CassandraAttachmentModule(),
+        new CassandraDeletedMessageModule(),
         new CassandraAnnotationModule()));
 
     private IProducer<CassandraMailboxManager> producer = new IProducer<CassandraMailboxManager>() {
@@ -96,6 +99,7 @@ public class CassandraMailboxManagerTest {
             CassandraMailboxPathDAO mailboxPathDAO = new CassandraMailboxPathDAO(CASSANDRA.getConf(), CASSANDRA.getTypesProvider());
             CassandraFirstUnseenDAO firstUnseenDAO = new CassandraFirstUnseenDAO(CASSANDRA.getConf());
             CassandraApplicableFlagDAO applicableFlagDAO = new CassandraApplicableFlagDAO(CASSANDRA.getConf());
+            CassandraDeletedMessageDAO deletedMessageDAO = new CassandraDeletedMessageDAO(CASSANDRA.getConf());
 
             CassandraMailboxSessionMapperFactory mapperFactory = new CassandraMailboxSessionMapperFactory(uidProvider,
                 modSeqProvider,
@@ -108,7 +112,8 @@ public class CassandraMailboxManagerTest {
                 mailboxDAO,
                 mailboxPathDAO,
                 firstUnseenDAO,
-                applicableFlagDAO);
+                applicableFlagDAO,
+                deletedMessageDAO);
 
             MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
             GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();

http://git-wip-us.apache.org/repos/asf/james-project/blob/8dba0425/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
index 8c0948d..b2eacd9 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraSubscriptionManagerTest.java
@@ -23,6 +23,7 @@ import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
 import org.apache.james.mailbox.AbstractSubscriptionManagerTest;
 import org.apache.james.mailbox.SubscriptionManager;
+import org.apache.james.mailbox.cassandra.mail.CassandraDeletedMessageDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraFirstUnseenDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraApplicableFlagDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraMailboxCounterDAO;
@@ -62,6 +63,7 @@ public class CassandraSubscriptionManagerTest extends AbstractSubscriptionManage
         CassandraMailboxPathDAO mailboxPathDAO = null;
         CassandraFirstUnseenDAO firstUnseenDAO = null;
         CassandraApplicableFlagDAO applicableFlagDAO = null;
+        CassandraDeletedMessageDAO deletedMessageDAO = null;
         return new CassandraSubscriptionManager(
             new CassandraMailboxSessionMapperFactory(
                 new CassandraUidProvider(cassandra.getConf()),
@@ -75,7 +77,7 @@ public class CassandraSubscriptionManagerTest extends AbstractSubscriptionManage
                 mailboxDAO,
                 mailboxPathDAO,
                 firstUnseenDAO,
-                applicableFlagDAO)
-        );
+                applicableFlagDAO,
+                deletedMessageDAO));
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/8dba0425/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
index 30e4dac..22af497 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
@@ -23,6 +23,7 @@ import static org.mockito.Mockito.mock;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
+import org.apache.james.mailbox.cassandra.mail.CassandraDeletedMessageDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraFirstUnseenDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraApplicableFlagDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraMailboxCounterDAO;
@@ -38,6 +39,7 @@ import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
@@ -62,6 +64,7 @@ public class CassandraTestSystemFixture {
         new CassandraMailboxCounterModule(),
         new CassandraMailboxRecentsModule(),
         new CassandraFirstUnseenModule(),
+        new CassandraDeletedMessageModule(),
         new CassandraUidModule(),
         new CassandraModSeqModule(),
         new CassandraAttachmentModule(),
@@ -85,6 +88,7 @@ public class CassandraTestSystemFixture {
         CassandraMailboxDAO mailboxDAO = new CassandraMailboxDAO(CASSANDRA.getConf(), CASSANDRA.getTypesProvider(), MAX_ACL_RETRY);
         CassandraMailboxPathDAO mailboxPathDAO = new CassandraMailboxPathDAO(CASSANDRA.getConf(), CASSANDRA.getTypesProvider());
         CassandraFirstUnseenDAO firstUnseenDAO = new CassandraFirstUnseenDAO(CASSANDRA.getConf());
+        CassandraDeletedMessageDAO deletedMessageDAO = new CassandraDeletedMessageDAO(CASSANDRA.getConf());
         return new CassandraMailboxSessionMapperFactory(uidProvider,
             modSeqProvider,
             CASSANDRA.getConf(),
@@ -96,7 +100,8 @@ public class CassandraTestSystemFixture {
             mailboxDAO,
             mailboxPathDAO,
             firstUnseenDAO,
-            applicableFlagDAO);
+            applicableFlagDAO,
+            deletedMessageDAO);
     }
 
     public static CassandraMailboxManager createMailboxManager(CassandraMailboxSessionMapperFactory mapperFactory) throws Exception{

http://git-wip-us.apache.org/repos/asf/james-project/blob/8dba0425/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandlerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandlerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandlerTest.java
index 8605076..b82fb4a 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandlerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraIndexTableHandlerTest.java
@@ -28,6 +28,7 @@ import java.util.Optional;
 import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 
+import com.github.steveash.guavate.Guavate;
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
 import org.apache.james.mailbox.FlagsBuilder;
@@ -35,12 +36,14 @@ import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.cassandra.CassandraMessageId;
 import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxRecentsModule;
 import org.apache.james.mailbox.model.ComposedMessageId;
 import org.apache.james.mailbox.model.ComposedMessageIdWithMetaData;
 import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
@@ -63,6 +66,7 @@ public class CassandraIndexTableHandlerTest {
     private CassandraApplicableFlagDAO applicableFlagDAO;
     private CassandraFirstUnseenDAO firstUnseenDAO;
     private CassandraIndexTableHandler testee;
+    private CassandraDeletedMessageDAO deletedMessageDAO;
     private Mailbox mailbox;
 
     @Before
@@ -72,15 +76,21 @@ public class CassandraIndexTableHandlerTest {
                 new CassandraMailboxCounterModule(),
                 new CassandraMailboxRecentsModule(),
                 new CassandraFirstUnseenModule(),
-                new CassandraApplicableFlagsModule()));
+                new CassandraApplicableFlagsModule(),
+                new CassandraDeletedMessageModule()));
         cassandra.ensureAllTables();
 
         mailboxCounterDAO = new CassandraMailboxCounterDAO(cassandra.getConf());
         mailboxRecentsDAO = new CassandraMailboxRecentsDAO(cassandra.getConf());
         firstUnseenDAO = new CassandraFirstUnseenDAO(cassandra.getConf());
         applicableFlagDAO = new CassandraApplicableFlagDAO(cassandra.getConf());
+        deletedMessageDAO = new CassandraDeletedMessageDAO(cassandra.getConf());
 
-        testee = new CassandraIndexTableHandler(mailboxRecentsDAO, mailboxCounterDAO, firstUnseenDAO, applicableFlagDAO);
+        testee = new CassandraIndexTableHandler(mailboxRecentsDAO,
+                                                mailboxCounterDAO,
+                                                firstUnseenDAO,
+                                                applicableFlagDAO,
+                                                deletedMessageDAO);
 
         mailbox = new SimpleMailbox(new MailboxPath("#private", "user", "name"),
             UID_VALIDITY,
@@ -245,6 +255,26 @@ public class CassandraIndexTableHandlerTest {
     }
 
     @Test
+    public void updateIndexOnDeleteShouldDeleteMessageFromDeletedMessage() throws Exception {
+        MailboxMessage message = mock(MailboxMessage.class);
+        when(message.getUid()).thenReturn(MESSAGE_UID);
+        deletedMessageDAO.addDeleted(MAILBOX_ID, MESSAGE_UID).join();
+
+        testee.updateIndexOnDelete(new ComposedMessageIdWithMetaData(
+                new ComposedMessageId(MAILBOX_ID, CASSANDRA_MESSAGE_ID, MESSAGE_UID),
+                new Flags(),
+                MODSEQ),
+            MAILBOX_ID).join();
+
+        assertThat(
+            deletedMessageDAO.
+                retrieveDeletedMessage(MAILBOX_ID, MessageRange.all())
+                .join()
+                .collect(Guavate.toImmutableList()))
+            .isEmpty();
+    }
+
+    @Test
     public void updateIndexOnFlagsUpdateShouldNotChangeMessageCount() throws Exception {
         MailboxMessage message = mock(MailboxMessage.class);
         when(message.createFlags()).thenReturn(new Flags());
@@ -283,6 +313,98 @@ public class CassandraIndexTableHandlerTest {
     }
 
     @Test
+    public void updateIndexOnFlagsUpdateShouldSaveMessageInDeletedMessageWhenDeletedFlagIsSet() throws Exception {
+        MailboxMessage message = mock(MailboxMessage.class);
+        when(message.createFlags()).thenReturn(new Flags());
+        when(message.getUid()).thenReturn(MESSAGE_UID);
+        testee.updateIndexOnAdd(message, MAILBOX_ID).join();
+
+        testee.updateIndexOnFlagsUpdate(MAILBOX_ID, UpdatedFlags.builder()
+            .uid(MESSAGE_UID)
+            .newFlags(new Flags(Flags.Flag.DELETED))
+            .oldFlags(new Flags())
+            .modSeq(MODSEQ)
+            .build()).join();
+
+        assertThat(
+            deletedMessageDAO.
+                retrieveDeletedMessage(MAILBOX_ID, MessageRange.all())
+                .join()
+                .collect(Guavate.toImmutableList()))
+            .containsExactly(MESSAGE_UID);
+    }
+
+    @Test
+    public void updateIndexOnFlagsUpdateShouldRemoveMessageInDeletedMessageWhenDeletedFlagIsUnset() throws Exception {
+        MailboxMessage message = mock(MailboxMessage.class);
+        when(message.createFlags()).thenReturn(new Flags());
+        when(message.getUid()).thenReturn(MESSAGE_UID);
+        testee.updateIndexOnAdd(message, MAILBOX_ID).join();
+
+        deletedMessageDAO.addDeleted(MAILBOX_ID, MESSAGE_UID).join();
+
+        testee.updateIndexOnFlagsUpdate(MAILBOX_ID, UpdatedFlags.builder()
+            .uid(MESSAGE_UID)
+            .newFlags(new Flags())
+            .oldFlags(new Flags(Flags.Flag.DELETED))
+            .modSeq(MODSEQ)
+            .build()).join();
+
+        assertThat(
+            deletedMessageDAO.
+                retrieveDeletedMessage(MAILBOX_ID, MessageRange.all())
+                .join()
+                .collect(Guavate.toImmutableList()))
+            .isEmpty();
+    }
+
+    @Test
+    public void updateIndexOnFlagsUpdateShouldNotRemoveMessageInDeletedMessageWhenDeletedFlagIsNotUnset() throws Exception {
+        MailboxMessage message = mock(MailboxMessage.class);
+        when(message.createFlags()).thenReturn(new Flags());
+        when(message.getUid()).thenReturn(MESSAGE_UID);
+        testee.updateIndexOnAdd(message, MAILBOX_ID).join();
+
+        deletedMessageDAO.addDeleted(MAILBOX_ID, MESSAGE_UID).join();
+
+        testee.updateIndexOnFlagsUpdate(MAILBOX_ID, UpdatedFlags.builder()
+            .uid(MESSAGE_UID)
+            .newFlags(new Flags())
+            .oldFlags(new Flags(Flags.Flag.SEEN))
+            .modSeq(MODSEQ)
+            .build()).join();
+
+        assertThat(
+            deletedMessageDAO.
+                retrieveDeletedMessage(MAILBOX_ID, MessageRange.all())
+                .join()
+                .collect(Guavate.toImmutableList()))
+            .containsExactly(MESSAGE_UID);
+    }
+
+    @Test
+    public void updateIndexOnFlagsUpdateShouldNotSaveMessageInDeletedMessageWhenDeletedFlagIsNotSet() throws Exception {
+        MailboxMessage message = mock(MailboxMessage.class);
+        when(message.createFlags()).thenReturn(new Flags());
+        when(message.getUid()).thenReturn(MESSAGE_UID);
+        testee.updateIndexOnAdd(message, MAILBOX_ID).join();
+
+        testee.updateIndexOnFlagsUpdate(MAILBOX_ID, UpdatedFlags.builder()
+            .uid(MESSAGE_UID)
+            .newFlags(new Flags(Flags.Flag.RECENT))
+            .oldFlags(new Flags())
+            .modSeq(MODSEQ)
+            .build()).join();
+
+        assertThat(
+            deletedMessageDAO.
+                retrieveDeletedMessage(MAILBOX_ID, MessageRange.all())
+                .join()
+                .collect(Guavate.toImmutableList()))
+            .isEmpty();
+    }
+
+    @Test
     public void updateIndexOnFlagsUpdateShouldIncrementUnseenMessageCountWhenSeenIsUnset() throws Exception {
         MailboxMessage message = mock(MailboxMessage.class);
         when(message.createFlags()).thenReturn(new Flags(Flags.Flag.SEEN));
@@ -390,6 +512,36 @@ public class CassandraIndexTableHandlerTest {
     }
 
     @Test
+    public void updateIndexOnAddShouldSaveMessageInDeletedWhenDeleted() throws Exception {
+        MailboxMessage message = mock(MailboxMessage.class);
+        when(message.createFlags()).thenReturn(new Flags(Flags.Flag.DELETED));
+        when(message.getUid()).thenReturn(MESSAGE_UID);
+        testee.updateIndexOnAdd(message, MAILBOX_ID).join();
+
+        assertThat(
+            deletedMessageDAO.
+                retrieveDeletedMessage(MAILBOX_ID, MessageRange.all())
+                .join()
+                .collect(Guavate.toImmutableList()))
+            .containsExactly(MESSAGE_UID);
+    }
+
+    @Test
+    public void updateIndexOnAddShouldNotSaveMessageInDeletedWhenNotDeleted() throws Exception {
+        MailboxMessage message = mock(MailboxMessage.class);
+        when(message.createFlags()).thenReturn(new Flags());
+        when(message.getUid()).thenReturn(MESSAGE_UID);
+        testee.updateIndexOnAdd(message, MAILBOX_ID).join();
+
+        assertThat(
+            deletedMessageDAO.
+                retrieveDeletedMessage(MAILBOX_ID, MessageRange.all())
+                .join()
+                .collect(Guavate.toImmutableList()))
+            .isEmpty();
+    }
+
+    @Test
     public void updateIndexOnAddShouldNotUpdateFirstUnseenWhenSeen() throws Exception {
         MailboxMessage message = mock(MailboxMessage.class);
         when(message.createFlags()).thenReturn(new Flags(Flags.Flag.SEEN));

http://git-wip-us.apache.org/repos/asf/james-project/blob/8dba0425/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
index dbcd3e3..56672d1 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
@@ -31,6 +31,7 @@ import org.apache.james.mailbox.cassandra.CassandraMessageId;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
@@ -53,6 +54,7 @@ public class CassandraMailboxManagerAttachmentTest extends AbstractMailboxManage
             new CassandraMailboxCounterModule(),
             new CassandraMailboxRecentsModule(),
             new CassandraFirstUnseenModule(),
+            new CassandraDeletedMessageModule(),
             new CassandraModSeqModule(),
             new CassandraUidModule(),
             new CassandraAttachmentModule(),
@@ -69,6 +71,7 @@ public class CassandraMailboxManagerAttachmentTest extends AbstractMailboxManage
         CassandraMailboxDAO mailboxDAO = new CassandraMailboxDAO(cassandra.getConf(), cassandra.getTypesProvider(), MAX_ACL_RETRY);
         CassandraMailboxPathDAO mailboxPathDAO = new CassandraMailboxPathDAO(cassandra.getConf(), cassandra.getTypesProvider());
         CassandraFirstUnseenDAO firstUnseenDAO = new CassandraFirstUnseenDAO(cassandra.getConf());
+        CassandraDeletedMessageDAO deletedMessageDAO = new CassandraDeletedMessageDAO(cassandra.getConf());
         mailboxSessionMapperFactory = new CassandraMailboxSessionMapperFactory(
                 new CassandraUidProvider(cassandra.getConf()),
                 new CassandraModSeqProvider(cassandra.getConf()),
@@ -81,7 +84,8 @@ public class CassandraMailboxManagerAttachmentTest extends AbstractMailboxManage
                 mailboxDAO,
                 mailboxPathDAO,
                 firstUnseenDAO,
-                new CassandraApplicableFlagDAO(cassandra.getConf()));
+                new CassandraApplicableFlagDAO(cassandra.getConf()),
+                deletedMessageDAO);
         Authenticator noAuthenticator = null;
         Authorizator noAuthorizator = null;
         mailboxManager = new CassandraMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(), new MessageParser(), messageIdFactory); 

http://git-wip-us.apache.org/repos/asf/james-project/blob/8dba0425/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 5df92b0..bcbd9cc 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
@@ -32,6 +32,7 @@ import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
@@ -68,7 +69,8 @@ public class CassandraMapperProvider implements MapperProvider {
         new CassandraAttachmentModule(),
         new CassandraAnnotationModule(),
         new CassandraFirstUnseenModule(),
-        new CassandraApplicableFlagsModule()));
+        new CassandraApplicableFlagsModule(),
+        new CassandraDeletedMessageModule()));
     public static final int MAX_ACL_RETRY = 10;
 
     private final MessageUidProvider messageUidProvider;
@@ -103,6 +105,7 @@ public class CassandraMapperProvider implements MapperProvider {
         CassandraMailboxDAO mailboxDAO = new CassandraMailboxDAO(cassandra.getConf(), cassandra.getTypesProvider(), MAX_ACL_RETRY);
         CassandraMailboxPathDAO mailboxPathDAO = new CassandraMailboxPathDAO(cassandra.getConf(), cassandra.getTypesProvider());
         CassandraFirstUnseenDAO firstUnseenDAO = new CassandraFirstUnseenDAO(cassandra.getConf());
+        CassandraDeletedMessageDAO deletedMessageDAO = new CassandraDeletedMessageDAO(cassandra.getConf());
         return new CassandraMailboxSessionMapperFactory(
             new CassandraUidProvider(cassandra.getConf()),
             cassandraModSeqProvider,
@@ -115,7 +118,8 @@ public class CassandraMapperProvider implements MapperProvider {
             mailboxDAO,
             mailboxPathDAO,
             firstUnseenDAO,
-            new CassandraApplicableFlagDAO(cassandra.getConf()));
+            new CassandraApplicableFlagDAO(cassandra.getConf()),
+            deletedMessageDAO);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/8dba0425/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
index cc3a65f..8d8f293 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
@@ -29,6 +29,7 @@ import org.apache.james.mailbox.SubscriptionManager;
 import org.apache.james.mailbox.cassandra.CassandraMailboxManager;
 import org.apache.james.mailbox.cassandra.CassandraMailboxSessionMapperFactory;
 import org.apache.james.mailbox.cassandra.CassandraMessageId;
+import org.apache.james.mailbox.cassandra.mail.CassandraDeletedMessageDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraFirstUnseenDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraApplicableFlagDAO;
 import org.apache.james.mailbox.cassandra.mail.CassandraMailboxCounterDAO;
@@ -44,6 +45,7 @@ import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule;
+import org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraFirstUnseenModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxCounterModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
@@ -88,6 +90,7 @@ public class CassandraHostSystem extends JamesImapHostSystem {
             new CassandraMailboxCounterModule(),
             new CassandraMailboxRecentsModule(),
             new CassandraFirstUnseenModule(),
+            new CassandraDeletedMessageModule(),
             new CassandraUidModule(),
             new CassandraModSeqModule(),
             new CassandraSubscriptionModule(),
@@ -110,10 +113,22 @@ public class CassandraHostSystem extends JamesImapHostSystem {
         CassandraMailboxPathDAO mailboxPathDAO = new CassandraMailboxPathDAO(session, typesProvider);
         CassandraFirstUnseenDAO firstUnseenDAO = new CassandraFirstUnseenDAO(session);
         CassandraApplicableFlagDAO applicableFlagDAO = new CassandraApplicableFlagDAO(session);
-
-        CassandraMailboxSessionMapperFactory mapperFactory = new CassandraMailboxSessionMapperFactory(uidProvider, modSeqProvider, 
-                session, messageDAO, messageIdDAO, imapUidDAO, mailboxCounterDAO, mailboxRecentsDAO, mailboxDAO, mailboxPathDAO,
-                firstUnseenDAO, applicableFlagDAO);
+        CassandraDeletedMessageDAO deletedMessageDAO = new CassandraDeletedMessageDAO(session);
+
+        CassandraMailboxSessionMapperFactory mapperFactory = new CassandraMailboxSessionMapperFactory(
+            uidProvider,
+            modSeqProvider,
+            session,
+            messageDAO,
+            messageIdDAO,
+            imapUidDAO,
+            mailboxCounterDAO,
+            mailboxRecentsDAO,
+            mailboxDAO,
+            mailboxPathDAO,
+            firstUnseenDAO,
+            applicableFlagDAO,
+            deletedMessageDAO);
 
         mailboxManager = new CassandraMailboxManager(mapperFactory, authenticator, authorizator, new JVMMailboxPathLocker(), new MessageParser(), messageIdFactory);
         QuotaRootResolver quotaRootResolver = new DefaultQuotaRootResolver(mapperFactory);

http://git-wip-us.apache.org/repos/asf/james-project/blob/8dba0425/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 291d154..a6e6ac3 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
@@ -116,8 +116,12 @@ public class CassandraMailboxModule extends AbstractModule {
         cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule.class);
         cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraAttachmentModule.class);
         cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraAnnotationModule.class);
+
         cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraApplicableFlagsModule.class);
 
+        cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraDeletedMessageModule.class);
+
+
         Multibinder.newSetBinder(binder(), MailboxManagerDefinition.class).addBinding().to(CassandraMailboxManagerDefinition.class);
     }
 
@@ -136,4 +140,4 @@ public class CassandraMailboxModule extends AbstractModule {
     }
     
 
-}
\ No newline at end of file
+}


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