james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1685951 - in /james/mailbox/trunk: cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
Date Wed, 17 Jun 2015 08:56:32 GMT
Author: btellier
Date: Wed Jun 17 08:56:32 2015
New Revision: 1685951

URL: http://svn.apache.org/r1685951
Log:
MAILBOX-231 Correct message count handling

Modified:
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java?rev=1685951&r1=1685950&r2=1685951&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
(original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
Wed Jun 17 08:56:32 2015
@@ -419,9 +419,19 @@ public class CassandraMessageMapper impl
                 throw new MailboxException("Max retries reached when asking an update of
flags on message " + uid + " for mailbox " + mailbox.getMailboxId());
             }
         }
+        manageUnseenMessageCounts(mailbox, originFlags, updatedFlags);
         result.add(new UpdatedFlags(message.getUid(), message.getModSeq(), originFlags, updatedFlags));
     }
 
+    private void manageUnseenMessageCounts(Mailbox<UUID> mailbox, Flags oldFlags, Flags
newFlags) {
+        if (oldFlags.contains(Flag.SEEN) && !newFlags.contains(Flag.SEEN)) {
+            incrementUnseen(mailbox);
+        }
+        if (!oldFlags.contains(Flag.SEEN) && newFlags.contains(Flag.SEEN)) {
+            decrementUnseen(mailbox);
+        }
+    }
+
     private Row findMessageByUid(Mailbox<UUID> mailbox, long uid) {
         ResultSet resultSet = session.execute(selectMessage(mailbox, uid));
         if ( resultSet.isExhausted() ) {
@@ -446,8 +456,13 @@ public class CassandraMessageMapper impl
 
     @Override
     public MessageMetaData copy(Mailbox<UUID> mailbox, Message<UUID> original)
throws MailboxException {
+
         original.setUid(uidProvider.nextUid(mailboxSession, mailbox));
         original.setModSeq(modSeqProvider.nextModSeq(mailboxSession, mailbox));
+        incrementCount(mailbox);
+        if(!original.isSeen()) {
+            incrementUnseen(mailbox);
+        }
         return save(mailbox, original);
     }
 

Modified: james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java?rev=1685951&r1=1685950&r2=1685951&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
(original)
+++ james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
Wed Jun 17 08:56:32 2015
@@ -115,8 +115,6 @@ public abstract class AbstractMessageMap
         assertThat(messageMapper.countUnseenMessagesInMailbox(benwaInboxMailbox)).isEqualTo(5);
     }
 
-    // We should decrement mailbox unseen count when a message is marked as read.
-    @Ignore
     @Test
     public void mailboxUnSeenCountShouldBeDecrementedAfterAMessageIsMarkedSeen() throws MailboxException
{
         saveMessages();
@@ -410,8 +408,6 @@ public abstract class AbstractMessageMap
         assertThat(messageMapper.getLastUid(benwaInboxMailbox)).isGreaterThan(uid);
     }
 
-    // Message count should be modified upon copy
-    @Ignore
     @Test
     public void copyShouldIncrementMessageCount() throws MailboxException, IOException {
         saveMessages();
@@ -419,8 +415,6 @@ public abstract class AbstractMessageMap
         assertThat(messageMapper.countMessagesInMailbox(benwaInboxMailbox)).isEqualTo(6);
     }
 
-    // Message unseen count should be modified upon copy.
-    @Ignore
     @Test
     public void copyOfUnSeenMessageShouldIncrementUnSeenMessageCount() throws MailboxException,
IOException {
         saveMessages();
@@ -436,8 +430,6 @@ public abstract class AbstractMessageMap
         assertThat(messageMapper.getHighestModSeq(benwaInboxMailbox)).isGreaterThan(modSeq);
     }
 
-    // ModSeq of copied messages is not set
-    @Ignore
     @Test
     public void copyShouldCreateAMessageInDestination() throws MailboxException, IOException
{
         saveMessages();



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