james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [5/5] james-project git commit: JAMES-1945 Use FirstUnseenDAO for retrieving first unseen message in CassandraMessageMapper
Date Tue, 21 Feb 2017 15:43:10 GMT
JAMES-1945 Use FirstUnseenDAO for retrieving first unseen message in CassandraMessageMapper

Test suite already convers :
 - First unseen on MessageMapper
 - Comination between MessageIdManager and MessageManager


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

Branch: refs/heads/master
Commit: 6b5d52789815826bc1ae5f7a86888de659a2a614
Parents: 72bb769
Author: benwa <btellier@linagora.com>
Authored: Tue Feb 21 17:20:35 2017 +0700
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Tue Feb 21 16:41:55 2017 +0100

----------------------------------------------------------------------
 .../CassandraMailboxSessionMapperFactory.java     |  2 +-
 .../cassandra/mail/CassandraMessageMapper.java    | 18 +++++++-----------
 2 files changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/6b5d5278/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 927bee5..3172410 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
@@ -102,7 +102,7 @@ public class CassandraMailboxSessionMapperFactory extends MailboxSessionMapperFa
     @Override
     public CassandraMessageMapper createMessageMapper(MailboxSession mailboxSession) {
         return new CassandraMessageMapper(uidProvider, modSeqProvider, null, maxRetry, createAttachmentMapper(mailboxSession),
-                messageDAO, messageIdDAO, imapUidDAO, mailboxCounterDAO, mailboxRecentsDAO,
indexTableHandler);
+                messageDAO, messageIdDAO, imapUidDAO, mailboxCounterDAO, mailboxRecentsDAO,
indexTableHandler, firstUnseenDAO);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/6b5d5278/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 c43f26b..c81ed79 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
@@ -82,11 +82,13 @@ public class CassandraMessageMapper implements MessageMapper {
     private final CassandraMailboxCounterDAO mailboxCounterDAO;
     private final CassandraMailboxRecentsDAO mailboxRecentDAO;
     private final CassandraIndexTableHandler indexTableHandler;
+    private final CassandraFirstUnseenDAO firstUnseenDAO;
 
     public CassandraMessageMapper(UidProvider uidProvider, ModSeqProvider modSeqProvider,
                                   MailboxSession mailboxSession, int maxRetries, AttachmentMapper
attachmentMapper,
                                   CassandraMessageDAO messageDAO, CassandraMessageIdDAO messageIdDAO,
CassandraMessageIdToImapUidDAO imapUidDAO,
-                                  CassandraMailboxCounterDAO mailboxCounterDAO, CassandraMailboxRecentsDAO
mailboxRecentDAO, CassandraIndexTableHandler indexTableHandler) {
+                                  CassandraMailboxCounterDAO mailboxCounterDAO, CassandraMailboxRecentsDAO
mailboxRecentDAO,
+                                  CassandraIndexTableHandler indexTableHandler, CassandraFirstUnseenDAO
firstUnseenDAO) {
         this.uidProvider = uidProvider;
         this.modSeqProvider = modSeqProvider;
         this.mailboxSession = mailboxSession;
@@ -98,6 +100,7 @@ public class CassandraMessageMapper implements MessageMapper {
         this.mailboxCounterDAO = mailboxCounterDAO;
         this.mailboxRecentDAO = mailboxRecentDAO;
         this.indexTableHandler = indexTableHandler;
+        this.firstUnseenDAO = firstUnseenDAO;
     }
 
     @Override
@@ -188,14 +191,9 @@ public class CassandraMessageMapper implements MessageMapper {
     @Override
     public MessageUid findFirstUnseenMessageUid(Mailbox mailbox) throws MailboxException
{
         CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
-        return retrieveMessages(retrieveMessageIds(mailboxId, MessageRange.all()), FetchType.Metadata,
Optional.empty())
-                .filter(message -> !message.isSeen())
-                .flatMap(message -> imapUidDAO.retrieve((CassandraMessageId) message.getMessageId(),
Optional.ofNullable(mailboxId)).join())
-                .map(ComposedMessageIdWithMetaData::getComposedMessageId)
-                .map(ComposedMessageId::getUid)
-                .sorted()
-                .findFirst()
-                .orElse(null);
+        return firstUnseenDAO.retrieveFirstUnread(mailboxId)
+            .join()
+            .orElse(null);
     }
 
     @Override
@@ -238,8 +236,6 @@ public class CassandraMessageMapper implements MessageMapper {
         return new SimpleMessageMetaData(message);
     }
 
-
-
     @Override
     public Iterator<UpdatedFlags> updateFlags(Mailbox mailbox, FlagsUpdateCalculator
flagUpdateCalculator, MessageRange set) throws MailboxException {
         CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();


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