james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [01/11] james-project git commit: JAMES-1825 use a MessageUid strong type instead of long in the whole code base
Date Mon, 10 Oct 2016 10:34:19 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 35ccb7baa -> ac3340b73


http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/protocols/imap/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java
index 5984cb8..148d222 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/SearchProcessorTest.java
@@ -35,6 +35,7 @@ import org.apache.james.imap.api.ImapConstants;
 import org.apache.james.imap.api.ImapSessionUtils;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.api.message.IdRange;
+import org.apache.james.imap.api.message.UidRange;
 import org.apache.james.imap.api.message.request.DayMonthYear;
 import org.apache.james.imap.api.message.request.SearchKey;
 import org.apache.james.imap.api.message.request.SearchOperation;
@@ -49,6 +50,7 @@ import org.apache.james.imap.message.response.SearchResponse;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.model.SearchQuery.AddressType;
@@ -64,6 +66,8 @@ import org.junit.runner.RunWith;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Optional;
+
 @RunWith(JMock.class)
 public class SearchProcessorTest {
     private static final int DAY = 6;
@@ -87,12 +91,14 @@ public class SearchProcessorTest {
 
     private static final String SUBJECT = "Myriad Harbour";
 
-    private static final IdRange[] IDS = { new IdRange(1),
-            new IdRange(42, 1048) };
+    private static final UidRange[] IDS = { 
+            new UidRange(MessageUid.of(1)),
+            new UidRange(MessageUid.of(42), MessageUid.of(1048)) 
+            };
 
-    private static final SearchQuery.NumericRange[] RANGES = {
-            new SearchQuery.NumericRange(1),
-            new SearchQuery.NumericRange(42, 1048) };
+    private static final SearchQuery.UidRange[] RANGES = {
+            new SearchQuery.UidRange(MessageUid.of(1)),
+            new SearchQuery.UidRange(MessageUid.of(42), MessageUid.of(1048)) };
     
     private static final MailboxPath mailboxPath = new MailboxPath("namespace", "user", "name");
 
@@ -154,13 +160,12 @@ public class SearchProcessorTest {
     public void testSequenceSetUpperUnlimited() throws Exception {
         expectsGetSelectedMailbox();
         final IdRange[] ids = { new IdRange(1, Long.MAX_VALUE) };
-        final SearchQuery.NumericRange[] ranges = { new SearchQuery.NumericRange(
-                42, 100L) };
+        final SearchQuery.UidRange[] ranges = { new SearchQuery.UidRange(MessageUid.of(42), MessageUid.of(100)) };
         mockery.checking(new Expectations() {{
         	allowing(selectedMailbox).existsCount();will(returnValue(100L));
-            oneOf(selectedMailbox).uid(with(equal(1)));will(returnValue(42L));
-            allowing(selectedMailbox).getFirstUid(); will(returnValue(1L));
-            allowing(selectedMailbox).getLastUid(); will(returnValue(100L));
+            oneOf(selectedMailbox).uid(with(equal(1)));will(returnValue(Optional.of(MessageUid.of(42))));
+            allowing(selectedMailbox).getFirstUid(); will(returnValue(Optional.of(MessageUid.of(1))));
+            allowing(selectedMailbox).getLastUid(); will(returnValue(Optional.of(MessageUid.of(100))));
 
         }});
         allowUnsolicitedResponses();
@@ -171,14 +176,13 @@ public class SearchProcessorTest {
     public void testSequenceSetMsnRange() throws Exception {
         expectsGetSelectedMailbox();
         final IdRange[] ids = { new IdRange(1, 5) };
-        final SearchQuery.NumericRange[] ranges = { new SearchQuery.NumericRange(
-                42, 1729) };
+        final SearchQuery.UidRange[] ranges = { new SearchQuery.UidRange(MessageUid.of(42), MessageUid.of(1729)) };
         mockery.checking(new Expectations() {{
         	allowing(selectedMailbox).existsCount();will(returnValue(2L));
-            oneOf(selectedMailbox).uid(with(equal(1)));will(returnValue(42L));
-            oneOf(selectedMailbox).uid(with(equal(5)));will(returnValue(1729L));
-            allowing(selectedMailbox).getFirstUid(); will(returnValue(1L));
-            allowing(selectedMailbox).getLastUid(); will(returnValue(Long.MAX_VALUE));
+            oneOf(selectedMailbox).uid(with(equal(1)));will(returnValue(Optional.of(MessageUid.of(42L))));
+            oneOf(selectedMailbox).uid(with(equal(5)));will(returnValue(Optional.of(MessageUid.of(1729L))));
+            allowing(selectedMailbox).getFirstUid(); will(returnValue(Optional.of(MessageUid.of(1L))));
+            allowing(selectedMailbox).getLastUid(); will(returnValue(Optional.of(MessageUid.MAX_VALUE)));
         }});
         allowUnsolicitedResponses();
         check(SearchKey.buildSequenceSet(ids), SearchQuery.uid(ranges));
@@ -188,11 +192,10 @@ public class SearchProcessorTest {
     public void testSequenceSetSingleMsn() throws Exception {
         expectsGetSelectedMailbox();
         final IdRange[] ids = { new IdRange(1) };
-        final SearchQuery.NumericRange[] ranges = { new SearchQuery.NumericRange(
-                42) };
+        final SearchQuery.UidRange[] ranges = { new SearchQuery.UidRange(MessageUid.of(42)) };
         mockery.checking(new Expectations() {{
         	allowing(selectedMailbox).existsCount();will(returnValue(1L));
-            exactly(2).of(selectedMailbox).uid(with(equal(1)));will(returnValue(42L));
+            exactly(2).of(selectedMailbox).uid(with(equal(1)));will(returnValue(Optional.of(MessageUid.of(42L))));
         }});
         allowUnsolicitedResponses();
         check(SearchKey.buildSequenceSet(ids), SearchQuery.uid(ranges));
@@ -215,7 +218,7 @@ public class SearchProcessorTest {
             atMost(1).of(selectedMailbox).flagUpdateUids();will(returnValue(Collections.EMPTY_LIST));
             atMost(1).of(selectedMailbox).resetEvents();
             
-            oneOf(selectedMailbox).getRecent();will(returnValue(new ArrayList<Long>()));
+            oneOf(selectedMailbox).getRecent();will(returnValue(new ArrayList<MessageUid>()));
         }});
     }
 
@@ -427,8 +430,8 @@ public class SearchProcessorTest {
     public void testUID() throws Exception {
     	mockery.checking(new Expectations() {{
 
-    		allowing(selectedMailbox).getFirstUid();will(returnValue(1L));
-    		allowing(selectedMailbox).getLastUid();will(returnValue(1048L));
+    		allowing(selectedMailbox).getFirstUid();will(returnValue(Optional.of(MessageUid.of(1))));
+    		allowing(selectedMailbox).getLastUid();will(returnValue(Optional.of(MessageUid.of(1048))));
             allowing(selectedMailbox).existsCount();will(returnValue(1L));
 
             }});
@@ -496,7 +499,7 @@ public class SearchProcessorTest {
             oneOf(mailbox).search(
                     with(equal(query)),
                     with(equal(mailboxSession)));will(
-                            returnValue(new ArrayList<Long>().iterator()));
+                            returnValue(new ArrayList<MessageUid>().iterator()));
             oneOf(responder).respond(with(equal(new SearchResponse(EMPTY, null))));
             allowing(selectedMailbox).getApplicableFlags(); will(returnValue(new Flags()));
             allowing(selectedMailbox).hasNewApplicableFlags(); will(returnValue(false));

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
index 7b7f7a2..6f0a15a 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java
@@ -26,35 +26,31 @@ import javax.mail.Flags;
 
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageMetaData;
 
 public class FakeMailboxListenerAdded extends MailboxListener.Added {
 
-    public List<Long> uids;
+    public List<MessageUid> uids;
 
-    public FakeMailboxListenerAdded(MailboxSession session, List<Long> uids, MailboxPath path) {
+    public FakeMailboxListenerAdded(MailboxSession session, List<MessageUid> uids, MailboxPath path) {
         super(session, path);
         this.uids = uids;
     }
 
-    /**
-     * @see org.apache.james.mailbox.MailboxListener.MessageEvent#getUids()
-     */
-    public List<Long> getUids() {
+    @Override
+    public List<MessageUid> getUids() {
         return uids;
     }
 
-
-    /**
-     * @see org.apache.james.mailbox.MailboxListener.Added#getMetaData(long)
-     */
-    public MessageMetaData getMetaData(long uid) {
+    @Override
+    public MessageMetaData getMetaData(MessageUid uid) {
         return new MessageMetaData() {
             
-            public long getUid() {
+            public MessageUid getUid() {
                 // TODO Auto-generated method stub
-                return 0;
+                return null;
             }
             
             public long getSize() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java
index ba7de3a..38e5588 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java
@@ -23,16 +23,17 @@ import java.util.List;
 
 import org.apache.james.mailbox.MailboxListener.FlagsUpdated;
 import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.UpdatedFlags;
 
 public class FakeMailboxListenerFlagsUpdate extends FlagsUpdated {
 
-    public List<Long> uids;
+    public List<MessageUid> uids;
 
     public List<UpdatedFlags> flags;
 
-    public FakeMailboxListenerFlagsUpdate(MailboxSession session, List<Long> uids, List<UpdatedFlags> flags, MailboxPath path) {
+    public FakeMailboxListenerFlagsUpdate(MailboxSession session, List<MessageUid> uids, List<UpdatedFlags> flags, MailboxPath path) {
         super(session, path);
         this.uids = uids;
         this.flags = flags;
@@ -45,10 +46,8 @@ public class FakeMailboxListenerFlagsUpdate extends FlagsUpdated {
         return flags;
     }
 
-    /**
-     * @see org.apache.james.mailbox.MailboxListener.MessageEvent#getUids()
-     */
-    public List<Long> getUids() {
+    @Override
+    public List<MessageUid> getUids() {
         return uids;
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
index 39bcb27..48aa27b 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
@@ -47,6 +47,7 @@ import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.BadCredentialsException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Content;
@@ -183,26 +184,27 @@ public class MailboxEventAnalyserTest {
                     return false;
                 }
 
-                
-                public Iterator<Long> search(SearchQuery searchQuery, MailboxSession mailboxSession) throws MailboxException {
+                @Override
+                public Iterator<MessageUid> search(SearchQuery searchQuery, MailboxSession mailboxSession) throws MailboxException {
                     throw new UnsupportedOperationException("Not implemented");
 
                 }
 
-                
-                public Iterator<Long> expunge(MessageRange set, MailboxSession mailboxSession) throws MailboxException {
+                @Override
+                public Iterator<MessageUid> expunge(MessageRange set, MailboxSession mailboxSession) throws MailboxException {
                     throw new UnsupportedOperationException("Not implemented");
 
                 }
 
                 
-                public Map<Long, Flags> setFlags(Flags flags, FlagsUpdateMode mode, MessageRange set, MailboxSession mailboxSession) throws MailboxException {
+                @Override
+                public Map<MessageUid, Flags> setFlags(Flags flags, FlagsUpdateMode mode, MessageRange set, MailboxSession mailboxSession) throws MailboxException {
                     throw new UnsupportedOperationException("Not implemented");
 
                 }
 
                 
-                public long appendMessage(InputStream msgIn, Date internalDate, MailboxSession mailboxSession, boolean isRecent, Flags flags) throws MailboxException {
+                public MessageUid appendMessage(InputStream msgIn, Date internalDate, MailboxSession mailboxSession, boolean isRecent, Flags flags) throws MailboxException {
                     throw new UnsupportedOperationException("Not implemented");
 
                 }
@@ -226,9 +228,9 @@ public class MailboxEventAnalyserTest {
                                     return 0;
                                 }
 
-                                
-                                public long getUid() {
-                                    return 1;
+                                @Override
+                                public MessageUid getUid() {
+                                    return MessageUid.of(1);
                                 }
 
                                 
@@ -410,7 +412,7 @@ public class MailboxEventAnalyserTest {
         }
 
         @Override
-        public Map<MailboxId, Collection<Long>> search(MultimailboxesSearchQuery expression, MailboxSession session) throws MailboxException {
+        public Map<MailboxId, Collection<MessageUid>> search(MultimailboxesSearchQuery expression, MailboxSession session) throws MailboxException {
             return null;
         }
 
@@ -598,7 +600,7 @@ public class MailboxEventAnalyserTest {
         
         SelectedMailboxImpl analyser = new SelectedMailboxImpl(mockManager, imapsession, mailboxPath);
         
-        analyser.event(new FakeMailboxListenerAdded(mSession, Arrays.asList(11L), mailboxPath));
+        analyser.event(new FakeMailboxListenerAdded(mSession, Arrays.asList(MessageUid.of(11)), mailboxPath));
         assertTrue(analyser.isSizeChanged());
     }
 
@@ -610,7 +612,7 @@ public class MailboxEventAnalyserTest {
         
         SelectedMailboxImpl analyser = new SelectedMailboxImpl(mockManager, imapsession, mailboxPath);
         
-        analyser.event(new FakeMailboxListenerAdded(mSession,  Arrays.asList(11L), mailboxPath));
+        analyser.event(new FakeMailboxListenerAdded(mSession,  Arrays.asList(MessageUid.of(11)), mailboxPath));
         analyser.resetEvents();
         assertFalse(analyser.isSizeChanged());
     }
@@ -624,7 +626,7 @@ public class MailboxEventAnalyserTest {
         SelectedMailboxImpl analyser = new SelectedMailboxImpl(mockManager, imapsession, mailboxPath);
         
         final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(
-                mSession,  Arrays.asList(90L),  Arrays.asList(new UpdatedFlags(90, -1, new Flags(), new Flags())), mailboxPath);
+                mSession,  Arrays.asList(MessageUid.of(90L)),  Arrays.asList(new UpdatedFlags(MessageUid.of(90), -1, new Flags(), new Flags())), mailboxPath);
         analyser.event(update);
         assertNotNull(analyser.flagUpdateUids());
         assertFalse(analyser.flagUpdateUids().iterator().hasNext());
@@ -632,7 +634,7 @@ public class MailboxEventAnalyserTest {
 
     @Test
     public void testShouldSetUidWhenSystemFlagChange() throws Exception {
-        final long uid = 900L;
+        final MessageUid uid = MessageUid.of(900);
         MyMailboxSession mSession = new MyMailboxSession(11);
         
         MyImapSession imapsession = new MyImapSession(mSession);
@@ -642,16 +644,16 @@ public class MailboxEventAnalyserTest {
         final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(
                 new MyMailboxSession(41), Arrays.asList(uid), Arrays.asList(new UpdatedFlags(uid, -1, new Flags(), new Flags(Flags.Flag.ANSWERED))), mailboxPath);
         analyser.event(update);
-        final Iterator<Long> iterator = analyser.flagUpdateUids().iterator();
+        final Iterator<MessageUid> iterator = analyser.flagUpdateUids().iterator();
         assertNotNull(iterator);
         assertTrue(iterator.hasNext());
-        assertEquals(new Long(uid), iterator.next());
+        assertEquals(uid, iterator.next());
         assertFalse(iterator.hasNext());
     }
 
     @Test
     public void testShouldClearFlagUidsUponReset() throws Exception {
-        final long uid = 900L;
+        final MessageUid uid = MessageUid.of(900);
         MyMailboxSession mSession = new MyMailboxSession(11);
         MyImapSession imapsession = new MyImapSession(mSession);
         SelectedMailboxImpl analyser = new SelectedMailboxImpl(mockManager, imapsession, mailboxPath);
@@ -668,7 +670,7 @@ public class MailboxEventAnalyserTest {
     @Test
     public void testShouldSetUidWhenSystemFlagChangeDifferentSessionInSilentMode()
             throws Exception {
-        final long uid = 900L;
+        final MessageUid uid = MessageUid.of(900);
         
         MyMailboxSession mSession = new MyMailboxSession(11);
         MyImapSession imapsession = new MyImapSession(mSession);
@@ -679,10 +681,10 @@ public class MailboxEventAnalyserTest {
         analyser.event(update);
         analyser.setSilentFlagChanges(true);
         analyser.event(update);
-        final Iterator<Long> iterator = analyser.flagUpdateUids().iterator();
+        final Iterator<MessageUid> iterator = analyser.flagUpdateUids().iterator();
         assertNotNull(iterator);
         assertTrue(iterator.hasNext());
-        assertEquals(new Long(uid), iterator.next());
+        assertEquals(uid, iterator.next());
         assertFalse(iterator.hasNext());
     }
 
@@ -695,11 +697,11 @@ public class MailboxEventAnalyserTest {
         
         
         final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(
-                mSession, Arrays.asList(345L), Arrays.asList(new UpdatedFlags(345, -1, new Flags(), new Flags())), mailboxPath);
+                mSession, Arrays.asList(MessageUid.of(345)), Arrays.asList(new UpdatedFlags(MessageUid.of(345), -1, new Flags(), new Flags())), mailboxPath);
         analyser.event(update);
         analyser.setSilentFlagChanges(true);
         analyser.event(update);
-        final Iterator<Long> iterator = analyser.flagUpdateUids().iterator();
+        final Iterator<MessageUid> iterator = analyser.flagUpdateUids().iterator();
         assertNotNull(iterator);
         assertFalse(iterator.hasNext());
     }
@@ -712,9 +714,9 @@ public class MailboxEventAnalyserTest {
         
         
         final FakeMailboxListenerFlagsUpdate update = new FakeMailboxListenerFlagsUpdate(
-                mSession, Arrays.asList(886L), Arrays.asList(new UpdatedFlags(886, -1, new Flags(), new Flags(Flags.Flag.RECENT))), mailboxPath);
+                mSession, Arrays.asList(MessageUid.of(886)), Arrays.asList(new UpdatedFlags(MessageUid.of(886), -1, new Flags(), new Flags(Flags.Flag.RECENT))), mailboxPath);
         analyser.event(update);
-        final Iterator<Long> iterator = analyser.flagUpdateUids().iterator();
+        final Iterator<MessageUid> iterator = analyser.flagUpdateUids().iterator();
         assertNotNull(iterator);
         assertFalse(iterator.hasNext());
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/protocols/pom.xml
----------------------------------------------------------------------
diff --git a/protocols/pom.xml b/protocols/pom.xml
index 2d750ad..d9285ec 100644
--- a/protocols/pom.xml
+++ b/protocols/pom.xml
@@ -257,6 +257,11 @@
                 <artifactId>mockito-core</artifactId>
                 <version>${mockito-core.version}</version>
             </dependency>
+            <dependency>
+            <groupId>nl.jqno.equalsverifier</groupId>
+                <artifactId>equalsverifier</artifactId>
+                <version>1.7.6</version>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
index f2a859b..013a23f 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/GetMessageListMethod.java
@@ -43,6 +43,7 @@ import org.apache.james.jmap.utils.SortToComparatorConvertor;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.FetchGroupImpl;
@@ -117,7 +118,7 @@ public class GetMessageListMethod implements Method {
         GetMessageListResponse.Builder builder = GetMessageListResponse.builder();
         try {
             MultimailboxesSearchQuery searchQuery = convertToSearchQuery(messageListRequest);
-            Map<MailboxId, Collection<Long>> searchResults = mailboxManager.search(searchQuery, mailboxSession);
+            Map<MailboxId, Collection<MessageUid>> searchResults = mailboxManager.search(searchQuery, mailboxSession);
             
             aggregateResults(mailboxSession, searchResults).entries().stream()
                 .sorted(comparatorFor(messageListRequest))
@@ -132,9 +133,9 @@ public class GetMessageListMethod implements Method {
         }
     }
 
-    private Multimap<MailboxPath, MessageResult> aggregateResults(MailboxSession mailboxSession, Map<MailboxId, Collection<Long>> searchResults) {
+    private Multimap<MailboxPath, MessageResult> aggregateResults(MailboxSession mailboxSession, Map<MailboxId, Collection<MessageUid>> searchResults) {
         Multimap<MailboxPath, MessageResult> messages = LinkedHashMultimap.create();
-        for (Map.Entry<MailboxId, Collection<Long>> mailboxResults: searchResults.entrySet()) {
+        for (Map.Entry<MailboxId, Collection<MessageUid>> mailboxResults: searchResults.entrySet()) {
             try {
                 aggregate(mailboxSession, messages, mailboxResults);
             } catch (MailboxException e) {
@@ -145,7 +146,7 @@ public class GetMessageListMethod implements Method {
         return messages;
     }
 
-    private void aggregate(MailboxSession mailboxSession, Multimap<MailboxPath, MessageResult> aggregation, Map.Entry<MailboxId, Collection<Long>> mailboxResults) throws MailboxNotFoundException, MailboxException {
+    private void aggregate(MailboxSession mailboxSession, Multimap<MailboxPath, MessageResult> aggregation, Map.Entry<MailboxId, Collection<MessageUid>> mailboxResults) throws MailboxNotFoundException, MailboxException {
         MailboxPath mailboxPath = mailboxManager.getMailbox(mailboxResults.getKey(), mailboxSession).getMailboxPath();
         MessageManager messageManager = getMessageManager(mailboxPath, mailboxSession)
             .orElseThrow(() -> new MailboxNotFoundException(mailboxPath));

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
index f270673..93eaca9 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMessagesCreationProcessor.java
@@ -58,6 +58,7 @@ import org.apache.james.lifecycle.api.LifecycleUtil;
 import org.apache.james.mailbox.AttachmentManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.AttachmentNotFoundException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
@@ -281,7 +282,7 @@ public class SetMessagesCreationProcessor implements SetMessagesProcessor {
         Date internalDate = Date.from(createdEntry.getValue().getDate().toInstant());
         Flags flags = getMessageFlags(createdEntry.getValue());
 
-        long uid = outbox.appendMessage(content, internalDate, session, flags.contains(Flags.Flag.RECENT), flags);
+        MessageUid uid = outbox.appendMessage(content, internalDate, session, flags.contains(Flags.Flag.RECENT), flags);
 
         return MetaDataWithContent.builder()
                 .uid(uid)

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageFactory.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageFactory.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageFactory.java
index fe090ce..125c680 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageFactory.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageFactory.java
@@ -36,6 +36,7 @@ import javax.mail.Flags;
 import javax.mail.internet.SharedInputStream;
 
 import org.apache.james.jmap.model.MessageContentExtractor.MessageContent;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.Cid;
 import org.apache.james.mailbox.model.MailboxId;
@@ -74,7 +75,7 @@ public class MessageFactory {
 
         return Message.builder()
                 .id(message.getMessageId())
-                .blobId(BlobId.of(String.valueOf(message.getUid())))
+                .blobId(BlobId.of(String.valueOf(message.getUid().asLong())))
                 .threadId(message.getMessageId().serialize())
                 .mailboxIds(ImmutableList.of(message.getMailboxId()))
                 .inReplyToMessageId(getHeader(mimeMessage, "in-reply-to"))
@@ -217,7 +218,7 @@ public class MessageFactory {
         }
         
         public static class Builder {
-            private Long uid;
+            private MessageUid uid;
             private Long modSeq;
             private Flags flags;
             private Long size;
@@ -228,7 +229,7 @@ public class MessageFactory {
             private MailboxId mailboxId;
             private MessageId messageId;
 
-            public Builder uid(long uid) {
+            public Builder uid(MessageUid uid) {
                 this.uid = uid;
                 return this;
             }
@@ -294,7 +295,7 @@ public class MessageFactory {
             }
         }
 
-        private final long uid;
+        private final MessageUid uid;
         private final long modSeq;
         private final Flags flags;
         private final long size;
@@ -305,7 +306,7 @@ public class MessageFactory {
         private final MailboxId mailboxId;
         private final MessageId messageId;
 
-        private MetaDataWithContent(long uid, long modSeq, Flags flags, long size, Date internalDate, InputStream content, SharedInputStream sharedContent, List<MessageAttachment> attachments, MailboxId mailboxId, MessageId messageId) {
+        private MetaDataWithContent(MessageUid uid, long modSeq, Flags flags, long size, Date internalDate, InputStream content, SharedInputStream sharedContent, List<MessageAttachment> attachments, MailboxId mailboxId, MessageId messageId) {
             this.uid = uid;
             this.modSeq = modSeq;
             this.flags = flags;
@@ -319,7 +320,7 @@ public class MessageFactory {
         }
 
         @Override
-        public long getUid() {
+        public MessageUid getUid() {
             return uid;
         }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageId.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageId.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageId.java
index 117124c..6f0c9c1 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageId.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/MessageId.java
@@ -20,6 +20,7 @@ package org.apache.james.jmap.model;
 
 import java.util.Objects;
 
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.MailboxSession.User;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxPath;
@@ -40,21 +41,21 @@ public class MessageId {
     @JsonCreator
     public static MessageId of(String id) {
         Triplet<String, String, String> parts = Triplet.fromIterable(Splitter.on(SEPARATOR).split(id));
-        return new MessageId(parts.getValue0(), parts.getValue1(), Long.valueOf(parts.getValue2()));
+        return new MessageId(parts.getValue0(), parts.getValue1(), MessageUid.of(Long.valueOf(parts.getValue2())));
     }
 
     private final String mailboxPath;
-    private final long uid;
+    private final MessageUid uid;
     private final String username;
 
-    public MessageId(User username, MailboxPath mailboxPath, long uid) {
+    public MessageId(User username, MailboxPath mailboxPath, MessageUid uid) {
         this.username = username.getUserName();
         this.mailboxPath = mailboxPath.getName();
         this.uid = uid;
     }
     
     @VisibleForTesting
-    MessageId(String username, String mailboxPath, long uid) {
+    MessageId(String username, String mailboxPath, MessageUid uid) {
         this.username = username;
         this.mailboxPath = mailboxPath;
         this.uid = uid;
@@ -64,7 +65,7 @@ public class MessageId {
         return username;
     }
     
-    public long getUid() {
+    public MessageUid getUid() {
         return uid;
     }
     
@@ -78,7 +79,7 @@ public class MessageId {
     
     @JsonValue
     public String serialize() {
-        return Joiner.on(SEPARATOR).join(username, mailboxPath, uid);
+        return Joiner.on(SEPARATOR).join(username, mailboxPath, uid.asLong());
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
index f7ea5e9..f1e00d9 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
@@ -28,6 +28,7 @@ import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.BadCredentialsException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.mock.MockMailboxSession;
@@ -241,7 +242,7 @@ public class FirstUserConnectionFilterThreadTest {
         }
 
         @Override
-        public Map<MailboxId, Collection<Long>> search(MultimailboxesSearchQuery expression, MailboxSession session) throws MailboxException {
+        public Map<MailboxId, Collection<MessageUid>> search(MultimailboxesSearchQuery expression, MailboxSession session) throws MailboxException {
             return null;
         }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
index e9b0bbf..4f4b9e4 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/GetMessagesMethodTest.java
@@ -18,12 +18,13 @@
  ****************************************************************/
 package org.apache.james.jmap.methods;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
 import java.io.ByteArrayInputStream;
 import java.util.Date;
 import java.util.List;
@@ -47,6 +48,7 @@ import org.apache.james.jmap.model.MessageProperties.MessageProperty;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
@@ -154,11 +156,11 @@ public class GetMessagesMethodTest {
         MessageManager inbox = mailboxManager.getMailbox(inboxPath, session);
         Date now = new Date();
         ByteArrayInputStream message1Content = new ByteArrayInputStream("Subject: message 1 subject\r\n\r\nmy message".getBytes(Charsets.UTF_8));
-        long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
+        MessageUid message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         ByteArrayInputStream message2Content = new ByteArrayInputStream("Subject: message 2 subject\r\n\r\nmy message".getBytes(Charsets.UTF_8));
-        long message2Uid = inbox.appendMessage(message2Content, now, session, false, null);
+        MessageUid message2Uid = inbox.appendMessage(message2Content, now, session, false, null);
         ByteArrayInputStream message3Content = new ByteArrayInputStream("Great-Header: message 3 subject\r\n\r\nmy message".getBytes(Charsets.UTF_8));
-        long message3Uid = inbox.appendMessage(message3Content, now, session, false, null);
+        MessageUid message3Uid = inbox.appendMessage(message3Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
                 .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid),
@@ -188,7 +190,7 @@ public class GetMessagesMethodTest {
                 + "Subject: message 1 subject\r\n"
                 + "\r\n"
                 + "my <b>HTML</b> message").getBytes(Charsets.UTF_8));
-        long messageUid = inbox.appendMessage(messageContent, now, session, false, null);
+        MessageUid messageUid = inbox.appendMessage(messageContent, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
                 .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, messageUid)))
@@ -210,7 +212,7 @@ public class GetMessagesMethodTest {
         MessageManager inbox = mailboxManager.getMailbox(inboxPath, session);
         Date now = new Date();
         ByteArrayInputStream message1Content = new ByteArrayInputStream("Subject: message 1 subject\r\n\r\nmy message".getBytes(Charsets.UTF_8));
-        long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
+        MessageUid message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
                 .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))
@@ -231,7 +233,7 @@ public class GetMessagesMethodTest {
         MessageManager inbox = mailboxManager.getMailbox(inboxPath, session);
         Date now = new Date();
         ByteArrayInputStream message1Content = new ByteArrayInputStream("Subject: message 1 subject\r\n\r\nmy message".getBytes(Charsets.UTF_8));
-        long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
+        MessageUid message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
                 .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))
@@ -251,7 +253,7 @@ public class GetMessagesMethodTest {
         MessageManager inbox = mailboxManager.getMailbox(inboxPath, session);
         Date now = new Date();
         ByteArrayInputStream message1Content = new ByteArrayInputStream("Subject: message 1 subject\r\n\r\nmy message".getBytes(Charsets.UTF_8));
-        long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
+        MessageUid message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
                 .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))
@@ -274,7 +276,7 @@ public class GetMessagesMethodTest {
         MessageManager inbox = mailboxManager.getMailbox(inboxPath, session);
         Date now = new Date();
         ByteArrayInputStream message1Content = new ByteArrayInputStream("Subject: message 1 subject\r\n\r\nmy message".getBytes(Charsets.UTF_8));
-        long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
+        MessageUid message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
                 .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))
@@ -300,7 +302,7 @@ public class GetMessagesMethodTest {
                 + "header1: Header1Content\r\n"
                 + "HEADer2: Header2Content\r\n"
                 + "Subject: message 1 subject\r\n\r\nmy message").getBytes(Charsets.UTF_8));
-        long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
+        MessageUid message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
                 .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))
@@ -327,7 +329,7 @@ public class GetMessagesMethodTest {
                 + "header1: Header1Content\r\n"
                 + "HEADer2: Header2Content\r\n"
                 + "Subject: message 1 subject\r\n\r\nmy message").getBytes(Charsets.UTF_8));
-        long message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
+        MessageUid message1Uid = inbox.appendMessage(message1Content, now, session, false, null);
         
         GetMessagesRequest request = GetMessagesRequest.builder()
                 .ids(ImmutableList.of(new MessageId(ROBERT, inboxPath, message1Uid)))

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
index 5a97018..11f500c 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/methods/SetMessagesCreationProcessorTest.java
@@ -57,6 +57,7 @@ import org.apache.james.jmap.utils.SystemMailboxesProvider;
 import org.apache.james.mailbox.AttachmentManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.AttachmentNotFoundException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.InMemoryId;
@@ -128,6 +129,7 @@ public class SetMessagesCreationProcessorTest {
         outbox = mock(MessageManager.class);
         when(outbox.getId()).thenReturn(OUTBOX_ID);
         when(outbox.getMailboxPath()).thenReturn(new MailboxPath(NAMESPACE, USER, OUTBOX));
+        when(outbox.appendMessage(any(InputStream.class), any(Date.class), any(MailboxSession.class), any(Boolean.class), any(Flags.class))).thenReturn(MessageUid.of(1));
         drafts = mock(MessageManager.class);
         when(drafts.getId()).thenReturn(DRAFTS_ID);
         when(drafts.getMailboxPath()).thenReturn(new MailboxPath(NAMESPACE, USER, DRAFTS));

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java
index d489272..9ac47f9 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageFactoryTest.java
@@ -32,6 +32,7 @@ import javax.mail.Flags.Flag;
 import org.apache.commons.io.IOUtils;
 import org.apache.james.jmap.model.MessageFactory.MetaDataWithContent;
 import org.apache.james.jmap.utils.HtmlTextExtractor;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.model.AttachmentId;
 import org.apache.james.mailbox.model.Cid;
@@ -63,7 +64,7 @@ public class MessageFactoryTest {
     @Test
     public void emptyMailShouldBeLoadedIntoMessage() throws Exception {
         MetaDataWithContent testMail = MetaDataWithContent.builder()
-                .uid(2)
+                .uid(MessageUid.of(2))
                 .flags(new Flags(Flag.SEEN))
                 .size(0)
                 .internalDate(INTERNAL_DATE)
@@ -86,7 +87,7 @@ public class MessageFactoryTest {
         flags.add(Flag.FLAGGED);
         flags.add(Flag.DRAFT);
         MetaDataWithContent testMail = MetaDataWithContent.builder()
-                .uid(2)
+                .uid(MessageUid.of(2))
                 .flags(flags)
                 .size(0)
                 .internalDate(INTERNAL_DATE)
@@ -112,7 +113,7 @@ public class MessageFactoryTest {
                 + "In-Reply-To: <SNT124-W2664003139C1E520CF4F6787D30@phx.gbl>\n"
                 + "Other-header: other header value";
         MetaDataWithContent testMail = MetaDataWithContent.builder()
-                .uid(2)
+                .uid(MessageUid.of(2))
                 .flags(new Flags(Flag.SEEN))
                 .size(headers.length())
                 .internalDate(INTERNAL_DATE)
@@ -168,7 +169,7 @@ public class MessageFactoryTest {
         String body = "Mail body";
         String mail = headers + "\n" + body;
         MetaDataWithContent testMail = MetaDataWithContent.builder()
-                .uid(2)
+                .uid(MessageUid.of(2))
                 .flags(new Flags(Flag.SEEN))
                 .size(mail.length())
                 .internalDate(INTERNAL_DATE)
@@ -194,7 +195,7 @@ public class MessageFactoryTest {
         assertThat(expectedPreview.length()).isEqualTo(256);
         String mail = headers + "\n" + body300;
         MetaDataWithContent testMail = MetaDataWithContent.builder()
-                .uid(2)
+                .uid(MessageUid.of(2))
                 .flags(new Flags(Flag.SEEN))
                 .size(mail.length())
                 .internalDate(INTERNAL_DATE)
@@ -210,7 +211,7 @@ public class MessageFactoryTest {
     @Test
     public void attachmentsShouldBeEmptyWhenNone() throws Exception {
         MetaDataWithContent testMail = MetaDataWithContent.builder()
-                .uid(2)
+                .uid(MessageUid.of(2))
                 .flags(new Flags(Flag.SEEN))
                 .size(0)
                 .internalDate(INTERNAL_DATE)
@@ -236,7 +237,7 @@ public class MessageFactoryTest {
                 .isInline(true)
                 .build();
         MetaDataWithContent testMail = MetaDataWithContent.builder()
-                .uid(2)
+                .uid(MessageUid.of(2))
                 .flags(new Flags(Flag.SEEN))
                 .size(0)
                 .internalDate(INTERNAL_DATE)

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageIdTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageIdTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageIdTest.java
index 0e0104e..4c4f2c8 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageIdTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/MessageIdTest.java
@@ -20,6 +20,7 @@ package org.apache.james.jmap.model;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.james.mailbox.MessageUid;
 import org.junit.Test;
 
 public class MessageIdTest {
@@ -55,8 +56,8 @@ public class MessageIdTest {
 
     @Test
     public void ofShouldWorkWhenMessageIdIsWellFormated() {
+        MessageId expected = new MessageId("username", "mailboxpath", MessageUid.of(321));
         String messageId = "username|mailboxpath|321";
-        MessageId expected = new MessageId("username", "mailboxpath", 321);
         
         MessageId actual = MessageId.of(messageId);
         
@@ -66,7 +67,7 @@ public class MessageIdTest {
     @Test
     public void ofShouldWorkWhenOnePartContainsAHyphen() {
         String messageId = "user-name|mailboxpath|321";
-        MessageId expected = new MessageId("user-name", "mailboxpath", 321);
+        MessageId expected = new MessageId("user-name", "mailboxpath", MessageUid.of(321));
         
         MessageId actual = MessageId.of(messageId);
         
@@ -76,7 +77,7 @@ public class MessageIdTest {
     @Test
     public void ofShouldWorkWhenSecondPartContainsAHyphen() {
         String messageId = "username|mailbox-path|321";
-        MessageId expected = new MessageId("username", "mailbox-path", 321);
+        MessageId expected = new MessageId("username", "mailbox-path", MessageUid.of(321));
         
         MessageId actual = MessageId.of(messageId);
         

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
index 4ee494d..68ddadb 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/MailFactoryTest.java
@@ -36,6 +36,7 @@ import org.apache.james.jmap.model.MessageFactory.MetaDataWithContent;
 import org.apache.james.jmap.model.MessageId;
 import org.apache.james.jmap.model.MessagePreviewGenerator;
 import org.apache.james.mailbox.FlagsBuilder;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.mailet.Mail;
@@ -64,7 +65,7 @@ public class MailFactoryTest {
         String content = headers
                 + "Hello! How are you?";
         message = MetaDataWithContent.builder()
-                .uid(2)
+                .uid(MessageUid.of(2))
                 .flags(new FlagsBuilder().add(Flags.Flag.SEEN).build())
                 .size(content.length())
                 .internalDate(new Date())

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/PostDequeueDecoratorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/PostDequeueDecoratorTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/PostDequeueDecoratorTest.java
index cd13e91..ea3bceb 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/PostDequeueDecoratorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/send/PostDequeueDecoratorTest.java
@@ -34,6 +34,7 @@ import org.apache.james.jmap.send.exception.MailShouldBeInOutboxException;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
 import org.apache.james.mailbox.model.FetchGroupImpl;
@@ -54,10 +55,10 @@ public class PostDequeueDecoratorTest {
     private static final String OUTBOX = "OUTBOX";
     private static final String SENT = "SENT";
     private static final String USERNAME = "username@domain.tld";
-    private static final long UID = 1;
+    private static final MessageUid UID = MessageUid.of(1);
     private static final MailboxPath OUTBOX_MAILBOX_PATH = new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, OUTBOX);
     private static final MailboxPath SENT_MAILBOX_PATH = new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, SENT);
-    private static final String MESSAGE_ID = USERNAME + "|" + OUTBOX_MAILBOX_PATH.getName() + "|" + UID;
+    private static final String MESSAGE_ID = USERNAME + "|" + OUTBOX_MAILBOX_PATH.getName() + "|" + UID.asLong();
     
     private MailboxManager mailboxManager;
     private MailQueueItem mockedMailQueueItem;
@@ -93,7 +94,7 @@ public class PostDequeueDecoratorTest {
         mailboxManager.createMailbox(SENT_MAILBOX_PATH, mailboxSession);
         MessageManager messageManager = mailboxManager.getMailbox(SENT_MAILBOX_PATH, mailboxSession);
         messageManager.appendMessage(new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), mailboxSession, false, new Flags());
-        MessageId inSentMessageId = MessageId.of(USERNAME + "|" + SENT_MAILBOX_PATH.getName() + "|" + UID);
+        MessageId inSentMessageId = MessageId.of(USERNAME + "|" + SENT_MAILBOX_PATH.getName() + "|" + UID.asLong());
         mail.setAttribute(MailMetadata.MAIL_METADATA_MESSAGE_ID_ATTRIBUTE, inSentMessageId.serialize());
         mail.setAttribute(MailMetadata.MAIL_METADATA_USERNAME_ATTRIBUTE, USERNAME);
         

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortToComparatorConvertorTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortToComparatorConvertorTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortToComparatorConvertorTest.java
index 5290a10..e8665f3 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortToComparatorConvertorTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/utils/SortToComparatorConvertorTest.java
@@ -30,6 +30,7 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageResult;
 import org.junit.Before;
@@ -51,11 +52,11 @@ public class SortToComparatorConvertorTest {
     public void setup() throws IOException {
         MessageResult firstMessageResult = mock(MessageResult.class);
         when(firstMessageResult.getInternalDate()).thenReturn(DATE_2017);
-        when(firstMessageResult.getUid()).thenReturn(1L);
+        when(firstMessageResult.getUid()).thenReturn(MessageUid.of(1));
         firstMessage = new Entry(mailboxPath, firstMessageResult);
         MessageResult secondMessageResult = mock(MessageResult.class);
         when(secondMessageResult.getInternalDate()).thenReturn(DATE_2018);
-        when(secondMessageResult.getUid()).thenReturn(2L);
+        when(secondMessageResult.getUid()).thenReturn(MessageUid.of(2));
         secondMessage = new Entry(mailboxPath, secondMessageResult);
         messages = Lists.newArrayList(firstMessage, secondMessage);
     }
@@ -92,7 +93,7 @@ public class SortToComparatorConvertorTest {
     public void comparatorForShouldChainComparatorsWhenOnlyMultipleElementInList() throws IOException {
         MessageResult thirdMessageResult = mock(MessageResult.class);
         when(thirdMessageResult.getInternalDate()).thenReturn(DATE_2018);
-        when(thirdMessageResult.getUid()).thenReturn(3L);
+        when(thirdMessageResult.getUid()).thenReturn(MessageUid.of(3));
         Entry thirdMessage = new Entry(mailboxPath, thirdMessageResult);
         messages.add(thirdMessage);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/34242a5b/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/mailbox/MailboxAdapter.java
----------------------------------------------------------------------
diff --git a/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/mailbox/MailboxAdapter.java b/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/mailbox/MailboxAdapter.java
index f018009..75ce1c1 100644
--- a/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/mailbox/MailboxAdapter.java
+++ b/server/protocols/protocols-pop3/src/main/java/org/apache/james/pop3server/mailbox/MailboxAdapter.java
@@ -32,6 +32,7 @@ import javax.mail.Flags;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.model.MessageResult;
@@ -97,7 +98,7 @@ public class MailboxAdapter implements Mailbox {
     public InputStream getMessageBody(String uid) throws IOException {
         try {
             mailboxManager.startProcessingRequest(session);
-            Iterator<MessageResult> results = manager.getMessages(MessageRange.one(new Long(uid)), BODY_GROUP, session);
+            Iterator<MessageResult> results = manager.getMessages(MessageUid.of(Long.valueOf(uid)).toRange(), BODY_GROUP, session);
             if (results.hasNext()) {
                 return results.next().getBody().getInputStream();
             } else {
@@ -114,7 +115,7 @@ public class MailboxAdapter implements Mailbox {
     public InputStream getMessageHeaders(String uid) throws IOException {
         try {
             mailboxManager.startProcessingRequest(session);
-            Iterator<MessageResult> results = manager.getMessages(MessageRange.one(new Long(uid)), HEADERS_GROUP,
+            Iterator<MessageResult> results = manager.getMessages(MessageUid.of(Long.valueOf(uid)).toRange(), HEADERS_GROUP,
                     session);
             if (results.hasNext()) {
                 return results.next().getHeaders().getInputStream();
@@ -132,7 +133,7 @@ public class MailboxAdapter implements Mailbox {
     public InputStream getMessage(String uid) throws IOException {
         try {
             mailboxManager.startProcessingRequest(session);
-            Iterator<MessageResult> results = manager.getMessages(MessageRange.one(new Long(uid)), FULL_GROUP, session);
+            Iterator<MessageResult> results = manager.getMessages(MessageUid.of(Long.valueOf(uid)).toRange(), FULL_GROUP, session);
             if (results.hasNext()) {
                 return results.next().getFullContent().getInputStream();
             } else {
@@ -153,7 +154,7 @@ public class MailboxAdapter implements Mailbox {
             List<MessageMetaData> mList = new ArrayList<MessageMetaData>();
             while (results.hasNext()) {
                 MessageResult result = results.next();
-                MessageMetaData metaData = new MessageMetaData(Long.toString(result.getUid()), result.getSize());
+                MessageMetaData metaData = new MessageMetaData(String.valueOf(result.getUid().asLong()), result.getSize());
                 mList.add(metaData);
             }
             return Collections.unmodifiableList(mList);
@@ -166,10 +167,10 @@ public class MailboxAdapter implements Mailbox {
 
     @Override
     public void remove(String... uids) throws IOException {
-        List<Long> uidList = new ArrayList<Long>();
+        List<MessageUid> uidList = new ArrayList<MessageUid>();
 
         for (String uid : uids) {
-            uidList.add(new Long(uid));
+            uidList.add(MessageUid.of(Long.valueOf(uid)));
         }
 
         List<MessageRange> ranges = MessageRange.toRanges(uidList);


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