james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject svn commit: r1688109 [1/6] - in /james/mailbox/trunk: caching/src/main/java/org/apache/james/mailbox/caching/ caching/src/main/java/org/apache/james/mailbox/caching/guava/ cassandra/src/main/java/org/apache/james/mailbox/cassandra/ cassandra/src/main/j...
Date Mon, 29 Jun 2015 08:21:14 GMT
Author: btellier
Date: Mon Jun 29 08:21:12 2015
New Revision: 1688109

URL: http://svn.apache.org/r1688109
Log:
MAILBOX-236 use strong types for Mailbox Id - contributed by Matthieu Baechlor

Added:
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseId.java
    james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRId.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAId.java
    james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirId.java
    james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/model/MailboxId.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/TestId.java
Modified:
    james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
    james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java
    james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java
    james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMessageMapper.java
    james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/MailboxByPathCache.java
    james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/MailboxMetadataCache.java
    james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxByPathCache.java
    james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMessageManager.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
    james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapperTest.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
    james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/SimpleMailboxACLJsonConverterTest.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMessageManager.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseUtils.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMessage.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMessageMapper.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseModSeqProvider.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseUidProvider.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailbox.java
    james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/user/HBaseSubscriptionMapper.java
    james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java
    james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseUtilsTest.java
    james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java
    james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMessageMapperTest.java
    james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailboxTest.java
    james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java
    james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java
    james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMessageManager.java
    james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java
    james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMessageMapper.java
    james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRModSeqProvider.java
    james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRUidProvider.java
    james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailbox.java
    james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMessage.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMessageManager.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAModSeqProvider.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAUidProvider.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMessage.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
    james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMessageManager.java
    james/mailbox/trunk/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
    james/mailbox/trunk/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
    james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java
    james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirStore.java
    james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
    james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
    james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java
    james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java
    james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirStressTest.java
    james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java
    james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
    james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java
    james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryModSeqProvider.java
    james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryUidProvider.java
    james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxManagerTest.java
    james/mailbox/trunk/memory/src/test/java/org/apache/james/mailbox/inmemory/InMemoryMailboxMapperTest.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/MailboxEventDispatcher.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/MailboxSessionMapperFactory.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxPath.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/StoreMessageResultIterator.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/AbstractLockingModSeqProvider.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/AbstractLockingUidProvider.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/AbstractMessageMapper.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapperFactory.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/MessageMapper.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/MessageMapperFactory.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/ModSeqProvider.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/UidProvider.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/model/AbstractMessage.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/model/Mailbox.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/model/Message.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailbox.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/quota/PerUserQuotaManager.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/LazyMessageSearchIndex.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/MessageSearchIndex.java
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/GroupFolderResolverTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/MailboxEventDispatcherFlagsTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/MessageBuilder.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/MessageResultImplTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsMultipartMixedTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsRFC822Test.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/SearchUtilsTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/SimpleMailboxMembership.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/StoreMessageResultIteratorTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMailboxMapperTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageMapperTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/AbstractMessageTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxAssertTests.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/MapperProvider.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/MessageAssertTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/MetadataMapAssertTest.java
    james/mailbox/trunk/store/src/test/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessageTest.java
    james/mailbox/trunk/tool/src/test/java/org/apache/james/mailbox/copier/MailboxCopierTest.java
    james/mailbox/trunk/zoo-seq-provider/src/main/java/org/apache/james/mailbox/store/mail/ZooUidProvider.java
    james/mailbox/trunk/zoo-seq-provider/src/test/java/org/apache/james/mailbox/store/mail/ZooUidProviderTest.java

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java (original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CacheInvalidatingMailboxListener.java Mon Jun 29 08:21:12 2015
@@ -3,12 +3,13 @@ package org.apache.james.mailbox.caching
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxListenerSupport;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
 /**
  * A MailboxListener that invalidates the configured caches in response to Events
  * 
  * @param <Id>
  */
-public class CacheInvalidatingMailboxListener<Id> implements MailboxListener {
+public class CacheInvalidatingMailboxListener<Id extends MailboxId> implements MailboxListener {
 
 	private MailboxByPathCache<Id> mailboxCacheByPath;
 	private MailboxMetadataCache<Id> mailboxMetadataCache;

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java (original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java Mon Jun 29 08:21:12 2015
@@ -6,6 +6,7 @@ import org.apache.james.mailbox.exceptio
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
 /**
@@ -15,7 +16,7 @@ import org.apache.james.mailbox.store.ma
  * @param <Id>
  */
 
-public class CachingMailboxMapper<Id> implements MailboxMapper<Id> {
+public class CachingMailboxMapper<Id extends MailboxId> implements MailboxMapper<Id> {
 
 	private MailboxMapper<Id> underlying;
 	private MailboxByPathCache<Id> cache;

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java (original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxSessionMapperFactory.java Mon Jun 29 08:21:12 2015
@@ -6,6 +6,7 @@ import org.apache.james.mailbox.exceptio
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.MessageMapper;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 
 /**
@@ -15,7 +16,7 @@ import org.apache.james.mailbox.store.us
  * 
  * @param <Id>
  */
-public class CachingMailboxSessionMapperFactory<Id> extends
+public class CachingMailboxSessionMapperFactory<Id extends MailboxId> extends
 		MailboxSessionMapperFactory<Id> {
 
 	private MailboxSessionMapperFactory<Id> underlying;

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMessageMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMessageMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMessageMapper.java (original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/CachingMessageMapper.java Mon Jun 29 08:21:12 2015
@@ -10,6 +10,7 @@ import org.apache.james.mailbox.model.Me
 import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.mail.MessageMapper;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.Message;
 
@@ -19,7 +20,7 @@ import org.apache.james.mailbox.store.ma
  * 
  * @param <Id>
  */
-public class CachingMessageMapper<Id> implements MessageMapper<Id> {
+public class CachingMessageMapper<Id extends MailboxId> implements MessageMapper<Id> {
 
 	
 	private MessageMapper<Id> underlying;

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/MailboxByPathCache.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/MailboxByPathCache.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/MailboxByPathCache.java (original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/MailboxByPathCache.java Mon Jun 29 08:21:12 2015
@@ -4,6 +4,7 @@ import org.apache.james.mailbox.exceptio
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
 /**
@@ -11,7 +12,7 @@ import org.apache.james.mailbox.store.ma
  * 
  * @param <Id>
  */
-public interface MailboxByPathCache<Id> {
+public interface MailboxByPathCache<Id extends MailboxId> {
 
 	public abstract Mailbox<Id> findMailboxByPath(MailboxPath mailboxName,
 			MailboxMapper<Id> underlying) throws MailboxNotFoundException,

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/MailboxMetadataCache.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/MailboxMetadataCache.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/MailboxMetadataCache.java (original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/MailboxMetadataCache.java Mon Jun 29 08:21:12 2015
@@ -2,6 +2,7 @@ package org.apache.james.mailbox.caching
 
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.store.mail.MessageMapper;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
 /**
@@ -10,7 +11,7 @@ import org.apache.james.mailbox.store.ma
  * 
  * @param <Id>
  */
-public interface MailboxMetadataCache<Id> {
+public interface MailboxMetadataCache<Id extends MailboxId> {
 
 	public abstract long countMessagesInMailbox(Mailbox<Id> mailbox,
 			MessageMapper<Id> underlying) throws MailboxException;

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxByPathCache.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxByPathCache.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxByPathCache.java (original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxByPathCache.java Mon Jun 29 08:21:12 2015
@@ -5,6 +5,7 @@ import org.apache.james.mailbox.exceptio
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
 import com.google.common.cache.Cache;
@@ -16,7 +17,7 @@ import com.google.common.cache.Cache;
  *
  * @param <Id>
  */
-public class GuavaMailboxByPathCache<Id> extends AbstractGuavaCache implements MailboxByPathCache<Id> {
+public class GuavaMailboxByPathCache<Id extends MailboxId> extends AbstractGuavaCache implements MailboxByPathCache<Id> {
 	
 	private final Cache<String, Mailbox<Id>> findMailboxByPathCache = BUILDER.build();
 

Modified: james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java (original)
+++ james/mailbox/trunk/caching/src/main/java/org/apache/james/mailbox/caching/guava/GuavaMailboxMetadataCache.java Mon Jun 29 08:21:12 2015
@@ -3,6 +3,7 @@ package org.apache.james.mailbox.caching
 import org.apache.james.mailbox.caching.MailboxMetadataCache;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.store.mail.MessageMapper;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
 import com.google.common.cache.Cache;
@@ -13,7 +14,7 @@ import com.google.common.cache.Cache;
  * @param <Id>
  */
 
-public class GuavaMailboxMetadataCache<Id> extends AbstractGuavaCache implements MailboxMetadataCache<Id> {
+public class GuavaMailboxMetadataCache<Id extends MailboxId> extends AbstractGuavaCache implements MailboxMetadataCache<Id> {
 
 	// TODO these can probably be instantiated more elegant way
 	private final Cache<Id, Long> cacheCountMessagesInMailbox = BUILDER.build();

Added: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java?rev=1688109&view=auto
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java (added)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraId.java Mon Jun 29 08:21:12 2015
@@ -0,0 +1,77 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.mailbox.cassandra;
+
+import java.util.UUID;
+
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+
+import com.datastax.driver.core.utils.UUIDs;
+
+public class CassandraId implements MailboxId {
+
+    private final UUID id;
+
+    public static CassandraId timeBased() {
+        return of(UUIDs.timeBased());
+    }
+
+    public static CassandraId of(UUID id) {
+        return new CassandraId(id);
+    }
+
+    private CassandraId(UUID id) {
+        this.id = id;
+    }
+
+    @Override
+    public String serialize() {
+        return id.toString();
+    }
+
+    public UUID asUuid() {
+        return id;
+    }
+    
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((id == null) ? 0 : id.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        CassandraId other = (CassandraId) obj;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        return true;
+    }
+
+}

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java (original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java Mon Jun 29 08:21:12 2015
@@ -19,8 +19,6 @@
 
 package org.apache.james.mailbox.cassandra;
 
-import java.util.UUID;
-
 import org.apache.james.mailbox.MailboxPathLocker;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
@@ -37,7 +35,7 @@ import org.apache.james.mailbox.store.ma
 /**
  * Cassandra implementation of {@link StoreMailboxManager}
  */
-public class CassandraMailboxManager extends StoreMailboxManager<UUID> {
+public class CassandraMailboxManager extends StoreMailboxManager<CassandraId> {
     private MailboxPathLocker locker;
 
     public CassandraMailboxManager(CassandraMailboxSessionMapperFactory mapperFactory, Authenticator authenticator, final MailboxPathLocker locker) {
@@ -46,14 +44,14 @@ public class CassandraMailboxManager ext
     }
 
     @Override
-    protected Mailbox<UUID> doCreateMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
-        SimpleMailbox<UUID> cassandraMailbox = new SimpleMailbox<>(mailboxPath, randomUidValidity());
+    protected Mailbox<CassandraId> doCreateMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+        SimpleMailbox<CassandraId> cassandraMailbox = new SimpleMailbox<>(mailboxPath, randomUidValidity());
         cassandraMailbox.setACL(SimpleMailboxACL.EMPTY);
         return cassandraMailbox;
     }
 
     @Override
-    protected StoreMessageManager<UUID> createMessageManager(Mailbox<UUID> mailboxRow, MailboxSession session) throws MailboxException {
+    protected StoreMessageManager<CassandraId> createMessageManager(Mailbox<CassandraId> mailboxRow, MailboxSession session) throws MailboxException {
         return new CassandraMessageManager(getMapperFactory(), getMessageSearchIndex(), getEventDispatcher(), this.locker, mailboxRow);
     }
 

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java (original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactory.java Mon Jun 29 08:21:12 2015
@@ -19,8 +19,6 @@
 
 package org.apache.james.mailbox.cassandra;
 
-import java.util.UUID;
-
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.cassandra.mail.CassandraMailboxMapper;
 import org.apache.james.mailbox.cassandra.mail.CassandraMessageMapper;
@@ -37,16 +35,16 @@ import com.datastax.driver.core.Session;
  * Cassandra implementation of {@link MailboxSessionMapperFactory}
  * 
  */
-public class CassandraMailboxSessionMapperFactory extends MailboxSessionMapperFactory<UUID> {
+public class CassandraMailboxSessionMapperFactory extends MailboxSessionMapperFactory<CassandraId> {
     private static final int DEFAULT_MAX_RETRY = 1000;
 
     private final Session session;
-    private final UidProvider<UUID> uidProvider;
-    private final ModSeqProvider<UUID> modSeqProvider;
+    private final UidProvider<CassandraId> uidProvider;
+    private final ModSeqProvider<CassandraId> modSeqProvider;
     private final CassandraTypesProvider typesProvider;
     private int maxRetry;
 
-    public CassandraMailboxSessionMapperFactory(UidProvider<UUID> uidProvider, ModSeqProvider<UUID> modSeqProvider, Session session, CassandraTypesProvider typesProvider) {
+    public CassandraMailboxSessionMapperFactory(UidProvider<CassandraId> uidProvider, ModSeqProvider<CassandraId> modSeqProvider, Session session, CassandraTypesProvider typesProvider) {
         this.uidProvider = uidProvider;
         this.modSeqProvider = modSeqProvider;
         this.session = session;
@@ -64,7 +62,7 @@ public class CassandraMailboxSessionMapp
     }
 
     @Override
-    public MailboxMapper<UUID> createMailboxMapper(MailboxSession mailboxSession) {
+    public MailboxMapper<CassandraId> createMailboxMapper(MailboxSession mailboxSession) {
         return new CassandraMailboxMapper(session, typesProvider, maxRetry);
     }
 
@@ -73,11 +71,11 @@ public class CassandraMailboxSessionMapp
         return new CassandraSubscriptionMapper(session);
     }
 
-    public ModSeqProvider<UUID> getModSeqProvider() {
+    public ModSeqProvider<CassandraId> getModSeqProvider() {
         return modSeqProvider;
     }
 
-    public UidProvider<UUID> getUidProvider() {
+    public UidProvider<CassandraId> getUidProvider() {
         return uidProvider;
     }
 

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMessageManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMessageManager.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMessageManager.java (original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMessageManager.java Mon Jun 29 08:21:12 2015
@@ -19,8 +19,6 @@
 
 package org.apache.james.mailbox.cassandra;
 
-import java.util.UUID;
-
 import javax.mail.Flags;
 
 import org.apache.james.mailbox.MailboxPathLocker;
@@ -38,9 +36,9 @@ import org.apache.james.mailbox.store.se
  * Cassandra implementation of {@link StoreMessageManager}
  * 
  */
-public class CassandraMessageManager extends StoreMessageManager<UUID> {
+public class CassandraMessageManager extends StoreMessageManager<CassandraId> {
 
-    public CassandraMessageManager(MailboxSessionMapperFactory<UUID> mapperFactory, MessageSearchIndex<UUID> index, MailboxEventDispatcher<UUID> dispatcher, MailboxPathLocker locker, Mailbox<UUID> mailbox) throws MailboxException {
+    public CassandraMessageManager(MailboxSessionMapperFactory<CassandraId> mapperFactory, MessageSearchIndex<CassandraId> index, MailboxEventDispatcher<CassandraId> dispatcher, MailboxPathLocker locker, Mailbox<CassandraId> mailbox) throws MailboxException {
         super(mapperFactory, index, dispatcher, locker, mailbox, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
 
     }

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java (original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java Mon Jun 29 08:21:12 2015
@@ -19,15 +19,19 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
-import com.datastax.driver.core.Session;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Throwables;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.select;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.update;
+
+import java.io.IOException;
+import java.util.Optional;
+
 import org.apache.james.mailbox.cassandra.CassandraConstants;
-import org.apache.james.mailbox.cassandra.mail.utils.SimpleMailboxACLJsonConverter;
+import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.cassandra.mail.utils.FunctionRunnerWithRetry;
+import org.apache.james.mailbox.cassandra.mail.utils.SimpleMailboxACLJsonConverter;
 import org.apache.james.mailbox.cassandra.table.CassandraACLTable;
 import org.apache.james.mailbox.cassandra.table.CassandraMailboxTable;
 import org.apache.james.mailbox.exception.MailboxException;
@@ -38,15 +42,12 @@ import org.apache.james.mailbox.store.ma
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-import java.util.Optional;
-import java.util.UUID;
-
-import static com.datastax.driver.core.querybuilder.QueryBuilder.select;
-import static com.datastax.driver.core.querybuilder.QueryBuilder.update;
-import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto;
-import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
-import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
 
 public class CassandraACLMapper {
 
@@ -55,18 +56,18 @@ public class CassandraACLMapper {
         void inject();
     }
 
-    private final Mailbox<UUID> mailbox;
+    private final Mailbox<CassandraId> mailbox;
     private final Session session;
     private final int maxRetry;
     private final CodeInjector codeInjector;
 
     private static final Logger LOG = LoggerFactory.getLogger(CassandraACLMapper.class);
 
-    public CassandraACLMapper(Mailbox<UUID> mailbox, Session session, int maxRetry) {
+    public CassandraACLMapper(Mailbox<CassandraId> mailbox, Session session, int maxRetry) {
         this(mailbox, session, maxRetry, () -> {});
     }
 
-    public CassandraACLMapper(Mailbox<UUID> mailbox, Session session, int maxRetry, CodeInjector codeInjector) {
+    public CassandraACLMapper(Mailbox<CassandraId> mailbox, Session session, int maxRetry, CodeInjector codeInjector) {
         Preconditions.checkArgument(maxRetry > 0);
         Preconditions.checkArgument(mailbox.getMailboxId() != null);
         this.mailbox = mailbox;
@@ -109,7 +110,7 @@ public class CassandraACLMapper {
         return session.execute(
             select(CassandraACLTable.ACL, CassandraACLTable.VERSION)
                 .from(CassandraACLTable.TABLE_NAME)
-                .where(eq(CassandraMailboxTable.ID, mailbox.getMailboxId()))
+                .where(eq(CassandraMailboxTable.ID, mailbox.getMailboxId().asUuid()))
         );
     }
 
@@ -119,7 +120,7 @@ public class CassandraACLMapper {
                 update(CassandraACLTable.TABLE_NAME)
                     .with(set(CassandraACLTable.ACL, SimpleMailboxACLJsonConverter.toJson(aclWithVersion.mailboxACL)))
                     .and(set(CassandraACLTable.VERSION, aclWithVersion.version + 1))
-                    .where(eq(CassandraACLTable.ID, mailbox.getMailboxId()))
+                    .where(eq(CassandraACLTable.ID, mailbox.getMailboxId().asUuid()))
                     .onlyIf(eq(CassandraACLTable.VERSION, aclWithVersion.version))
             );
         } catch (JsonProcessingException exception) {
@@ -131,7 +132,7 @@ public class CassandraACLMapper {
         try {
             return session.execute(
                 insertInto(CassandraACLTable.TABLE_NAME)
-                    .value(CassandraACLTable.ID, mailbox.getMailboxId())
+                    .value(CassandraACLTable.ID, mailbox.getMailboxId().asUuid())
                     .value(CassandraACLTable.ACL, SimpleMailboxACLJsonConverter.toJson(acl))
                     .value(CassandraACLTable.VERSION, 0)
                     .ifNotExists()

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java (original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java Mon Jun 29 08:21:12 2015
@@ -19,43 +19,49 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
-import static com.datastax.driver.core.querybuilder.QueryBuilder.*;
-import static org.apache.james.mailbox.cassandra.table.CassandraMailboxTable.*;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.select;
+import static org.apache.james.mailbox.cassandra.table.CassandraMailboxTable.FIELDS;
+import static org.apache.james.mailbox.cassandra.table.CassandraMailboxTable.ID;
+import static org.apache.james.mailbox.cassandra.table.CassandraMailboxTable.MAILBOX_BASE;
+import static org.apache.james.mailbox.cassandra.table.CassandraMailboxTable.NAME;
+import static org.apache.james.mailbox.cassandra.table.CassandraMailboxTable.PATH;
+import static org.apache.james.mailbox.cassandra.table.CassandraMailboxTable.TABLE_NAME;
+import static org.apache.james.mailbox.cassandra.table.CassandraMailboxTable.UIDVALIDITY;
 
 import java.util.Collections;
 import java.util.List;
-import java.util.Optional;
 import java.util.StringTokenizer;
-import java.util.UUID;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 import java.util.stream.StreamSupport;
 
-import com.datastax.driver.core.utils.UUIDs;
-import com.google.common.base.Preconditions;
+import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.cassandra.CassandraTypesProvider;
 import org.apache.james.mailbox.cassandra.CassandraTypesProvider.TYPE;
-import org.apache.james.mailbox.cassandra.table.CassandraMailboxTable;
+import org.apache.james.mailbox.cassandra.table.CassandraMailboxTable.MailboxBase;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
 import com.datastax.driver.core.Session;
 import com.datastax.driver.core.querybuilder.QueryBuilder;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableList.Builder;
-import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 
 /**
  * Data access management for mailbox.
  */
-public class CassandraMailboxMapper implements MailboxMapper<UUID> {
+public class CassandraMailboxMapper implements MailboxMapper<CassandraId> {
 
     public static final String WILDCARD = "%";
     private final Session session;
@@ -69,12 +75,15 @@ public class CassandraMailboxMapper impl
     }
 
     @Override
-    public void delete(Mailbox<UUID> mailbox) throws MailboxException {
-        session.execute(QueryBuilder.delete().from(TABLE_NAME).where(eq(ID, mailbox.getMailboxId())));
+    public void delete(Mailbox<CassandraId> mailbox) throws MailboxException {
+        session.execute(
+                QueryBuilder.delete()
+                .from(TABLE_NAME)
+                .where(eq(ID, mailbox.getMailboxId().asUuid())));
     }
 
     @Override
-    public Mailbox<UUID> findMailboxByPath(MailboxPath path) throws MailboxException {
+    public Mailbox<CassandraId> findMailboxByPath(MailboxPath path) throws MailboxException {
         ResultSet resultSet = session.execute(select(FIELDS).from(TABLE_NAME).where(eq(PATH, path.toString())));
         if (resultSet.isExhausted()) {
             throw new MailboxNotFoundException(path);
@@ -83,20 +92,20 @@ public class CassandraMailboxMapper impl
         }
     }
 
-    private SimpleMailbox<UUID> mailbox(Row row) {
-        SimpleMailbox<UUID> mailbox = new SimpleMailbox<>(
+    private SimpleMailbox<CassandraId> mailbox(Row row) {
+        SimpleMailbox<CassandraId> mailbox = new SimpleMailbox<>(
             new MailboxPath(
                 row.getUDTValue(MAILBOX_BASE).getString(MailboxBase.NAMESPACE),
                 row.getUDTValue(MAILBOX_BASE).getString(MailboxBase.USER),
                 row.getString(NAME)),
             row.getLong(UIDVALIDITY));
-        mailbox.setMailboxId(row.getUUID(ID));
+        mailbox.setMailboxId(CassandraId.of(row.getUUID(ID)));
         mailbox.setACL(new CassandraACLMapper(mailbox, session, maxRetry).getACL());
         return mailbox;
     }
 
     @Override
-    public List<Mailbox<UUID>> findMailboxWithPathLike(MailboxPath path) throws MailboxException {
+    public List<Mailbox<CassandraId>> findMailboxWithPathLike(MailboxPath path) throws MailboxException {
         Pattern regex = Pattern.compile(constructEscapedRegexForMailboxNameMatching(path));
         return getMailboxFilteredByNamespaceAndUserStream(path.getNamespace(), path.getUser())
             .filter((row) -> regex.matcher(row.getString(NAME)).matches())
@@ -119,19 +128,19 @@ public class CassandraMailboxMapper impl
     }
 
     @Override
-    public void save(Mailbox<UUID> mailbox) throws MailboxException {
+    public void save(Mailbox<CassandraId> mailbox) throws MailboxException {
         Preconditions.checkArgument(mailbox instanceof SimpleMailbox);
-        SimpleMailbox<UUID> cassandraMailbox = (SimpleMailbox<UUID>) mailbox;
+        SimpleMailbox<CassandraId> cassandraMailbox = (SimpleMailbox<CassandraId>) mailbox;
         if (cassandraMailbox.getMailboxId() == null) {
-            cassandraMailbox.setMailboxId(UUIDs.timeBased());
+            cassandraMailbox.setMailboxId(CassandraId.timeBased());
         }
         upsertMailbox(cassandraMailbox);
     }
 
-    private void upsertMailbox(SimpleMailbox<UUID> mailbox) throws MailboxException {
+    private void upsertMailbox(SimpleMailbox<CassandraId> mailbox) throws MailboxException {
         session.execute(
             insertInto(TABLE_NAME)
-                .value(ID, mailbox.getMailboxId())
+                .value(ID, mailbox.getMailboxId().asUuid())
                 .value(NAME, mailbox.getName())
                 .value(UIDVALIDITY, mailbox.getUidValidity())
                 .value(MAILBOX_BASE, typesProvider.getDefinedUserType(TYPE.MailboxBase)
@@ -152,7 +161,7 @@ public class CassandraMailboxMapper impl
     }
 
     @Override
-    public boolean hasChildren(Mailbox<UUID> mailbox, char delimiter) {
+    public boolean hasChildren(Mailbox<CassandraId> mailbox, char delimiter) {
         final Pattern regex = Pattern.compile(Pattern.quote( mailbox.getName() + String.valueOf(delimiter)) + ".*");
         return getMailboxFilteredByNamespaceAndUserStream(mailbox.getNamespace(), mailbox.getUser())
             .anyMatch((row) -> regex.matcher(row.getString(NAME)).matches());
@@ -171,8 +180,8 @@ public class CassandraMailboxMapper impl
     }
 
     @Override
-    public List<Mailbox<UUID>> list() throws MailboxException {
-        Builder<Mailbox<UUID>> result = ImmutableList.<Mailbox<UUID>> builder();
+    public List<Mailbox<CassandraId>> list() throws MailboxException {
+        Builder<Mailbox<CassandraId>> result = ImmutableList.<Mailbox<CassandraId>> builder();
         for (Row row : session.execute(select(FIELDS).from(TABLE_NAME))) {
             result.add(mailbox(row));
         }
@@ -185,7 +194,7 @@ public class CassandraMailboxMapper impl
     }
 
     @Override
-    public void updateACL(Mailbox<UUID> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException {
+    public void updateACL(Mailbox<CassandraId> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException {
         new CassandraACLMapper(mailbox, session, maxRetry).updateACL(mailboxACLCommand);
     }
 

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=1688109&r1=1688108&r2=1688109&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 Mon Jun 29 08:21:12 2015
@@ -30,7 +30,6 @@ import static com.datastax.driver.core.q
 import static com.datastax.driver.core.querybuilder.QueryBuilder.select;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.update;
-import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Properties;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.BODY_CONTENT;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.BODY_OCTECTS;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.BODY_START_OCTET;
@@ -60,21 +59,21 @@ import java.nio.ByteBuffer;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.UUID;
 import java.util.stream.Collectors;
 
 import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 import javax.mail.util.SharedByteArrayInputStream;
 
-import com.datastax.driver.core.UDTValue;
 import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.cassandra.CassandraConstants;
+import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.cassandra.CassandraTypesProvider;
 import org.apache.james.mailbox.cassandra.CassandraTypesProvider.TYPE;
 import org.apache.james.mailbox.cassandra.table.CassandraMailboxCountersTable;
 import org.apache.james.mailbox.cassandra.table.CassandraMessageTable;
+import org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Properties;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.MessageRange;
@@ -94,7 +93,7 @@ import com.datastax.driver.core.Prepared
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
 import com.datastax.driver.core.Session;
-import com.datastax.driver.core.TupleValue;
+import com.datastax.driver.core.UDTValue;
 import com.datastax.driver.core.querybuilder.Assignment;
 import com.datastax.driver.core.querybuilder.Insert;
 import com.datastax.driver.core.querybuilder.QueryBuilder;
@@ -109,27 +108,27 @@ import com.google.common.primitives.Byte
 /**
  * Cassandra implementation of a {@link MessageMapper}.
  */
-public class CassandraMessageMapper implements MessageMapper<UUID> {
+public class CassandraMessageMapper implements MessageMapper<CassandraId> {
 
     private final Session session;
-    private final ModSeqProvider<UUID> modSeqProvider;
+    private final ModSeqProvider<CassandraId> modSeqProvider;
     private final MailboxSession mailboxSession;
-    private final UidProvider<UUID> uidProvider;
+    private final UidProvider<CassandraId> uidProvider;
     private final CassandraTypesProvider typesProvider;
 
     private int maxRetries;
 
     private final static int DEFAULT_MAX_RETRIES = 10000;
 
-    public CassandraMessageMapper(Session session, UidProvider<UUID> uidProvider, ModSeqProvider<UUID> modSeqProvider, CassandraTypesProvider typesProvider) {
+    public CassandraMessageMapper(Session session, UidProvider<CassandraId> uidProvider, ModSeqProvider<CassandraId> modSeqProvider, CassandraTypesProvider typesProvider) {
         this(session, uidProvider, modSeqProvider, null, DEFAULT_MAX_RETRIES, typesProvider);
     }
 
-    public CassandraMessageMapper(Session session, UidProvider<UUID> uidProvider, ModSeqProvider<UUID> modSeqProvider, MailboxSession mailboxSession, CassandraTypesProvider typesProvider) {
+    public CassandraMessageMapper(Session session, UidProvider<CassandraId> uidProvider, ModSeqProvider<CassandraId> modSeqProvider, MailboxSession mailboxSession, CassandraTypesProvider typesProvider) {
         this(session, uidProvider, modSeqProvider, mailboxSession, DEFAULT_MAX_RETRIES, typesProvider);
     }
 
-    public CassandraMessageMapper(Session session, UidProvider<UUID> uidProvider, ModSeqProvider<UUID> modSeqProvider, MailboxSession mailboxSession, int maxRetries, CassandraTypesProvider typesProvider) {
+    public CassandraMessageMapper(Session session, UidProvider<CassandraId> uidProvider, ModSeqProvider<CassandraId> modSeqProvider, MailboxSession mailboxSession, int maxRetries, CassandraTypesProvider typesProvider) {
         this.session = session;
         this.uidProvider = uidProvider;
         this.modSeqProvider = modSeqProvider;
@@ -139,14 +138,20 @@ public class CassandraMessageMapper impl
     }
 
     @Override
-    public long countMessagesInMailbox(Mailbox<UUID> mailbox) throws MailboxException {
-        ResultSet results = session.execute(select(CassandraMailboxCountersTable.COUNT).from(CassandraMailboxCountersTable.TABLE_NAME).where(eq(CassandraMailboxCountersTable.MAILBOX_ID, mailbox.getMailboxId())));
+    public long countMessagesInMailbox(Mailbox<CassandraId> mailbox) throws MailboxException {
+        ResultSet results = session.execute(
+                select(CassandraMailboxCountersTable.COUNT)
+                .from(CassandraMailboxCountersTable.TABLE_NAME)
+                .where(eq(CassandraMailboxCountersTable.MAILBOX_ID, mailbox.getMailboxId().asUuid())));
         return results.isExhausted() ? 0 : results.one().getLong(CassandraMailboxCountersTable.COUNT);
     }
 
     @Override
-    public long countUnseenMessagesInMailbox(Mailbox<UUID> mailbox) throws MailboxException {
-        ResultSet results = session.execute(select(CassandraMailboxCountersTable.UNSEEN).from(CassandraMailboxCountersTable.TABLE_NAME).where(eq(CassandraMailboxCountersTable.MAILBOX_ID, mailbox.getMailboxId())));
+    public long countUnseenMessagesInMailbox(Mailbox<CassandraId> mailbox) throws MailboxException {
+        ResultSet results = session.execute(
+                select(CassandraMailboxCountersTable.UNSEEN)
+                .from(CassandraMailboxCountersTable.TABLE_NAME)
+                .where(eq(CassandraMailboxCountersTable.MAILBOX_ID, mailbox.getMailboxId().asUuid())));
         if (!results.isExhausted()) {
             Row row = results.one();
             if (row.getColumnDefinitions().contains(CassandraMailboxCountersTable.UNSEEN)) {
@@ -157,37 +162,44 @@ public class CassandraMessageMapper impl
     }
 
     @Override
-    public void delete(Mailbox<UUID> mailbox, Message<UUID> message) throws MailboxException {
-        session.execute(QueryBuilder.delete().from(TABLE_NAME).where(eq(MAILBOX_ID, mailbox.getMailboxId())).and(eq(IMAP_UID, message.getUid())));
+    public void delete(Mailbox<CassandraId> mailbox, Message<CassandraId> message) throws MailboxException {
+        session.execute(
+                QueryBuilder.delete()
+                    .from(TABLE_NAME)
+                    .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid()))
+                    .and(eq(IMAP_UID, message.getUid())));
         decrementCount(mailbox);
         if (!message.isSeen()) {
             decrementUnseen(mailbox);
         }
     }
 
-    private void decrementCount(Mailbox<UUID> mailbox) {
+    private void decrementCount(Mailbox<CassandraId> mailbox) {
         updateMailbox(mailbox, decr(CassandraMailboxCountersTable.COUNT));
     }
 
-    private void incrementCount(Mailbox<UUID> mailbox) {
+    private void incrementCount(Mailbox<CassandraId> mailbox) {
         updateMailbox(mailbox, incr(CassandraMailboxCountersTable.COUNT));
     }
 
-    private void decrementUnseen(Mailbox<UUID> mailbox) {
+    private void decrementUnseen(Mailbox<CassandraId> mailbox) {
         updateMailbox(mailbox, decr(CassandraMailboxCountersTable.UNSEEN));
     }
 
-    private void incrementUnseen(Mailbox<UUID> mailbox) {
+    private void incrementUnseen(Mailbox<CassandraId> mailbox) {
         updateMailbox(mailbox, incr(CassandraMailboxCountersTable.UNSEEN));
     }
 
-    private void updateMailbox(Mailbox<UUID> mailbox, Assignment operation) {
-        session.execute(update(CassandraMailboxCountersTable.TABLE_NAME).with(operation).where(eq(CassandraMailboxCountersTable.MAILBOX_ID, mailbox.getMailboxId())));
+    private void updateMailbox(Mailbox<CassandraId> mailbox, Assignment operation) {
+        session.execute(
+                update(CassandraMailboxCountersTable.TABLE_NAME)
+                .with(operation)
+                .where(eq(CassandraMailboxCountersTable.MAILBOX_ID, mailbox.getMailboxId().asUuid())));
     }
 
     @Override
-    public Iterator<Message<UUID>> findInMailbox(Mailbox<UUID> mailbox, MessageRange set, FetchType ftype, int max) throws MailboxException {
-        Builder<Message<UUID>> result = ImmutableSortedSet.<Message<UUID>> naturalOrder();
+    public Iterator<Message<CassandraId>> findInMailbox(Mailbox<CassandraId> mailbox, MessageRange set, FetchType ftype, int max) throws MailboxException {
+        Builder<Message<CassandraId>> result = ImmutableSortedSet.<Message<CassandraId>> naturalOrder();
         ResultSet rows = session.execute(buildQuery(mailbox, set));
         for (Row row : rows) {
             result.add(message(row));
@@ -222,13 +234,21 @@ public class CassandraMessageMapper impl
         return property;
     }
 
-    private Message<UUID> message(Row row) {
-        SimpleMessage<UUID> message = new SimpleMessage<UUID>(row.getDate(INTERNAL_DATE), row.getInt(FULL_CONTENT_OCTETS), row.getInt(BODY_START_OCTET), new SharedByteArrayInputStream(getFullContent(row)), getFlags(row), getPropertyBuilder(row), row.getUUID(MAILBOX_ID));
+    private Message<CassandraId> message(Row row) {
+        SimpleMessage<CassandraId> message = 
+                new SimpleMessage<CassandraId>(
+                        row.getDate(INTERNAL_DATE), 
+                        row.getInt(FULL_CONTENT_OCTETS), 
+                        row.getInt(BODY_START_OCTET), 
+                        new SharedByteArrayInputStream(getFullContent(row)), 
+                        getFlags(row), 
+                        getPropertyBuilder(row), 
+                        CassandraId.of(row.getUUID(MAILBOX_ID)));
         message.setUid(row.getLong(IMAP_UID));
         return message;
     }
 
-    private Where buildQuery(Mailbox<UUID> mailbox, MessageRange set) {
+    private Where buildQuery(Mailbox<CassandraId> mailbox, MessageRange set) {
         final MessageRange.Type type = set.getType();
         switch (type) {
         case ALL:
@@ -243,24 +263,36 @@ public class CassandraMessageMapper impl
         throw new UnsupportedOperationException();
     }
 
-    private Where selectAll(Mailbox<UUID> mailbox) {
-        return select(FIELDS).from(TABLE_NAME).where(eq(MAILBOX_ID, mailbox.getMailboxId()));
+    private Where selectAll(Mailbox<CassandraId> mailbox) {
+        return select(FIELDS)
+                .from(TABLE_NAME)
+                .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid()));
     }
 
-    private Where selectFrom(Mailbox<UUID> mailbox, long uid) {
-        return select(FIELDS).from(TABLE_NAME).where(eq(MAILBOX_ID, mailbox.getMailboxId())).and(gte(IMAP_UID, uid));
+    private Where selectFrom(Mailbox<CassandraId> mailbox, long uid) {
+        return select(FIELDS)
+                .from(TABLE_NAME)
+                .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid()))
+                .and(gte(IMAP_UID, uid));
     }
 
-    private Where selectRange(Mailbox<UUID> mailbox, long from, long to) {
-        return select(FIELDS).from(TABLE_NAME).where(eq(MAILBOX_ID, mailbox.getMailboxId())).and(gte(IMAP_UID, from)).and(lte(IMAP_UID, to));
+    private Where selectRange(Mailbox<CassandraId> mailbox, long from, long to) {
+        return select(FIELDS)
+                .from(TABLE_NAME)
+                .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid()))
+                .and(gte(IMAP_UID, from))
+                .and(lte(IMAP_UID, to));
     }
 
-    private Where selectMessage(Mailbox<UUID> mailbox, long uid) {
-        return select(FIELDS).from(TABLE_NAME).where(eq(MAILBOX_ID, mailbox.getMailboxId())).and(eq(IMAP_UID, uid));
+    private Where selectMessage(Mailbox<CassandraId> mailbox, long uid) {
+        return select(FIELDS)
+                .from(TABLE_NAME)
+                .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid()))
+                .and(eq(IMAP_UID, uid));
     }
 
     @Override
-    public List<Long> findRecentMessageUidsInMailbox(Mailbox<UUID> mailbox) throws MailboxException {
+    public List<Long> findRecentMessageUidsInMailbox(Mailbox<CassandraId> mailbox) throws MailboxException {
         ImmutableList.Builder<Long> result = ImmutableList.<Long> builder();
         ResultSet rows = session.execute(selectAll(mailbox).orderBy(asc(IMAP_UID)));
         for (Row row : rows) {
@@ -272,7 +304,7 @@ public class CassandraMessageMapper impl
     }
 
     @Override
-    public Long findFirstUnseenMessageUid(Mailbox<UUID> mailbox) throws MailboxException {
+    public Long findFirstUnseenMessageUid(Mailbox<CassandraId> mailbox) throws MailboxException {
         ResultSet rows = session.execute(selectAll(mailbox).orderBy(asc(IMAP_UID)));
         for (Row row : rows) {
             if (!row.getBool(SEEN)) {
@@ -283,12 +315,12 @@ public class CassandraMessageMapper impl
     }
 
     @Override
-    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(final Mailbox<UUID> mailbox, MessageRange set) throws MailboxException {
+    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(final Mailbox<CassandraId> mailbox, MessageRange set) throws MailboxException {
         ImmutableMap.Builder<Long, MessageMetaData> deletedMessages = ImmutableMap.builder();
         ResultSet messages = session.execute(buildQuery(mailbox, set));
         for (Row row : messages) {
             if (row.getBool(DELETED)) {
-                Message<UUID> message = message(row);
+                Message<CassandraId> message = message(row);
                 delete(mailbox, message);
                 deletedMessages.put(message.getUid(), new SimpleMessageMetaData(message));
             }
@@ -297,7 +329,7 @@ public class CassandraMessageMapper impl
     }
 
     @Override
-    public MessageMetaData move(Mailbox<UUID> mailbox, Message<UUID> original) throws MailboxException {
+    public MessageMetaData move(Mailbox<CassandraId> mailbox, Message<CassandraId> original) throws MailboxException {
         throw new UnsupportedOperationException("Not implemented - see https://issues.apache.org/jira/browse/IMAP-370");
     }
 
@@ -307,7 +339,7 @@ public class CassandraMessageMapper impl
     }
 
     @Override
-    public long getHighestModSeq(Mailbox<UUID> mailbox) throws MailboxException {
+    public long getHighestModSeq(Mailbox<CassandraId> mailbox) throws MailboxException {
         return modSeqProvider.highestModSeq(mailboxSession, mailbox);
     }
 
@@ -317,7 +349,7 @@ public class CassandraMessageMapper impl
     }
 
     @Override
-    public MessageMetaData add(Mailbox<UUID> mailbox, Message<UUID> message) throws MailboxException {
+    public MessageMetaData add(Mailbox<CassandraId> mailbox, Message<CassandraId> message) throws MailboxException {
         message.setUid(uidProvider.nextUid(mailboxSession, mailbox));
         message.setModSeq(modSeqProvider.nextModSeq(mailboxSession, mailbox));
         MessageMetaData messageMetaData = save(mailbox, message);
@@ -328,10 +360,10 @@ public class CassandraMessageMapper impl
         return messageMetaData;
     }
 
-    private MessageMetaData save(Mailbox<UUID> mailbox, Message<UUID> message) throws MailboxException {
+    private MessageMetaData save(Mailbox<CassandraId> mailbox, Message<CassandraId> message) throws MailboxException {
         try {
             Insert query = insertInto(TABLE_NAME)
-                    .value(MAILBOX_ID, mailbox.getMailboxId())
+                    .value(MAILBOX_ID, mailbox.getMailboxId().asUuid())
                     .value(IMAP_UID, message.getUid())
                     .value(MOD_SEQ, message.getModSeq())
                     .value(INTERNAL_DATE, message.getInternalDate())
@@ -367,7 +399,7 @@ public class CassandraMessageMapper impl
         }
     }
 
-    private boolean conditionalSave(Mailbox<UUID> mailbox, Message<UUID> message, long flagVersion) throws MailboxException {
+    private boolean conditionalSave(Mailbox<CassandraId> mailbox, Message<CassandraId> message, long flagVersion) throws MailboxException {
         ResultSet resultSet = session.execute(
                 update(TABLE_NAME)
                         .with(set(ANSWERED, message.isAnswered()))
@@ -379,7 +411,7 @@ public class CassandraMessageMapper impl
                         .and(set(USER, message.createFlags().contains(Flag.USER)))
                         .and(set(FLAG_VERSION, flagVersion + 1))
                         .where(eq(IMAP_UID, message.getUid()))
-                        .and(eq(MAILBOX_ID, message.getMailboxId()))
+                        .and(eq(MAILBOX_ID, message.getMailboxId().asUuid()))
                         .onlyIf(eq(FLAG_VERSION, flagVersion))
         );
         return resultSet.one().getBool(CassandraConstants.LIGHTWEIGHT_TRANSACTION_APPLIED);
@@ -400,7 +432,7 @@ public class CassandraMessageMapper impl
      * @throws MailboxException
      */
     @Override
-    public Iterator<UpdatedFlags> updateFlags(Mailbox<UUID> mailbox, Flags flags, boolean value, boolean replace, MessageRange set) throws MailboxException {
+    public Iterator<UpdatedFlags> updateFlags(Mailbox<CassandraId> mailbox, Flags flags, boolean value, boolean replace, MessageRange set) throws MailboxException {
         ImmutableList.Builder<UpdatedFlags> result = ImmutableList.builder();
         for (Row row : session.execute(buildQuery(mailbox, set))) {
             updateMessage(mailbox, flags, value, replace, result, row);
@@ -408,9 +440,9 @@ public class CassandraMessageMapper impl
         return result.build().iterator();
     }
 
-    private void updateMessage(Mailbox<UUID> mailbox, Flags flags, boolean value, boolean replace, ImmutableList.Builder<UpdatedFlags> result, Row row) throws MailboxException {
+    private void updateMessage(Mailbox<CassandraId> mailbox, Flags flags, boolean value, boolean replace, ImmutableList.Builder<UpdatedFlags> result, Row row) throws MailboxException {
         // Get the message and basic information about it
-        Message<UUID> message = message(row);
+        Message<CassandraId> message = message(row);
         long flagVersion = row.getLong(FLAG_VERSION);
         long uid = message.getUid();
         // update flags
@@ -457,7 +489,7 @@ public class CassandraMessageMapper impl
         result.add(new UpdatedFlags(message.getUid(), message.getModSeq(), originFlags, updatedFlags));
     }
 
-    private void manageUnseenMessageCounts(Mailbox<UUID> mailbox, Flags oldFlags, Flags newFlags) {
+    private void manageUnseenMessageCounts(Mailbox<CassandraId> mailbox, Flags oldFlags, Flags newFlags) {
         if (oldFlags.contains(Flag.SEEN) && !newFlags.contains(Flag.SEEN)) {
             incrementUnseen(mailbox);
         }
@@ -466,7 +498,7 @@ public class CassandraMessageMapper impl
         }
     }
 
-    private Row findMessageByUid(Mailbox<UUID> mailbox, long uid) {
+    private Row findMessageByUid(Mailbox<CassandraId> mailbox, long uid) {
         ResultSet resultSet = session.execute(selectMessage(mailbox, uid));
         if ( resultSet.isExhausted() ) {
             return null;
@@ -474,7 +506,7 @@ public class CassandraMessageMapper impl
         return resultSet.one();
     }
 
-    private Flags buildFlags(Message<UUID> message, Flags flags, boolean value, boolean replace) {
+    private Flags buildFlags(Message<CassandraId> message, Flags flags, boolean value, boolean replace) {
         if (replace) {
             return flags;
         } else {
@@ -489,7 +521,7 @@ public class CassandraMessageMapper impl
     }
 
     @Override
-    public MessageMetaData copy(Mailbox<UUID> mailbox, Message<UUID> original) throws MailboxException {
+    public MessageMetaData copy(Mailbox<CassandraId> mailbox, Message<CassandraId> original) throws MailboxException {
 
         original.setUid(uidProvider.nextUid(mailboxSession, mailbox));
         original.setModSeq(modSeqProvider.nextModSeq(mailboxSession, mailbox));
@@ -502,7 +534,7 @@ public class CassandraMessageMapper impl
     }
 
     @Override
-    public long getLastUid(Mailbox<UUID> mailbox) throws MailboxException {
+    public long getLastUid(Mailbox<CassandraId> mailbox) throws MailboxException {
         return uidProvider.lastUid(mailboxSession, mailbox);
     }
 

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java (original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java Mon Jun 29 08:21:12 2015
@@ -30,9 +30,9 @@ import static org.apache.james.mailbox.c
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageModseqTable.TABLE_NAME;
 
 import java.util.Optional;
-import java.util.UUID;
 
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.cassandra.mail.utils.FunctionRunnerWithRetry;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
@@ -45,7 +45,7 @@ import com.datastax.driver.core.Session;
 import com.datastax.driver.core.querybuilder.BuiltStatement;
 import com.google.common.base.Throwables;
 
-public class CassandraModSeqProvider implements ModSeqProvider<UUID> {
+public class CassandraModSeqProvider implements ModSeqProvider<CassandraId> {
 
     private static final int DEFAULT_MAX_RETRY = 100000;
     private static final Logger LOG = LoggerFactory.getLogger(CassandraModSeqProvider.class);
@@ -64,7 +64,7 @@ public class CassandraModSeqProvider imp
     }
 
     @Override
-    public long nextModSeq(MailboxSession mailboxSession, Mailbox<UUID> mailbox) throws MailboxException {
+    public long nextModSeq(MailboxSession mailboxSession, Mailbox<CassandraId> mailbox) throws MailboxException {
         if (findHighestModSeq(mailboxSession, mailbox).isFirst()) {
             Optional<ModSeq> optional = tryInsertModSeq(mailbox, FIRST_MODSEQ);
             if (optional.isPresent()) {
@@ -85,15 +85,15 @@ public class CassandraModSeqProvider imp
     }
 
     @Override
-    public long highestModSeq(MailboxSession mailboxSession, Mailbox<UUID> mailbox) throws MailboxException {
+    public long highestModSeq(MailboxSession mailboxSession, Mailbox<CassandraId> mailbox) throws MailboxException {
         return findHighestModSeq(mailboxSession, mailbox).getValue();
     }
     
-    private ModSeq findHighestModSeq(MailboxSession mailboxSession, Mailbox<UUID> mailbox) throws MailboxException {
+    private ModSeq findHighestModSeq(MailboxSession mailboxSession, Mailbox<CassandraId> mailbox) throws MailboxException {
         ResultSet result = session.execute(
                 select(NEXT_MODSEQ)
                     .from(TABLE_NAME)
-                    .where(eq(MAILBOX_ID, mailbox.getMailboxId())));
+                    .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid())));
         if (result.isExhausted()) {
             return FIRST_MODSEQ;
         } else {
@@ -101,22 +101,22 @@ public class CassandraModSeqProvider imp
         }
     }
 
-    private Optional<ModSeq> tryInsertModSeq(Mailbox<UUID> mailbox, ModSeq modSeq) {
+    private Optional<ModSeq> tryInsertModSeq(Mailbox<CassandraId> mailbox, ModSeq modSeq) {
         ModSeq nextModSeq = modSeq.next();
         return transactionalStatementToOptionalModSeq(nextModSeq,
                 insertInto(TABLE_NAME)
                     .value(NEXT_MODSEQ, nextModSeq.getValue())
-                    .value(MAILBOX_ID, mailbox.getMailboxId())
+                    .value(MAILBOX_ID, mailbox.getMailboxId().asUuid())
                     .ifNotExists());
     }
     
-    private Optional<ModSeq> tryUpdateModSeq(Mailbox<UUID> mailbox, ModSeq modSeq) {
+    private Optional<ModSeq> tryUpdateModSeq(Mailbox<CassandraId> mailbox, ModSeq modSeq) {
         ModSeq nextModSeq = modSeq.next();
         return transactionalStatementToOptionalModSeq(nextModSeq,
                 update(TABLE_NAME)
                     .onlyIf(eq(NEXT_MODSEQ, modSeq.getValue()))
                     .with(set(NEXT_MODSEQ, nextModSeq.getValue()))
-                    .where(eq(MAILBOX_ID, mailbox.getMailboxId())));
+                    .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid())));
     }
 
     private Optional<ModSeq> transactionalStatementToOptionalModSeq(ModSeq modSeq, BuiltStatement statement) {

Modified: james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java (original)
+++ james/mailbox/trunk/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java Mon Jun 29 08:21:12 2015
@@ -19,18 +19,17 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
-import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto;
-import static com.datastax.driver.core.querybuilder.QueryBuilder.update;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.eq;
-import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.select;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
+import static com.datastax.driver.core.querybuilder.QueryBuilder.update;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageUidTable.MAILBOX_ID;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageUidTable.NEXT_UID;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageUidTable.TABLE_NAME;
 
-import java.util.UUID;
-
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.store.mail.UidProvider;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
@@ -38,7 +37,7 @@ import org.apache.james.mailbox.store.ma
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Session;
 
-public class CassandraUidProvider implements UidProvider<UUID> {
+public class CassandraUidProvider implements UidProvider<CassandraId> {
     public final static int DEFAULT_MAX_RETRY = 100000;
 
     private Session session;
@@ -55,10 +54,14 @@ public class CassandraUidProvider implem
     }
 
     @Override
-    public long nextUid(MailboxSession mailboxSession, Mailbox<UUID> mailbox) throws MailboxException {
+    public long nextUid(MailboxSession mailboxSession, Mailbox<CassandraId> mailbox) throws MailboxException {
         long lastUid = lastUid(mailboxSession, mailbox);
         if (lastUid == 0) {
-            ResultSet result = session.execute(insertInto(TABLE_NAME).value(NEXT_UID, ++lastUid).value(MAILBOX_ID, mailbox.getMailboxId()).ifNotExists());
+            ResultSet result = session.execute(
+                    insertInto(TABLE_NAME)
+                    .value(NEXT_UID, ++lastUid)
+                    .value(MAILBOX_ID, mailbox.getMailboxId().asUuid())
+                    .ifNotExists());
             if(result.one().getBool(applied)) {
                 return lastUid;
             }
@@ -68,7 +71,11 @@ public class CassandraUidProvider implem
         do {
             tries++;
             lastUid = lastUid(mailboxSession, mailbox);
-            ResultSet result = session.execute(update(TABLE_NAME).onlyIf(eq(NEXT_UID, lastUid)).with(set(NEXT_UID, ++lastUid)).where(eq(MAILBOX_ID, mailbox.getMailboxId())));
+            ResultSet result = session.execute(
+                    update(TABLE_NAME)
+                    .onlyIf(eq(NEXT_UID, lastUid))
+                    .with(set(NEXT_UID, ++lastUid))
+                    .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid())));
             isApplied = result.one().getBool(applied);
         } while (! isApplied && tries < maxRetry);
         if( ! isApplied ) {
@@ -78,8 +85,11 @@ public class CassandraUidProvider implem
     }
 
     @Override
-    public long lastUid(MailboxSession mailboxSession, Mailbox<UUID> mailbox) throws MailboxException {
-        ResultSet result = session.execute(select(NEXT_UID).from(TABLE_NAME).where(eq(MAILBOX_ID, mailbox.getMailboxId())));
+    public long lastUid(MailboxSession mailboxSession, Mailbox<CassandraId> mailbox) throws MailboxException {
+        ResultSet result = session.execute(
+                select(NEXT_UID)
+                .from(TABLE_NAME)
+                .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid())));
         return result.isExhausted() ? 0 : result.one().getLong(NEXT_UID);
     }
 

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java (original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java Mon Jun 29 08:21:12 2015
@@ -22,8 +22,6 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import java.util.UUID;
-
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.cassandra.mail.CassandraModSeqProvider;
 import org.apache.james.mailbox.cassandra.mail.CassandraUidProvider;
@@ -60,7 +58,7 @@ public class CassandraMailboxSessionMapp
         LOG.info("createMessageMapper");
         MailboxSession session = null;
         CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null, null, null, null);
-        MessageMapper<UUID> messageMapper = instance.createMessageMapper(session);
+        MessageMapper<CassandraId> messageMapper = instance.createMessageMapper(session);
         assertNotNull(messageMapper);
         assertTrue(messageMapper instanceof MessageMapper);
     }
@@ -74,7 +72,7 @@ public class CassandraMailboxSessionMapp
         LOG.info("createMailboxMapper");
         MailboxSession session = null;
         CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null, null, null, null);
-        MailboxMapper<UUID> mailboxMapper = instance.createMailboxMapper(session);
+        MailboxMapper<CassandraId> mailboxMapper = instance.createMailboxMapper(session);
         assertNotNull(mailboxMapper);
         assertTrue(mailboxMapper instanceof MailboxMapper);
     }
@@ -100,9 +98,9 @@ public class CassandraMailboxSessionMapp
     @Test
     public void testGetModSeqProvider() {
         LOG.info("getModSeqProvider");
-        ModSeqProvider<UUID> expResult = new CassandraModSeqProvider(CLUSTER.getConf());
+        ModSeqProvider<CassandraId> expResult = new CassandraModSeqProvider(CLUSTER.getConf());
         CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null, expResult, null, null);
-        ModSeqProvider<UUID> result = instance.getModSeqProvider();
+        ModSeqProvider<CassandraId> result = instance.getModSeqProvider();
         assertEquals(expResult, result);
     }
 
@@ -113,9 +111,9 @@ public class CassandraMailboxSessionMapp
     @Test
     public void testGetUidProvider() {
         LOG.info("getUidProvider");
-        UidProvider<UUID> expResult = new CassandraUidProvider(CLUSTER.getConf());
+        UidProvider<CassandraId> expResult = new CassandraUidProvider(CLUSTER.getConf());
         CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory((CassandraUidProvider) expResult, null, null, null);
-        UidProvider<UUID> result = instance.getUidProvider();
+        UidProvider<CassandraId> result = instance.getUidProvider();
         assertEquals(expResult, result);
     }
 }

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java (original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java Mon Jun 29 08:21:12 2015
@@ -18,12 +18,20 @@
  ****************************************************************/
 package org.apache.james.mailbox.cassandra.mail;
 
-import static org.assertj.core.api.Assertions.assertThat;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto;
+import static org.assertj.core.api.Assertions.assertThat;
 
-import com.google.common.base.Throwables;
+import java.util.UUID;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
 import org.apache.james.mailbox.cassandra.CassandraClusterSingleton;
+import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.cassandra.table.CassandraACLTable;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxACL;
@@ -34,20 +42,13 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.UUID;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import com.google.common.base.Throwables;
 
 public class CassandraACLMapperTest {
 
     private CassandraACLMapper cassandraACLMapper;
     private CassandraClusterSingleton cassandra;
-    private SimpleMailbox<UUID> mailbox;
+    private SimpleMailbox<CassandraId> mailbox;
     private int uidValidity;
     private int maxRetry;
     private ExecutorService executor;
@@ -58,7 +59,7 @@ public class CassandraACLMapperTest {
         cassandra.ensureAllTables();
         uidValidity = 10;
         mailbox = new SimpleMailbox<>(new MailboxPath("#private", "benwa@linagora.com", "INBOX"), uidValidity);
-        mailbox.setMailboxId(UUID.fromString("464765a0-e4e7-11e4-aba4-710c1de3782b"));
+        mailbox.setMailboxId(CassandraId.of(UUID.fromString("464765a0-e4e7-11e4-aba4-710c1de3782b")));
         maxRetry = 100;
         cassandraACLMapper = new CassandraACLMapper(mailbox, cassandra.getConf(), maxRetry);
         executor = Executors.newFixedThreadPool(2);
@@ -89,7 +90,7 @@ public class CassandraACLMapperTest {
     public void retrieveACLWhenPresentInBaseShouldReturnCorrespondingACL() throws Exception {
         cassandra.getConf().execute(
             insertInto(CassandraACLTable.TABLE_NAME)
-                .value(CassandraACLTable.ID, mailbox.getMailboxId())
+                .value(CassandraACLTable.ID, mailbox.getMailboxId().asUuid())
                 .value(CassandraACLTable.ACL, "{\"entries\":{\"bob\":64}}")
                 .value(CassandraACLTable.VERSION, 1)
         );
@@ -105,7 +106,7 @@ public class CassandraACLMapperTest {
     public void retrieveACLWhenInvalidInBaseShouldReturnEmptyACL() throws Exception {
         cassandra.getConf().execute(
             insertInto(CassandraACLTable.TABLE_NAME)
-                .value(CassandraACLTable.ID, mailbox.getMailboxId())
+                .value(CassandraACLTable.ID, mailbox.getMailboxId().asUuid())
                 .value(CassandraACLTable.ACL, "{\"entries\":{\"bob\":invalid}}")
                 .value(CassandraACLTable.VERSION, 1)
         );
@@ -165,7 +166,7 @@ public class CassandraACLMapperTest {
     public void updateInvalidACLShouldBeBasedOnEmptyACL() throws Exception {
         cassandra.getConf().execute(
             insertInto(CassandraACLTable.TABLE_NAME)
-                .value(CassandraACLTable.ID, mailbox.getMailboxId())
+                .value(CassandraACLTable.ID, mailbox.getMailboxId().asUuid())
                 .value(CassandraACLTable.ACL, "{\"entries\":{\"bob\":invalid}}")
                 .value(CassandraACLTable.VERSION, 1)
         );

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java (original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java Mon Jun 29 08:21:12 2015
@@ -18,11 +18,10 @@
  ****************************************************************/
 package org.apache.james.mailbox.cassandra.mail;
 
+import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.store.mail.model.AbstractMailboxMapperTest;
 
-import java.util.UUID;
-
-public class CassandraMailboxMapperTest extends AbstractMailboxMapperTest<UUID> {
+public class CassandraMailboxMapperTest extends AbstractMailboxMapperTest<CassandraId> {
     public CassandraMailboxMapperTest() {
         super(new CassandraMapperProvider());
     }



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