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 [3/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/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java (original)
+++ james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapperTest.java Mon Jun 29 08:21:12 2015
@@ -15,13 +15,31 @@
  */
 package org.apache.james.mailbox.hbase.mail;
 
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES_TABLE;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_META_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_TABLE;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_BODY_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_HEADERS_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS;
+import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS_TABLE;
+import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
+import static org.apache.james.mailbox.hbase.HBaseUtils.mailboxFromResult;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.UUID;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTable;
@@ -30,15 +48,12 @@ import org.apache.hadoop.hbase.util.Byte
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.hbase.HBaseClusterSingleton;
-import static org.apache.james.mailbox.hbase.HBaseNames.*;
-import static org.apache.james.mailbox.hbase.HBaseUtils.mailboxFromResult;
-import static org.apache.james.mailbox.hbase.HBaseUtils.mailboxRowKey;
+import org.apache.james.mailbox.hbase.HBaseId;
 import org.apache.james.mailbox.hbase.io.ChunkInputStream;
 import org.apache.james.mailbox.hbase.io.ChunkOutputStream;
 import org.apache.james.mailbox.hbase.mail.model.HBaseMailbox;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-import static org.junit.Assert.*;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -125,7 +140,7 @@ public class HBaseMailboxMapperTest {
         LOG.info("findMailboxWithPathLike");
         MailboxPath path = pathsList.get(pathsList.size() / 2);
 
-        List<Mailbox<UUID>> result = mapper.findMailboxWithPathLike(path);
+        List<Mailbox<HBaseId>> result = mapper.findMailboxWithPathLike(path);
         assertEquals(1, result.size());
 
         int start = 3;
@@ -150,7 +165,7 @@ public class HBaseMailboxMapperTest {
      */
     private void testList() throws Exception {
         LOG.info("list");
-        List<Mailbox<UUID>> result = mapper.list();
+        List<Mailbox<HBaseId>> result = mapper.list();
         assertEquals(mailboxList.size(), result.size());
 
     }
@@ -164,7 +179,7 @@ public class HBaseMailboxMapperTest {
 
         final HBaseMailbox mlbx = mailboxList.get(mailboxList.size() / 2);
 
-        final Get get = new Get(mailboxRowKey(mlbx.getMailboxId()));
+        final Get get = new Get(mlbx.getMailboxId().toBytes());
         // get all columns for the DATA column family
         get.addFamily(MAILBOX_CF);
 
@@ -178,7 +193,7 @@ public class HBaseMailboxMapperTest {
         assertEquals(mlbx.getLastUid(), newValue.getLastUid());
         assertEquals(mlbx.getUidValidity(), newValue.getUidValidity());
         assertEquals(mlbx.getHighestModSeq(), newValue.getHighestModSeq());
-        assertArrayEquals(mailboxRowKey(mlbx.getMailboxId()), mailboxRowKey(newValue.getMailboxId()));
+        assertArrayEquals(mlbx.getMailboxId().toBytes(), newValue.getMailboxId().toBytes());
     }
 
     /**

Modified: james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMessageMapperTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMessageMapperTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMessageMapperTest.java (original)
+++ james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/HBaseMessageMapperTest.java Mon Jun 29 08:21:12 2015
@@ -18,16 +18,34 @@
  ****************************************************************/
 package org.apache.james.mailbox.hbase.mail;
 
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOXES_TABLE;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_META_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_TABLE;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_BODY_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_DATA_HEADERS_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS;
+import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTIONS_TABLE;
+import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
+import static org.junit.Assert.assertEquals;
+
 import java.io.IOException;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Random;
+
 import javax.mail.Flags;
 import javax.mail.internet.SharedInputStream;
 import javax.mail.util.SharedByteArrayInputStream;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.hbase.HBaseClusterSingleton;
-import static org.apache.james.mailbox.hbase.HBaseNames.*;
+import org.apache.james.mailbox.hbase.HBaseId;
 import org.apache.james.mailbox.hbase.mail.model.HBaseMailbox;
 import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.model.MailboxPath;
@@ -35,7 +53,6 @@ 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.PropertyBuilder;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMessage;
-import static org.junit.Assert.assertEquals;
 import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -53,8 +70,8 @@ public class HBaseMessageMapperTest {
     private static HBaseModSeqProvider modSeqProvider;
     private static HBaseMessageMapper messageMapper;
     private static final List<MailboxPath> MBOX_PATHS = new ArrayList<MailboxPath>();
-    private static final List<Mailbox<UUID>> MBOXES = new ArrayList<Mailbox<UUID>>();
-    private static final List<Message<UUID>> MESSAGE_NO = new ArrayList<Message<UUID>>();
+    private static final List<Mailbox<HBaseId>> MBOXES = new ArrayList<Mailbox<HBaseId>>();
+    private static final List<Message<HBaseId>> MESSAGE_NO = new ArrayList<Message<HBaseId>>();
     private static final int COUNT = 5;
     private static Configuration conf;
     /*
@@ -120,12 +137,12 @@ public class HBaseMessageMapperTest {
         propBuilder.setSubType("html");
         propBuilder.setTextualLineCount(2L);
 
-        SimpleMessage<UUID> myMsg;
+        SimpleMessage<HBaseId> myMsg;
         final Flags flags = new Flags(Flags.Flag.RECENT);
         final Date today = new Date();
 
         for (int i = 0; i < COUNT * 2; i++) {
-            myMsg = new SimpleMessage<UUID>(today, messageTemplate.length,
+            myMsg = new SimpleMessage<HBaseId>(today, messageTemplate.length,
                     messageTemplate.length - 20, content, flags, propBuilder,
                     MBOXES.get(1).getMailboxId());
             if (i == COUNT * 2 - 1) {

Modified: james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailboxTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailboxTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailboxTest.java (original)
+++ james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailboxTest.java Mon Jun 29 08:21:12 2015
@@ -18,9 +18,12 @@
  ****************************************************************/
 package org.apache.james.mailbox.hbase.mail.model;
 
+import static org.junit.Assert.assertEquals;
+
 import java.util.UUID;
+
+import org.apache.james.mailbox.hbase.HBaseId;
 import org.apache.james.mailbox.model.MailboxPath;
-import static org.junit.Assert.assertEquals;
 import org.junit.Test;
 
 /**
@@ -37,7 +40,7 @@ public class HBaseMailboxTest {
         final MailboxPath mailboxPath = new MailboxPath("gsoc", "ieugen", "INBOX");
         final HBaseMailbox instance = new HBaseMailbox(mailboxPath, 10);
 
-        UUID expResult = UUID.randomUUID();
+        HBaseId expResult = HBaseId.of(UUID.randomUUID());
         instance.setMailboxId(expResult);
         assertEquals(expResult, instance.getMailboxId());
 
@@ -114,8 +117,8 @@ public class HBaseMailboxTest {
         // from the hashCode()
         final int PRIME = 31;
         int result = 1;
-        UUID mailboxId = instance.getMailboxId();
-        int expResult = PRIME * result + (int) (mailboxId.getMostSignificantBits() ^ (mailboxId.getMostSignificantBits() >>> 32));
+        HBaseId mailboxId = instance.getMailboxId();
+        int expResult = PRIME * result + (int) (mailboxId.getRawId().getMostSignificantBits() ^ (mailboxId.getRawId().getMostSignificantBits() >>> 32));
 
         assertEquals(expResult, instance.hashCode());
     }

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

Modified: james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java (original)
+++ james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxManager.java Mon Jun 29 08:21:12 2015
@@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory;
  * JCR implementation of a MailboxManager
  * 
  */
-public class JCRMailboxManager extends StoreMailboxManager<String> implements JCRImapConstants {
+public class JCRMailboxManager extends StoreMailboxManager<JCRId> implements JCRImapConstants {
 
     private final Logger logger = LoggerFactory.getLogger(JCRMailboxManager.class);
     
@@ -51,12 +51,12 @@ public class JCRMailboxManager extends S
 
     
     @Override
-    protected StoreMessageManager<String> createMessageManager(Mailbox<String> mailboxEntity, MailboxSession session) throws MailboxException{
+    protected StoreMessageManager<JCRId> createMessageManager(Mailbox<JCRId> mailboxEntity, MailboxSession session) throws MailboxException{
         return new JCRMessageManager(getMapperFactory(), getMessageSearchIndex(), getEventDispatcher(), getLocker(), (JCRMailbox) mailboxEntity, getAclResolver(), getGroupMembershipResolver(), logger, getDelimiter());
     }
 
     @Override
-    protected Mailbox<String> doCreateMailbox(MailboxPath path, MailboxSession session) throws MailboxException {
+    protected Mailbox<JCRId> doCreateMailbox(MailboxPath path, MailboxSession session) throws MailboxException {
         return new org.apache.james.mailbox.jcr.mail.model.JCRMailbox(path, randomUidValidity(), logger);
     }
 

Modified: james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java (original)
+++ james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMailboxSessionMapperFactory.java Mon Jun 29 08:21:12 2015
@@ -36,20 +36,20 @@ import org.apache.james.mailbox.store.us
  * 
  *
  */
-public class JCRMailboxSessionMapperFactory extends MailboxSessionMapperFactory<String> {
+public class JCRMailboxSessionMapperFactory extends MailboxSessionMapperFactory<JCRId> {
 
     private final MailboxSessionJCRRepository repository;
     private final static int DEFAULT_SCALING = 2;
     private final int scaling;
     private int messageScaling;
-    private UidProvider<String> uidProvider;
-    private ModSeqProvider<String> modSeqProvider;
+    private UidProvider<JCRId> uidProvider;
+    private ModSeqProvider<JCRId> modSeqProvider;
 
-    public JCRMailboxSessionMapperFactory(final MailboxSessionJCRRepository repository, final UidProvider<String> uidProvider, final ModSeqProvider<String> modSeqProvider) {
+    public JCRMailboxSessionMapperFactory(final MailboxSessionJCRRepository repository, final UidProvider<JCRId> uidProvider, final ModSeqProvider<JCRId> modSeqProvider) {
         this(repository, uidProvider, modSeqProvider, DEFAULT_SCALING, JCRMessageMapper.MESSAGE_SCALE_DAY);
     }
 
-    public JCRMailboxSessionMapperFactory(final MailboxSessionJCRRepository repository,  final UidProvider<String> uidProvider, final ModSeqProvider<String> modSeqProvider, final int scaling, final int messageScaling) {
+    public JCRMailboxSessionMapperFactory(final MailboxSessionJCRRepository repository,  final UidProvider<JCRId> uidProvider, final ModSeqProvider<JCRId> modSeqProvider, final int scaling, final int messageScaling) {
         this.repository = repository;
         this.scaling = scaling;
         this.messageScaling = messageScaling;
@@ -58,13 +58,13 @@ public class JCRMailboxSessionMapperFact
     }
     
     @Override
-    public MailboxMapper<String> createMailboxMapper(MailboxSession session) throws MailboxException {
+    public MailboxMapper<JCRId> createMailboxMapper(MailboxSession session) throws MailboxException {
         JCRMailboxMapper mapper = new JCRMailboxMapper(repository, session, scaling);
         return mapper;
     }
 
     @Override
-    public MessageMapper<String> createMessageMapper(MailboxSession session) throws MailboxException {
+    public MessageMapper<JCRId> createMessageMapper(MailboxSession session) throws MailboxException {
         JCRMessageMapper messageMapper = new JCRMessageMapper(repository, session, uidProvider, modSeqProvider,  messageScaling);
         return messageMapper;
     }

Modified: james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMessageManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMessageManager.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMessageManager.java (original)
+++ james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/JCRMessageManager.java Mon Jun 29 08:21:12 2015
@@ -42,20 +42,20 @@ import org.slf4j.Logger;
  * JCR implementation of a {@link org.apache.james.mailbox.MessageManager}
  *
  */
-public class JCRMessageManager extends StoreMessageManager<String> {
+public class JCRMessageManager extends StoreMessageManager<JCRId> {
 
     private final Logger log;
 
-    public JCRMessageManager(MailboxSessionMapperFactory<String> mapperFactory, MessageSearchIndex<String> index, 
-            final MailboxEventDispatcher<String> dispatcher, final MailboxPathLocker locker, final JCRMailbox mailbox, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver, final Logger log, final char delimiter) throws MailboxException {
+    public JCRMessageManager(MailboxSessionMapperFactory<JCRId> mapperFactory, MessageSearchIndex<JCRId> index, 
+            final MailboxEventDispatcher<JCRId> dispatcher, final MailboxPathLocker locker, final JCRMailbox mailbox, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver, final Logger log, final char delimiter) throws MailboxException {
         super(mapperFactory, index, dispatcher, locker, mailbox, aclResolver, groupMembershipResolver);
         this.log = log;
     }
 
 
     @Override
-    protected Message<String> createMessage(Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder) throws MailboxException{
-        final Message<String> message = new JCRMessage(getMailboxEntity().getMailboxId(), internalDate, 
+    protected Message<JCRId> createMessage(Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder) throws MailboxException{
+        final Message<JCRId> message = new JCRMessage(getMailboxEntity().getMailboxId(), internalDate, 
                 size, flags, content, bodyStartOctet, propertyBuilder, log);
         return message;
     }

Modified: james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java (original)
+++ james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java Mon Jun 29 08:21:12 2015
@@ -37,6 +37,7 @@ import org.apache.james.mailbox.MailboxS
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.jcr.AbstractJCRScalingMapper;
+import org.apache.james.mailbox.jcr.JCRId;
 import org.apache.james.mailbox.jcr.MailboxSessionJCRRepository;
 import org.apache.james.mailbox.jcr.mail.model.JCRMailbox;
 import org.apache.james.mailbox.model.MailboxACL;
@@ -49,7 +50,7 @@ import org.apache.james.mailbox.store.ma
  * 
  * 
  */
-public class JCRMailboxMapper extends AbstractJCRScalingMapper implements MailboxMapper<String> {
+public class JCRMailboxMapper extends AbstractJCRScalingMapper implements MailboxMapper<JCRId> {
 
 
 	public JCRMailboxMapper(final MailboxSessionJCRRepository repos, MailboxSession session, final int scaling) {
@@ -63,9 +64,9 @@ public class JCRMailboxMapper extends Ab
      * org.apache.james.mailbox.store.mail.MailboxMapper#delete(org.apache.james
      * .imap.store.mail.model.Mailbox)
      */
-    public void delete(Mailbox<String> mailbox) throws MailboxException {
+    public void delete(Mailbox<JCRId> mailbox) throws MailboxException {
         try {
-            Node node = getSession().getNodeByIdentifier(((JCRMailbox) mailbox).getMailboxId());
+            Node node = getSession().getNodeByIdentifier(((JCRMailbox) mailbox).getMailboxId().serialize());
                    
             node.remove();
             
@@ -80,7 +81,7 @@ public class JCRMailboxMapper extends Ab
      * (non-Javadoc)
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxByPath(org.apache.james.imap.api.MailboxPath)
      */
-    public Mailbox<String> findMailboxByPath(MailboxPath path) throws MailboxException, MailboxNotFoundException {
+    public Mailbox<JCRId> findMailboxByPath(MailboxPath path) throws MailboxException, MailboxNotFoundException {
         try {
             String name = Text.escapeIllegalXpathSearchChars(path.getName());
             String user = path.getUser();
@@ -111,8 +112,8 @@ public class JCRMailboxMapper extends Ab
      * (non-Javadoc)
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxWithPathLike(org.apache.james.imap.api.MailboxPath)
      */
-    public List<Mailbox<String>> findMailboxWithPathLike(MailboxPath path) throws MailboxException {
-        List<Mailbox<String>> mailboxList = new ArrayList<Mailbox<String>>();
+    public List<Mailbox<JCRId>> findMailboxWithPathLike(MailboxPath path) throws MailboxException {
+        List<Mailbox<JCRId>> mailboxList = new ArrayList<Mailbox<JCRId>>();
         try {
             String name = Text.escapeIllegalXpathSearchChars(path.getName());
             String user = path.getUser();
@@ -144,14 +145,14 @@ public class JCRMailboxMapper extends Ab
      * org.apache.james.mailbox.store.mail.MailboxMapper#save(org.apache.james.
      * imap.store.mail.model.Mailbox)
      */
-    public void save(Mailbox<String> mailbox) throws MailboxException {
+    public void save(Mailbox<JCRId> mailbox) throws MailboxException {
         
         try {
             final JCRMailbox jcrMailbox = (JCRMailbox)mailbox;
             Node node = null;
 
             if (jcrMailbox.isPersistent()) {
-                node = getSession().getNodeByIdentifier(jcrMailbox.getMailboxId());
+                node = getSession().getNodeByIdentifier(jcrMailbox.getMailboxId().serialize());
             }
             if (node == null) {
                 Node rootNode = getSession().getRootNode();
@@ -188,7 +189,7 @@ public class JCRMailboxMapper extends Ab
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#hasChildren(org.apache.james.
      * imap.store.mail.model.Mailbox)
      */
-    public boolean hasChildren(Mailbox<String> mailbox, char delimiter)
+    public boolean hasChildren(Mailbox<JCRId> mailbox, char delimiter)
             throws MailboxException, MailboxNotFoundException {
         try {
             String name = Text.escapeIllegalXpathSearchChars(mailbox.getName());
@@ -217,9 +218,9 @@ public class JCRMailboxMapper extends Ab
      * (non-Javadoc)
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#list()
      */
-    public List<Mailbox<String>> list() throws MailboxException {
+    public List<Mailbox<JCRId>> list() throws MailboxException {
         try {
-            List<Mailbox<String>> mList = new ArrayList<Mailbox<String>>();
+            List<Mailbox<JCRId>> mList = new ArrayList<Mailbox<JCRId>>();
             QueryManager manager = getSession().getWorkspace().getQueryManager();
 
             String queryString = "/jcr:root/" + MAILBOXES_PATH + "//element(*,jamesMailbox:mailbox)";
@@ -235,7 +236,7 @@ public class JCRMailboxMapper extends Ab
     }
 
     @Override
-    public void updateACL(Mailbox<String> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException {
+    public void updateACL(Mailbox<JCRId> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException {
         mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand));
     }
 }

Modified: james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMessageMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMessageMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMessageMapper.java (original)
+++ james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMessageMapper.java Mon Jun 29 08:21:12 2015
@@ -40,6 +40,7 @@ import org.apache.jackrabbit.commons.Jcr
 import org.apache.jackrabbit.util.ISO9075;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.jcr.JCRId;
 import org.apache.james.mailbox.jcr.JCRImapConstants;
 import org.apache.james.mailbox.jcr.MailboxSessionJCRRepository;
 import org.apache.james.mailbox.jcr.mail.model.JCRMessage;
@@ -59,7 +60,7 @@ import org.apache.james.mailbox.store.ma
  * message as a seperate child node under the mailbox
  * 
  */
-public class JCRMessageMapper extends AbstractMessageMapper<String> implements JCRImapConstants {
+public class JCRMessageMapper extends AbstractMessageMapper<JCRId> implements JCRImapConstants {
 
     /**
      * Store the messages directly in the mailbox: .../mailbox/
@@ -118,7 +119,7 @@ public class JCRMessageMapper extends Ab
      *            {@link #MESSAGE_SCALE_YEAR}
      */
     public JCRMessageMapper(final MailboxSessionJCRRepository repository, MailboxSession mSession,
-            UidProvider<String> uidProvider, ModSeqProvider<String> modSeqProvider, int scaleType) {
+            UidProvider<JCRId> uidProvider, ModSeqProvider<JCRId> modSeqProvider, int scaleType) {
         super(mSession, uidProvider, modSeqProvider);
         this.repository = repository;
         this.scaleType = scaleType;
@@ -138,7 +139,7 @@ public class JCRMessageMapper extends Ab
      *            {@link ModSeqProvider} to use
      */
     public JCRMessageMapper(final MailboxSessionJCRRepository repos, MailboxSession session,
-            UidProvider<String> uidProvider, ModSeqProvider<String> modSeqProvider) {
+            UidProvider<JCRId> uidProvider, ModSeqProvider<JCRId> modSeqProvider) {
         this(repos, session, uidProvider, modSeqProvider, MESSAGE_SCALE_DAY);
     }
 
@@ -205,7 +206,7 @@ public class JCRMessageMapper extends Ab
      * org.apache.james.mailbox.store.mail.MessageMapper#countMessagesInMailbox
      * ()
      */
-    public long countMessagesInMailbox(Mailbox<String> mailbox) throws MailboxException {
+    public long countMessagesInMailbox(Mailbox<JCRId> mailbox) throws MailboxException {
         try {
             // we use order by because without it count will always be 0 in
             // jackrabbit
@@ -235,7 +236,7 @@ public class JCRMessageMapper extends Ab
      * @see org.apache.james.mailbox.store.mail.MessageMapper#
      * countUnseenMessagesInMailbox ()
      */
-    public long countUnseenMessagesInMailbox(Mailbox<String> mailbox) throws MailboxException {
+    public long countUnseenMessagesInMailbox(Mailbox<JCRId> mailbox) throws MailboxException {
 
         try {
             // we use order by because without it count will always be 0 in
@@ -269,7 +270,7 @@ public class JCRMessageMapper extends Ab
      * .mailbox.store.mail.model.Mailbox,
      * org.apache.james.mailbox.store.mail.model.Message)
      */
-    public void delete(Mailbox<String> mailbox, Message<String> message) throws MailboxException {
+    public void delete(Mailbox<JCRId> mailbox, Message<JCRId> message) throws MailboxException {
         JCRMessage membership = (JCRMessage) message;
         if (membership.isPersistent()) {
             try {
@@ -290,10 +291,10 @@ public class JCRMessageMapper extends Ab
      * org.apache.james.mailbox.MessageRange,
      * org.apache.james.mailbox.store.mail.MessageMapper.FetchType, int)
      */
-    public Iterator<Message<String>> findInMailbox(Mailbox<String> mailbox, MessageRange set, FetchType fType, int max)
+    public Iterator<Message<JCRId>> findInMailbox(Mailbox<JCRId> mailbox, MessageRange set, FetchType fType, int max)
             throws MailboxException {
         try {
-            List<Message<String>> results;
+            List<Message<JCRId>> results;
             long from = set.getUidFrom();
             final long to = set.getUidTo();
             final Type type = set.getType();
@@ -329,7 +330,7 @@ public class JCRMessageMapper extends Ab
      * @see org.apache.james.mailbox.store.mail.MessageMapper#
      * findRecentMessageUidsInMailbox ()
      */
-    public List<Long> findRecentMessageUidsInMailbox(Mailbox<String> mailbox) throws MailboxException {
+    public List<Long> findRecentMessageUidsInMailbox(Mailbox<JCRId> mailbox) throws MailboxException {
 
         try {
 
@@ -359,7 +360,7 @@ public class JCRMessageMapper extends Ab
      * org.apache.james.mailbox.store.mail.MessageMapper#findFirstUnseenMessageUid
      * (org.apache.james.mailbox.store.mail.model.Mailbox)
      */
-    public Long findFirstUnseenMessageUid(Mailbox<String> mailbox) throws MailboxException {
+    public Long findFirstUnseenMessageUid(Mailbox<JCRId> mailbox) throws MailboxException {
         try {
             String queryString = "/jcr:root" + getMailboxPath(mailbox) + "//element(*,jamesMailbox:message)[@"
                     + JCRMessage.SEEN_PROPERTY + "='false'] order by @" + JCRMessage.UID_PROPERTY;
@@ -382,10 +383,10 @@ public class JCRMessageMapper extends Ab
     }
 
     @Override
-    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox<String> mailbox, MessageRange set)
+    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox<JCRId> mailbox, MessageRange set)
             throws MailboxException {
         try {
-            final List<Message<String>> results;
+            final List<Message<JCRId>> results;
             final long from = set.getUidFrom();
             final long to = set.getUidTo();
             final Type type = set.getType();
@@ -406,7 +407,7 @@ public class JCRMessageMapper extends Ab
             }
             Map<Long, MessageMetaData> uids = new HashMap<Long, MessageMetaData>();
             for (int i = 0; i < results.size(); i++) {
-                Message<String> m = results.get(i);
+                Message<JCRId> m = results.get(i);
                 long uid = m.getUid();
                 uids.put(uid, new SimpleMessageMetaData(m));
                 delete(mailbox, m);
@@ -424,22 +425,22 @@ public class JCRMessageMapper extends Ab
      *      org.apache.james.mailbox.store.mail.model.Message)
      */
     @Override
-    public MessageMetaData move(Mailbox<String> mailbox, Message<String> original) throws MailboxException {
+    public MessageMetaData move(Mailbox<JCRId> mailbox, Message<JCRId> original) throws MailboxException {
         throw new UnsupportedOperationException("Not implemented - see https://issues.apache.org/jira/browse/IMAP-370");
     }
 
     @Override
-    protected MessageMetaData copy(Mailbox<String> mailbox, long uid, long modSeq, Message<String> original)
+    protected MessageMetaData copy(Mailbox<JCRId> mailbox, long uid, long modSeq, Message<JCRId> original)
             throws MailboxException {
         try {
-            String newMessagePath = getSession().getNodeByIdentifier(mailbox.getMailboxId()).getPath() + NODE_DELIMITER
+            String newMessagePath = getSession().getNodeByIdentifier(mailbox.getMailboxId().serialize()).getPath() + NODE_DELIMITER
                     + String.valueOf(uid);
             getSession().getWorkspace().copy(
                     ((JCRMessage) original).getNode().getPath(),
-                    getSession().getNodeByIdentifier(mailbox.getMailboxId()).getPath() + NODE_DELIMITER
+                    getSession().getNodeByIdentifier(mailbox.getMailboxId().serialize()).getPath() + NODE_DELIMITER
                             + String.valueOf(uid));
             Node node = getSession().getNode(newMessagePath);
-            node.setProperty(JCRMessage.MAILBOX_UUID_PROPERTY, mailbox.getMailboxId());
+            node.setProperty(JCRMessage.MAILBOX_UUID_PROPERTY, mailbox.getMailboxId().serialize());
             node.setProperty(JCRMessage.UID_PROPERTY, uid);
             node.setProperty(JCRMessage.MODSEQ_PROPERTY, modSeq);
             // A copy of a message is recent
@@ -452,7 +453,7 @@ public class JCRMessageMapper extends Ab
     }
 
     @Override
-    protected MessageMetaData save(Mailbox<String> mailbox, Message<String> message) throws MailboxException {
+    protected MessageMetaData save(Mailbox<JCRId> mailbox, Message<JCRId> message) throws MailboxException {
         final JCRMessage membership = (JCRMessage) message;
         try {
     
@@ -479,7 +480,7 @@ public class JCRMessageMapper extends Ab
                 final String hour = convertIntToString(cal.get(Calendar.HOUR_OF_DAY));
                 final String min = convertIntToString(cal.get(Calendar.MINUTE));
     
-                Node mailboxNode = getSession().getNodeByIdentifier(mailbox.getMailboxId());
+                Node mailboxNode = getSession().getNodeByIdentifier(mailbox.getMailboxId().serialize());
                 Node node = mailboxNode;
     
                 if (scaleType > MESSAGE_SCALE_NONE) {
@@ -539,13 +540,13 @@ public class JCRMessageMapper extends Ab
      * @throws ItemNotFoundException
      * @throws RepositoryException
      */
-    private String getMailboxPath(Mailbox<String> mailbox) throws ItemNotFoundException, RepositoryException {
-        return ISO9075.encodePath(getSession().getNodeByIdentifier(mailbox.getMailboxId()).getPath());
+    private String getMailboxPath(Mailbox<JCRId> mailbox) throws ItemNotFoundException, RepositoryException {
+        return ISO9075.encodePath(getSession().getNodeByIdentifier(mailbox.getMailboxId().serialize()).getPath());
     }
 
-    private List<Message<String>> findMessagesInMailboxAfterUID(Mailbox<String> mailbox, long uid, int batchSize)
+    private List<Message<JCRId>> findMessagesInMailboxAfterUID(Mailbox<JCRId> mailbox, long uid, int batchSize)
             throws RepositoryException {
-        List<Message<String>> list = new ArrayList<Message<String>>();
+        List<Message<JCRId>> list = new ArrayList<Message<JCRId>>();
         String queryString = "/jcr:root" + getMailboxPath(mailbox) + "//element(*,jamesMailbox:message)[@"
                 + JCRMessage.UID_PROPERTY + ">=" + uid + "] order by @" + JCRMessage.UID_PROPERTY;
 
@@ -562,9 +563,9 @@ public class JCRMessageMapper extends Ab
         return list;
     }
 
-    private List<Message<String>> findMessageInMailboxWithUID(Mailbox<String> mailbox, long uid)
+    private List<Message<JCRId>> findMessageInMailboxWithUID(Mailbox<JCRId> mailbox, long uid)
             throws RepositoryException {
-        List<Message<String>> list = new ArrayList<Message<String>>();
+        List<Message<JCRId>> list = new ArrayList<Message<JCRId>>();
         String queryString = "/jcr:root" + getMailboxPath(mailbox) + "//element(*,jamesMailbox:message)[@"
                 + JCRMessage.UID_PROPERTY + "=" + uid + "]";
 
@@ -579,9 +580,9 @@ public class JCRMessageMapper extends Ab
         return list;
     }
 
-    private List<Message<String>> findMessagesInMailboxBetweenUIDs(Mailbox<String> mailbox, long from, long to,
+    private List<Message<JCRId>> findMessagesInMailboxBetweenUIDs(Mailbox<JCRId> mailbox, long from, long to,
             int batchSize) throws RepositoryException {
-        List<Message<String>> list = new ArrayList<Message<String>>();
+        List<Message<JCRId>> list = new ArrayList<Message<JCRId>>();
         String queryString = "/jcr:root" + getMailboxPath(mailbox) + "//element(*,jamesMailbox:message)[@"
                 + JCRMessage.UID_PROPERTY + ">=" + from + " and @" + JCRMessage.UID_PROPERTY + "<=" + to
                 + "] order by @" + JCRMessage.UID_PROPERTY;
@@ -599,9 +600,9 @@ public class JCRMessageMapper extends Ab
         return list;
     }
 
-    private List<Message<String>> findMessagesInMailbox(Mailbox<String> mailbox, int batchSize)
+    private List<Message<JCRId>> findMessagesInMailbox(Mailbox<JCRId> mailbox, int batchSize)
             throws RepositoryException {
-        List<Message<String>> list = new ArrayList<Message<String>>();
+        List<Message<JCRId>> list = new ArrayList<Message<JCRId>>();
 
         String queryString = "/jcr:root" + getMailboxPath(mailbox) + "//element(*,jamesMailbox:message) order by @"
                 + JCRMessage.UID_PROPERTY;
@@ -618,9 +619,9 @@ public class JCRMessageMapper extends Ab
         return list;
     }
 
-    private List<Message<String>> findDeletedMessagesInMailboxAfterUID(Mailbox<String> mailbox, long uid)
+    private List<Message<JCRId>> findDeletedMessagesInMailboxAfterUID(Mailbox<JCRId> mailbox, long uid)
             throws RepositoryException {
-        List<Message<String>> list = new ArrayList<Message<String>>();
+        List<Message<JCRId>> list = new ArrayList<Message<JCRId>>();
         String queryString = "/jcr:root" + getMailboxPath(mailbox) + "//element(*,jamesMailbox:message)[@"
                 + JCRMessage.UID_PROPERTY + ">=" + uid + " and @" + JCRMessage.DELETED_PROPERTY + "='true'] order by @"
                 + JCRMessage.UID_PROPERTY;
@@ -635,9 +636,9 @@ public class JCRMessageMapper extends Ab
         return list;
     }
 
-    private List<Message<String>> findDeletedMessageInMailboxWithUID(Mailbox<String> mailbox, long uid)
+    private List<Message<JCRId>> findDeletedMessageInMailboxWithUID(Mailbox<JCRId> mailbox, long uid)
             throws RepositoryException {
-        List<Message<String>> list = new ArrayList<Message<String>>();
+        List<Message<JCRId>> list = new ArrayList<Message<JCRId>>();
         String queryString = "/jcr:root" + getMailboxPath(mailbox) + "//element(*,jamesMailbox:message)[@"
                 + JCRMessage.UID_PROPERTY + "=" + uid + " and @" + JCRMessage.DELETED_PROPERTY + "='true']";
         QueryManager manager = getSession().getWorkspace().getQueryManager();
@@ -653,9 +654,9 @@ public class JCRMessageMapper extends Ab
         return list;
     }
 
-    private List<Message<String>> findDeletedMessagesInMailboxBetweenUIDs(Mailbox<String> mailbox, long from, long to)
+    private List<Message<JCRId>> findDeletedMessagesInMailboxBetweenUIDs(Mailbox<JCRId> mailbox, long from, long to)
             throws RepositoryException {
-        List<Message<String>> list = new ArrayList<Message<String>>();
+        List<Message<JCRId>> list = new ArrayList<Message<JCRId>>();
         String queryString = "/jcr:root" + getMailboxPath(mailbox) + "//element(*,jamesMailbox:message)[@"
                 + JCRMessage.UID_PROPERTY + ">=" + from + " and @" + JCRMessage.UID_PROPERTY + "<=" + to + " and @"
                 + JCRMessage.DELETED_PROPERTY + "='true'] order by @" + JCRMessage.UID_PROPERTY;
@@ -670,9 +671,9 @@ public class JCRMessageMapper extends Ab
         return list;
     }
 
-    private List<Message<String>> findDeletedMessagesInMailbox(Mailbox<String> mailbox) throws RepositoryException {
+    private List<Message<JCRId>> findDeletedMessagesInMailbox(Mailbox<JCRId> mailbox) throws RepositoryException {
 
-        List<Message<String>> list = new ArrayList<Message<String>>();
+        List<Message<JCRId>> list = new ArrayList<Message<JCRId>>();
         String queryString = "/jcr:root" + getMailboxPath(mailbox) + "//element(*,jamesMailbox:message)[@"
                 + JCRMessage.DELETED_PROPERTY + "='true'] order by @" + JCRMessage.UID_PROPERTY;
 

Modified: james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRModSeqProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRModSeqProvider.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRModSeqProvider.java (original)
+++ james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRModSeqProvider.java Mon Jun 29 08:21:12 2015
@@ -25,12 +25,13 @@ import javax.jcr.Session;
 import org.apache.james.mailbox.MailboxPathLocker;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.jcr.JCRId;
 import org.apache.james.mailbox.jcr.MailboxSessionJCRRepository;
 import org.apache.james.mailbox.jcr.mail.model.JCRMailbox;
 import org.apache.james.mailbox.store.mail.AbstractLockingModSeqProvider;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
-public class JCRModSeqProvider extends AbstractLockingModSeqProvider<String>{
+public class JCRModSeqProvider extends AbstractLockingModSeqProvider<JCRId>{
 
     private MailboxSessionJCRRepository repository;
 
@@ -40,10 +41,10 @@ public class JCRModSeqProvider extends A
     }
 
     @Override
-    public long highestModSeq(MailboxSession session, Mailbox<String> mailbox) throws MailboxException {
+    public long highestModSeq(MailboxSession session, Mailbox<JCRId> mailbox) throws MailboxException {
         try {
             Session s = repository.login(session);
-            Node node = s.getNodeByIdentifier(mailbox.getMailboxId());
+            Node node = s.getNodeByIdentifier(mailbox.getMailboxId().serialize());
             return node.getProperty(JCRMailbox.HIGHESTMODSEQ_PROPERTY).getLong();
         } catch (RepositoryException e) {
             throw new MailboxException("Unable to get highest mod-sequence for mailbox " + mailbox, e);
@@ -51,10 +52,10 @@ public class JCRModSeqProvider extends A
     }
 
     @Override
-    protected long lockedNextModSeq(MailboxSession session, Mailbox<String> mailbox) throws MailboxException {
+    protected long lockedNextModSeq(MailboxSession session, Mailbox<JCRId> mailbox) throws MailboxException {
         try {
             Session s = repository.login(session);
-            Node node = s.getNodeByIdentifier(mailbox.getMailboxId());
+            Node node = s.getNodeByIdentifier(mailbox.getMailboxId().serialize());
             long modseq = node.getProperty(JCRMailbox.HIGHESTMODSEQ_PROPERTY).getLong();
             modseq++;
             node.setProperty(JCRMailbox.HIGHESTMODSEQ_PROPERTY, modseq);

Modified: james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRUidProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRUidProvider.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRUidProvider.java (original)
+++ james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRUidProvider.java Mon Jun 29 08:21:12 2015
@@ -25,12 +25,13 @@ import javax.jcr.Session;
 import org.apache.james.mailbox.MailboxPathLocker;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.jcr.JCRId;
 import org.apache.james.mailbox.jcr.MailboxSessionJCRRepository;
 import org.apache.james.mailbox.jcr.mail.model.JCRMailbox;
 import org.apache.james.mailbox.store.mail.AbstractLockingUidProvider;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
-public class JCRUidProvider extends AbstractLockingUidProvider<String>{
+public class JCRUidProvider extends AbstractLockingUidProvider<JCRId> {
 
     private MailboxSessionJCRRepository repository;
 
@@ -40,10 +41,10 @@ public class JCRUidProvider extends Abst
     }
 
     @Override
-    public long lastUid(MailboxSession mailboxSession, Mailbox<String> mailbox) throws MailboxException {
+    public long lastUid(MailboxSession mailboxSession, Mailbox<JCRId> mailbox) throws MailboxException {
         try {
             Session s = repository.login(mailboxSession);
-            Node node = s.getNodeByIdentifier(mailbox.getMailboxId());
+            Node node = s.getNodeByIdentifier(mailbox.getMailboxId().serialize());
             return node.getProperty(JCRMailbox.LASTUID_PROPERTY).getLong();
         } catch (RepositoryException e) {
             throw new MailboxException("Unable to get last uid for mailbox " + mailbox, e);
@@ -52,10 +53,10 @@ public class JCRUidProvider extends Abst
     }
 
     @Override
-    protected long lockedNextUid(MailboxSession session, Mailbox<String> mailbox) throws MailboxException {
+    protected long lockedNextUid(MailboxSession session, Mailbox<JCRId> mailbox) throws MailboxException {
         try {
             Session s = repository.login(session);
-            Node node = s.getNodeByIdentifier(mailbox.getMailboxId());
+            Node node = s.getNodeByIdentifier(mailbox.getMailboxId().serialize());
             long uid = node.getProperty(JCRMailbox.LASTUID_PROPERTY).getLong();
             uid++;
             node.setProperty(JCRMailbox.LASTUID_PROPERTY, uid);

Modified: james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailbox.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailbox.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailbox.java (original)
+++ james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailbox.java Mon Jun 29 08:21:12 2015
@@ -23,6 +23,7 @@ import javax.jcr.RepositoryException;
 
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.util.Text;
+import org.apache.james.mailbox.jcr.JCRId;
 import org.apache.james.mailbox.jcr.JCRImapConstants;
 import org.apache.james.mailbox.jcr.Persistent;
 import org.apache.james.mailbox.model.MailboxACL;
@@ -35,7 +36,7 @@ import org.slf4j.Logger;
 /**
  * JCR implementation of a {@link Mailbox}
  */
-public class JCRMailbox implements Mailbox<String>, JCRImapConstants, Persistent{
+public class JCRMailbox implements Mailbox<JCRId>, JCRImapConstants, Persistent{
 
     private static final String TAB = " ";
 
@@ -202,10 +203,10 @@ public class JCRMailbox implements Mailb
      * (non-Javadoc)
      * @see org.apache.james.mailbox.store.mail.model.Mailbox#getMailboxId()
      */
-    public String getMailboxId() {
+    public JCRId getMailboxId() {
         if (isPersistent()) {
             try {
-                return node.getIdentifier();
+                return JCRId.of(node.getIdentifier());
             } catch (RepositoryException e) {
                 logger.error("Unable to access property " + JcrConstants.JCR_UUID, e);
             }

Modified: james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMessage.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMessage.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMessage.java (original)
+++ james/mailbox/trunk/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMessage.java Mon Jun 29 08:21:12 2015
@@ -38,6 +38,7 @@ import org.apache.commons.io.input.Bound
 import org.apache.jackrabbit.JcrConstants;
 import org.apache.jackrabbit.commons.JcrUtils;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.jcr.JCRId;
 import org.apache.james.mailbox.jcr.JCRImapConstants;
 import org.apache.james.mailbox.jcr.Persistent;
 import org.apache.james.mailbox.store.mail.model.AbstractMessage;
@@ -50,7 +51,7 @@ import org.slf4j.Logger;
  * JCR implementation of {@link Message}
  *
  */
-public class JCRMessage extends AbstractMessage<String> implements JCRImapConstants, Persistent{
+public class JCRMessage extends AbstractMessage<JCRId> implements JCRImapConstants, Persistent{
 
     private Node node;
     private final Logger logger;
@@ -61,7 +62,7 @@ public class JCRMessage extends Abstract
     private List<JCRProperty> properties;
     private int bodyStartOctet;
     
-    private String mailboxUUID;
+    private JCRId mailboxUUID;
     private long uid;
     private Date internalDate;
     private long size;
@@ -102,7 +103,7 @@ public class JCRMessage extends Abstract
         this.node = node;
     }
     
-    public JCRMessage(String mailboxUUID, Date internalDate, int size, Flags flags, SharedInputStream content,
+    public JCRMessage(JCRId mailboxUUID, Date internalDate, int size, Flags flags, SharedInputStream content,
             int bodyStartOctet,  final PropertyBuilder propertyBuilder, Logger logger) {
         super();
         this.mailboxUUID = mailboxUUID;
@@ -131,7 +132,7 @@ public class JCRMessage extends Abstract
      * @param message
      * @throws IOException 
      */
-    public JCRMessage(String mailboxUUID, long uid,  long modSeq, JCRMessage message, Logger logger) throws MailboxException {
+    public JCRMessage(JCRId mailboxUUID, long uid,  long modSeq, JCRMessage message, Logger logger) throws MailboxException {
         this.mailboxUUID = mailboxUUID;
         this.internalDate = message.getInternalDate();
         this.size = message.getFullContentOctets();
@@ -293,7 +294,7 @@ public class JCRMessage extends Abstract
         // This also fix https://issues.apache.org/jira/browse/IMAP-159
         if (isPersistent() == false) {
             node.setProperty(SIZE_PROPERTY, getFullContentOctets());
-            node.setProperty(MAILBOX_UUID_PROPERTY, getMailboxId());
+            node.setProperty(MAILBOX_UUID_PROPERTY, getMailboxId().serialize());
             node.setProperty(UID_PROPERTY, getUid());
             node.setProperty(MODSEQ_PROPERTY, getModSeq());
 
@@ -428,10 +429,10 @@ public class JCRMessage extends Abstract
      * @see
      * org.apache.james.mailbox.store.mail.model.MailboxMembership#getMailboxId()
      */
-    public String getMailboxId() {
+    public JCRId getMailboxId() {
         if (isPersistent()) {
             try {
-                return node.getProperty(MAILBOX_UUID_PROPERTY).getString();
+                return JCRId.of(node.getProperty(MAILBOX_UUID_PROPERTY).getString());
             } catch (RepositoryException e) {
                 logger.error("Unable to access property "
                         + MAILBOX_UUID_PROPERTY, e);

Added: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAId.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAId.java?rev=1688109&view=auto
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAId.java (added)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAId.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.jpa;
+
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+
+public class JPAId implements MailboxId {
+
+    public static JPAId of(long value) {
+        return new JPAId(value);
+    }
+
+    private final long value;
+
+    public JPAId(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;
+        JPAId other = (JPAId) obj;
+        if (value != other.value)
+            return false;
+        return true;
+    }
+    
+}

Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java (original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxManager.java Mon Jun 29 08:21:12 2015
@@ -34,7 +34,7 @@ import org.apache.james.mailbox.store.tr
 /**
  * JPA implementation of {@link StoreMailboxManager}
  */
-public abstract class JPAMailboxManager extends StoreMailboxManager<Long> {
+public abstract class JPAMailboxManager extends StoreMailboxManager<JPAId> {
     
     public JPAMailboxManager(JPAMailboxSessionMapperFactory mailboxSessionMapperFactory,
             final Authenticator authenticator, final MailboxPathLocker locker, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) {
@@ -42,7 +42,7 @@ public abstract class JPAMailboxManager
     }
     
     @Override
-    protected Mailbox<Long> doCreateMailbox(MailboxPath path, MailboxSession session) throws MailboxException {
+    protected Mailbox<JPAId> doCreateMailbox(MailboxPath path, MailboxSession session) throws MailboxException {
         return  new JPAMailbox(path, randomUidValidity());
     }
 

Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java (original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMailboxSessionMapperFactory.java Mon Jun 29 08:21:12 2015
@@ -36,13 +36,13 @@ import org.apache.james.mailbox.store.us
  * JPA implementation of {@link MailboxSessionMapperFactory}
  *
  */
-public class JPAMailboxSessionMapperFactory extends MailboxSessionMapperFactory<Long> {
+public class JPAMailboxSessionMapperFactory extends MailboxSessionMapperFactory<JPAId> {
 
     private final EntityManagerFactory entityManagerFactory;
-    private final UidProvider<Long> uidProvider;
-    private final ModSeqProvider<Long> modSeqProvider;
+    private final UidProvider<JPAId> uidProvider;
+    private final ModSeqProvider<JPAId> modSeqProvider;
 
-    public JPAMailboxSessionMapperFactory(EntityManagerFactory entityManagerFactory, UidProvider<Long> uidProvider, ModSeqProvider<Long> modSeqProvider) {
+    public JPAMailboxSessionMapperFactory(EntityManagerFactory entityManagerFactory, UidProvider<JPAId> uidProvider, ModSeqProvider<JPAId> modSeqProvider) {
         this.entityManagerFactory = entityManagerFactory;
         this.uidProvider = uidProvider;
         this.modSeqProvider = modSeqProvider;
@@ -50,12 +50,12 @@ public class JPAMailboxSessionMapperFact
     }
     
     @Override
-    public MailboxMapper<Long> createMailboxMapper(MailboxSession session) {
+    public MailboxMapper<JPAId> createMailboxMapper(MailboxSession session) {
         return new JPAMailboxMapper(entityManagerFactory);
     }
 
     @Override
-    public MessageMapper<Long> createMessageMapper(MailboxSession session) {
+    public MessageMapper<JPAId> createMessageMapper(MailboxSession session) {
         return new JPAMessageMapper(session, uidProvider, modSeqProvider, entityManagerFactory);
     }
 

Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMessageManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMessageManager.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMessageManager.java (original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/JPAMessageManager.java Mon Jun 29 08:21:12 2015
@@ -41,17 +41,21 @@ import org.apache.james.mailbox.store.se
 /**
  * Abstract base class which should be used from JPA implementations.
  */
-public class JPAMessageManager extends StoreMessageManager<Long> {
+public class JPAMessageManager extends StoreMessageManager<JPAId> {
     
-    public JPAMessageManager(MailboxSessionMapperFactory<Long> mapperFactory, final MessageSearchIndex<Long> index, final MailboxEventDispatcher<Long> dispatcher, final MailboxPathLocker locker, final Mailbox<Long> mailbox, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) throws MailboxException {
+    public JPAMessageManager(MailboxSessionMapperFactory<JPAId> mapperFactory, final MessageSearchIndex<JPAId> index, 
+    			final MailboxEventDispatcher<JPAId> dispatcher, final MailboxPathLocker locker, 
+    			final Mailbox<JPAId> mailbox, MailboxACLResolver aclResolver, 
+    			GroupMembershipResolver groupMembershipResolver) throws MailboxException {
+    	
         super(mapperFactory, index, dispatcher, locker, mailbox, aclResolver, groupMembershipResolver);     
     }
     
     @Override
-    protected Message<Long> createMessage(Date internalDate, final int size, int bodyStartOctet, final SharedInputStream content, 
+    protected Message<JPAId> createMessage(Date internalDate, final int size, int bodyStartOctet, final SharedInputStream content, 
             final Flags flags, PropertyBuilder propertyBuilder) throws MailboxException{
 
-        final Message<Long> message = new JPAMessage((JPAMailbox) getMailboxEntity(), internalDate, size, flags, content,  bodyStartOctet,  propertyBuilder);
+        final Message<JPAId> message = new JPAMessage((JPAMailbox) getMailboxEntity(), internalDate, size, flags, content,  bodyStartOctet,  propertyBuilder);
         return message;
     }
 

Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java (original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java Mon Jun 29 08:21:12 2015
@@ -30,6 +30,7 @@ import javax.persistence.RollbackExcepti
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxExistsException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
+import org.apache.james.mailbox.jpa.JPAId;
 import org.apache.james.mailbox.jpa.JPATransactionalMapper;
 import org.apache.james.mailbox.jpa.mail.model.JPAMailbox;
 import org.apache.james.mailbox.model.MailboxACL;
@@ -40,7 +41,7 @@ import org.apache.james.mailbox.store.ma
 /**
  * Data access management for mailbox.
  */
-public class JPAMailboxMapper extends JPATransactionalMapper implements MailboxMapper<Long> {
+public class JPAMailboxMapper extends JPATransactionalMapper implements MailboxMapper<JPAId> {
 
     private static final char SQL_WILDCARD_CHAR = '%';
     private String lastMailboxName;
@@ -72,7 +73,7 @@ public class JPAMailboxMapper extends JP
     /**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#save(Mailbox)
      */
-    public void save(Mailbox<Long> mailbox) throws MailboxException {
+    public void save(Mailbox<JPAId> mailbox) throws MailboxException {
         try {
             this.lastMailboxName = mailbox.getName();
             getEntityManager().persist(mailbox);
@@ -84,7 +85,7 @@ public class JPAMailboxMapper extends JP
     /**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxByPath(MailboxPath)
      */
-    public Mailbox<Long> findMailboxByPath(MailboxPath mailboxPath) throws MailboxException, MailboxNotFoundException {
+    public Mailbox<JPAId> findMailboxByPath(MailboxPath mailboxPath) throws MailboxException, MailboxNotFoundException {
         try {
             if (mailboxPath.getUser() == null) {
                 return (JPAMailbox) getEntityManager().createNamedQuery("findMailboxByName").setParameter("nameParam", mailboxPath.getName()).setParameter("namespaceParam", mailboxPath.getNamespace()).getSingleResult();
@@ -101,9 +102,9 @@ public class JPAMailboxMapper extends JP
     /**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#delete(Mailbox)
      */
-    public void delete(Mailbox<Long> mailbox) throws MailboxException {
+    public void delete(Mailbox<JPAId> mailbox) throws MailboxException {
         try {  
-            getEntityManager().createNamedQuery("deleteMessages").setParameter("idParam", mailbox.getMailboxId()).executeUpdate();
+            getEntityManager().createNamedQuery("deleteMessages").setParameter("idParam", mailbox.getMailboxId().getRawId()).executeUpdate();
             getEntityManager().remove(mailbox);
         } catch (PersistenceException e) {
             throw new MailboxException("Delete of mailbox " + mailbox + " failed", e);
@@ -114,7 +115,7 @@ public class JPAMailboxMapper extends JP
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#findMailboxWithPathLike(MailboxPath)
      */
     @SuppressWarnings("unchecked")
-    public List<Mailbox<Long>> findMailboxWithPathLike(MailboxPath path) throws MailboxException {
+    public List<Mailbox<JPAId>> findMailboxWithPathLike(MailboxPath path) throws MailboxException {
         try {
             if (path.getUser() == null) {
                 return getEntityManager().createNamedQuery("findMailboxWithNameLike").setParameter("nameParam", SQL_WILDCARD_CHAR + path.getName() + SQL_WILDCARD_CHAR).setParameter("namespaceParam", path.getNamespace()).getResultList();
@@ -145,7 +146,7 @@ public class JPAMailboxMapper extends JP
     /**
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#hasChildren(Mailbox, char)
      */
-    public boolean hasChildren(Mailbox<Long> mailbox, char delimiter) throws MailboxException,
+    public boolean hasChildren(Mailbox<JPAId> mailbox, char delimiter) throws MailboxException,
             MailboxNotFoundException {
         final String name = mailbox.getName() + delimiter + SQL_WILDCARD_CHAR; 
         final Long numberOfChildMailboxes;
@@ -161,7 +162,7 @@ public class JPAMailboxMapper extends JP
      * @see org.apache.james.mailbox.store.mail.MailboxMapper#list()
      */
     @SuppressWarnings("unchecked")
-    public List<Mailbox<Long>> list() throws MailboxException{
+    public List<Mailbox<JPAId>> list() throws MailboxException{
         try {
             return getEntityManager().createNamedQuery("listMailboxes").getResultList();
         } catch (PersistenceException e) {
@@ -170,7 +171,7 @@ public class JPAMailboxMapper extends JP
     }
 
     @Override
-    public void updateACL(Mailbox<Long> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException {
+    public void updateACL(Mailbox<JPAId> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException {
         mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand));
     }
 }

Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java (original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMessageMapper.java Mon Jun 29 08:21:12 2015
@@ -31,6 +31,7 @@ import javax.persistence.Query;
 
 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.jpa.mail.model.openjpa.AbstractJPAMessage;
 import org.apache.james.mailbox.jpa.mail.model.openjpa.JPAEncryptedMessage;
@@ -51,12 +52,12 @@ import org.apache.openjpa.persistence.Ar
 /**
  * JPA implementation of a {@link MessageMapper}. This class is not thread-safe!
  */
-public class JPAMessageMapper extends AbstractMessageMapper<Long> implements MessageMapper<Long> {
+public class JPAMessageMapper extends AbstractMessageMapper<JPAId> implements MessageMapper<JPAId> {
     protected EntityManagerFactory entityManagerFactory;
     protected EntityManager entityManager;
 
-    public JPAMessageMapper(final MailboxSession session, final UidProvider<Long> uidProvider,
-            ModSeqProvider<Long> modSeqProvider, final EntityManagerFactory entityManagerFactory) {
+    public JPAMessageMapper(final MailboxSession session, final UidProvider<JPAId> uidProvider,
+            ModSeqProvider<JPAId> modSeqProvider, final EntityManagerFactory entityManagerFactory) {
         super(session, uidProvider, modSeqProvider);
         this.entityManagerFactory = entityManagerFactory;
     }
@@ -123,10 +124,10 @@ public class JPAMessageMapper extends Ab
      *      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<JPAId>> findInMailbox(Mailbox<JPAId> mailbox, MessageRange set, FetchType fType, int max)
             throws MailboxException {
         try {
-            List<Message<Long>> results;
+            List<Message<JPAId>> results;
             long from = set.getUidFrom();
             final long to = set.getUidTo();
             final Type type = set.getType();
@@ -157,10 +158,10 @@ public class JPAMessageMapper extends Ab
     /**
      * @see org.apache.james.mailbox.store.mail.MessageMapper#countMessagesInMailbox(Mailbox)
      */
-    public long countMessagesInMailbox(Mailbox<Long> mailbox) throws MailboxException {
+    public long countMessagesInMailbox(Mailbox<JPAId> mailbox) throws MailboxException {
         try {
             return (Long) getEntityManager().createNamedQuery("countMessagesInMailbox")
-                    .setParameter("idParam", mailbox.getMailboxId()).getSingleResult();
+                    .setParameter("idParam", mailbox.getMailboxId().getRawId()).getSingleResult();
         } catch (PersistenceException e) {
             throw new MailboxException("Count of messages failed in mailbox " + mailbox, e);
         }
@@ -169,10 +170,10 @@ public class JPAMessageMapper extends Ab
     /**
      * @see org.apache.james.mailbox.store.mail.MessageMapper#countUnseenMessagesInMailbox(Mailbox)
      */
-    public long countUnseenMessagesInMailbox(Mailbox<Long> mailbox) throws MailboxException {
+    public long countUnseenMessagesInMailbox(Mailbox<JPAId> mailbox) throws MailboxException {
         try {
             return (Long) getEntityManager().createNamedQuery("countUnseenMessagesInMailbox")
-                    .setParameter("idParam", mailbox.getMailboxId()).getSingleResult();
+                    .setParameter("idParam", mailbox.getMailboxId().getRawId()).getSingleResult();
         } catch (PersistenceException e) {
             throw new MailboxException("Count of useen messages failed in mailbox " + mailbox, e);
         }
@@ -182,7 +183,7 @@ public class JPAMessageMapper extends Ab
      * @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<JPAId> mailbox, Message<JPAId> message) throws MailboxException {
         try {
             getEntityManager().remove(message);
         } catch (PersistenceException e) {
@@ -194,12 +195,12 @@ public class JPAMessageMapper extends Ab
      * @see org.apache.james.mailbox.store.mail.MessageMapper#findFirstUnseenMessageUid(Mailbox)
      */
     @SuppressWarnings("unchecked")
-    public Long findFirstUnseenMessageUid(Mailbox<Long> mailbox) throws MailboxException {
+    public Long findFirstUnseenMessageUid(Mailbox<JPAId> mailbox) throws MailboxException {
         try {
             Query query = getEntityManager().createNamedQuery("findUnseenMessagesInMailboxOrderByUid").setParameter(
-                    "idParam", mailbox.getMailboxId());
+                    "idParam", mailbox.getMailboxId().getRawId());
             query.setMaxResults(1);
-            List<Message<Long>> result = query.getResultList();
+            List<Message<JPAId>> result = query.getResultList();
             if (result.isEmpty()) {
                 return null;
             } else {
@@ -214,10 +215,10 @@ public class JPAMessageMapper extends Ab
      * @see org.apache.james.mailbox.store.mail.MessageMapper#findRecentMessageUidsInMailbox(Mailbox)
      */
     @SuppressWarnings("unchecked")
-    public List<Long> findRecentMessageUidsInMailbox(Mailbox<Long> mailbox) throws MailboxException {
+    public List<Long> findRecentMessageUidsInMailbox(Mailbox<JPAId> mailbox) throws MailboxException {
         try {
             Query query = getEntityManager().createNamedQuery("findRecentMessageUidsInMailbox").setParameter("idParam",
-                    mailbox.getMailboxId());
+                    mailbox.getMailboxId().getRawId());
             return query.getResultList();
         } catch (PersistenceException e) {
             throw new MailboxException("Search of recent messages failed in mailbox " + mailbox, e);
@@ -225,11 +226,11 @@ public class JPAMessageMapper extends Ab
     }
 
     @Override
-    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox<Long> mailbox, MessageRange set)
+    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox<JPAId> mailbox, MessageRange set)
             throws MailboxException {
         try {
             final Map<Long, MessageMetaData> data;
-            final List<Message<Long>> results;
+            final List<Message<JPAId>> results;
             final long from = set.getUidFrom();
             final long to = set.getUidTo();
 
@@ -270,7 +271,7 @@ public class JPAMessageMapper extends Ab
      *      org.apache.james.mailbox.store.mail.model.Message)
      */
     @Override
-    public MessageMetaData move(Mailbox<Long> mailbox, Message<Long> original) throws MailboxException {
+    public MessageMetaData move(Mailbox<JPAId> mailbox, Message<JPAId> original) throws MailboxException {
         throw new UnsupportedOperationException("Not implemented - see https://issues.apache.org/jira/browse/IMAP-370");
     }
 
@@ -278,9 +279,9 @@ public class JPAMessageMapper extends Ab
      * @see org.apache.james.mailbox.store.mail.AbstractMessageMapper#copy(Mailbox,
      *      long, long, Message)
      */
-    protected MessageMetaData copy(Mailbox<Long> mailbox, long uid, long modSeq, Message<Long> original)
+    protected MessageMetaData copy(Mailbox<JPAId> mailbox, long uid, long modSeq, Message<JPAId> original)
             throws MailboxException {
-        Message<Long> copy;
+        Message<JPAId> copy;
         if (original instanceof JPAStreamingMessage) {
             copy = new JPAStreamingMessage((JPAMailbox) mailbox, uid, modSeq, original);
         } else if (original instanceof JPAEncryptedMessage) {
@@ -295,7 +296,7 @@ public class JPAMessageMapper extends Ab
      * @see org.apache.james.mailbox.store.mail.AbstractMessageMapper#save(Mailbox,
      *      Message)
      */
-    protected MessageMetaData save(Mailbox<Long> mailbox, Message<Long> message) throws MailboxException {
+    protected MessageMetaData save(Mailbox<JPAId> mailbox, Message<JPAId> message) throws MailboxException {
 
         try {
 
@@ -304,7 +305,7 @@ public class JPAMessageMapper extends Ab
             // If we don't this, we will get an
             // org.apache.openjpa.persistence.ArgumentException.
             ((AbstractJPAMessage) message)
-                    .setMailbox(getEntityManager().find(JPAMailbox.class, mailbox.getMailboxId()));
+                    .setMailbox(getEntityManager().find(JPAMailbox.class, mailbox.getMailboxId().getRawId()));
 
             getEntityManager().persist(message);
             return new SimpleMessageMetaData(message);
@@ -316,9 +317,9 @@ public class JPAMessageMapper extends Ab
     }
 
     @SuppressWarnings("unchecked")
-    private List<Message<Long>> findMessagesInMailboxAfterUID(Mailbox<Long> mailbox, long uid, int batchSize) {
+    private List<Message<JPAId>> findMessagesInMailboxAfterUID(Mailbox<JPAId> mailbox, long uid, int batchSize) {
         Query query = getEntityManager().createNamedQuery("findMessagesInMailboxAfterUID")
-                .setParameter("idParam", mailbox.getMailboxId()).setParameter("uidParam", uid);
+                .setParameter("idParam", mailbox.getMailboxId().getRawId()).setParameter("uidParam", uid);
 
         if (batchSize > 0)
             query.setMaxResults(batchSize);
@@ -327,17 +328,17 @@ public class JPAMessageMapper extends Ab
     }
 
     @SuppressWarnings("unchecked")
-    private List<Message<Long>> findMessagesInMailboxWithUID(Mailbox<Long> mailbox, long uid) {
+    private List<Message<JPAId>> findMessagesInMailboxWithUID(Mailbox<JPAId> mailbox, long uid) {
         return getEntityManager().createNamedQuery("findMessagesInMailboxWithUID")
-                .setParameter("idParam", mailbox.getMailboxId()).setParameter("uidParam", uid).setMaxResults(1)
+                .setParameter("idParam", mailbox.getMailboxId().getRawId()).setParameter("uidParam", uid).setMaxResults(1)
                 .getResultList();
     }
 
     @SuppressWarnings("unchecked")
-    private List<Message<Long>> findMessagesInMailboxBetweenUIDs(Mailbox<Long> mailbox, long from, long to,
+    private List<Message<JPAId>> findMessagesInMailboxBetweenUIDs(Mailbox<JPAId> mailbox, long from, long to,
             int batchSize) {
         Query query = getEntityManager().createNamedQuery("findMessagesInMailboxBetweenUIDs")
-                .setParameter("idParam", mailbox.getMailboxId()).setParameter("fromParam", from)
+                .setParameter("idParam", mailbox.getMailboxId().getRawId()).setParameter("fromParam", from)
                 .setParameter("toParam", to);
 
         if (batchSize > 0)
@@ -347,67 +348,67 @@ public class JPAMessageMapper extends Ab
     }
 
     @SuppressWarnings("unchecked")
-    private List<Message<Long>> findMessagesInMailbox(Mailbox<Long> mailbox, int batchSize) {
+    private List<Message<JPAId>> findMessagesInMailbox(Mailbox<JPAId> mailbox, int batchSize) {
         Query query = getEntityManager().createNamedQuery("findMessagesInMailbox").setParameter("idParam",
-                mailbox.getMailboxId());
+                mailbox.getMailboxId().getRawId());
         if (batchSize > 0)
             query.setMaxResults(batchSize);
         return query.getResultList();
     }
 
-    private Map<Long, MessageMetaData> createMetaData(List<Message<Long>> uids) {
+    private Map<Long, MessageMetaData> createMetaData(List<Message<JPAId>> uids) {
         final Map<Long, MessageMetaData> data = new HashMap<Long, MessageMetaData>();
         for (int i = 0; i < uids.size(); i++) {
-            Message<Long> m = uids.get(i);
+            Message<JPAId> m = uids.get(i);
             data.put(m.getUid(), new SimpleMessageMetaData(m));
         }
         return data;
     }
 
-    private int deleteDeletedMessagesInMailbox(Mailbox<Long> mailbox) {
+    private int deleteDeletedMessagesInMailbox(Mailbox<JPAId> mailbox) {
         return getEntityManager().createNamedQuery("deleteDeletedMessagesInMailbox")
-                .setParameter("idParam", mailbox.getMailboxId()).executeUpdate();
+                .setParameter("idParam", mailbox.getMailboxId().getRawId()).executeUpdate();
     }
 
-    private int deleteDeletedMessagesInMailboxAfterUID(Mailbox<Long> mailbox, long uid) {
+    private int deleteDeletedMessagesInMailboxAfterUID(Mailbox<JPAId> mailbox, long uid) {
         return getEntityManager().createNamedQuery("deleteDeletedMessagesInMailboxAfterUID")
-                .setParameter("idParam", mailbox.getMailboxId()).setParameter("uidParam", uid).executeUpdate();
+                .setParameter("idParam", mailbox.getMailboxId().getRawId()).setParameter("uidParam", uid).executeUpdate();
     }
 
-    private int deleteDeletedMessagesInMailboxWithUID(Mailbox<Long> mailbox, long uid) {
+    private int deleteDeletedMessagesInMailboxWithUID(Mailbox<JPAId> mailbox, long uid) {
         return getEntityManager().createNamedQuery("deleteDeletedMessagesInMailboxWithUID")
-                .setParameter("idParam", mailbox.getMailboxId()).setParameter("uidParam", uid).executeUpdate();
+                .setParameter("idParam", mailbox.getMailboxId().getRawId()).setParameter("uidParam", uid).executeUpdate();
     }
 
-    private int deleteDeletedMessagesInMailboxBetweenUIDs(Mailbox<Long> mailbox, long from, long to) {
+    private int deleteDeletedMessagesInMailboxBetweenUIDs(Mailbox<JPAId> mailbox, long from, long to) {
         return getEntityManager().createNamedQuery("deleteDeletedMessagesInMailboxBetweenUIDs")
-                .setParameter("idParam", mailbox.getMailboxId()).setParameter("fromParam", from)
+                .setParameter("idParam", mailbox.getMailboxId().getRawId()).setParameter("fromParam", from)
                 .setParameter("toParam", to).executeUpdate();
     }
 
     @SuppressWarnings("unchecked")
-    private List<Message<Long>> findDeletedMessagesInMailbox(Mailbox<Long> mailbox) {
+    private List<Message<JPAId>> findDeletedMessagesInMailbox(Mailbox<JPAId> mailbox) {
         return getEntityManager().createNamedQuery("findDeletedMessagesInMailbox")
-                .setParameter("idParam", mailbox.getMailboxId()).getResultList();
+                .setParameter("idParam", mailbox.getMailboxId().getRawId()).getResultList();
     }
 
     @SuppressWarnings("unchecked")
-    private List<Message<Long>> findDeletedMessagesInMailboxAfterUID(Mailbox<Long> mailbox, long uid) {
+    private List<Message<JPAId>> findDeletedMessagesInMailboxAfterUID(Mailbox<JPAId> mailbox, long uid) {
         return getEntityManager().createNamedQuery("findDeletedMessagesInMailboxAfterUID")
-                .setParameter("idParam", mailbox.getMailboxId()).setParameter("uidParam", uid).getResultList();
+                .setParameter("idParam", mailbox.getMailboxId().getRawId()).setParameter("uidParam", uid).getResultList();
     }
 
     @SuppressWarnings("unchecked")
-    private List<Message<Long>> findDeletedMessagesInMailboxWithUID(Mailbox<Long> mailbox, long uid) {
+    private List<Message<JPAId>> findDeletedMessagesInMailboxWithUID(Mailbox<JPAId> mailbox, long uid) {
         return getEntityManager().createNamedQuery("findDeletedMessagesInMailboxWithUID")
-                .setParameter("idParam", mailbox.getMailboxId()).setParameter("uidParam", uid).setMaxResults(1)
+                .setParameter("idParam", mailbox.getMailboxId().getRawId()).setParameter("uidParam", uid).setMaxResults(1)
                 .getResultList();
     }
 
     @SuppressWarnings("unchecked")
-    private List<Message<Long>> findDeletedMessagesInMailboxBetweenUIDs(Mailbox<Long> mailbox, long from, long to) {
+    private List<Message<JPAId>> findDeletedMessagesInMailboxBetweenUIDs(Mailbox<JPAId> mailbox, long from, long to) {
         return getEntityManager().createNamedQuery("findDeletedMessagesInMailboxBetweenUIDs")
-                .setParameter("idParam", mailbox.getMailboxId()).setParameter("fromParam", from)
+                .setParameter("idParam", mailbox.getMailboxId().getRawId()).setParameter("fromParam", from)
                 .setParameter("toParam", to).getResultList();
     }
 }

Modified: james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAModSeqProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAModSeqProvider.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAModSeqProvider.java (original)
+++ james/mailbox/trunk/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAModSeqProvider.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.AbstractLockingModSeqProvider;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 
-public class JPAModSeqProvider extends AbstractLockingModSeqProvider<Long>{
+public class JPAModSeqProvider extends AbstractLockingModSeqProvider<JPAId> {
 
     private EntityManagerFactory factory;
 
@@ -39,12 +40,12 @@ public class JPAModSeqProvider extends A
     }
 
     @Override
-    public long highestModSeq(MailboxSession session, Mailbox<Long> mailbox) throws MailboxException {
+    public long highestModSeq(MailboxSession session, Mailbox<JPAId> mailbox) throws MailboxException {
         EntityManager manager = null;
         try {
             manager = factory.createEntityManager();
             manager.getTransaction().begin();
-            long highest = (Long) manager.createNamedQuery("findHighestModSeq").setParameter("idParam", mailbox.getMailboxId()).getSingleResult();
+            long highest = (Long) manager.createNamedQuery("findHighestModSeq").setParameter("idParam", mailbox.getMailboxId().getRawId()).getSingleResult();
             manager.getTransaction().commit();
             return highest;
         } catch (PersistenceException e) {
@@ -60,12 +61,12 @@ public class JPAModSeqProvider extends A
     }
 
     @Override
-    protected long lockedNextModSeq(MailboxSession session, Mailbox<Long> mailbox) throws MailboxException {
+    protected long lockedNextModSeq(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 modSeq = m.consumeModSeq();
             manager.persist(m);
             manager.getTransaction().commit();



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