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 [4/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
Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAUidProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAUidProvider.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAUidProvider.java (original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAUidProvider.java Mon Jun 29 08:21:12 2015
@@ -25,11 +25,12 @@ import javax.persistence.PersistenceExce
 import org.apache.james.mailbox.MailboxPathLocker;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.jpa.JPAId;
 import org.apache.james.mailbox.jpa.mail.model.JPAMailbox;
 import org.apache.james.mailbox.store.mail.AbstractLockingUidProvider;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
-public class JPAUidProvider extends AbstractLockingUidProvider<Long>{
+public class JPAUidProvider extends AbstractLockingUidProvider<JPAId> {
 
     private EntityManagerFactory factory;
 
@@ -40,12 +41,12 @@ public class JPAUidProvider extends Abst
     
     
     @Override
-    public long lastUid(MailboxSession session, Mailbox<Long> mailbox) throws MailboxException {
+    public long lastUid(MailboxSession session, Mailbox<JPAId> mailbox) throws MailboxException {
         EntityManager manager = null;
         try {
             manager = factory.createEntityManager();
             manager.getTransaction().begin();
-            long uid = (Long) manager.createNamedQuery("findLastUid").setParameter("idParam", mailbox.getMailboxId()).getSingleResult();
+            long uid = (Long) manager.createNamedQuery("findLastUid").setParameter("idParam", mailbox.getMailboxId().getRawId()).getSingleResult();
             manager.getTransaction().commit();
             return uid;
         } catch (PersistenceException e) {
@@ -61,12 +62,12 @@ public class JPAUidProvider extends Abst
     }
 
     @Override
-    protected long lockedNextUid(MailboxSession session, Mailbox<Long> mailbox) throws MailboxException {
+    protected long lockedNextUid(MailboxSession session, Mailbox<JPAId> mailbox) throws MailboxException {
         EntityManager manager = null;
         try {
             manager = factory.createEntityManager();
             manager.getTransaction().begin();
-            JPAMailbox m = manager.find(JPAMailbox.class, mailbox.getMailboxId());
+            JPAMailbox m = manager.find(JPAMailbox.class, mailbox.getMailboxId().getRawId());
             long uid = m.consumeUid();
             manager.persist(m);
             manager.getTransaction().commit();

Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java (original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java Mon Jun 29 08:21:12 2015
@@ -27,6 +27,7 @@ import javax.persistence.NamedQueries;
 import javax.persistence.NamedQuery;
 import javax.persistence.Table;
 
+import org.apache.james.mailbox.jpa.JPAId;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.SimpleMailboxACL;
@@ -58,7 +59,7 @@ import org.apache.james.mailbox.store.ma
     @NamedQuery(name="findLastUid",
         query="SELECT mailbox.lastUid FROM Mailbox mailbox WHERE mailbox.mailboxId = :idParam")
 })
-public class JPAMailbox implements Mailbox<Long> {
+public class JPAMailbox implements Mailbox<JPAId> {
     
     private static final String TAB = " ";
 
@@ -113,8 +114,8 @@ public class JPAMailbox implements Mailb
     /**
      * @see org.apache.james.mailbox.store.mail.model.Mailbox#getMailboxId()
      */
-    public Long getMailboxId() {
-        return mailboxId;
+    public JPAId getMailboxId() {
+        return JPAId.of(mailboxId);
     }
 
     /**

Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMessage.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMessage.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMessage.java (original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMessage.java Mon Jun 29 08:21:12 2015
@@ -38,6 +38,7 @@ import javax.persistence.OneToMany;
 import javax.persistence.OrderBy;
 
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.jpa.JPAId;
 import org.apache.james.mailbox.jpa.mail.model.JPAMailbox;
 import org.apache.james.mailbox.jpa.mail.model.JPAProperty;
 import org.apache.james.mailbox.jpa.mail.model.JPAUserFlag;
@@ -98,7 +99,7 @@ import org.apache.openjpa.persistence.jd
             query="DELETE FROM Message message")
 })
 @MappedSuperclass
-public abstract class AbstractJPAMessage extends AbstractMessage<Long> {
+public abstract class AbstractJPAMessage extends AbstractMessage<JPAId> {
 
 
 
@@ -309,7 +310,7 @@ public abstract class AbstractJPAMessage
     public int hashCode() {
         final int PRIME = 31;
         int result = 1;
-        result = PRIME * result + (int) (getMailboxId() ^ (getMailboxId() >>> 32));
+        result = PRIME * result + (int) (getMailboxId().getRawId() ^ (getMailboxId().getRawId() >>> 32));
         result = PRIME * result + (int) (uid ^ (uid >>> 32));
         return result;
     }
@@ -409,7 +410,7 @@ public abstract class AbstractJPAMessage
     /**
      * @see org.apache.james.mailbox.store.mail.model.Message#getMailboxId()
      */
-    public Long getMailboxId() {
+    public JPAId getMailboxId() {
         return getMailbox().getMailboxId();
     }
 

Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java (original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMailboxManager.java Mon Jun 29 08:21:12 2015
@@ -25,6 +25,7 @@ import org.apache.james.mailbox.MailboxS
 import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.acl.MailboxACLResolver;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.jpa.JPAId;
 import org.apache.james.mailbox.jpa.JPAMailboxManager;
 import org.apache.james.mailbox.jpa.JPAMailboxSessionMapperFactory;
 import org.apache.james.mailbox.jpa.mail.model.openjpa.EncryptDecryptHelper;
@@ -66,8 +67,8 @@ public class OpenJPAMailboxManager exten
     }
 
     @Override
-    protected StoreMessageManager<Long> createMessageManager(Mailbox<Long> mailboxRow, MailboxSession session) throws MailboxException {
-        StoreMessageManager<Long> result =  new OpenJPAMessageManager(getMapperFactory(), getMessageSearchIndex(), getEventDispatcher(), getLocker(), mailboxRow, feature, getAclResolver(), getGroupMembershipResolver());
+    protected StoreMessageManager<JPAId> createMessageManager(Mailbox<JPAId> mailboxRow, MailboxSession session) throws MailboxException {
+        StoreMessageManager<JPAId> result =  new OpenJPAMessageManager(getMapperFactory(), getMessageSearchIndex(), getEventDispatcher(), getLocker(), mailboxRow, feature, getAclResolver(), getGroupMembershipResolver());
         return result;
     }
 }

Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMessageManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMessageManager.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMessageManager.java (original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/openjpa/OpenJPAMessageManager.java Mon Jun 29 08:21:12 2015
@@ -28,6 +28,7 @@ import org.apache.james.mailbox.MailboxP
 import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.acl.MailboxACLResolver;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.jpa.JPAId;
 import org.apache.james.mailbox.jpa.JPAMessageManager;
 import org.apache.james.mailbox.jpa.mail.model.JPAMailbox;
 import org.apache.james.mailbox.jpa.mail.model.openjpa.JPAEncryptedMessage;
@@ -52,19 +53,24 @@ public class OpenJPAMessageManager exten
         Encryption
     }
     
-    public OpenJPAMessageManager(MailboxSessionMapperFactory<Long> mapperFactory, MessageSearchIndex<Long> index,
-            MailboxEventDispatcher<Long> dispatcher, MailboxPathLocker locker, Mailbox<Long> mailbox, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) throws MailboxException {
+    public OpenJPAMessageManager(MailboxSessionMapperFactory<JPAId> mapperFactory, 
+    		MessageSearchIndex<JPAId> index,MailboxEventDispatcher<JPAId> dispatcher, 
+    		MailboxPathLocker locker, Mailbox<JPAId> mailbox, MailboxACLResolver aclResolver, 
+    		GroupMembershipResolver groupMembershipResolver) throws MailboxException {
         this(mapperFactory, index, dispatcher, locker,  mailbox, AdvancedFeature.None, aclResolver, groupMembershipResolver);
     }
 
-    public OpenJPAMessageManager(MailboxSessionMapperFactory<Long> mapperFactory, MessageSearchIndex<Long> index, 
-            MailboxEventDispatcher<Long> dispatcher, MailboxPathLocker locker, Mailbox<Long> mailbox, final AdvancedFeature f, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) throws MailboxException {
+    public OpenJPAMessageManager(MailboxSessionMapperFactory<JPAId> mapperFactory, 
+    		MessageSearchIndex<JPAId> index, MailboxEventDispatcher<JPAId> dispatcher, 
+    		MailboxPathLocker locker, Mailbox<JPAId> mailbox, final AdvancedFeature f, 
+    		MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) throws MailboxException {
+    	
         super(mapperFactory,  index, dispatcher, locker, mailbox, aclResolver, groupMembershipResolver);
         this.feature = f;
     }
 
     @Override
-    protected Message<Long> createMessage(Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder) throws MailboxException {
+    protected Message<JPAId> createMessage(Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder) throws MailboxException {
         int headerEnd = bodyStartOctet -2;
         if (headerEnd < 0) {
             headerEnd = 0;

Modified: james/mailbox/trunk/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java (original)
+++ james/mailbox/trunk/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java Mon Jun 29 08:21:12 2015
@@ -57,6 +57,7 @@ import org.apache.james.mailbox.model.Se
 import org.apache.james.mailbox.model.SearchQuery.NumericRange;
 import org.apache.james.mailbox.model.SearchQuery.UidCriterion;
 import org.apache.james.mailbox.store.mail.MessageMapperFactory;
+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;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
@@ -114,7 +115,7 @@ import org.apache.lucene.util.Version;
 
  * @param <Id>
  */
-public class LuceneMessageSearchIndex<Id> extends ListeningMessageSearchIndex<Id>{
+public class LuceneMessageSearchIndex<Id extends MailboxId> extends ListeningMessageSearchIndex<Id> {
     private final static Date MAX_DATE;
     private final static Date MIN_DATE;
     
@@ -408,7 +409,7 @@ public class LuceneMessageSearchIndex<Id
         try {
             searcher = new IndexSearcher(IndexReader.open(writer, true));
             BooleanQuery query = new BooleanQuery();
-            query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().toString())), BooleanClause.Occur.MUST);
+            query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().serialize())), BooleanClause.Occur.MUST);
             // Not return flags documents
             query.add(new PrefixQuery(new Term(FLAGS_FIELD, "")), BooleanClause.Occur.MUST_NOT);
             List<Criterion> crits = searchQuery.getCriterias();
@@ -449,11 +450,11 @@ public class LuceneMessageSearchIndex<Id
     private Document createMessageDocument(final MailboxSession session, final Message<?> membership) throws MailboxException{
         final Document doc = new Document();
         // TODO: Better handling
-        doc.add(new Field(MAILBOX_ID_FIELD, membership.getMailboxId().toString().toUpperCase(Locale.ENGLISH), Store.YES, Index.NOT_ANALYZED));
+        doc.add(new Field(MAILBOX_ID_FIELD, membership.getMailboxId().serialize().toUpperCase(Locale.ENGLISH), Store.YES, Index.NOT_ANALYZED));
         doc.add(new NumericField(UID_FIELD,Store.YES, true).setLongValue(membership.getUid()));
         
         // create an unqiue key for the document which can be used later on updates to find the document
-        doc.add(new Field(ID_FIELD, membership.getMailboxId().toString().toUpperCase(Locale.ENGLISH) +"-" + Long.toString(membership.getUid()), Store.YES, Index.NOT_ANALYZED));
+        doc.add(new Field(ID_FIELD, membership.getMailboxId().serialize().toUpperCase(Locale.ENGLISH) +"-" + Long.toString(membership.getUid()), Store.YES, Index.NOT_ANALYZED));
 
         doc.add(new Field(INTERNAL_DATE_FIELD_YEAR_RESOLUTION, DateTools.dateToString(membership.getInternalDate(), DateTools.Resolution.YEAR), Store.NO, Index.NOT_ANALYZED));
         doc.add(new Field(INTERNAL_DATE_FIELD_MONTH_RESOLUTION, DateTools.dateToString(membership.getInternalDate(), DateTools.Resolution.MONTH), Store.NO, Index.NOT_ANALYZED));
@@ -892,7 +893,7 @@ public class LuceneMessageSearchIndex<Id
             
             query.add(bQuery, BooleanClause.Occur.MUST);
         }
-        query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().toString())), BooleanClause.Occur.MUST);
+        query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().serialize())), BooleanClause.Occur.MUST);
         
         
         IndexSearcher searcher = null;
@@ -1128,7 +1129,7 @@ public class LuceneMessageSearchIndex<Id
             for (int i = 0; i < crits.size(); i++) {
                 conQuery.add(createQuery(crits.get(i), mailbox, recentUids), BooleanClause.Occur.SHOULD);
             }
-            nor.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().toString())), BooleanClause.Occur.MUST);
+            nor.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().serialize())), BooleanClause.Occur.MUST);
 
             nor.add(conQuery, BooleanClause.Occur.MUST_NOT);
             return nor;
@@ -1205,7 +1206,7 @@ public class LuceneMessageSearchIndex<Id
         try {
             IndexSearcher searcher = new IndexSearcher(IndexReader.open(writer, true));
             BooleanQuery query = new BooleanQuery();
-            query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().toString())), BooleanClause.Occur.MUST);
+            query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().serialize())), BooleanClause.Occur.MUST);
             query.add(createQuery(range), BooleanClause.Occur.MUST);
             query.add( new PrefixQuery(new Term(FLAGS_FIELD, "")), BooleanClause.Occur.MUST);
 
@@ -1237,8 +1238,8 @@ public class LuceneMessageSearchIndex<Id
      */
     private Document createFlagsDocument(Message<?> message) {
         Document doc = new Document();
-        doc.add(new Field(ID_FIELD, "flags-" + message.getMailboxId().toString() +"-" + Long.toString(message.getUid()), Store.YES, Index.NOT_ANALYZED));
-        doc.add(new Field(MAILBOX_ID_FIELD, message.getMailboxId().toString(), Store.YES, Index.NOT_ANALYZED));
+        doc.add(new Field(ID_FIELD, "flags-" + message.getMailboxId().serialize() +"-" + Long.toString(message.getUid()), Store.YES, Index.NOT_ANALYZED));
+        doc.add(new Field(MAILBOX_ID_FIELD, message.getMailboxId().serialize(), Store.YES, Index.NOT_ANALYZED));
         doc.add(new NumericField(UID_FIELD,Store.YES, true).setLongValue(message.getUid()));
         
         indexFlags(doc, message.createFlags());
@@ -1286,7 +1287,7 @@ public class LuceneMessageSearchIndex<Id
      */
     public void delete(MailboxSession session, Mailbox<Id> mailbox, MessageRange range) throws MailboxException {
         BooleanQuery query = new BooleanQuery();
-        query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().toString())), BooleanClause.Occur.MUST);
+        query.add(new TermQuery(new Term(MAILBOX_ID_FIELD, mailbox.getMailboxId().serialize())), BooleanClause.Occur.MUST);
         query.add(createQuery(range), BooleanClause.Occur.MUST);
         
         try {

Modified: james/mailbox/trunk/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java (original)
+++ james/mailbox/trunk/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java Mon Jun 29 08:21:12 2015
@@ -42,6 +42,7 @@ import org.apache.james.mailbox.model.Se
 import org.apache.james.mailbox.model.SearchQuery.Sort.SortClause;
 import org.apache.james.mailbox.store.MessageBuilder;
 import org.apache.james.mailbox.store.SimpleMailboxMembership;
+import org.apache.james.mailbox.store.TestId;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.Message;
 import org.apache.lucene.store.RAMDirectory;
@@ -50,8 +51,8 @@ import org.junit.Test;
 
 public class LuceneMessageSearchIndexTest {
 
-    private LuceneMessageSearchIndex<Long> index;
-
+	private LuceneMessageSearchIndex<TestId> index;
+    
     private SimpleMailbox mailbox = new SimpleMailbox(0);
     private SimpleMailbox mailbox2 = new SimpleMailbox(1);
     private SimpleMailbox mailbox3 = new SimpleMailbox(2);
@@ -69,7 +70,7 @@ public class LuceneMessageSearchIndexTes
             + "It has " + RHUBARD + ".\r\n" + "It has " + CUSTARD + ".\r\n"
             + "It needs naught else.\r\n";
 
-    Message<Long> row;
+    Message<TestId> row;
 
     protected boolean useLenient() {
         return true;
@@ -77,7 +78,7 @@ public class LuceneMessageSearchIndexTes
     
     @Before
     public void setUp() throws Exception {
-        index = new LuceneMessageSearchIndex<Long>(null, new RAMDirectory(), true, useLenient());
+        index = new LuceneMessageSearchIndex<TestId>(null, new RAMDirectory(), true, useLenient());
         index.setEnableSuffixMatch(true);
         Map<String, String> headersSubject = new HashMap<String, String>();
         headersSubject.put("Subject", "test (fwd)");
@@ -704,14 +705,14 @@ public class LuceneMessageSearchIndexTes
         assertFalse(it4.hasNext());
     }
     
-    private final class SimpleMailbox implements Mailbox<Long> {
-        private long id;
+    private final class SimpleMailbox implements Mailbox<TestId> {
+        private TestId id;
 
         public SimpleMailbox(long id) {
-            this.id = id;
+        	this.id = TestId.of(id);
         }
 
-        public Long getMailboxId() {
+        public TestId getMailboxId() {
             return id;
         }
 
@@ -732,7 +733,7 @@ public class LuceneMessageSearchIndexTes
         }
 
         public String getName() {
-            return Long.toString(id);
+            return id.serialize();
         }
 
         public void setName(String name) {

Added: james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirId.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirId.java?rev=1688109&view=auto
==============================================================================
--- james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirId.java (added)
+++ james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirId.java Mon Jun 29 08:21:12 2015
@@ -0,0 +1,71 @@
+/****************************************************************
+ * 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.maildir;
+
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+
+public class MaildirId implements MailboxId {
+
+    public static MaildirId of(int id) {
+        return new MaildirId(id);
+    }
+
+    private final int id;
+
+    private MaildirId(int id) {
+        this.id = id;
+    }
+
+    public int getRawId() {
+        return id;
+    }
+
+    @Override
+    public String serialize() {
+        return String.valueOf(id);
+    }
+
+    @Override
+    public String toString() {
+        return String.valueOf(id);
+    }
+    
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + id;
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        MaildirId other = (MaildirId) obj;
+        if (id != other.id)
+            return false;
+        return true;
+    }
+
+}
\ No newline at end of file

Modified: james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java (original)
+++ james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirMailboxSessionMapperFactory.java Mon Jun 29 08:21:12 2015
@@ -30,7 +30,7 @@ import org.apache.james.mailbox.store.ma
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 
 public class MaildirMailboxSessionMapperFactory extends
-        MailboxSessionMapperFactory<Integer> {
+        MailboxSessionMapperFactory<MaildirId> {
 
     private final MaildirStore store;
 
@@ -41,13 +41,13 @@ public class MaildirMailboxSessionMapper
     
     
     @Override
-    public MailboxMapper<Integer> createMailboxMapper(MailboxSession session)
+    public MailboxMapper<MaildirId> createMailboxMapper(MailboxSession session)
             throws MailboxException {
         return new MaildirMailboxMapper(store, session);
     }
 
     @Override
-    public MessageMapper<Integer> createMessageMapper(MailboxSession session)
+    public MessageMapper<MaildirId> createMessageMapper(MailboxSession session)
             throws MailboxException {
         return new MaildirMessageMapper(session, store);
     }

Modified: james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirStore.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirStore.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirStore.java (original)
+++ james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirStore.java Mon Jun 29 08:21:12 2015
@@ -34,7 +34,7 @@ import org.apache.james.mailbox.store.ma
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 
-public class MaildirStore implements UidProvider<Integer>, ModSeqProvider<Integer>{
+public class MaildirStore implements UidProvider<MaildirId>, ModSeqProvider<MaildirId> {
 
     public static final String PATH_USER = "%user";
     public static final String PATH_DOMAIN = "%domain";
@@ -78,7 +78,7 @@ public class MaildirStore implements Uid
      * @param mailbox
      * @return The MaildirFolder
      */
-    public MaildirFolder createMaildirFolder(Mailbox<Integer> mailbox) {
+    public MaildirFolder createMaildirFolder(Mailbox<MaildirId> mailbox) {
         MaildirFolder mf = new MaildirFolder(getFolderName(mailbox), new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName()), locker);
         mf.setMessageNameStrictParse(isMessageNameStrictParse());
         return mf;
@@ -93,7 +93,7 @@ public class MaildirStore implements Uid
      * @return The Mailbox object populated with data from the file system
      * @throws MailboxException If the mailbox folder doesn't exist or can't be read
      */
-    public Mailbox<Integer> loadMailbox(MailboxSession session, File root, String namespace, String user, String folderName) throws MailboxException {
+    public Mailbox<MaildirId> loadMailbox(MailboxSession session, File root, String namespace, String user, String folderName) throws MailboxException {
         String mailboxName = getMailboxNameFromFolderName(folderName);
         return loadMailbox(session, new File(root, folderName), new MailboxPath(namespace, user, mailboxName));
     }
@@ -105,7 +105,7 @@ public class MaildirStore implements Uid
      * @throws MailboxNotFoundException If the mailbox folder doesn't exist
      * @throws MailboxException If the mailbox folder can't be read
      */
-    public Mailbox<Integer> loadMailbox(MailboxSession session, MailboxPath mailboxPath)
+    public Mailbox<MaildirId> loadMailbox(MailboxSession session, MailboxPath mailboxPath)
     throws MailboxNotFoundException, MailboxException {
         MaildirFolder folder = new MaildirFolder(getFolderName(mailboxPath), mailboxPath, locker);
         folder.setMessageNameStrictParse(isMessageNameStrictParse());
@@ -121,11 +121,11 @@ public class MaildirStore implements Uid
      * @return The Mailbox object populated with data from the file system
      * @throws MailboxException If the mailbox folder doesn't exist or can't be read
      */
-    private Mailbox<Integer> loadMailbox(MailboxSession session, File mailboxFile, MailboxPath mailboxPath) throws MailboxException {
+    private Mailbox<MaildirId> loadMailbox(MailboxSession session, File mailboxFile, MailboxPath mailboxPath) throws MailboxException {
         MaildirFolder folder = new MaildirFolder(mailboxFile.getAbsolutePath(), mailboxPath, locker);
         folder.setMessageNameStrictParse(isMessageNameStrictParse());
         try {
-            Mailbox<Integer> loadedMailbox = new SimpleMailbox<Integer>(mailboxPath, folder.getUidValidity());
+            Mailbox<MaildirId> loadedMailbox = new SimpleMailbox<MaildirId>(mailboxPath, folder.getUidValidity());
             loadedMailbox.setACL(folder.getACL(session));
             return loadedMailbox;
         } catch (IOException e) {
@@ -224,7 +224,7 @@ public class MaildirStore implements Uid
      * @param mailbox The mailbox
      * @return The absolute path to the folder containing the mailbox
      */
-    public String getFolderName(Mailbox<Integer> mailbox) {
+    public String getFolderName(Mailbox<MaildirId> mailbox) {
         return getFolderName(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName());
     }
     
@@ -241,7 +241,7 @@ public class MaildirStore implements Uid
      * @see org.apache.james.mailbox.store.mail.UidProvider#nextUid(org.apache.james.mailbox.MailboxSession, org.apache.james.mailbox.store.mail.model.Mailbox)
      */
     @Override
-    public long nextUid(MailboxSession session, Mailbox<Integer> mailbox) throws MailboxException {
+    public long nextUid(MailboxSession session, Mailbox<MaildirId> mailbox) throws MailboxException {
         try {
             return createMaildirFolder(mailbox).getLastUid(session) +1;
         } catch (MailboxException e) {
@@ -250,12 +250,12 @@ public class MaildirStore implements Uid
     }
 
     @Override
-    public long nextModSeq(MailboxSession session, Mailbox<Integer> mailbox) throws MailboxException {
+    public long nextModSeq(MailboxSession session, Mailbox<MaildirId> mailbox) throws MailboxException {
         return System.currentTimeMillis();
     }
 
     @Override
-    public long highestModSeq(MailboxSession session, Mailbox<Integer> mailbox) throws MailboxException {
+    public long highestModSeq(MailboxSession session, Mailbox<MaildirId> mailbox) throws MailboxException {
         try {
             return createMaildirFolder(mailbox).getHighestModSeq();
         } catch (IOException e) {
@@ -264,7 +264,7 @@ public class MaildirStore implements Uid
     }
 
     @Override
-    public long lastUid(MailboxSession session, Mailbox<Integer> mailbox) throws MailboxException {
+    public long lastUid(MailboxSession session, Mailbox<MaildirId> mailbox) throws MailboxException {
        return createMaildirFolder(mailbox).getLastUid(session);
     }
 

Modified: james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java (original)
+++ james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java Mon Jun 29 08:21:12 2015
@@ -32,6 +32,7 @@ import org.apache.james.mailbox.exceptio
 import org.apache.james.mailbox.exception.MailboxExistsException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.maildir.MaildirFolder;
+import org.apache.james.mailbox.maildir.MaildirId;
 import org.apache.james.mailbox.maildir.MaildirMessageName;
 import org.apache.james.mailbox.maildir.MaildirStore;
 import org.apache.james.mailbox.model.MailboxACL;
@@ -42,7 +43,7 @@ import org.apache.james.mailbox.store.ma
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
 import org.apache.james.mailbox.store.transaction.NonTransactionalMapper;
 
-public class MaildirMailboxMapper extends NonTransactionalMapper implements MailboxMapper<Integer> {
+public class MaildirMailboxMapper extends NonTransactionalMapper implements MailboxMapper<MaildirId> {
 
     /**
      * The {@link MaildirStore} the mailboxes reside in
@@ -52,7 +53,7 @@ public class MaildirMailboxMapper extend
     /**
      * A request-scoped list of mailboxes in order to refer to them via id
      */
-    private ArrayList<Mailbox<Integer>> mailboxCache = new ArrayList<Mailbox<Integer>>();
+    private ArrayList<Mailbox<MaildirId>> mailboxCache = new ArrayList<Mailbox<MaildirId>>();
 
     private final MailboxSession session;
     
@@ -65,7 +66,7 @@ public class MaildirMailboxMapper extend
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#delete(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
     @Override
-    public void delete(Mailbox<Integer> mailbox) throws MailboxException {
+    public void delete(Mailbox<MaildirId> mailbox) throws MailboxException {
         
         String folderName = maildirStore.getFolderName(mailbox);
         File folder = new File(folderName);
@@ -106,9 +107,9 @@ public class MaildirMailboxMapper extend
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxByPath(org.apache.james.mailbox.model.MailboxPath)
      */
     @Override
-    public Mailbox<Integer> findMailboxByPath(MailboxPath mailboxPath)
+    public Mailbox<MaildirId> findMailboxByPath(MailboxPath mailboxPath)
             throws MailboxException, MailboxNotFoundException {      
-        Mailbox<Integer> mailbox = maildirStore.loadMailbox(session, mailboxPath);
+        Mailbox<MaildirId> mailbox = maildirStore.loadMailbox(session, mailboxPath);
         return cacheMailbox(mailbox);
     }
     
@@ -116,22 +117,22 @@ public class MaildirMailboxMapper extend
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxWithPathLike(org.apache.james.mailbox.model.MailboxPath)
      */
     @Override
-    public List<Mailbox<Integer>> findMailboxWithPathLike(MailboxPath mailboxPath)
+    public List<Mailbox<MaildirId>> findMailboxWithPathLike(MailboxPath mailboxPath)
             throws MailboxException {
         final Pattern searchPattern = Pattern.compile("[" + MaildirStore.maildirDelimiter + "]"
                 + mailboxPath.getName().replace(".", "\\.").replace(MaildirStore.WILDCARD, ".*"));
         FilenameFilter filter = MaildirMessageName.createRegexFilter(searchPattern);
         File root = maildirStore.getMailboxRootForUser(mailboxPath.getUser());
         File[] folders = root.listFiles(filter);
-        ArrayList<Mailbox<Integer>> mailboxList = new ArrayList<Mailbox<Integer>>();
+        ArrayList<Mailbox<MaildirId>> mailboxList = new ArrayList<Mailbox<MaildirId>>();
         for (File folder : folders)
             if (folder.isDirectory()) {
-                Mailbox<Integer> mailbox = maildirStore.loadMailbox(session, root, mailboxPath.getNamespace(), mailboxPath.getUser(), folder.getName());
+                Mailbox<MaildirId> mailbox = maildirStore.loadMailbox(session, root, mailboxPath.getNamespace(), mailboxPath.getUser(), folder.getName());
                 mailboxList.add(cacheMailbox(mailbox));
             }
         // INBOX is in the root of the folder
         if (Pattern.matches(mailboxPath.getName().replace(MaildirStore.WILDCARD, ".*"), MailboxConstants.INBOX)) {
-            Mailbox<Integer> mailbox = maildirStore.loadMailbox(session, root, mailboxPath.getNamespace(), mailboxPath.getUser(), "");
+            Mailbox<MaildirId> mailbox = maildirStore.loadMailbox(session, root, mailboxPath.getNamespace(), mailboxPath.getUser(), "");
             mailboxList.add(0, cacheMailbox(mailbox));
         }
         return mailboxList;
@@ -141,9 +142,9 @@ public class MaildirMailboxMapper extend
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#hasChildren(org.apache.james.mailbox.store.mail.model.Mailbox, char)
      */
     @Override
-    public boolean hasChildren(Mailbox<Integer> mailbox, char delimiter) throws MailboxException, MailboxNotFoundException {
+    public boolean hasChildren(Mailbox<MaildirId> mailbox, char delimiter) throws MailboxException, MailboxNotFoundException {
         String searchString = mailbox.getName() + MaildirStore.maildirDelimiter + MaildirStore.WILDCARD;
-        List<Mailbox<Integer>> mailboxes = findMailboxWithPathLike(
+        List<Mailbox<MaildirId>> mailboxes = findMailboxWithPathLike(
                 new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), searchString));
         return (mailboxes.size() > 0);
     }
@@ -152,9 +153,9 @@ public class MaildirMailboxMapper extend
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#save(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
     @Override
-    public void save(Mailbox<Integer> mailbox) throws MailboxException {
+    public void save(Mailbox<MaildirId> mailbox) throws MailboxException {
         try {
-            Mailbox<Integer> originalMailbox = getCachedMailbox(mailbox.getMailboxId());
+            Mailbox<MaildirId> originalMailbox = getCachedMailbox(mailbox.getMailboxId());
             MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
             // equals with null check
             if (originalMailbox.getName() == null ? mailbox.getName() != null : !originalMailbox.getName().equals(mailbox.getName())) {
@@ -228,10 +229,10 @@ public class MaildirMailboxMapper extend
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#list()
      */
     @Override
-    public List<Mailbox<Integer>> list() throws MailboxException {
+    public List<Mailbox<MaildirId>> list() throws MailboxException {
         
        File maildirRoot = maildirStore.getMaildirRoot();
-       List<Mailbox<Integer>> mailboxList = new ArrayList<Mailbox<Integer>>();
+       List<Mailbox<MaildirId>> mailboxList = new ArrayList<Mailbox<MaildirId>>();
         
        if (maildirStore.getMaildirLocation().endsWith("/" + MaildirStore.PATH_FULLUSER)) {
            File[] users = maildirRoot.listFiles();
@@ -262,10 +263,10 @@ public class MaildirMailboxMapper extend
      * @param mailbox The mailbox to cache
      * @return The id of the cached mailbox
      */
-    private Mailbox<Integer> cacheMailbox(Mailbox<Integer> mailbox) {
-        mailboxCache.add(new SimpleMailbox<Integer>(mailbox));
+    private Mailbox<MaildirId> cacheMailbox(Mailbox<MaildirId> mailbox) {
+        mailboxCache.add(new SimpleMailbox<MaildirId>(mailbox));
         int id = mailboxCache.size() - 1;
-        ((SimpleMailbox<Integer>) mailbox).setMailboxId(id);
+        ((SimpleMailbox<MaildirId>) mailbox).setMailboxId(MaildirId.of(id));
         return mailbox;
     }
     
@@ -275,17 +276,17 @@ public class MaildirMailboxMapper extend
      * @return The mailbox
      * @throws MailboxNotFoundException If the mailboxId is not in the cache
      */
-    private Mailbox<Integer> getCachedMailbox(Integer mailboxId) throws MailboxNotFoundException {
+    private Mailbox<MaildirId> getCachedMailbox(MaildirId mailboxId) throws MailboxNotFoundException {
         if (mailboxId == null)
             throw new MailboxNotFoundException("null");
         try {
-            return mailboxCache.get(mailboxId);
+            return mailboxCache.get(mailboxId.getRawId());
         } catch (IndexOutOfBoundsException e) {
             throw new MailboxNotFoundException(String.valueOf(mailboxId));
         }
     }
     
-    private void visitUsersForMailboxList(File domain, File[] users, List<Mailbox<Integer>> mailboxList) throws MailboxException {
+    private void visitUsersForMailboxList(File domain, File[] users, List<Mailbox<MaildirId>> mailboxList) throws MailboxException {
         
         String userName = null;
         
@@ -327,7 +328,7 @@ public class MaildirMailboxMapper extend
     }
 
     @Override
-    public void updateACL(Mailbox<Integer> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException {
+    public void updateACL(Mailbox<MaildirId> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException {
         MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
         MailboxACL newACL = mailbox.getACL().apply(mailboxACLCommand);
         folder.setACL(session, newACL);

Modified: james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java (original)
+++ james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMessageMapper.java Mon Jun 29 08:21:12 2015
@@ -38,6 +38,7 @@ import org.apache.commons.io.FileUtils;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.maildir.MaildirFolder;
+import org.apache.james.mailbox.maildir.MaildirId;
 import org.apache.james.mailbox.maildir.MaildirMessageName;
 import org.apache.james.mailbox.maildir.MaildirStore;
 import org.apache.james.mailbox.maildir.mail.model.MaildirMessage;
@@ -51,7 +52,7 @@ import org.apache.james.mailbox.store.ma
 import org.apache.james.mailbox.store.mail.model.Message;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMessage;
 
-public class MaildirMessageMapper extends AbstractMessageMapper<Integer> {
+public class MaildirMessageMapper extends AbstractMessageMapper<MaildirId> {
 
     private final MaildirStore maildirStore;
     private final static int BUF_SIZE = 2048;
@@ -65,7 +66,7 @@ public class MaildirMessageMapper extend
      * @see org.apache.james.mailbox.store.mail.MessageMapper#countMessagesInMailbox(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
     @Override
-    public long countMessagesInMailbox(Mailbox<Integer> mailbox) throws MailboxException {
+    public long countMessagesInMailbox(Mailbox<MaildirId> mailbox) throws MailboxException {
         MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
         File newFolder = folder.getNewFolder();
         File curFolder = folder.getCurFolder();
@@ -82,7 +83,7 @@ public class MaildirMessageMapper extend
      * @see org.apache.james.mailbox.store.mail.MessageMapper#countUnseenMessagesInMailbox(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
     @Override
-    public long countUnseenMessagesInMailbox(Mailbox<Integer> mailbox) throws MailboxException {
+    public long countUnseenMessagesInMailbox(Mailbox<MaildirId> mailbox) throws MailboxException {
         MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
         File newFolder = folder.getNewFolder();
         File curFolder = folder.getCurFolder();
@@ -100,7 +101,7 @@ public class MaildirMessageMapper extend
      *      org.apache.james.mailbox.store.mail.model.Message)
      */
     @Override
-    public void delete(Mailbox<Integer> mailbox, Message<Integer> message) throws MailboxException {
+    public void delete(Mailbox<MaildirId> mailbox, Message<MaildirId> message) throws MailboxException {
         MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
         try {
             folder.delete(mailboxSession, message.getUid());
@@ -115,9 +116,9 @@ public class MaildirMessageMapper extend
      *      org.apache.james.mailbox.store.mail.MessageMapper.FetchType, int)
      */
     @Override
-    public Iterator<Message<Integer>> findInMailbox(Mailbox<Integer> mailbox, MessageRange set, FetchType fType, int max)
+    public Iterator<Message<MaildirId>> findInMailbox(Mailbox<MaildirId> mailbox, MessageRange set, FetchType fType, int max)
             throws MailboxException {
-        final List<Message<Integer>> results;
+        final List<Message<MaildirId>> results;
         final long from = set.getUidFrom();
         final long to = set.getUidTo();
         final Type type = set.getType();
@@ -144,7 +145,7 @@ public class MaildirMessageMapper extend
      * @see org.apache.james.mailbox.store.mail.MessageMapper#findRecentMessageUidsInMailbox(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
     @Override
-    public List<Long> findRecentMessageUidsInMailbox(Mailbox<Integer> mailbox) throws MailboxException {
+    public List<Long> findRecentMessageUidsInMailbox(Mailbox<MaildirId> mailbox) throws MailboxException {
         MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
         SortedMap<Long, MaildirMessageName> recentMessageNames = folder.getRecentMessages(mailboxSession);
         return new ArrayList<Long>(recentMessageNames.keySet());
@@ -155,8 +156,8 @@ public class MaildirMessageMapper extend
      * @see org.apache.james.mailbox.store.mail.MessageMapper#findFirstUnseenMessageUid(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
     @Override
-    public Long findFirstUnseenMessageUid(Mailbox<Integer> mailbox) throws MailboxException {
-        List<Message<Integer>> result = findMessagesInMailbox(mailbox, MaildirMessageName.FILTER_UNSEEN_MESSAGES, 1);
+    public Long findFirstUnseenMessageUid(Mailbox<MaildirId> mailbox) throws MailboxException {
+        List<Message<MaildirId>> result = findMessagesInMailbox(mailbox, MaildirMessageName.FILTER_UNSEEN_MESSAGES, 1);
         if (result.isEmpty()) {
             return null;
         } else {
@@ -170,14 +171,14 @@ public class MaildirMessageMapper extend
      *      org.apache.james.mailbox.model.MessageRange)
      */
     @Override
-    public Iterator<UpdatedFlags> updateFlags(final Mailbox<Integer> mailbox, final Flags flags, final boolean value,
+    public Iterator<UpdatedFlags> updateFlags(final Mailbox<MaildirId> mailbox, final Flags flags, final boolean value,
             final boolean replace, final MessageRange set) throws MailboxException {
         final List<UpdatedFlags> updatedFlags = new ArrayList<UpdatedFlags>();
         final MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
 
-        Iterator<Message<Integer>> it = findInMailbox(mailbox, set, FetchType.Metadata, -1);
+        Iterator<Message<MaildirId>> it = findInMailbox(mailbox, set, FetchType.Metadata, -1);
         while (it.hasNext()) {
-            final Message<Integer> member = it.next();
+            final Message<MaildirId> member = it.next();
             Flags originalFlags = member.createFlags();
             if (replace) {
                 member.setFlags(flags);
@@ -239,9 +240,9 @@ public class MaildirMessageMapper extend
     }
 
     @Override
-    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox<Integer> mailbox, MessageRange set)
+    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox<MaildirId> mailbox, MessageRange set)
             throws MailboxException {
-        List<Message<Integer>> results = new ArrayList<Message<Integer>>();
+        List<Message<MaildirId>> results = new ArrayList<Message<MaildirId>>();
         final long from = set.getUidFrom();
         final long to = set.getUidTo();
         final Type type = set.getType();
@@ -264,7 +265,7 @@ public class MaildirMessageMapper extend
         }
         Map<Long, MessageMetaData> uids = new HashMap<Long, MessageMetaData>();
         for (int i = 0; i < results.size(); i++) {
-            Message<Integer> m = results.get(i);
+            Message<MaildirId> m = results.get(i);
             long uid = m.getUid();
             uids.put(uid, new SimpleMessageMetaData(m));
             delete(mailbox, m);
@@ -280,7 +281,7 @@ public class MaildirMessageMapper extend
      *      org.apache.james.mailbox.store.mail.model.Message)
      */
     @Override
-    public MessageMetaData move(Mailbox<Integer> mailbox, Message<Integer> original) throws MailboxException {
+    public MessageMetaData move(Mailbox<MaildirId> mailbox, Message<MaildirId> original) throws MailboxException {
         throw new UnsupportedOperationException("Not implemented - see https://issues.apache.org/jira/browse/IMAP-370");
     }
 
@@ -290,9 +291,9 @@ public class MaildirMessageMapper extend
      *      org.apache.james.mailbox.store.mail.model.Message)
      */
     @Override
-    protected MessageMetaData copy(Mailbox<Integer> mailbox, long uid, long modSeq, Message<Integer> original)
+    protected MessageMetaData copy(Mailbox<MaildirId> mailbox, long uid, long modSeq, Message<MaildirId> original)
             throws MailboxException {
-        SimpleMessage<Integer> theCopy = new SimpleMessage<Integer>(mailbox, original);
+        SimpleMessage<MaildirId> theCopy = new SimpleMessage<MaildirId>(mailbox, original);
         Flags flags = theCopy.createFlags();
         flags.add(Flag.RECENT);
         theCopy.setFlags(flags);
@@ -304,7 +305,7 @@ public class MaildirMessageMapper extend
      *      org.apache.james.mailbox.store.mail.model.Message)
      */
     @Override
-    protected MessageMetaData save(Mailbox<Integer> mailbox, Message<Integer> message) throws MailboxException {
+    protected MessageMetaData save(Mailbox<MaildirId> mailbox, Message<MaildirId> message) throws MailboxException {
         MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
         long uid = 0;
         // a new message
@@ -390,13 +391,13 @@ public class MaildirMessageMapper extend
 
     }
 
-    private List<Message<Integer>> findMessageInMailboxWithUID(Mailbox<Integer> mailbox, long uid)
+    private List<Message<MaildirId>> findMessageInMailboxWithUID(Mailbox<MaildirId> mailbox, long uid)
             throws MailboxException {
         MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
         try {
             MaildirMessageName messageName = folder.getMessageNameByUid(mailboxSession, uid);
 
-            ArrayList<Message<Integer>> messages = new ArrayList<Message<Integer>>();
+            ArrayList<Message<MaildirId>> messages = new ArrayList<Message<MaildirId>>();
             if (messageName != null && messageName.getFile().exists()) {
                 messages.add(new MaildirMessage(mailbox, uid, messageName));
             }
@@ -407,7 +408,7 @@ public class MaildirMessageMapper extend
         }
     }
 
-    private List<Message<Integer>> findMessagesInMailboxBetweenUIDs(Mailbox<Integer> mailbox, FilenameFilter filter,
+    private List<Message<MaildirId>> findMessagesInMailboxBetweenUIDs(Mailbox<MaildirId> mailbox, FilenameFilter filter,
             long from, long to, int max) throws MailboxException {
         MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
         int cur = 0;
@@ -418,7 +419,7 @@ public class MaildirMessageMapper extend
             else
                 uidMap = folder.getUidMap(mailboxSession, from, to);
 
-            ArrayList<Message<Integer>> messages = new ArrayList<Message<Integer>>();
+            ArrayList<Message<MaildirId>> messages = new ArrayList<Message<MaildirId>>();
             for (Entry<Long, MaildirMessageName> entry : uidMap.entrySet()) {
                 messages.add(new MaildirMessage(mailbox, entry.getKey(), entry.getValue()));
                 if (max != -1) {
@@ -434,13 +435,13 @@ public class MaildirMessageMapper extend
 
     }
 
-    private List<Message<Integer>> findMessagesInMailbox(Mailbox<Integer> mailbox, FilenameFilter filter, int limit)
+    private List<Message<MaildirId>> findMessagesInMailbox(Mailbox<MaildirId> mailbox, FilenameFilter filter, int limit)
             throws MailboxException {
         MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
         try {
             SortedMap<Long, MaildirMessageName> uidMap = folder.getUidMap(mailboxSession, filter, limit);
 
-            ArrayList<Message<Integer>> filtered = new ArrayList<Message<Integer>>(uidMap.size());
+            ArrayList<Message<MaildirId>> filtered = new ArrayList<Message<MaildirId>>(uidMap.size());
             for (Entry<Long, MaildirMessageName> entry : uidMap.entrySet())
                 filtered.add(new MaildirMessage(mailbox, entry.getKey(), entry.getValue()));
             return filtered;
@@ -450,12 +451,12 @@ public class MaildirMessageMapper extend
 
     }
 
-    private List<Message<Integer>> findDeletedMessageInMailboxWithUID(Mailbox<Integer> mailbox, long uid)
+    private List<Message<MaildirId>> findDeletedMessageInMailboxWithUID(Mailbox<MaildirId> mailbox, long uid)
             throws MailboxException {
         MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
         try {
             MaildirMessageName messageName = folder.getMessageNameByUid(mailboxSession, uid);
-            ArrayList<Message<Integer>> messages = new ArrayList<Message<Integer>>();
+            ArrayList<Message<MaildirId>> messages = new ArrayList<Message<MaildirId>>();
             if (MaildirMessageName.FILTER_DELETED_MESSAGES.accept(null, messageName.getFullName())) {
                 messages.add(new MaildirMessage(mailbox, uid, messageName));
             }

Modified: james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java (original)
+++ james/mailbox/trunk/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java Mon Jun 29 08:21:12 2015
@@ -18,8 +18,21 @@
  ****************************************************************/
 package org.apache.james.mailbox.maildir.mail.model;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.util.Date;
+import java.util.List;
+
+import javax.mail.Flags;
+import javax.mail.util.SharedFileInputStream;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mailbox.maildir.MaildirFolder;
+import org.apache.james.mailbox.maildir.MaildirId;
 import org.apache.james.mailbox.maildir.MaildirMessageName;
 import org.apache.james.mailbox.store.mail.model.AbstractMessage;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
@@ -35,15 +48,9 @@ import org.apache.james.mime4j.stream.Mi
 import org.apache.james.mime4j.stream.MimeTokenStream;
 import org.apache.james.mime4j.stream.RecursionMode;
 
-import javax.mail.Flags;
-import javax.mail.util.SharedFileInputStream;
-import java.io.*;
-import java.util.Date;
-import java.util.List;
-
-public class MaildirMessage extends AbstractMessage<Integer> {
+public class MaildirMessage extends AbstractMessage<MaildirId> {
 
-    private MaildirMessageName messageName;
+	private MaildirMessageName messageName;
     private int bodyStartOctet;
     private final PropertyBuilder propertyBuilder = new PropertyBuilder();
     private boolean parsed;
@@ -53,12 +60,12 @@ public class MaildirMessage extends Abst
     private boolean flagged;
     private boolean recent;
     private boolean seen;
-    private Mailbox<Integer> mailbox;
+    private Mailbox<MaildirId> mailbox;
     private long uid;
     protected boolean newMessage;
     private long modSeq;
     
-    public MaildirMessage(Mailbox<Integer> mailbox, long uid, MaildirMessageName messageName) throws IOException {
+    public MaildirMessage(Mailbox<MaildirId> mailbox, long uid, MaildirMessageName messageName) throws IOException {
         this.mailbox = mailbox;
         setUid(uid);
         setModSeq(messageName.getFile().lastModified());
@@ -83,7 +90,7 @@ public class MaildirMessage extends Abst
 
     
     @Override
-    public Integer getMailboxId() {
+    public MaildirId getMailboxId() {
         return mailbox.getMailboxId();
     }
 

Modified: james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java (original)
+++ james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerTest.java Mon Jun 29 08:21:12 2015
@@ -118,7 +118,7 @@ public class MaildirMailboxManagerTest e
             MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
             GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
 
-            StoreMailboxManager<Integer> manager = new StoreMailboxManager<Integer>(mf, null, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
+            StoreMailboxManager<MaildirId> manager = new StoreMailboxManager<MaildirId>(mf, null, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
             manager.init();
             setMailboxManager(manager);
             try {
@@ -151,7 +151,7 @@ public class MaildirMailboxManagerTest e
             MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
             GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
 
-            StoreMailboxManager<Integer> manager = new StoreMailboxManager<Integer>(mf, null, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
+            StoreMailboxManager<MaildirId> manager = new StoreMailboxManager<MaildirId>(mf, null, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
             manager.init();
             setMailboxManager(manager);
             try {
@@ -183,7 +183,7 @@ public class MaildirMailboxManagerTest e
         MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
         GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
 
-        StoreMailboxManager<Integer> manager = new StoreMailboxManager<Integer>(mf, null, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
+        StoreMailboxManager<MaildirId> manager = new StoreMailboxManager<MaildirId>(mf, null, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
         manager.init();
         setMailboxManager(manager);
         try {

Modified: james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirStressTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirStressTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirStressTest.java (original)
+++ james/mailbox/trunk/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirStressTest.java Mon Jun 29 08:21:12 2015
@@ -38,7 +38,7 @@ public class MaildirStressTest extends A
 
     private static final String MAILDIR_HOME = "target/Maildir";
 
-    private StoreMailboxManager<Integer> mailboxManager;
+    private StoreMailboxManager<MaildirId> mailboxManager;
     
     @Before
     public void setUp() throws MailboxException {
@@ -48,7 +48,7 @@ public class MaildirStressTest extends A
         MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
         GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
 
-        mailboxManager = new StoreMailboxManager<Integer>(mf, null, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
+        mailboxManager = new StoreMailboxManager<MaildirId>(mf, null, new JVMMailboxPathLocker(), aclResolver, groupMembershipResolver);
         mailboxManager.init();
 
     }

Added: james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java?rev=1688109&view=auto
==============================================================================
--- james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java (added)
+++ james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryId.java Mon Jun 29 08:21:12 2015
@@ -0,0 +1,71 @@
+/****************************************************************
+ * 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.inmemory;
+
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+
+public class InMemoryId implements MailboxId {
+
+    public static InMemoryId of(long value) {
+        return new InMemoryId(value);
+    }
+
+    private final long value;
+
+    private InMemoryId(long value) {
+        this.value = value;
+    }
+
+    @Override
+    public String serialize() {
+        return String.valueOf(value);
+    }
+
+    @Override
+    public String toString() {
+        return String.valueOf(value);
+    }
+
+    public long getRawId() {
+        return value;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (int) (value ^ (value >>> 32));
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        InMemoryId other = (InMemoryId) obj;
+        if (value != other.value)
+            return false;
+        return true;
+    }
+
+}

Modified: james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java (original)
+++ james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/InMemoryMailboxSessionMapperFactory.java Mon Jun 29 08:21:12 2015
@@ -31,10 +31,10 @@ import org.apache.james.mailbox.store.ma
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 
-public class InMemoryMailboxSessionMapperFactory extends MailboxSessionMapperFactory<Long> {
+public class InMemoryMailboxSessionMapperFactory extends MailboxSessionMapperFactory<InMemoryId> {
 
-    private MailboxMapper<Long> mailboxMapper;
-    private MessageMapper<Long> messageMapper;
+    private MailboxMapper<InMemoryId> mailboxMapper;
+    private MessageMapper<InMemoryId> messageMapper;
     private SubscriptionMapper subscriptionMapper;
     
     public InMemoryMailboxSessionMapperFactory() {
@@ -44,12 +44,12 @@ public class InMemoryMailboxSessionMappe
     }
     
     @Override
-    public MailboxMapper<Long> createMailboxMapper(MailboxSession session) throws MailboxException {
+    public MailboxMapper<InMemoryId> createMailboxMapper(MailboxSession session) throws MailboxException {
         return mailboxMapper;
     }
 
     @Override
-    public MessageMapper<Long> createMessageMapper(MailboxSession session) throws MailboxException {
+    public MessageMapper<InMemoryId> createMessageMapper(MailboxSession session) throws MailboxException {
         return messageMapper;
     }
 

Modified: james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java (original)
+++ james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java Mon Jun 29 08:21:12 2015
@@ -26,26 +26,27 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 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;
 
-public class InMemoryMailboxMapper implements MailboxMapper<Long> {
+public class InMemoryMailboxMapper implements MailboxMapper<InMemoryId> {
     
     private static final int INITIAL_SIZE = 128;
-    private final Map<Long, Mailbox<Long>> mailboxesById;
+    private final Map<InMemoryId, Mailbox<InMemoryId>> mailboxesById;
     private final static AtomicLong IDS = new AtomicLong();
 
     public InMemoryMailboxMapper() {
-        mailboxesById = new ConcurrentHashMap<Long, Mailbox<Long>>(INITIAL_SIZE);
+        mailboxesById = new ConcurrentHashMap<InMemoryId, Mailbox<InMemoryId>>(INITIAL_SIZE);
     }
 
     /**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#delete(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
-    public void delete(Mailbox<Long> mailbox) throws MailboxException {
+    public void delete(Mailbox<InMemoryId> mailbox) throws MailboxException {
         mailboxesById.remove(mailbox.getMailboxId());
     }
 
@@ -56,9 +57,9 @@ public class InMemoryMailboxMapper imple
     /**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxByPath(org.apache.james.mailbox.model.MailboxPath)
      */
-    public synchronized Mailbox<Long> findMailboxByPath(MailboxPath path) throws MailboxException, MailboxNotFoundException {
-        Mailbox<Long> result = null;
-        for (final Mailbox<Long> mailbox:mailboxesById.values()) {
+    public synchronized Mailbox<InMemoryId> findMailboxByPath(MailboxPath path) throws MailboxException, MailboxNotFoundException {
+        Mailbox<InMemoryId> result = null;
+        for (final Mailbox<InMemoryId> mailbox:mailboxesById.values()) {
             MailboxPath mp = new MailboxPath(mailbox.getNamespace(), mailbox.getUser(), mailbox.getName());
             if (mp.equals(path)) {
                 result = mailbox;
@@ -75,10 +76,10 @@ public class InMemoryMailboxMapper imple
     /**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxWithPathLike(org.apache.james.mailbox.model.MailboxPath)
      */
-    public List<Mailbox<Long>> findMailboxWithPathLike(MailboxPath path) throws MailboxException {
+    public List<Mailbox<InMemoryId>> findMailboxWithPathLike(MailboxPath path) throws MailboxException {
         final String regex = path.getName().replace("%", ".*");
-        List<Mailbox<Long>> results = new ArrayList<Mailbox<Long>>();
-        for (final Mailbox<Long> mailbox:mailboxesById.values()) {
+        List<Mailbox<InMemoryId>> results = new ArrayList<Mailbox<InMemoryId>>();
+        for (final Mailbox<InMemoryId> mailbox:mailboxesById.values()) {
             if (mailboxMatchesRegex(mailbox, path, regex)) {
                 results.add(mailbox);
             }
@@ -86,7 +87,7 @@ public class InMemoryMailboxMapper imple
         return results;
     }
 
-    private boolean mailboxMatchesRegex(Mailbox<Long> mailbox, MailboxPath path, String regex) {
+    private boolean mailboxMatchesRegex(Mailbox<InMemoryId> mailbox, MailboxPath path, String regex) {
         return mailbox.getNamespace().equals(path.getNamespace())
             && mailbox.getUser().equals(path.getUser())
             && mailbox.getName().matches(regex);
@@ -95,11 +96,11 @@ public class InMemoryMailboxMapper imple
     /**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#save(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
-    public void save(Mailbox<Long> mailbox) throws MailboxException {
-        Long id = mailbox.getMailboxId();
+    public void save(Mailbox<InMemoryId> mailbox) throws MailboxException {
+        InMemoryId id = mailbox.getMailboxId();
         if (id == null) {
-            id = IDS.incrementAndGet();
-            ((SimpleMailbox<Long>) mailbox).setMailboxId(id);
+            id = InMemoryId.of(IDS.incrementAndGet());
+            ((SimpleMailbox<InMemoryId>) mailbox).setMailboxId(id);
         }
         mailboxesById.put(id, mailbox);
     }
@@ -114,10 +115,10 @@ public class InMemoryMailboxMapper imple
     /**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#hasChildren(org.apache.james.mailbox.store.mail.model.Mailbox, char)
      */
-    public boolean hasChildren(Mailbox<Long> mailbox, char delimiter) throws MailboxException,
+    public boolean hasChildren(Mailbox<InMemoryId> mailbox, char delimiter) throws MailboxException,
             MailboxNotFoundException {
         String mailboxName = mailbox.getName() + delimiter;
-        for (final Mailbox<Long> box:mailboxesById.values()) {
+        for (final Mailbox<InMemoryId> box:mailboxesById.values()) {
             if (box.getName().startsWith(mailboxName)) {
                 return true;
             }
@@ -128,8 +129,8 @@ public class InMemoryMailboxMapper imple
     /**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#list()
      */
-    public List<Mailbox<Long>> list() throws MailboxException {
-        return new ArrayList<Mailbox<Long>>(mailboxesById.values());
+    public List<Mailbox<InMemoryId>> list() throws MailboxException {
+        return new ArrayList<Mailbox<InMemoryId>>(mailboxesById.values());
     }
 
     public <T> T execute(Transaction<T> transaction) throws MailboxException {
@@ -137,7 +138,7 @@ public class InMemoryMailboxMapper imple
     }
 
     @Override
-    public void updateACL(Mailbox<Long> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException{
+    public void updateACL(Mailbox<InMemoryId> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException{
         mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand));
     }
 }

Modified: james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java (original)
+++ james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMessageMapper.java Mon Jun 29 08:21:12 2015
@@ -32,6 +32,7 @@ import javax.mail.Flags.Flag;
 
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.store.SimpleMessageMetaData;
@@ -42,21 +43,21 @@ import org.apache.james.mailbox.store.ma
 import org.apache.james.mailbox.store.mail.model.Message;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMessage;
 
-public class InMemoryMessageMapper extends AbstractMessageMapper<Long> {
+public class InMemoryMessageMapper extends AbstractMessageMapper<InMemoryId> {
 
-    private Map<Long, Map<Long, Message<Long>>> mailboxByUid;
+    private Map<InMemoryId, Map<Long, Message<InMemoryId>>> mailboxByUid;
     private static final int INITIAL_SIZE = 256;
 
-    public InMemoryMessageMapper(MailboxSession session, UidProvider<Long> uidProvider,
-            ModSeqProvider<Long> modSeqProvider) {
+    public InMemoryMessageMapper(MailboxSession session, UidProvider<InMemoryId> uidProvider,
+            ModSeqProvider<InMemoryId> modSeqProvider) {
         super(session, uidProvider, modSeqProvider);
-        this.mailboxByUid = new ConcurrentHashMap<Long, Map<Long, Message<Long>>>(INITIAL_SIZE);
+        this.mailboxByUid = new ConcurrentHashMap<InMemoryId, Map<Long, Message<InMemoryId>>>(INITIAL_SIZE);
     }
 
-    private Map<Long, Message<Long>> getMembershipByUidForMailbox(Mailbox<Long> mailbox) {
-        Map<Long, Message<Long>> membershipByUid = mailboxByUid.get(mailbox.getMailboxId());
+    private Map<Long, Message<InMemoryId>> getMembershipByUidForMailbox(Mailbox<InMemoryId> mailbox) {
+        Map<Long, Message<InMemoryId>> membershipByUid = mailboxByUid.get(mailbox.getMailboxId());
         if (membershipByUid == null) {
-            membershipByUid = new ConcurrentHashMap<Long, Message<Long>>(INITIAL_SIZE);
+            membershipByUid = new ConcurrentHashMap<Long, Message<InMemoryId>>(INITIAL_SIZE);
             mailboxByUid.put(mailbox.getMailboxId(), membershipByUid);
         }
         return membershipByUid;
@@ -65,16 +66,16 @@ public class InMemoryMessageMapper exten
     /**
      * @see org.apache.james.mailbox.store.mail.MessageMapper#countMessagesInMailbox(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
-    public long countMessagesInMailbox(Mailbox<Long> mailbox) throws MailboxException {
+    public long countMessagesInMailbox(Mailbox<InMemoryId> mailbox) throws MailboxException {
         return getMembershipByUidForMailbox(mailbox).size();
     }
 
     /**
      * @see org.apache.james.mailbox.store.mail.MessageMapper#countUnseenMessagesInMailbox(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
-    public long countUnseenMessagesInMailbox(Mailbox<Long> mailbox) throws MailboxException {
+    public long countUnseenMessagesInMailbox(Mailbox<InMemoryId> mailbox) throws MailboxException {
         long count = 0;
-        for (Message<Long> member : getMembershipByUidForMailbox(mailbox).values()) {
+        for (Message<InMemoryId> member : getMembershipByUidForMailbox(mailbox).values()) {
             if (!member.isSeen()) {
                 count++;
             }
@@ -86,7 +87,7 @@ public class InMemoryMessageMapper exten
      * @see org.apache.james.mailbox.store.mail.MessageMapper#delete(org.apache.james.mailbox.store.mail.model.Mailbox,
      *      org.apache.james.mailbox.store.mail.model.Message)
      */
-    public void delete(Mailbox<Long> mailbox, Message<Long> message) throws MailboxException {
+    public void delete(Mailbox<InMemoryId> mailbox, Message<InMemoryId> message) throws MailboxException {
         getMembershipByUidForMailbox(mailbox).remove(message.getUid());
     }
 
@@ -95,25 +96,25 @@ public class InMemoryMessageMapper exten
      *      org.apache.james.mailbox.model.MessageRange,
      *      org.apache.james.mailbox.store.mail.MessageMapper.FetchType, int)
      */
-    public Iterator<Message<Long>> findInMailbox(Mailbox<Long> mailbox, MessageRange set, FetchType ftype, int max)
+    public Iterator<Message<InMemoryId>> findInMailbox(Mailbox<InMemoryId> mailbox, MessageRange set, FetchType ftype, int max)
             throws MailboxException {
-        List<Message<Long>> results;
+        List<Message<InMemoryId>> results;
         final MessageRange.Type type = set.getType();
         switch (type) {
         case ALL:
-            results = new ArrayList<Message<Long>>(getMembershipByUidForMailbox(mailbox).values());
+            results = new ArrayList<Message<InMemoryId>>(getMembershipByUidForMailbox(mailbox).values());
             break;
         case FROM:
-            results = new ArrayList<Message<Long>>(getMembershipByUidForMailbox(mailbox).values());
-            for (final Iterator<Message<Long>> it = results.iterator(); it.hasNext();) {
+            results = new ArrayList<Message<InMemoryId>>(getMembershipByUidForMailbox(mailbox).values());
+            for (final Iterator<Message<InMemoryId>> it = results.iterator(); it.hasNext();) {
                 if (it.next().getUid() < set.getUidFrom()) {
                     it.remove();
                 }
             }
             break;
         case RANGE:
-            results = new ArrayList<Message<Long>>(getMembershipByUidForMailbox(mailbox).values());
-            for (final Iterator<Message<Long>> it = results.iterator(); it.hasNext();) {
+            results = new ArrayList<Message<InMemoryId>>(getMembershipByUidForMailbox(mailbox).values());
+            for (final Iterator<Message<InMemoryId>> it = results.iterator(); it.hasNext();) {
                 final long uid = it.next().getUid();
                 if (uid < set.getUidFrom() || uid > set.getUidTo()) {
                     it.remove();
@@ -121,14 +122,14 @@ public class InMemoryMessageMapper exten
             }
             break;
         case ONE:
-            results = new ArrayList<Message<Long>>(1);
-            final Message<Long> member = getMembershipByUidForMailbox(mailbox).get(set.getUidFrom());
+            results = new ArrayList<Message<InMemoryId>>(1);
+            final Message<InMemoryId> member = getMembershipByUidForMailbox(mailbox).get(set.getUidFrom());
             if (member != null) {
                 results.add(member);
             }
             break;
         default:
-            results = new ArrayList<Message<Long>>();
+            results = new ArrayList<Message<InMemoryId>>();
             break;
         }
         Collections.sort(results);
@@ -142,9 +143,9 @@ public class InMemoryMessageMapper exten
     /**
      * @see org.apache.james.mailbox.store.mail.MessageMapper#findRecentMessageUidsInMailbox(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
-    public List<Long> findRecentMessageUidsInMailbox(Mailbox<Long> mailbox) throws MailboxException {
+    public List<Long> findRecentMessageUidsInMailbox(Mailbox<InMemoryId> mailbox) throws MailboxException {
         final List<Long> results = new ArrayList<Long>();
-        for (Message<Long> member : getMembershipByUidForMailbox(mailbox).values()) {
+        for (Message<InMemoryId> member : getMembershipByUidForMailbox(mailbox).values()) {
             if (member.isRecent()) {
                 results.add(member.getUid());
             }
@@ -157,11 +158,11 @@ public class InMemoryMessageMapper exten
     /**
      * @see org.apache.james.mailbox.store.mail.MessageMapper#findFirstUnseenMessageUid(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
-    public Long findFirstUnseenMessageUid(Mailbox<Long> mailbox) throws MailboxException {
-        List<Message<Long>> memberships = new ArrayList<Message<Long>>(getMembershipByUidForMailbox(mailbox).values());
+    public Long findFirstUnseenMessageUid(Mailbox<InMemoryId> mailbox) throws MailboxException {
+        List<Message<InMemoryId>> memberships = new ArrayList<Message<InMemoryId>>(getMembershipByUidForMailbox(mailbox).values());
         Collections.sort(memberships);
         for (int i = 0; i < memberships.size(); i++) {
-            Message<Long> m = memberships.get(i);
+            Message<InMemoryId> m = memberships.get(i);
             if (m.isSeen() == false) {
                 return m.getUid();
             }
@@ -170,13 +171,13 @@ public class InMemoryMessageMapper exten
     }
 
     @Override
-    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(final Mailbox<Long> mailbox, MessageRange set)
+    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(final Mailbox<InMemoryId> mailbox, MessageRange set)
             throws MailboxException {
         final Map<Long, MessageMetaData> filteredResult = new HashMap<Long, MessageMetaData>();
 
-        Iterator<Message<Long>> it = findInMailbox(mailbox, set, FetchType.Metadata, -1);
+        Iterator<Message<InMemoryId>> it = findInMailbox(mailbox, set, FetchType.Metadata, -1);
         while (it.hasNext()) {
-            Message<Long> member = it.next();
+            Message<InMemoryId> member = it.next();
             if (member.isDeleted()) {
                 filteredResult.put(member.getUid(), new SimpleMessageMetaData(member));
 
@@ -197,7 +198,7 @@ public class InMemoryMessageMapper exten
      *      org.apache.james.mailbox.store.mail.model.Message)
      */
     @Override
-    public MessageMetaData move(Mailbox<Long> mailbox, Message<Long> original) throws MailboxException {
+    public MessageMetaData move(Mailbox<InMemoryId> mailbox, Message<InMemoryId> original) throws MailboxException {
         throw new UnsupportedOperationException("Not implemented - see https://issues.apache.org/jira/browse/IMAP-370");
     }
 
@@ -212,9 +213,9 @@ public class InMemoryMessageMapper exten
      * @see org.apache.james.mailbox.store.mail.AbstractMessageMapper#copy(org.apache.james.mailbox.store.mail.model.Mailbox,
      *      long, long, org.apache.james.mailbox.store.mail.model.Message)
      */
-    protected MessageMetaData copy(Mailbox<Long> mailbox, long uid, long modSeq, Message<Long> original)
+    protected MessageMetaData copy(Mailbox<InMemoryId> mailbox, long uid, long modSeq, Message<InMemoryId> original)
             throws MailboxException {
-        SimpleMessage<Long> message = new SimpleMessage<Long>(mailbox, original);
+        SimpleMessage<InMemoryId> message = new SimpleMessage<InMemoryId>(mailbox, original);
         message.setUid(uid);
         message.setModSeq(modSeq);
         Flags flags = original.createFlags();
@@ -229,8 +230,8 @@ public class InMemoryMessageMapper exten
      * @see org.apache.james.mailbox.store.mail.AbstractMessageMapper#save(org.apache.james.mailbox.store.mail.model.Mailbox,
      *      org.apache.james.mailbox.store.mail.model.Message)
      */
-    protected MessageMetaData save(Mailbox<Long> mailbox, Message<Long> message) throws MailboxException {
-        SimpleMessage<Long> copy = new SimpleMessage<Long>(mailbox, message);
+    protected MessageMetaData save(Mailbox<InMemoryId> mailbox, Message<InMemoryId> message) throws MailboxException {
+        SimpleMessage<InMemoryId> copy = new SimpleMessage<InMemoryId>(mailbox, message);
         copy.setUid(message.getUid());
         copy.setModSeq(message.getModSeq());
         getMembershipByUidForMailbox(mailbox).put(message.getUid(), copy);

Modified: james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryModSeqProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryModSeqProvider.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryModSeqProvider.java (original)
+++ james/mailbox/trunk/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryModSeqProvider.java Mon Jun 29 08:21:12 2015
@@ -25,23 +25,24 @@ import java.util.concurrent.atomic.Atomi
 
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
-public class InMemoryModSeqProvider implements ModSeqProvider<Long>{
-    private final ConcurrentMap<Long, AtomicLong> map = new ConcurrentHashMap<Long, AtomicLong>();
+public class InMemoryModSeqProvider implements ModSeqProvider<InMemoryId>{
+    private final ConcurrentMap<InMemoryId, AtomicLong> map = new ConcurrentHashMap<InMemoryId, AtomicLong>();
 
     @Override
-    public long nextModSeq(MailboxSession session, Mailbox<Long> mailbox) throws MailboxException {
+    public long nextModSeq(MailboxSession session, Mailbox<InMemoryId> mailbox) throws MailboxException {
         return getHighest(mailbox.getMailboxId()).incrementAndGet();
 
     }
 
     @Override
-    public long highestModSeq(MailboxSession session, Mailbox<Long> mailbox) throws MailboxException {
+    public long highestModSeq(MailboxSession session, Mailbox<InMemoryId> mailbox) throws MailboxException {
         return getHighest(mailbox.getMailboxId()).get();
     }
-    private AtomicLong getHighest(Long id) {
+    private AtomicLong getHighest(InMemoryId id) {
         AtomicLong uid = map.get(id);
         if (uid == null) {
             uid = new AtomicLong(0);



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