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 [2/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/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java (original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java Mon Jun 29 08:21:12 2015
@@ -1,23 +1,20 @@
 package org.apache.james.mailbox.cassandra.mail;
 
-import com.datastax.driver.core.utils.UUIDs;
 import org.apache.james.mailbox.cassandra.CassandraClusterSingleton;
+import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.cassandra.CassandraMailboxSessionMapperFactory;
-import org.apache.james.mailbox.cassandra.CassandraTypesProvider;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.model.MapperProvider;
 
-import java.util.UUID;
-
-public class CassandraMapperProvider implements MapperProvider<UUID> {
+public class CassandraMapperProvider implements MapperProvider<CassandraId> {
 
     private static final CassandraClusterSingleton cassandra = CassandraClusterSingleton.build();
 
     @Override
-    public MailboxMapper<UUID> createMailboxMapper() throws MailboxException {
+    public MailboxMapper<CassandraId> createMailboxMapper() throws MailboxException {
         return new CassandraMailboxSessionMapperFactory(
             new CassandraUidProvider(cassandra.getConf()),
             new CassandraModSeqProvider(cassandra.getConf()),
@@ -27,7 +24,7 @@ public class CassandraMapperProvider imp
     }
 
     @Override
-    public MessageMapper<UUID> createMessageMapper() throws MailboxException {
+    public MessageMapper<CassandraId> createMessageMapper() throws MailboxException {
         return new CassandraMailboxSessionMapperFactory(
             new CassandraUidProvider(cassandra.getConf()),
             new CassandraModSeqProvider(cassandra.getConf()),
@@ -37,8 +34,8 @@ public class CassandraMapperProvider imp
     }
 
     @Override
-    public UUID generateId() {
-        return UUIDs.timeBased();
+    public CassandraId generateId() {
+        return CassandraId.timeBased();
     }
 
     @Override

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

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java (original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidAndModSeqProviderTest.java Mon Jun 29 08:21:12 2015
@@ -23,12 +23,12 @@ import static org.junit.Assert.assertEqu
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.UUID;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.LongConsumer;
 import java.util.stream.LongStream;
 
 import org.apache.james.mailbox.cassandra.CassandraClusterSingleton;
+import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
@@ -54,7 +54,7 @@ public class CassandraUidAndModSeqProvid
     private CassandraUidProvider uidProvider;
     private CassandraModSeqProvider modSeqProvider;
     private CassandraMailboxMapper mapper;
-    private List<SimpleMailbox<UUID>> mailboxList;
+    private List<SimpleMailbox<CassandraId>> mailboxList;
     private List<MailboxPath> pathsList;
 
     @Before
@@ -64,7 +64,7 @@ public class CassandraUidAndModSeqProvid
         modSeqProvider = new CassandraModSeqProvider(CASSANDRA.getConf());
         mapper = new CassandraMailboxMapper(CASSANDRA.getConf(), CASSANDRA.getTypesProvider(), MAX_RETRY);
         fillMailboxList();
-        for (SimpleMailbox<UUID> mailbox : mailboxList) {
+        for (SimpleMailbox<CassandraId> mailbox : mailboxList) {
             mapper.save(mailbox);
         }
     }
@@ -98,7 +98,7 @@ public class CassandraUidAndModSeqProvid
     @Test
     public void lastUidShouldRetrieveValueStoredByNextUid() throws Exception {
         MailboxPath path = new MailboxPath("gsoc", "ieugen", "Trash");
-        SimpleMailbox<UUID> newBox = new SimpleMailbox<>(path, 1234);
+        SimpleMailbox<CassandraId> newBox = new SimpleMailbox<>(path, 1234);
         mapper.save(newBox);
         mailboxList.add(newBox);
         pathsList.add(path);
@@ -115,7 +115,7 @@ public class CassandraUidAndModSeqProvid
 
     @Test
     public void nextUidShouldIncrementValueByOne() throws Exception {
-        SimpleMailbox<UUID> mailbox = mailboxList.get(mailboxList.size() / 2);
+        SimpleMailbox<CassandraId> mailbox = mailboxList.get(mailboxList.size() / 2);
         long lastUid = uidProvider.lastUid(null, mailbox);
         LongStream.range(lastUid + 1, lastUid + 10)
             .forEach(propagateException(value -> {
@@ -128,7 +128,7 @@ public class CassandraUidAndModSeqProvid
     @Test
     public void highestModSeqShouldRetrieveValueStoredNextModSeq() throws Exception {
         MailboxPath path = new MailboxPath("gsoc", "ieugen", "Trash");
-        SimpleMailbox<UUID> newBox = new SimpleMailbox<>(path, 1234);
+        SimpleMailbox<CassandraId> newBox = new SimpleMailbox<>(path, 1234);
         mapper.save(newBox);
         mailboxList.add(newBox);
         pathsList.add(path);
@@ -145,7 +145,7 @@ public class CassandraUidAndModSeqProvid
 
     @Test
     public void nextModSeqShouldIncrementValueByOne() throws Exception {
-        SimpleMailbox<UUID> mailbox = mailboxList.get(mailboxList.size() / 2);
+        SimpleMailbox<CassandraId> mailbox = mailboxList.get(mailboxList.size() / 2);
         long lastUid = modSeqProvider.highestModSeq(null, mailbox);
         LongStream.range(lastUid + 1, lastUid + 10)
             .forEach(propagateException(value -> {
@@ -157,7 +157,7 @@ public class CassandraUidAndModSeqProvid
 
     @Test
     public void nextModSeqShouldIncrementValueWhenParallelCalls() throws Exception {
-        SimpleMailbox<UUID> mailbox = mailboxList.get(mailboxList.size() / 2);
+        SimpleMailbox<CassandraId> mailbox = mailboxList.get(mailboxList.size() / 2);
         long lastUid = modSeqProvider.highestModSeq(null, mailbox);
         final AtomicLong previousValue = new AtomicLong();
         LongStream.range(lastUid + 1, lastUid + 10)

Modified: james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/SimpleMailboxACLJsonConverterTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/SimpleMailboxACLJsonConverterTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/SimpleMailboxACLJsonConverterTest.java (original)
+++ james/mailbox/trunk/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/utils/SimpleMailboxACLJsonConverterTest.java Mon Jun 29 08:21:12 2015
@@ -22,8 +22,6 @@ package org.apache.james.mailbox.cassand
 import static net.javacrumbs.jsonunit.core.Option.IGNORING_ARRAY_ORDER;
 import static net.javacrumbs.jsonunit.fluent.JsonFluentAssert.assertThatJson;
 import static org.assertj.core.api.Assertions.assertThat;
-import java.util.HashMap;
-import java.util.Map;
 
 import java.util.HashMap;
 import java.util.Map;

Added: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseId.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseId.java?rev=1688109&view=auto
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseId.java (added)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseId.java Mon Jun 29 08:21:12 2015
@@ -0,0 +1,80 @@
+/****************************************************************
+ * 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.hbase;
+
+import java.util.UUID;
+
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.james.mailbox.store.mail.model.MailboxId;
+
+public class HBaseId implements MailboxId {
+
+    private final UUID id;
+
+    public static HBaseId of(UUID id) {
+        return new HBaseId(id);
+    }
+
+    private HBaseId(UUID id) {
+        this.id = id;
+    }
+
+    public UUID getRawId() {
+        return id;
+    }
+
+    @Override
+    public String serialize() {
+        return id.toString();
+    }
+
+    public byte[] toBytes() {
+        return Bytes.add(
+                    Bytes.toBytes(id.getMostSignificantBits()),
+                    Bytes.toBytes(id.getLeastSignificantBits()));
+    }
+
+    @Override
+    public String toString() {
+        return id.toString();
+    }
+
+    @Override
+    public int hashCode() {
+        return (int) ((id == null) ? 0 : (id.getMostSignificantBits() ^ (id.getMostSignificantBits() >>> 32)));
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        HBaseId other = (HBaseId) obj;
+        if (id == null) {
+            if (other.id != null)
+                return false;
+        } else if (!id.equals(other.id))
+            return false;
+        return true;
+    }
+
+}

Modified: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java (original)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxManager.java Mon Jun 29 08:21:12 2015
@@ -39,7 +39,7 @@ import org.apache.james.mailbox.store.tr
  * HBase implementation of {@link StoreMailboxManager}
  * 
  */
-public class HBaseMailboxManager extends StoreMailboxManager<UUID> {
+public class HBaseMailboxManager extends StoreMailboxManager<HBaseId> {
 
     public HBaseMailboxManager(HBaseMailboxSessionMapperFactory mapperFactory, Authenticator authenticator, MailboxPathLocker locker, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) {
         super(mapperFactory, authenticator, locker, aclResolver, groupMembershipResolver);
@@ -50,7 +50,7 @@ public class HBaseMailboxManager extends
     }
 
     @Override
-    protected Mailbox<UUID> doCreateMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+    protected Mailbox<HBaseId> doCreateMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
         return new HBaseMailbox(mailboxPath, randomUidValidity());
     }
 
@@ -81,8 +81,8 @@ public class HBaseMailboxManager extends
     }
 
     @Override
-    protected StoreMessageManager<UUID> createMessageManager(Mailbox<UUID> mailboxRow, MailboxSession session) throws MailboxException {
-        StoreMessageManager<UUID> result = new HBaseMessageManager(getMapperFactory(), getMessageSearchIndex(), getEventDispatcher(), getLocker(), mailboxRow, getAclResolver(), getGroupMembershipResolver());
+    protected StoreMessageManager<HBaseId> createMessageManager(Mailbox<HBaseId> mailboxRow, MailboxSession session) throws MailboxException {
+        StoreMessageManager<HBaseId> result = new HBaseMessageManager(getMapperFactory(), getMessageSearchIndex(), getEventDispatcher(), getLocker(), mailboxRow, getAclResolver(), getGroupMembershipResolver());
         return result;
     }
 }

Modified: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java (original)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactory.java Mon Jun 29 08:21:12 2015
@@ -18,7 +18,17 @@
  ****************************************************************/
 package org.apache.james.mailbox.hbase;
 
-import java.util.UUID;
+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_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_TABLE;
+import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
+
+import java.io.IOException;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HTableDescriptor;
@@ -26,8 +36,6 @@ import org.apache.hadoop.hbase.MasterNot
 import org.apache.hadoop.hbase.ZooKeeperConnectionException;
 import org.apache.hadoop.hbase.client.HBaseAdmin;
 import org.apache.james.mailbox.MailboxSession;
-import static org.apache.james.mailbox.hbase.HBaseNames.*;
-
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.SubscriptionException;
 import org.apache.james.mailbox.hbase.mail.HBaseMailboxMapper;
@@ -44,11 +52,11 @@ import org.apache.james.mailbox.store.us
  * HBase implementation of {@link MailboxSessionMapperFactory}
  *
  */
-public class HBaseMailboxSessionMapperFactory extends MailboxSessionMapperFactory<UUID> {
+public class HBaseMailboxSessionMapperFactory extends MailboxSessionMapperFactory<HBaseId> {
 
     private final Configuration conf;
-    private final UidProvider<UUID> uidProvider;
-    private final ModSeqProvider<UUID> modSeqProvider;
+    private final UidProvider<HBaseId> uidProvider;
+    private final ModSeqProvider<HBaseId> modSeqProvider;
 
     /**
      * Creates  the necessary tables in HBase if they do not exist.
@@ -60,7 +68,7 @@ public class HBaseMailboxSessionMapperFa
      * @throws ZooKeeperConnectionException
      * @throws IOException
      */
-    public HBaseMailboxSessionMapperFactory(Configuration conf, UidProvider<UUID> uidProvider, ModSeqProvider<UUID> modSeqProvider) {
+    public HBaseMailboxSessionMapperFactory(Configuration conf, UidProvider<HBaseId> uidProvider, ModSeqProvider<HBaseId> modSeqProvider) {
         this.conf = conf;
         this.uidProvider = uidProvider;
         this.modSeqProvider = modSeqProvider;
@@ -114,12 +122,12 @@ public class HBaseMailboxSessionMapperFa
     }
 
     @Override
-    public MessageMapper<UUID> createMessageMapper(MailboxSession session) throws MailboxException {
+    public MessageMapper<HBaseId> createMessageMapper(MailboxSession session) throws MailboxException {
         return new HBaseMessageMapper(session, uidProvider, modSeqProvider, this.conf);
     }
 
     @Override
-    public MailboxMapper<UUID> createMailboxMapper(MailboxSession session) throws MailboxException {
+    public MailboxMapper<HBaseId> createMailboxMapper(MailboxSession session) throws MailboxException {
         return new HBaseMailboxMapper(this.conf);
     }
 
@@ -140,7 +148,7 @@ public class HBaseMailboxSessionMapperFa
      * Returns the ModSeqProvider used.
      * @return The used modSeqProvider
      */
-    public ModSeqProvider<UUID> getModSeqProvider() {
+    public ModSeqProvider<HBaseId> getModSeqProvider() {
         return modSeqProvider;
     }
 
@@ -148,7 +156,7 @@ public class HBaseMailboxSessionMapperFa
      * Returns the UidProvider that generates UID's for mailboxes.
      * @return The provider that generates UID's for mailboxes
      */
-    public UidProvider<UUID> getUidProvider() {
+    public UidProvider<HBaseId> getUidProvider() {
         return uidProvider;
     }
 }

Modified: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMessageManager.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMessageManager.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMessageManager.java (original)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseMessageManager.java Mon Jun 29 08:21:12 2015
@@ -18,8 +18,6 @@
  ****************************************************************/
 package org.apache.james.mailbox.hbase;
 
-import java.util.UUID;
-
 import javax.mail.Flags;
 
 import org.apache.james.mailbox.MailboxPathLocker;
@@ -37,10 +35,10 @@ import org.apache.james.mailbox.store.se
  * HBase implementation of MessageManager.
  * 
  */
-public class HBaseMessageManager extends StoreMessageManager<UUID> {
+public class HBaseMessageManager extends StoreMessageManager<HBaseId> {
 
-    public HBaseMessageManager(MailboxSessionMapperFactory<UUID> mapperFactory, MessageSearchIndex<UUID> index,
-            MailboxEventDispatcher<UUID> dispatcher, MailboxPathLocker locker, Mailbox<UUID> mailbox, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) throws MailboxException {
+    public HBaseMessageManager(MailboxSessionMapperFactory<HBaseId> mapperFactory, MessageSearchIndex<HBaseId> index,
+            MailboxEventDispatcher<HBaseId> dispatcher, MailboxPathLocker locker, Mailbox<HBaseId> mailbox, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) throws MailboxException {
         super(mapperFactory, index, dispatcher, locker, mailbox, aclResolver, groupMembershipResolver);
 
     }

Modified: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseUtils.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseUtils.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseUtils.java (original)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/HBaseUtils.java Mon Jun 29 08:21:12 2015
@@ -18,11 +18,48 @@
  ****************************************************************/
 package org.apache.james.mailbox.hbase;
 
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_ANSWERED;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_DELETED;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_DRAFT;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_FLAGGED;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_RECENT;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_SEEN;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_USER;
+import static org.apache.james.mailbox.hbase.FlagConvertor.PREFIX_SFLAGS_B;
+import static org.apache.james.mailbox.hbase.FlagConvertor.PREFIX_UFLAGS_B;
+import static org.apache.james.mailbox.hbase.FlagConvertor.systemFlagFromBytes;
+import static org.apache.james.mailbox.hbase.FlagConvertor.userFlagFromBytes;
+import static org.apache.james.mailbox.hbase.FlagConvertor.userFlagToBytes;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_HIGHEST_MODSEQ;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_LASTUID;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_MESSAGE_COUNT;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_NAME;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_NAMESPACE;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_UIDVALIDITY;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_USER;
+import static org.apache.james.mailbox.hbase.HBaseNames.MARKER_MISSING;
+import static org.apache.james.mailbox.hbase.HBaseNames.MARKER_PRESENT;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_META_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_BODY_OCTETS;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_CONTENT_OCTETS;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_INTERNALDATE;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_MEDIA_TYPE;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_MODSEQ;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_SUB_TYPE;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_TEXT_LINE_COUNT;
+import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
+import static org.apache.james.mailbox.hbase.PropertyConvertor.PREFIX_PROP_B;
+import static org.apache.james.mailbox.hbase.PropertyConvertor.getProperty;
+import static org.apache.james.mailbox.hbase.PropertyConvertor.getQualifier;
+import static org.apache.james.mailbox.hbase.PropertyConvertor.getValue;
+
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.NavigableMap;
 import java.util.UUID;
+
 import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 
@@ -33,8 +70,8 @@ import org.apache.hadoop.hbase.client.Pu
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.james.mailbox.hbase.io.ChunkInputStream;
-import org.apache.james.mailbox.hbase.mail.model.HBaseMailbox;
 import org.apache.james.mailbox.hbase.mail.HBaseMessage;
+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 org.apache.james.mailbox.store.mail.model.Message;
@@ -42,10 +79,6 @@ import org.apache.james.mailbox.store.ma
 import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
 import org.apache.james.mailbox.store.user.model.Subscription;
 
-import static org.apache.james.mailbox.hbase.FlagConvertor.*;
-import static org.apache.james.mailbox.hbase.PropertyConvertor.*;
-import static org.apache.james.mailbox.hbase.HBaseNames.*;
-
 /**
  * HBase utility classes for mailbox and message manipulation.
  * @author ieugen
@@ -58,7 +91,7 @@ public class HBaseUtils {
      * @param result a result of a HBase Get operation 
      * @return a Mailbox object
      */
-    public static Mailbox<UUID> mailboxFromResult(Result result) {
+    public static Mailbox<HBaseId> mailboxFromResult(Result result) {
         NavigableMap<byte[], byte[]> rawMailbox = result.getFamilyMap(MAILBOX_CF);
         //TODO: should we test for null values?
         MailboxPath path = new MailboxPath(Bytes.toString(rawMailbox.get(MAILBOX_NAMESPACE)),
@@ -66,7 +99,7 @@ public class HBaseUtils {
                 Bytes.toString(rawMailbox.get(MAILBOX_NAME)));
 
         HBaseMailbox mailbox = new HBaseMailbox(path, Bytes.toLong(rawMailbox.get(MAILBOX_UIDVALIDITY)));
-        mailbox.setMailboxId(UUIDFromRowKey(result.getRow()));
+        mailbox.setMailboxId(HBaseIdFromRowKey(result.getRow()));
         mailbox.setHighestModSeq(Bytes.toLong(rawMailbox.get(MAILBOX_HIGHEST_MODSEQ)));
         mailbox.setLastUid(Bytes.toLong(rawMailbox.get(MAILBOX_LASTUID)));
         mailbox.setMessageCount(Bytes.toLong(rawMailbox.get(MAILBOX_MESSAGE_COUNT)));
@@ -74,27 +107,12 @@ public class HBaseUtils {
     }
 
     /**
-     * This returns the row key needed for HBase. Having the method here ensure 
-     * we have a consistent way to generate the rowkey.
-     *
-     * Convenience method for generating a rowKey when you don't have a mailbox object.
-     * @param uuid
-     * @return rowkey byte array that can be used with HBase API
-     */
-    public static byte[] mailboxRowKey(UUID uuid) {
-        byte[] rowKey = new byte[16];
-        int offset = Bytes.putLong(rowKey, 0, uuid.getMostSignificantBits());
-        Bytes.putLong(rowKey, offset, uuid.getLeastSignificantBits());
-        return rowKey;
-    }
-
-    /**
      * Returns a UUID from the a byte array.
      * @param rowkey
      * @return UUID calculated from the byte array
      */
-    public static UUID UUIDFromRowKey(byte[] rowkey) {
-        return new UUID(Bytes.toLong(rowkey, 0), Bytes.toLong(rowkey, 8));
+    public static HBaseId HBaseIdFromRowKey(byte[] rowkey) {
+        return HBaseId.of(new UUID(Bytes.toLong(rowkey, 0), Bytes.toLong(rowkey, 8)));
     }
 
     /**
@@ -102,7 +120,7 @@ public class HBaseUtils {
      * @return a Put object
      */
     public static Put toPut(HBaseMailbox mailbox) {
-        Put put = new Put(mailboxRowKey(mailbox.getMailboxId()));
+        Put put = new Put(mailbox.getMailboxId().toBytes());
         // we don't store null values and we don't restore them. it's a column based store.
         if (mailbox.getName() != null) {
             put.add(MAILBOX_CF, MAILBOX_NAME, Bytes.toBytes(mailbox.getName()));
@@ -127,7 +145,7 @@ public class HBaseUtils {
      * @param message
      * @return a put that contains all metadata information.
      */
-    public static Put metadataToPut(Message<UUID> message) {
+    public static Put metadataToPut(Message<HBaseId> message) {
         Put put = new Put(messageRowKey(message));
         // we store the message uid and mailbox uid in the row key
         // store the meta data
@@ -185,7 +203,7 @@ public class HBaseUtils {
      * @param message message to get row key from
      * @return rowkey byte array that can be used with HBase API
      */
-    public static byte[] messageRowKey(Message<UUID> message) {
+    public static byte[] messageRowKey(Message<HBaseId> message) {
         return messageRowKey(message.getMailboxId(), message.getUid());
     }
 
@@ -197,26 +215,20 @@ public class HBaseUtils {
      * @param uid message uid
      * @return rowkey byte array that can be used with HBase API
      */
-    public static byte[] messageRowKey(UUID mailboxUid, long uid) {
+    public static byte[] messageRowKey(HBaseId mailboxUid, long uid) {
         /**  message uid's are stored in reverse order so we will always have the most recent messages first*/
-        byte[] ba = Bytes.add(Bytes.toBytes(mailboxUid.getMostSignificantBits()),
-                Bytes.toBytes(mailboxUid.getLeastSignificantBits()),
-                Bytes.toBytes(Long.MAX_VALUE - uid));
-        //System.out.println(Bytes.toStringBinary(ba));
-        return ba;
+        return Bytes.add(mailboxUid.toBytes(), Bytes.toBytes(Long.MAX_VALUE - uid));
     }
 
     /**
      * Utility to build row keys from mailboxUID and a value. The value is added to 
      * the key without any other operations. 
-     * @param mailboxUid mailbox UUID
+     * @param mailboxUid mailbox HBaseId
      * @param value
      * @return rowkey byte array that can be used with HBase API
      */
-    public static byte[] customMessageRowKey(UUID mailboxUid, long value) {
-        return Bytes.add(Bytes.toBytes(mailboxUid.getMostSignificantBits()),
-                Bytes.toBytes(mailboxUid.getLeastSignificantBits()),
-                Bytes.toBytes(value));
+    public static byte[] customMessageRowKey(HBaseId mailboxUid, long value) {
+        return Bytes.add(mailboxUid.toBytes(), Bytes.toBytes(value));
     }
 
     /**
@@ -228,7 +240,7 @@ public class HBaseUtils {
      * @param result the result object containing message data
      * @return a HBaseMessage instance with message metadata.
      */
-    public static Message<UUID> messageMetaFromResult(Configuration conf, Result result) {
+    public static Message<HBaseId> messageMetaFromResult(Configuration conf, Result result) {
         HBaseMessage message = null;
         Flags flags = new Flags();
         List<Property> propList = new ArrayList<Property>();
@@ -288,7 +300,7 @@ public class HBaseUtils {
             }
             i++;
         }
-        UUID uuid = UUIDFromRowKey(result.getRow());
+        HBaseId uuid = HBaseIdFromRowKey(result.getRow());
         uid = Long.MAX_VALUE - Bytes.toLong(result.getRow(), 16);
         PropertyBuilder props = new PropertyBuilder(propList);
         props.setMediaType(mediaType);
@@ -316,7 +328,7 @@ public class HBaseUtils {
      * @param flags
      * @return a put object with 
      */
-    public static Put flagsToPut(Message<UUID> message, Flags flags) {
+    public static Put flagsToPut(Message<HBaseId> message, Flags flags) {
         Put put = new Put(messageRowKey(message));
         //system flags
         if (flags.contains(Flag.ANSWERED)) {
@@ -364,7 +376,7 @@ public class HBaseUtils {
         return put;
     }
 
-    public static Delete flagsToDelete(Message<UUID> message, Flags flags) {
+    public static Delete flagsToDelete(Message<HBaseId> message, Flags flags) {
         Delete delete = new Delete(messageRowKey(message));
         //we mark for delete flags that are not present (they will be Put'ed)
         if (flags.contains(Flag.ANSWERED)) {

Modified: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java (original)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java Mon Jun 29 08:21:12 2015
@@ -28,13 +28,11 @@ import static org.apache.james.mailbox.h
 import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_TABLE;
 import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGE_INTERNALDATE;
 import static org.apache.james.mailbox.hbase.HBaseUtils.mailboxFromResult;
-import static org.apache.james.mailbox.hbase.HBaseUtils.mailboxRowKey;
 import static org.apache.james.mailbox.hbase.HBaseUtils.toPut;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.UUID;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.client.Delete;
@@ -52,6 +50,7 @@ import org.apache.hadoop.hbase.util.Byte
 import org.apache.hadoop.io.IOUtils;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
+import org.apache.james.mailbox.hbase.HBaseId;
 import org.apache.james.mailbox.hbase.HBaseNonTransactionalMapper;
 import org.apache.james.mailbox.hbase.mail.model.HBaseMailbox;
 import org.apache.james.mailbox.model.MailboxACL;
@@ -63,7 +62,7 @@ import org.apache.james.mailbox.store.ma
  * Data access management for mailbox.
  *
  */
-public class HBaseMailboxMapper extends HBaseNonTransactionalMapper implements MailboxMapper<UUID> {
+public class HBaseMailboxMapper extends HBaseNonTransactionalMapper implements MailboxMapper<HBaseId> {
 
     /**
      * Link to the HBase Configuration object and specific mailbox names
@@ -75,7 +74,7 @@ public class HBaseMailboxMapper extends
     }
     
     @Override
-    public Mailbox<UUID> findMailboxByPath(MailboxPath mailboxPath) throws MailboxException, MailboxNotFoundException {
+    public Mailbox<HBaseId> findMailboxByPath(MailboxPath mailboxPath) throws MailboxException, MailboxNotFoundException {
         HTable mailboxes = null;
         ResultScanner scanner = null;
         try {
@@ -126,7 +125,7 @@ public class HBaseMailboxMapper extends
     }
     
     @Override
-    public List<Mailbox<UUID>> findMailboxWithPathLike(MailboxPath mailboxPath) throws MailboxException {
+    public List<Mailbox<HBaseId>> findMailboxWithPathLike(MailboxPath mailboxPath) throws MailboxException {
         HTable mailboxes = null;
         ResultScanner scanner = null;
         try {
@@ -167,7 +166,7 @@ public class HBaseMailboxMapper extends
             scan.setFilter(filters);
             scanner = mailboxes.getScanner(scan);
             
-            List<Mailbox<UUID>> mailboxList = new ArrayList<Mailbox<UUID>>();
+            List<Mailbox<HBaseId>> mailboxList = new ArrayList<Mailbox<HBaseId>>();
             
             for (Result result : scanner) {
                 mailboxList.add(mailboxFromResult(result));
@@ -188,7 +187,7 @@ public class HBaseMailboxMapper extends
     }
     
     @Override
-    public List<Mailbox<UUID>> list() throws MailboxException {
+    public List<Mailbox<HBaseId>> list() throws MailboxException {
         HTable mailboxes = null;
         ResultScanner scanner = null;
         //TODO: possible performance isssues, we are creating an object from all the rows in HBase mailbox table
@@ -199,11 +198,11 @@ public class HBaseMailboxMapper extends
             scan.setCaching(mailboxes.getScannerCaching() * 2);
             scan.setMaxVersions(1);
             scanner = mailboxes.getScanner(scan);
-            List<Mailbox<UUID>> mailboxList = new ArrayList<Mailbox<UUID>>();
+            List<Mailbox<HBaseId>> mailboxList = new ArrayList<Mailbox<HBaseId>>();
             
             Result result;
             while ((result = scanner.next()) != null) {
-                Mailbox<UUID> mlbx = mailboxFromResult(result);
+                Mailbox<HBaseId> mlbx = mailboxFromResult(result);
                 mailboxList.add(mlbx);
             }
             return mailboxList;
@@ -226,7 +225,7 @@ public class HBaseMailboxMapper extends
     }
     
     @Override
-    public void save(Mailbox<UUID> mlbx) throws MailboxException {
+    public void save(Mailbox<HBaseId> mlbx) throws MailboxException {
         //TODO: maybe switch to checkAndPut for transactions
         HTable mailboxes = null;
         try {
@@ -250,13 +249,13 @@ public class HBaseMailboxMapper extends
     }
     
     @Override
-    public void delete(Mailbox<UUID> mlbx) throws MailboxException {
+    public void delete(Mailbox<HBaseId> mlbx) throws MailboxException {
         //TODO: maybe switch to checkAndDelete
         HTable mailboxes = null;
         try {
             mailboxes = new HTable(conf, MAILBOXES_TABLE);
             //TODO: delete all maessages from this mailbox
-            Delete delete = new Delete(mailboxRowKey(mlbx.getMailboxId()));
+            Delete delete = new Delete(mlbx.getMailboxId().toBytes());
             mailboxes.delete(delete);
         } catch (IOException ex) {
             throw new MailboxException("IOException in HBase cluster during delete()", ex);
@@ -272,7 +271,7 @@ public class HBaseMailboxMapper extends
     }
     
     @Override
-    public boolean hasChildren(final Mailbox<UUID> mailbox, final char c) throws MailboxException, MailboxNotFoundException {
+    public boolean hasChildren(final Mailbox<HBaseId> mailbox, final char c) throws MailboxException, MailboxNotFoundException {
         HTable mailboxes = null;
         ResultScanner scanner = null;
         try {
@@ -395,7 +394,7 @@ public class HBaseMailboxMapper extends
     }
 
     @Override
-    public void updateACL(Mailbox<UUID> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException {
+    public void updateACL(Mailbox<HBaseId> mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException {
         mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand));
     }
 }

Modified: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMessage.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMessage.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMessage.java (original)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMessage.java Mon Jun 29 08:21:12 2015
@@ -18,39 +18,41 @@
  ****************************************************************/
 package org.apache.james.mailbox.hbase.mail;
 
+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.HBaseUtils.messageRowKey;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
-import java.util.UUID;
 
 import javax.mail.Flags;
-import org.apache.hadoop.conf.Configuration;
 
+import org.apache.hadoop.conf.Configuration;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.hbase.HBaseId;
 import org.apache.james.mailbox.hbase.io.ChunkInputStream;
 import org.apache.james.mailbox.store.mail.model.AbstractMessage;
 import org.apache.james.mailbox.store.mail.model.Message;
 import org.apache.james.mailbox.store.mail.model.Property;
 import org.apache.james.mailbox.store.mail.model.impl.PropertyBuilder;
 
-import static org.apache.james.mailbox.hbase.HBaseUtils.*;
-import static org.apache.james.mailbox.hbase.HBaseNames.*;
-
 /**
  * Concrete HBaseMessage implementation. This implementation does not store any
  * message content. The message content is retrieved using a ChunkedInputStream
  * directly from HBase.
  */
-public class HBaseMessage extends AbstractMessage<UUID> {
+public class HBaseMessage extends AbstractMessage<HBaseId> {
 
     private static final String TOSTRING_SEPARATOR = " ";
     /** Configuration for the HBase cluster */
     private final Configuration conf;
     /** The value for the mailboxId field */
-    private UUID mailboxId;
+    private HBaseId mailboxId;
     /** The value for the uid field */
     private long uid;
     /** The value for the modSeq field */
@@ -92,7 +94,7 @@ public class HBaseMessage extends Abstra
      * @param original
      * @throws MailboxException
      */
-    public HBaseMessage(Configuration conf, UUID mailboxId, long uid, long modSeq, Message<?> original) throws MailboxException {
+    public HBaseMessage(Configuration conf, HBaseId mailboxId, long uid, long modSeq, Message<?> original) throws MailboxException {
         super();
         this.conf = conf;
         this.mailboxId = mailboxId;
@@ -124,7 +126,7 @@ public class HBaseMessage extends Abstra
      * @param bodyStartOctet
      * @param propertyBuilder
      */
-    public HBaseMessage(Configuration conf, UUID mailboxId, Date internalDate, Flags flags, long contentOctets, int bodyStartOctet, PropertyBuilder propertyBuilder) {
+    public HBaseMessage(Configuration conf, HBaseId mailboxId, Date internalDate, Flags flags, long contentOctets, int bodyStartOctet, PropertyBuilder propertyBuilder) {
         super();
         this.conf = conf;
         this.mailboxId = mailboxId;
@@ -162,7 +164,7 @@ public class HBaseMessage extends Abstra
     public int hashCode() {
         final int PRIME = 31;
         int result = 1;
-        result = PRIME * result + (int) (getMailboxId().getMostSignificantBits() ^ (getMailboxId().getMostSignificantBits() >>> 32));
+        result = PRIME * result + mailboxId.hashCode();
         result = PRIME * result + (int) (uid ^ (uid >>> 32));
         return result;
     }
@@ -283,7 +285,7 @@ public class HBaseMessage extends Abstra
      * @see org.apache.james.mailbox.store.mail.model.Message#getMailboxId()
      */
     @Override
-    public UUID getMailboxId() {
+    public HBaseId getMailboxId() {
         return mailboxId;
     }
 

Modified: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMessageMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMessageMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMessageMapper.java (original)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMessageMapper.java Mon Jun 29 08:21:12 2015
@@ -18,9 +18,28 @@
  ****************************************************************/
 package org.apache.james.mailbox.hbase.mail;
 
-import org.apache.hadoop.conf.Configuration;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_DELETED;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_RECENT;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_SEEN;
+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.MAILBOX_HIGHEST_MODSEQ;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_MESSAGE_COUNT;
+import static org.apache.james.mailbox.hbase.HBaseNames.MARKER_MISSING;
+import static org.apache.james.mailbox.hbase.HBaseNames.MARKER_PRESENT;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAX_COLUMN_SIZE;
+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.MESSAGE_MODSEQ;
+import static org.apache.james.mailbox.hbase.HBaseUtils.customMessageRowKey;
+import static org.apache.james.mailbox.hbase.HBaseUtils.flagsToPut;
+import static org.apache.james.mailbox.hbase.HBaseUtils.messageMetaFromResult;
+import static org.apache.james.mailbox.hbase.HBaseUtils.messageRowKey;
+import static org.apache.james.mailbox.hbase.HBaseUtils.metadataToPut;
+
 import java.io.BufferedInputStream;
-import org.apache.hadoop.hbase.client.Put;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -28,11 +47,14 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.UUID;
+
 import javax.mail.Flags;
+
+import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.client.Delete;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTable;
+import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.client.Result;
 import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
@@ -43,38 +65,35 @@ import org.apache.hadoop.hbase.filter.Si
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.hbase.HBaseId;
 import org.apache.james.mailbox.hbase.io.ChunkOutputStream;
 import org.apache.james.mailbox.model.MessageMetaData;
 import org.apache.james.mailbox.model.MessageRange;
-import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.model.MessageRange.Type;
+import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.SimpleMessageMetaData;
-import org.apache.james.mailbox.store.transaction.NonTransactionalMapper;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.UidProvider;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.apache.james.mailbox.store.mail.model.Message;
-
-import static org.apache.james.mailbox.hbase.HBaseUtils.*;
-import static org.apache.james.mailbox.hbase.HBaseNames.*;
-import static org.apache.james.mailbox.hbase.FlagConvertor.*;
+import org.apache.james.mailbox.store.transaction.NonTransactionalMapper;
 
 /**
  * HBase implementation of a {@link MessageMapper}.
  * I don't know if this class is thread-safe! Asume it is not!
  *
  */
-public class HBaseMessageMapper extends NonTransactionalMapper implements MessageMapper<UUID> {
+public class HBaseMessageMapper extends NonTransactionalMapper implements MessageMapper<HBaseId> {
 
     private final Configuration conf;
     private final MailboxSession mailboxSession;
-    private final UidProvider<UUID> uidProvider;
-    private final ModSeqProvider<UUID> modSeqProvider;
+    private final UidProvider<HBaseId> uidProvider;
+    private final ModSeqProvider<HBaseId> modSeqProvider;
 
     public HBaseMessageMapper(final MailboxSession session,
-            final UidProvider<UUID> uidProvider,
-            ModSeqProvider<UUID> modSeqProvider, Configuration conf) {
+            final UidProvider<HBaseId> uidProvider,
+            ModSeqProvider<HBaseId> modSeqProvider, Configuration conf) {
         this.mailboxSession = session;
         this.modSeqProvider = modSeqProvider;
         this.uidProvider = uidProvider;
@@ -86,9 +105,9 @@ public class HBaseMessageMapper extends
     }
 
     @Override
-    public Iterator<Message<UUID>> findInMailbox(Mailbox<UUID> mailbox, MessageRange set, FetchType fType, int max) throws MailboxException {
+    public Iterator<Message<HBaseId>> findInMailbox(Mailbox<HBaseId> mailbox, MessageRange set, FetchType fType, int max) throws MailboxException {
         try {
-            List<Message<UUID>> results;
+            List<Message<HBaseId>> results;
             long from = set.getUidFrom();
             final long to = set.getUidTo();
             final Type type = set.getType();
@@ -115,12 +134,11 @@ public class HBaseMessageMapper extends
         }
     }
 
-    private List<Message<UUID>> findMessagesInMailbox(Mailbox<UUID> mailbox, int batchSize, boolean flaggedForDelete) throws IOException {
-        List<Message<UUID>> messageList = new ArrayList<Message<UUID>>();
+    private List<Message<HBaseId>> findMessagesInMailbox(Mailbox<HBaseId> mailbox, int batchSize, boolean flaggedForDelete) throws IOException {
+        List<Message<HBaseId>> messageList = new ArrayList<Message<HBaseId>>();
         HTable messages = new HTable(conf, MESSAGES_TABLE);
         Scan scan = new Scan(customMessageRowKey(mailbox.getMailboxId(), 0L),
-                new PrefixFilter(Bytes.add(Bytes.toBytes(mailbox.getMailboxId().getMostSignificantBits()),
-                Bytes.toBytes(mailbox.getMailboxId().getLeastSignificantBits()))));
+                new PrefixFilter(mailbox.getMailboxId().toBytes()));
         if (flaggedForDelete) {
             SingleColumnValueFilter filter = new SingleColumnValueFilter(MESSAGES_META_CF, FLAGS_DELETED, CompareOp.EQUAL, MARKER_PRESENT);
             filter.setFilterIfMissing(true);
@@ -145,8 +163,8 @@ public class HBaseMessageMapper extends
         return messageList;
     }
 
-    private List<Message<UUID>> findMessagesInMailboxWithUID(Mailbox<UUID> mailbox, final long messageUid, final boolean flaggedForDelete) throws IOException {
-        List<Message<UUID>> messageList = new ArrayList<Message<UUID>>();
+    private List<Message<HBaseId>> findMessagesInMailboxWithUID(Mailbox<HBaseId> mailbox, final long messageUid, final boolean flaggedForDelete) throws IOException {
+        List<Message<HBaseId>> messageList = new ArrayList<Message<HBaseId>>();
         HTable messages = new HTable(conf, MESSAGES_TABLE);
         Get get = new Get(messageRowKey(mailbox.getMailboxId(), messageUid));
         get.setMaxVersions(1);
@@ -160,7 +178,7 @@ public class HBaseMessageMapper extends
         }
         get.addFamily(MESSAGES_META_CF);
         Result result = messages.get(get);
-        Message<UUID> message = null;
+        Message<HBaseId> message = null;
         if (!result.isEmpty()) {
             message = messageMetaFromResult(conf, result);
             messageList.add(message);
@@ -169,8 +187,8 @@ public class HBaseMessageMapper extends
         return messageList;
     }
 
-    private List<Message<UUID>> findMessagesInMailboxAfterUID(Mailbox<UUID> mailbox, final long from, final int batchSize, final boolean flaggedForDelete) throws IOException {
-        List<Message<UUID>> messageList = new ArrayList<Message<UUID>>();
+    private List<Message<HBaseId>> findMessagesInMailboxAfterUID(Mailbox<HBaseId> mailbox, final long from, final int batchSize, final boolean flaggedForDelete) throws IOException {
+        List<Message<HBaseId>> messageList = new ArrayList<Message<HBaseId>>();
         HTable messages = new HTable(conf, MESSAGES_TABLE);
         // uids are stored in reverse so we need to search
         Scan scan = new Scan(messageRowKey(mailbox.getMailboxId(), Long.MAX_VALUE),
@@ -199,8 +217,8 @@ public class HBaseMessageMapper extends
         return messageList;
     }
 
-    private List<Message<UUID>> findMessagesInMailboxBetweenUIDs(Mailbox<UUID> mailbox, final long from, final long to, final int batchSize, final boolean flaggedForDelete) throws IOException {
-        List<Message<UUID>> messageList = new ArrayList<Message<UUID>>();
+    private List<Message<HBaseId>> findMessagesInMailboxBetweenUIDs(Mailbox<HBaseId> mailbox, final long from, final long to, final int batchSize, final boolean flaggedForDelete) throws IOException {
+        List<Message<HBaseId>> messageList = new ArrayList<Message<HBaseId>>();
         if (from > to) {
             return messageList;
         }
@@ -227,7 +245,7 @@ public class HBaseMessageMapper extends
             if (count == 0) {
                 break;
             }
-            Message<UUID> message = messageMetaFromResult(conf, result);
+            Message<HBaseId> message = messageMetaFromResult(conf, result);
             messageList.add(message);
             count--;
         }
@@ -239,10 +257,10 @@ public class HBaseMessageMapper extends
     }
 
     @Override
-    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox<UUID> mailbox, MessageRange set) throws MailboxException {
+    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox<HBaseId> mailbox, MessageRange set) throws MailboxException {
         try {
             final Map<Long, MessageMetaData> data;
-            final List<Message<UUID>> results;
+            final List<Message<HBaseId>> results;
             final long from = set.getUidFrom();
             final long to = set.getUidTo();
 
@@ -277,11 +295,11 @@ public class HBaseMessageMapper extends
     }
 
     @Override
-    public long countMessagesInMailbox(Mailbox<UUID> mailbox) throws MailboxException {
+    public long countMessagesInMailbox(Mailbox<HBaseId> mailbox) throws MailboxException {
         HTable mailboxes = null;
         try {
             mailboxes = new HTable(conf, MAILBOXES_TABLE);
-            Get get = new Get(mailboxRowKey(mailbox.getMailboxId()));
+            Get get = new Get(mailbox.getMailboxId().toBytes());
             get.addColumn(MAILBOX_CF, MAILBOX_MESSAGE_COUNT);
             get.setMaxVersions(1);
             Result result = mailboxes.get(get);
@@ -301,7 +319,7 @@ public class HBaseMessageMapper extends
     }
 
     @Override
-    public long countUnseenMessagesInMailbox(Mailbox<UUID> mailbox) throws MailboxException {
+    public long countUnseenMessagesInMailbox(Mailbox<HBaseId> mailbox) throws MailboxException {
         /* TODO: see if it is possible to store the number of unseen messages in the mailbox table
          * and just return that value with a Get and kepp it up to date.
          */
@@ -338,7 +356,7 @@ public class HBaseMessageMapper extends
     }
 
     @Override
-    public void delete(Mailbox<UUID> mailbox, Message<UUID> message) throws MailboxException {
+    public void delete(Mailbox<HBaseId> mailbox, Message<HBaseId> message) throws MailboxException {
         //TODO: maybe switch to checkAndDelete
         HTable messages = null;
         HTable mailboxes = null;
@@ -349,7 +367,7 @@ public class HBaseMessageMapper extends
              *  and implement countMessages with get.
              */
             Delete delete = new Delete(messageRowKey(message));
-            mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, -1);
+            mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, -1);
             messages.delete(delete);
 
         } catch (IOException ex) {
@@ -376,7 +394,7 @@ public class HBaseMessageMapper extends
     }
 
     @Override
-    public Long findFirstUnseenMessageUid(Mailbox<UUID> mailbox) throws MailboxException {
+    public Long findFirstUnseenMessageUid(Mailbox<HBaseId> mailbox) throws MailboxException {
         HTable messages = null;
         ResultScanner scanner = null;
         try {
@@ -415,7 +433,7 @@ public class HBaseMessageMapper extends
     }
 
     @Override
-    public List<Long> findRecentMessageUidsInMailbox(Mailbox<UUID> mailbox) throws MailboxException {
+    public List<Long> findRecentMessageUidsInMailbox(Mailbox<HBaseId> mailbox) throws MailboxException {
         /** TODO: improve performance by implementing a last seen and last recent value per mailbox.
          * maybe one more call to HBase is less expensive than iterating throgh all rows.
          */
@@ -460,7 +478,7 @@ public class HBaseMessageMapper extends
      * @see org.apache.james.mailbox.store.mail.MessageMapper#add(org.apache.james.mailbox.store.mail.model.Mailbox, org.apache.james.mailbox.store.mail.model.Message)
      */
     @Override
-    public MessageMetaData add(Mailbox<UUID> mailbox, Message<UUID> message) throws MailboxException {
+    public MessageMetaData add(Mailbox<HBaseId> mailbox, Message<HBaseId> message) throws MailboxException {
         message.setUid(uidProvider.nextUid(mailboxSession, mailbox));
         // if a mailbox does not support mod-sequences the provider may be null
         if (modSeqProvider != null) {
@@ -476,10 +494,10 @@ public class HBaseMessageMapper extends
      * @see org.apache.james.mailbox.store.mail.MessageMapper#updateFlags(org.apache.james.mailbox.store.mail.model.Mailbox, javax.mail.Flags, boolean, boolean, org.apache.james.mailbox.MessageRange)
      */
     @Override
-    public Iterator<UpdatedFlags> updateFlags(final Mailbox<UUID> mailbox, final Flags flags, final boolean value, final boolean replace, MessageRange set) throws MailboxException {
+    public Iterator<UpdatedFlags> updateFlags(final Mailbox<HBaseId> mailbox, final Flags flags, final boolean value, final boolean replace, MessageRange set) throws MailboxException {
 
         final List<UpdatedFlags> updatedFlags = new ArrayList<UpdatedFlags>();
-        Iterator<Message<UUID>> messagesFound = findInMailbox(mailbox, set, FetchType.Metadata, -1);
+        Iterator<Message<HBaseId>> messagesFound = findInMailbox(mailbox, set, FetchType.Metadata, -1);
 
         HTable messages = null;
         long modSeq = -1;
@@ -494,7 +512,7 @@ public class HBaseMessageMapper extends
             messages = new HTable(conf, MESSAGES_TABLE);
             while (messagesFound.hasNext()) {
                 Put put = null;
-                final Message<UUID> member = messagesFound.next();
+                final Message<HBaseId> member = messagesFound.next();
                 Flags originalFlags = member.createFlags();
 
                 if (replace) {
@@ -541,7 +559,7 @@ public class HBaseMessageMapper extends
      * @see org.apache.james.mailbox.store.mail.MessageMapper#copy(org.apache.james.mailbox.store.mail.model.Mailbox, org.apache.james.mailbox.store.mail.model.Message)
      */
     @Override
-    public MessageMetaData copy(Mailbox<UUID> mailbox, Message<UUID> original) throws MailboxException {
+    public MessageMetaData copy(Mailbox<HBaseId> mailbox, Message<HBaseId> original) throws MailboxException {
         long uid = uidProvider.nextUid(mailboxSession, mailbox);
         long modSeq = -1;
         if (modSeqProvider != null) {
@@ -558,7 +576,7 @@ public class HBaseMessageMapper extends
      * @see org.apache.james.mailbox.store.mail.MessageMapper#copy(org.apache.james.mailbox.store.mail.model.Mailbox, org.apache.james.mailbox.store.mail.model.Message)
      */
     @Override
-    public MessageMetaData move(Mailbox<UUID> mailbox, Message<UUID> original) throws MailboxException {
+    public MessageMetaData move(Mailbox<HBaseId> mailbox, Message<HBaseId> original) throws MailboxException {
     	//TODO implement if possible
     	throw new UnsupportedOperationException();
     }
@@ -568,7 +586,7 @@ public class HBaseMessageMapper extends
      * @see org.apache.james.mailbox.store.mail.MessageMapper#getLastUid(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
     @Override
-    public long getLastUid(Mailbox<UUID> mailbox) throws MailboxException {
+    public long getLastUid(Mailbox<HBaseId> mailbox) throws MailboxException {
         return uidProvider.lastUid(mailboxSession, mailbox);
     }
 
@@ -577,7 +595,7 @@ public class HBaseMessageMapper extends
      * @see org.apache.james.mailbox.store.mail.MessageMapper#getHighestModSeq(org.apache.james.mailbox.store.mail.model.Mailbox)
      */
     @Override
-    public long getHighestModSeq(Mailbox<UUID> mailbox) throws MailboxException {
+    public long getHighestModSeq(Mailbox<HBaseId> mailbox) throws MailboxException {
         return modSeqProvider.highestModSeq(mailboxSession, mailbox);
     }
 
@@ -589,7 +607,7 @@ public class HBaseMessageMapper extends
      * @return metaData
      * @throws MailboxException
      */
-    protected MessageMetaData save(Mailbox<UUID> mailbox, Message<UUID> message) throws MailboxException {
+    protected MessageMetaData save(Mailbox<HBaseId> mailbox, Message<HBaseId> message) throws MailboxException {
         HTable messages = null;
         HTable mailboxes = null;
         BufferedInputStream in = null;
@@ -622,7 +640,7 @@ public class HBaseMessageMapper extends
             in.close();
             out.close();
             // increase the message count for the current mailbox
-            mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, 1);
+            mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, 1);
             return new SimpleMessageMetaData(message);
         } catch (IOException ex) {
             throw new MailboxException("Error setting flags for messages in " + mailbox, ex);
@@ -658,19 +676,19 @@ public class HBaseMessageMapper extends
         }
     }
 
-    private void deleteDeletedMessagesInMailboxWithUID(Mailbox<UUID> mailbox, long uid) throws IOException {
+    private void deleteDeletedMessagesInMailboxWithUID(Mailbox<HBaseId> mailbox, long uid) throws IOException {
         //TODO: do I have to check if the message is flagged for delete here?
         HTable messages = new HTable(conf, MESSAGES_TABLE);
         HTable mailboxes = new HTable(conf, MAILBOXES_TABLE);
         Delete delete = new Delete(messageRowKey(mailbox.getMailboxId(), uid));
         messages.delete(delete);
-        mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, -1);
-        mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ, 1);
+        mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, -1);
+        mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ, 1);
         mailboxes.close();
         messages.close();
     }
 
-    private void deleteDeletedMessagesInMailboxBetweenUIDs(Mailbox<UUID> mailbox, long fromUid, long toUid) throws IOException {
+    private void deleteDeletedMessagesInMailboxBetweenUIDs(Mailbox<HBaseId> mailbox, long fromUid, long toUid) throws IOException {
         HTable messages = new HTable(conf, MESSAGES_TABLE);
         HTable mailboxes = new HTable(conf, MAILBOXES_TABLE);
         List<Delete> deletes = new ArrayList<Delete>();
@@ -690,13 +708,13 @@ public class HBaseMessageMapper extends
         long totalDeletes = deletes.size();
         scanner.close();
         messages.delete(deletes);
-        mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, -(totalDeletes - deletes.size()));
-        mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ, 1);
+        mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, -(totalDeletes - deletes.size()));
+        mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ, 1);
         mailboxes.close();
         messages.close();
     }
 
-    private void deleteDeletedMessagesInMailboxAfterUID(Mailbox<UUID> mailbox, long fromUid) throws IOException {
+    private void deleteDeletedMessagesInMailboxAfterUID(Mailbox<HBaseId> mailbox, long fromUid) throws IOException {
         HTable messages = new HTable(conf, MESSAGES_TABLE);
         HTable mailboxes = new HTable(conf, MAILBOXES_TABLE);
         List<Delete> deletes = new ArrayList<Delete>();
@@ -716,13 +734,13 @@ public class HBaseMessageMapper extends
         long totalDeletes = deletes.size();
         scanner.close();
         messages.delete(deletes);
-        mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, -(totalDeletes - deletes.size()));
-        mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ, 1);
+        mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, -(totalDeletes - deletes.size()));
+        mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ, 1);
         mailboxes.close();
         messages.close();
     }
 
-    private void deleteDeletedMessagesInMailbox(Mailbox<UUID> mailbox) throws IOException {
+    private void deleteDeletedMessagesInMailbox(Mailbox<HBaseId> mailbox) throws IOException {
         HTable messages = new HTable(conf, MESSAGES_TABLE);
         HTable mailboxes = new HTable(conf, MAILBOXES_TABLE);
         List<Delete> deletes = new ArrayList<Delete>();
@@ -730,8 +748,7 @@ public class HBaseMessageMapper extends
          * HBase scan operaion are exclusive to the upper bound when providing stop row key.
          */
         Scan scan = new Scan(customMessageRowKey(mailbox.getMailboxId(), 0L),
-                new PrefixFilter(Bytes.add(Bytes.toBytes(mailbox.getMailboxId().getMostSignificantBits()),
-                Bytes.toBytes(mailbox.getMailboxId().getLeastSignificantBits()))));
+                new PrefixFilter(mailbox.getMailboxId().toBytes()));
         scan.addColumn(MESSAGES_META_CF, FLAGS_DELETED);
         SingleColumnValueFilter filter = new SingleColumnValueFilter(MESSAGES_META_CF, FLAGS_DELETED, CompareOp.EQUAL, MARKER_PRESENT);
         scan.setFilter(filter);
@@ -744,16 +761,16 @@ public class HBaseMessageMapper extends
         long totalDeletes = deletes.size();
         scanner.close();
         messages.delete(deletes);
-        mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, -(totalDeletes - deletes.size()));
-        mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ, 1);
+        mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_MESSAGE_COUNT, -(totalDeletes - deletes.size()));
+        mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ, 1);
         mailboxes.close();
         messages.close();
     }
 
-    private Map<Long, MessageMetaData> createMetaData(List<Message<UUID>> uids) {
+    private Map<Long, MessageMetaData> createMetaData(List<Message<HBaseId>> uids) {
         final Map<Long, MessageMetaData> data = new HashMap<Long, MessageMetaData>();
         for (int i = 0; i < uids.size(); i++) {
-            Message<UUID> m = uids.get(i);
+            Message<HBaseId> m = uids.get(i);
             data.put(m.getUid(), new SimpleMessageMetaData(m));
         }
         return data;

Modified: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseModSeqProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseModSeqProvider.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseModSeqProvider.java (original)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseModSeqProvider.java Mon Jun 29 08:21:12 2015
@@ -18,8 +18,12 @@
  ****************************************************************/
 package org.apache.james.mailbox.hbase.mail;
 
+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.MAILBOX_HIGHEST_MODSEQ;
+
 import java.io.IOException;
-import java.util.UUID;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.client.Get;
 import org.apache.hadoop.hbase.client.HTable;
@@ -27,16 +31,14 @@ import org.apache.hadoop.hbase.client.Re
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.hbase.HBaseId;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-
-import static org.apache.james.mailbox.hbase.HBaseUtils.*;
-import static org.apache.james.mailbox.hbase.HBaseNames.*;
 /**
  * ModSeqProvider implementation for HBase.
  * 
  */
-public class HBaseModSeqProvider implements ModSeqProvider<UUID> {
+public class HBaseModSeqProvider implements ModSeqProvider<HBaseId> {
 
     /** Link to the HBase Configuration object and specific mailbox names */
     private final Configuration conf;
@@ -46,11 +48,11 @@ public class HBaseModSeqProvider impleme
     }
 
     @Override
-    public long highestModSeq(MailboxSession session, Mailbox<UUID> mailbox) throws MailboxException {
+    public long highestModSeq(MailboxSession session, Mailbox<HBaseId> mailbox) throws MailboxException {
         HTable mailboxes = null;
         try {
             mailboxes = new HTable(conf, MAILBOXES_TABLE);
-            Get get = new Get(mailboxRowKey(mailbox.getMailboxId()));
+            Get get = new Get(mailbox.getMailboxId().toBytes());
             get.addColumn(MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ);
             get.setMaxVersions(1);
             Result result = mailboxes.get(get);
@@ -74,11 +76,11 @@ public class HBaseModSeqProvider impleme
     }
 
     @Override
-    public long nextModSeq(MailboxSession session, Mailbox<UUID> mailbox) throws MailboxException {
+    public long nextModSeq(MailboxSession session, Mailbox<HBaseId> mailbox) throws MailboxException {
         HTable mailboxes = null;
         try {
             mailboxes = new HTable(conf, MAILBOXES_TABLE);
-            long newValue = mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ, 1);
+            long newValue = mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_HIGHEST_MODSEQ, 1);
             return newValue;
         } catch (IOException e) {
             throw new MailboxException("lastUid", e);

Modified: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseUidProvider.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseUidProvider.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseUidProvider.java (original)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseUidProvider.java Mon Jun 29 08:21:12 2015
@@ -18,8 +18,11 @@
  ****************************************************************/
 package org.apache.james.mailbox.hbase.mail;
 
+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.MAILBOX_LASTUID;
+
 import java.io.IOException;
-import java.util.UUID;
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.client.Get;
@@ -28,16 +31,14 @@ import org.apache.hadoop.hbase.client.Re
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.hbase.HBaseId;
 import org.apache.james.mailbox.store.mail.UidProvider;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-
-import static org.apache.james.mailbox.hbase.HBaseUtils.*;
-import static org.apache.james.mailbox.hbase.HBaseNames.*;
 /**
  * Message UidProvider for HBase.
  * 
  */
-public class HBaseUidProvider implements UidProvider<UUID> {
+public class HBaseUidProvider implements UidProvider<HBaseId> {
 
     /** Link to the HBase Configuration object and specific mailbox names */
     private final Configuration conf;
@@ -54,11 +55,11 @@ public class HBaseUidProvider implements
      * @throws MailboxException 
      */
     @Override
-    public long lastUid(MailboxSession session, Mailbox<UUID> mailbox) throws MailboxException {
+    public long lastUid(MailboxSession session, Mailbox<HBaseId> mailbox) throws MailboxException {
         HTable mailboxes = null;
         try {
             mailboxes = new HTable(conf, MAILBOXES_TABLE);
-            Get get = new Get(mailboxRowKey(mailbox.getMailboxId()));
+            Get get = new Get(mailbox.getMailboxId().toBytes());
             get.addColumn(MAILBOX_CF, MAILBOX_LASTUID);
             get.setMaxVersions(1);
             Result result = mailboxes.get(get);
@@ -90,11 +91,11 @@ public class HBaseUidProvider implements
      * @throws MailboxException 
      */
     @Override
-    public long nextUid(MailboxSession session, Mailbox<UUID> mailbox) throws MailboxException {
+    public long nextUid(MailboxSession session, Mailbox<HBaseId> mailbox) throws MailboxException {
         HTable mailboxes = null;
         try {
             mailboxes = new HTable(conf, MAILBOXES_TABLE);
-            long newValue = mailboxes.incrementColumnValue(mailboxRowKey(mailbox.getMailboxId()), MAILBOX_CF, MAILBOX_LASTUID, 1);
+            long newValue = mailboxes.incrementColumnValue(mailbox.getMailboxId().toBytes(), MAILBOX_CF, MAILBOX_LASTUID, 1);
             mailboxes.close();
             return newValue;
         } catch (IOException e) {

Modified: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailbox.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailbox.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailbox.java (original)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailbox.java Mon Jun 29 08:21:12 2015
@@ -20,6 +20,7 @@ package org.apache.james.mailbox.hbase.m
 
 import java.util.UUID;
 
+import org.apache.james.mailbox.hbase.HBaseId;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.SimpleMailboxACL;
@@ -30,11 +31,11 @@ import org.apache.james.mailbox.store.ma
  * implementations.
  * 
  */
-public class HBaseMailbox implements Mailbox<UUID> {
+public class HBaseMailbox implements Mailbox<HBaseId> {
 
     private static final String TAB = " ";
     /** The value for the mailboxId field */
-    private UUID mailboxId;
+    private HBaseId mailboxId;
     /** The value for the name field */
     private String name;
     /** The value for the uidValidity field */
@@ -52,18 +53,18 @@ public class HBaseMailbox implements Mai
         this.namespace = mailboxPath.getNamespace();
         this.uidValidity = uidValidity;
         //TODO: this has to change to something that can guarantee that mailboxId is unique
-        this.mailboxId = UUID.randomUUID();
+        this.mailboxId = HBaseId.of(UUID.randomUUID());
     }
 
     /**
      * @see org.apache.james.mailbox.store.mail.model.Mailbox#getMailboxId()
      */
     @Override
-    public UUID getMailboxId() {
+    public HBaseId getMailboxId() {
         return mailboxId;
     }
 
-    public void setMailboxId(UUID mailboxId) {
+    public void setMailboxId(HBaseId mailboxId) {
         this.mailboxId = mailboxId;
     }
     /*
@@ -143,7 +144,7 @@ public class HBaseMailbox implements Mai
     public int hashCode() {
         final int PRIME = 31;
         int result = 1;
-        result = PRIME * result + (int) (mailboxId.getMostSignificantBits() ^ (mailboxId.getMostSignificantBits() >>> 32));
+        result = PRIME * result + mailboxId.hashCode();
         return result;
     }
 

Modified: james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/user/HBaseSubscriptionMapper.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/user/HBaseSubscriptionMapper.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/user/HBaseSubscriptionMapper.java (original)
+++ james/mailbox/trunk/hbase/src/main/java/org/apache/james/mailbox/hbase/user/HBaseSubscriptionMapper.java Mon Jun 29 08:21:12 2015
@@ -18,9 +18,14 @@
  ****************************************************************/
 package org.apache.james.mailbox.hbase.user;
 
+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.toPut;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.client.Delete;
@@ -34,9 +39,6 @@ import org.apache.james.mailbox.hbase.HB
 import org.apache.james.mailbox.store.user.SubscriptionMapper;
 import org.apache.james.mailbox.store.user.model.Subscription;
 import org.apache.james.mailbox.store.user.model.impl.SimpleSubscription;
-
-import static org.apache.james.mailbox.hbase.HBaseUtils.*;
-import static org.apache.james.mailbox.hbase.HBaseNames.*;
 /**
  * HBase implementation of a {@link SubscriptionMapper}. 
  * I don't know if this class is thread-safe!

Modified: james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java (original)
+++ james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxSessionMapperFactoryTest.java Mon Jun 29 08:21:12 2015
@@ -19,7 +19,6 @@
 package org.apache.james.mailbox.hbase;
 
 import java.io.IOException;
-import java.util.UUID;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.james.mailbox.MailboxSession;
 import static org.apache.james.mailbox.hbase.HBaseNames.*;
@@ -75,7 +74,7 @@ public class HBaseMailboxSessionMapperFa
         LOG.info("createMessageMapper");
         MailboxSession session = null;
         HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, null, null);
-        MessageMapper<UUID> messageMapper = instance.createMessageMapper(session);
+        MessageMapper<HBaseId> messageMapper = instance.createMessageMapper(session);
         assertNotNull(messageMapper);
         assertTrue(messageMapper instanceof MessageMapper);
     }
@@ -89,7 +88,7 @@ public class HBaseMailboxSessionMapperFa
         LOG.info("createMailboxMapper");
         MailboxSession session = null;
         HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, null, null);
-        MailboxMapper<UUID> mailboxMapper = instance.createMailboxMapper(session);
+        MailboxMapper<HBaseId> mailboxMapper = instance.createMailboxMapper(session);
         assertNotNull(mailboxMapper);
         assertTrue(mailboxMapper instanceof MailboxMapper);
     }
@@ -115,9 +114,9 @@ public class HBaseMailboxSessionMapperFa
     @Test
     public void testGetModSeqProvider() {
         LOG.info("getModSeqProvider");
-        ModSeqProvider<UUID> expResult = new HBaseModSeqProvider(conf);
+        ModSeqProvider<HBaseId> expResult = new HBaseModSeqProvider(conf);
         HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, null, expResult);
-        ModSeqProvider<UUID> result = instance.getModSeqProvider();
+        ModSeqProvider<HBaseId> result = instance.getModSeqProvider();
         assertEquals(expResult, result);
     }
 
@@ -127,9 +126,9 @@ public class HBaseMailboxSessionMapperFa
     @Test
     public void testGetUidProvider() {
         LOG.info("getUidProvider");
-        UidProvider<UUID> expResult = new HBaseUidProvider(conf);
+        UidProvider<HBaseId> expResult = new HBaseUidProvider(conf);
         HBaseMailboxSessionMapperFactory instance = new HBaseMailboxSessionMapperFactory(conf, expResult, null);
-        UidProvider<UUID> result = instance.getUidProvider();
+        UidProvider<HBaseId> result = instance.getUidProvider();
         assertEquals(expResult, result);
     }
 }

Modified: james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseUtilsTest.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseUtilsTest.java?rev=1688109&r1=1688108&r2=1688109&view=diff
==============================================================================
--- james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseUtilsTest.java (original)
+++ james/mailbox/trunk/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseUtilsTest.java Mon Jun 29 08:21:12 2015
@@ -18,16 +18,41 @@
  ****************************************************************/
 package org.apache.james.mailbox.hbase;
 
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_ANSWERED;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_DELETED;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_DRAFT;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_FLAGGED;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_RECENT;
+import static org.apache.james.mailbox.hbase.FlagConvertor.FLAGS_SEEN;
+import static org.apache.james.mailbox.hbase.FlagConvertor.userFlagToBytes;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_HIGHEST_MODSEQ;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_LASTUID;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_MESSAGE_COUNT;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_NAME;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_NAMESPACE;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_UIDVALIDITY;
+import static org.apache.james.mailbox.hbase.HBaseNames.MAILBOX_USER;
+import static org.apache.james.mailbox.hbase.HBaseNames.MARKER_MISSING;
+import static org.apache.james.mailbox.hbase.HBaseNames.MARKER_PRESENT;
+import static org.apache.james.mailbox.hbase.HBaseNames.MESSAGES_META_CF;
+import static org.apache.james.mailbox.hbase.HBaseNames.SUBSCRIPTION_CF;
+import static org.apache.james.mailbox.hbase.HBaseUtils.HBaseIdFromRowKey;
+import static org.apache.james.mailbox.hbase.HBaseUtils.flagsToPut;
+import static org.apache.james.mailbox.hbase.HBaseUtils.toPut;
+import static org.apache.james.mailbox.hbase.PropertyConvertor.getProperty;
+import static org.apache.james.mailbox.hbase.PropertyConvertor.getValue;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 import java.util.Date;
 import java.util.UUID;
+
 import javax.mail.Flags;
+
 import org.apache.hadoop.hbase.client.Put;
 import org.apache.hadoop.hbase.util.Bytes;
-import static org.apache.james.mailbox.hbase.FlagConvertor.*;
-import static org.apache.james.mailbox.hbase.HBaseNames.*;
-import static org.apache.james.mailbox.hbase.HBaseUtils.*;
-import static org.apache.james.mailbox.hbase.PropertyConvertor.getProperty;
-import static org.apache.james.mailbox.hbase.PropertyConvertor.getValue;
 import org.apache.james.mailbox.hbase.mail.model.HBaseMailbox;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.store.mail.model.Property;
@@ -36,14 +61,13 @@ import org.apache.james.mailbox.store.ma
 import org.apache.james.mailbox.store.mail.model.impl.SimpleProperty;
 import org.apache.james.mailbox.store.user.model.Subscription;
 import org.apache.james.mailbox.store.user.model.impl.SimpleSubscription;
-import static org.junit.Assert.*;
 import org.junit.Test;
 
 /**
  * Tests for HBase Mailbox store utility methods .
  */
 public class HBaseUtilsTest {
-
+    
     /**
      * Test of mailboxRowKey method, of class HBaseMailbox.
      */
@@ -51,15 +75,15 @@ public class HBaseUtilsTest {
     public void testRowKey_All() {
         System.out.println("getRowKey and UUIDFromRowKey");
         final HBaseMailbox mailbox = new HBaseMailbox(new MailboxPath("gsoc", "ieugen", "INBOX"), 1234);
-        UUID uuid = mailbox.getMailboxId();
-        byte[] expResult = mailboxRowKey(uuid);
-        byte[] result = mailboxRowKey(mailbox.getMailboxId());
+        HBaseId uuid = mailbox.getMailboxId();
+        byte[] expResult = uuid.toBytes();
+        byte[] result = mailbox.getMailboxId().toBytes();
         assertArrayEquals(expResult, result);
 
-        UUID newUUID = UUIDFromRowKey(result);
+        HBaseId newUUID = HBaseIdFromRowKey(result);
         assertEquals(uuid, newUUID);
 
-        newUUID = UUIDFromRowKey(expResult);
+        newUUID = HBaseIdFromRowKey(expResult);
         assertEquals(uuid, newUUID);
     }
 
@@ -72,7 +96,7 @@ public class HBaseUtilsTest {
         final HBaseMailbox instance = new HBaseMailbox(new MailboxPath("gsoc", "ieugen", "INBOX"), 1234);
 
         Put result = toPut(instance);
-        assertArrayEquals(mailboxRowKey(instance.getMailboxId()), result.getRow());
+        assertArrayEquals(instance.getMailboxId().toBytes(), result.getRow());
         assertTrue(result.has(MAILBOX_CF, MAILBOX_USER, Bytes.toBytes(instance.getUser())));
         assertTrue(result.has(MAILBOX_CF, MAILBOX_NAME, Bytes.toBytes(instance.getName())));
         assertTrue(result.has(MAILBOX_CF, MAILBOX_NAMESPACE, Bytes.toBytes(instance.getNamespace())));
@@ -121,7 +145,7 @@ public class HBaseUtilsTest {
         flags.add(Flags.Flag.FLAGGED);
         flags.add("userFlag1");
         flags.add("userFlag2");
-        UUID uuid = UUID.randomUUID();
+        HBaseId uuid = HBaseId.of(UUID.randomUUID());
         final SimpleMessage message = new SimpleMessage(new Date(), 100, 10, null, flags, new PropertyBuilder(), uuid);
         Put put = flagsToPut(message, flags);
         //test for the system flags



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