james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [12/13] james-project git commit: JAMES-1733 Remove generics from mailbox API
Date Tue, 17 May 2016 08:14:58 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
index b406391..2e18dec 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMapper.java
@@ -48,10 +48,10 @@ import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Fla
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Flag.DELETED;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Flag.DRAFT;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Flag.FLAGGED;
-import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Flag.USER_FLAGS;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Flag.RECENT;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Flag.SEEN;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Flag.USER;
+import static org.apache.james.mailbox.cassandra.table.CassandraMessageTable.Flag.USER_FLAGS;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -69,16 +69,13 @@ import javax.mail.Flags;
 import javax.mail.Flags.Flag;
 import javax.mail.util.SharedByteArrayInputStream;
 
-import com.datastax.driver.core.Statement;
-import com.datastax.driver.core.querybuilder.Select;
-import com.google.common.base.Throwables;
 import org.apache.james.backends.cassandra.init.CassandraTypesProvider;
 import org.apache.james.backends.cassandra.utils.CassandraConstants;
 import org.apache.james.backends.cassandra.utils.CassandraUtils;
+import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;
 import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.cassandra.CassandraId;
-import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;
 import org.apache.james.mailbox.cassandra.mail.utils.MessageDeletedDuringFlagsUpdateException;
 import org.apache.james.mailbox.cassandra.table.CassandraMailboxCountersTable;
 import org.apache.james.mailbox.cassandra.table.CassandraMessageTable;
@@ -101,23 +98,26 @@ import org.apache.james.mailbox.store.mail.model.impl.SimpleProperty;
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
 import com.datastax.driver.core.Session;
+import com.datastax.driver.core.Statement;
 import com.datastax.driver.core.UDTValue;
 import com.datastax.driver.core.querybuilder.Assignment;
 import com.datastax.driver.core.querybuilder.QueryBuilder;
+import com.datastax.driver.core.querybuilder.Select;
 import com.datastax.driver.core.querybuilder.Select.Where;
+import com.google.common.base.Throwables;
 import com.google.common.io.ByteStreams;
 import com.google.common.primitives.Bytes;
 
-public class CassandraMessageMapper implements MessageMapper<CassandraId> {
+public class CassandraMessageMapper implements MessageMapper {
 
     private final Session session;
-    private final ModSeqProvider<CassandraId> modSeqProvider;
+    private final ModSeqProvider modSeqProvider;
     private final MailboxSession mailboxSession;
-    private final UidProvider<CassandraId> uidProvider;
+    private final UidProvider uidProvider;
     private final CassandraTypesProvider typesProvider;
     private final int maxRetries;
 
-    public CassandraMessageMapper(Session session, UidProvider<CassandraId> uidProvider, ModSeqProvider<CassandraId> modSeqProvider, MailboxSession mailboxSession, int maxRetries, CassandraTypesProvider typesProvider) {
+    public CassandraMessageMapper(Session session, UidProvider uidProvider, ModSeqProvider modSeqProvider, MailboxSession mailboxSession, int maxRetries, CassandraTypesProvider typesProvider) {
         this.session = session;
         this.uidProvider = uidProvider;
         this.modSeqProvider = modSeqProvider;
@@ -127,20 +127,22 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
     }
 
     @Override
-    public long countMessagesInMailbox(Mailbox<CassandraId> mailbox) throws MailboxException {
+    public long countMessagesInMailbox(Mailbox mailbox) throws MailboxException {
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
         ResultSet results = session.execute(
             select(CassandraMailboxCountersTable.COUNT)
                 .from(CassandraMailboxCountersTable.TABLE_NAME)
-                .where(eq(CassandraMailboxCountersTable.MAILBOX_ID, mailbox.getMailboxId().asUuid())));
+                .where(eq(CassandraMailboxCountersTable.MAILBOX_ID, mailboxId.asUuid())));
         return results.isExhausted() ? 0 : results.one().getLong(CassandraMailboxCountersTable.COUNT);
     }
 
     @Override
-    public long countUnseenMessagesInMailbox(Mailbox<CassandraId> mailbox) throws MailboxException {
+    public long countUnseenMessagesInMailbox(Mailbox mailbox) throws MailboxException {
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
         ResultSet results = session.execute(
             select(CassandraMailboxCountersTable.UNSEEN)
                 .from(CassandraMailboxCountersTable.TABLE_NAME)
-                .where(eq(CassandraMailboxCountersTable.MAILBOX_ID, mailbox.getMailboxId().asUuid())));
+                .where(eq(CassandraMailboxCountersTable.MAILBOX_ID, mailboxId.asUuid())));
         if (!results.isExhausted()) {
             Row row = results.one();
             if (row.getColumnDefinitions().contains(CassandraMailboxCountersTable.UNSEEN)) {
@@ -151,11 +153,11 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
     }
 
     @Override
-    public void delete(Mailbox<CassandraId> mailbox, MailboxMessage<CassandraId> message) {
-        deleteUsingMailboxId(mailbox.getMailboxId(), message);
+    public void delete(Mailbox mailbox, MailboxMessage message) {
+        deleteUsingMailboxId(((CassandraId) mailbox.getMailboxId()), message);
     }
 
-    private void deleteUsingMailboxId(CassandraId mailboxId, MailboxMessage<CassandraId> message) {
+    private void deleteUsingMailboxId(CassandraId mailboxId, MailboxMessage message) {
         session.execute(
             QueryBuilder.delete()
                 .from(TABLE_NAME)
@@ -168,8 +170,9 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
     }
 
     @Override
-    public Iterator<MailboxMessage<CassandraId>> findInMailbox(Mailbox<CassandraId> mailbox, MessageRange set, FetchType ftype, int max) throws MailboxException {
-        return CassandraUtils.convertToStream(session.execute(buildSelectQueryWithLimit(buildQuery(mailbox, set, ftype), max)))
+    public Iterator<MailboxMessage> findInMailbox(Mailbox mailbox, MessageRange set, FetchType ftype, int max) throws MailboxException {
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
+        return CassandraUtils.convertToStream(session.execute(buildSelectQueryWithLimit(buildQuery(mailboxId, set, ftype), max)))
             .map(row -> message(row, ftype))
             .sorted(Comparator.comparingLong(MailboxMessage::getUid))
             .iterator();
@@ -183,16 +186,18 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
     }
 
     @Override
-    public List<Long> findRecentMessageUidsInMailbox(Mailbox<CassandraId> mailbox) throws MailboxException {
-        return CassandraUtils.convertToStream(session.execute(selectAll(mailbox, FetchType.Metadata).and((eq(RECENT, true)))))
+    public List<Long> findRecentMessageUidsInMailbox(Mailbox mailbox) throws MailboxException {
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
+        return CassandraUtils.convertToStream(session.execute(selectAll(mailboxId, FetchType.Metadata).and((eq(RECENT, true)))))
             .map((row) -> row.getLong(IMAP_UID))
             .sorted()
             .collect(Collectors.toList());
     }
 
     @Override
-    public Long findFirstUnseenMessageUid(Mailbox<CassandraId> mailbox) throws MailboxException {
-        return CassandraUtils.convertToStream(session.execute(selectAll(mailbox, FetchType.Metadata).and((eq(SEEN, false)))))
+    public Long findFirstUnseenMessageUid(Mailbox mailbox) throws MailboxException {
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
+        return CassandraUtils.convertToStream(session.execute(selectAll(mailboxId, FetchType.Metadata).and((eq(SEEN, false)))))
             .map((row) -> row.getLong(IMAP_UID))
             .sorted()
             .findFirst()
@@ -200,17 +205,18 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
     }
 
     @Override
-    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox<CassandraId> mailbox, MessageRange set) throws MailboxException {
-        return CassandraUtils.convertToStream(session.execute(buildQuery(mailbox, set, FetchType.Metadata).and(eq(DELETED, true))))
+    public Map<Long, MessageMetaData> expungeMarkedForDeletionInMailbox(Mailbox mailbox, MessageRange set) throws MailboxException {
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
+        return CassandraUtils.convertToStream(session.execute(buildQuery(mailboxId, set, FetchType.Metadata).and(eq(DELETED, true))))
             .map(row -> message(row, FetchType.Metadata))
             .peek((message) -> delete(mailbox, message))
             .collect(Collectors.toMap(MailboxMessage::getUid, SimpleMessageMetaData::new));
     }
 
     @Override
-    public MessageMetaData move(Mailbox<CassandraId> destinationMailbox, MailboxMessage<CassandraId> original) throws MailboxException {
+    public MessageMetaData move(Mailbox destinationMailbox, MailboxMessage original) throws MailboxException {
         MessageMetaData messageMetaData = copy(destinationMailbox, original);
-        deleteUsingMailboxId(original.getMailboxId(), original);
+        deleteUsingMailboxId((CassandraId) original.getMailboxId(), original);
         return messageMetaData;
     }
 
@@ -220,25 +226,27 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
     }
 
     @Override
-    public long getHighestModSeq(Mailbox<CassandraId> mailbox) throws MailboxException {
+    public long getHighestModSeq(Mailbox mailbox) throws MailboxException {
         return modSeqProvider.highestModSeq(mailboxSession, mailbox);
     }
 
     @Override
-    public MessageMetaData add(Mailbox<CassandraId> mailbox, MailboxMessage<CassandraId> message) throws MailboxException {
+    public MessageMetaData add(Mailbox mailbox, MailboxMessage message) throws MailboxException {
         message.setUid(uidProvider.nextUid(mailboxSession, mailbox));
         message.setModSeq(modSeqProvider.nextModSeq(mailboxSession, mailbox));
         MessageMetaData messageMetaData = save(mailbox, message);
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
         if (!message.isSeen()) {
-            incrementUnseen(mailbox.getMailboxId());
+            incrementUnseen(mailboxId);
         }
-        incrementCount(mailbox.getMailboxId());
+        incrementCount(mailboxId);
         return messageMetaData;
     }
 
     @Override
-    public Iterator<UpdatedFlags> updateFlags(Mailbox<CassandraId> mailbox, FlagsUpdateCalculator flagUpdateCalculator, MessageRange set) throws MailboxException {
-        return CassandraUtils.convertToStream(session.execute(buildQuery(mailbox, set, FetchType.Metadata)))
+    public Iterator<UpdatedFlags> updateFlags(Mailbox mailbox, FlagsUpdateCalculator flagUpdateCalculator, MessageRange set) throws MailboxException {
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
+        return CassandraUtils.convertToStream(session.execute(buildQuery(mailboxId, set, FetchType.Metadata)))
             .map((row) -> updateFlagsOnMessage(mailbox, flagUpdateCalculator, row))
             .filter(Optional::isPresent)
             .map(Optional::get)
@@ -253,13 +261,13 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
     }
 
     @Override
-    public MessageMetaData copy(Mailbox<CassandraId> mailbox, MailboxMessage<CassandraId> original) throws MailboxException {
+    public MessageMetaData copy(Mailbox mailbox, MailboxMessage original) throws MailboxException {
         original.setFlags(new FlagsBuilder().add(original.createFlags()).add(Flag.RECENT).build());
         return add(mailbox, original);
     }
 
     @Override
-    public long getLastUid(Mailbox<CassandraId> mailbox) throws MailboxException {
+    public long getLastUid(Mailbox mailbox) throws MailboxException {
         return uidProvider.lastUid(mailboxSession, mailbox);
     }
 
@@ -283,9 +291,9 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
         session.execute(update(CassandraMailboxCountersTable.TABLE_NAME).with(operation).where(eq(CassandraMailboxCountersTable.MAILBOX_ID, mailboxId.asUuid())));
     }
 
-    private MailboxMessage<CassandraId> message(Row row, FetchType fetchType) {
-        SimpleMailboxMessage<CassandraId> message =
-            new SimpleMailboxMessage<>(
+    private MailboxMessage message(Row row, FetchType fetchType) {
+        SimpleMailboxMessage message =
+            new SimpleMailboxMessage(
                 row.getDate(INTERNAL_DATE),
                 row.getLong(FULL_CONTENT_OCTETS),
                 row.getInt(BODY_START_OCTET),
@@ -320,10 +328,11 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
         return property;
     }
 
-    private MessageMetaData save(Mailbox<CassandraId> mailbox, MailboxMessage<CassandraId> message) throws MailboxException {
+    private MessageMetaData save(Mailbox mailbox, MailboxMessage message) throws MailboxException {
         try {
+            CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
             session.execute(insertInto(TABLE_NAME)
-                .value(MAILBOX_ID, mailbox.getMailboxId().asUuid())
+                .value(MAILBOX_ID, mailboxId.asUuid())
                 .value(IMAP_UID, message.getUid())
                 .value(MOD_SEQ, message.getModSeq())
                 .value(INTERNAL_DATE, message.getInternalDate())
@@ -355,26 +364,27 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
         }
     }
 
-    private Set<String> userFlagsSet(MailboxMessage<CassandraId> message) {
+    private Set<String> userFlagsSet(MailboxMessage message) {
         return Arrays.stream(message.createFlags().getUserFlags()).collect(Collectors.toSet());
     }
 
-    private void manageUnseenMessageCounts(Mailbox<CassandraId> mailbox, Flags oldFlags, Flags newFlags) {
+    private void manageUnseenMessageCounts(Mailbox mailbox, Flags oldFlags, Flags newFlags) {
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
         if (oldFlags.contains(Flag.SEEN) && !newFlags.contains(Flag.SEEN)) {
-            incrementUnseen(mailbox.getMailboxId());
+            incrementUnseen(mailboxId);
         }
         if (!oldFlags.contains(Flag.SEEN) && newFlags.contains(Flag.SEEN)) {
-            decrementUnseen(mailbox.getMailboxId());
+            decrementUnseen(mailboxId);
         }
     }
 
-    private Optional<UpdatedFlags> updateFlagsOnMessage(Mailbox<CassandraId> mailbox, FlagsUpdateCalculator flagUpdateCalculator, Row row) {
+    private Optional<UpdatedFlags> updateFlagsOnMessage(Mailbox mailbox, FlagsUpdateCalculator flagUpdateCalculator, Row row) {
         return tryMessageFlagsUpdate(flagUpdateCalculator, mailbox, message(row, FetchType.Metadata))
             .map(Optional::of)
             .orElse(handleRetries(mailbox, flagUpdateCalculator, row.getLong(IMAP_UID)));
     }
 
-    private Optional<UpdatedFlags> tryMessageFlagsUpdate(FlagsUpdateCalculator flagUpdateCalculator, Mailbox<CassandraId> mailbox, MailboxMessage<CassandraId> message) {
+    private Optional<UpdatedFlags> tryMessageFlagsUpdate(FlagsUpdateCalculator flagUpdateCalculator, Mailbox mailbox, MailboxMessage message) {
         try {
             long oldModSeq = message.getModSeq();
             Flags oldFlags = message.createFlags();
@@ -391,7 +401,7 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
         }
     }
 
-    private Optional<UpdatedFlags> handleRetries(Mailbox<CassandraId> mailbox, FlagsUpdateCalculator flagUpdateCalculator, long uid) {
+    private Optional<UpdatedFlags> handleRetries(Mailbox mailbox, FlagsUpdateCalculator flagUpdateCalculator, long uid) {
         try {
             return Optional.of(
                 new FunctionRunnerWithRetry(maxRetries)
@@ -404,15 +414,17 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
         }
     }
 
-    private Optional<UpdatedFlags> retryMessageFlagsUpdate(Mailbox<CassandraId> mailbox, long uid, FlagsUpdateCalculator flagUpdateCalculator) {
+    private Optional<UpdatedFlags> retryMessageFlagsUpdate(Mailbox mailbox, long uid, FlagsUpdateCalculator flagUpdateCalculator) {
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
         return tryMessageFlagsUpdate(flagUpdateCalculator,
             mailbox,
-            message(Optional.ofNullable(session.execute(selectMessage(mailbox, uid, FetchType.Metadata)).one())
-                .orElseThrow(() -> new MessageDeletedDuringFlagsUpdateException(mailbox.getMailboxId(), uid)),
+            message(Optional.ofNullable(session.execute(selectMessage(mailboxId, uid, FetchType.Metadata)).one())
+                .orElseThrow(() -> new MessageDeletedDuringFlagsUpdateException(mailboxId, uid)),
                 FetchType.Metadata));
     }
 
-    private boolean conditionalSave(MailboxMessage<CassandraId> message, long oldModSeq) {
+    private boolean conditionalSave(MailboxMessage message, long oldModSeq) {
+        CassandraId mailboxId = (CassandraId) message.getMailboxId();
         ResultSet resultSet = session.execute(
             update(TABLE_NAME)
                 .with(set(ANSWERED, message.isAnswered()))
@@ -425,7 +437,7 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
                 .and(set(USER_FLAGS, userFlagsSet(message)))
                 .and(set(MOD_SEQ, message.getModSeq()))
                 .where(eq(IMAP_UID, message.getUid()))
-                .and(eq(MAILBOX_ID, message.getMailboxId().asUuid()))
+                .and(eq(MAILBOX_ID, mailboxId.asUuid()))
                 .onlyIf(eq(MOD_SEQ, oldModSeq)));
         return resultSet.one().getBool(CassandraConstants.LIGHTWEIGHT_TRANSACTION_APPLIED);
     }
@@ -434,45 +446,45 @@ public class CassandraMessageMapper implements MessageMapper<CassandraId> {
         return ByteBuffer.wrap(ByteStreams.toByteArray(stream));
     }
 
-    private Where buildQuery(Mailbox<CassandraId> mailbox, MessageRange set, FetchType fetchType) {
+    private Where buildQuery(CassandraId mailboxId, MessageRange set, FetchType fetchType) {
         switch (set.getType()) {
         case ALL:
-            return selectAll(mailbox, fetchType);
+            return selectAll(mailboxId, fetchType);
         case FROM:
-            return selectFrom(mailbox, set.getUidFrom(), fetchType);
+            return selectFrom(mailboxId, set.getUidFrom(), fetchType);
         case RANGE:
-            return selectRange(mailbox, set.getUidFrom(), set.getUidTo(), fetchType);
+            return selectRange(mailboxId, set.getUidFrom(), set.getUidTo(), fetchType);
         case ONE:
-            return selectMessage(mailbox, set.getUidFrom(), fetchType);
+            return selectMessage(mailboxId, set.getUidFrom(), fetchType);
         }
         throw new UnsupportedOperationException();
     }
 
-    private Where selectAll(Mailbox<CassandraId> mailbox, FetchType fetchType) {
+    private Where selectAll(CassandraId mailboxId, FetchType fetchType) {
         return select(retrieveFields(fetchType))
             .from(TABLE_NAME)
-            .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid()));
+            .where(eq(MAILBOX_ID, mailboxId.asUuid()));
     }
 
-    private Where selectFrom(Mailbox<CassandraId> mailbox, long uid, FetchType fetchType) {
+    private Where selectFrom(CassandraId mailboxId, long uid, FetchType fetchType) {
         return select(retrieveFields(fetchType))
             .from(TABLE_NAME)
-            .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid()))
+            .where(eq(MAILBOX_ID, mailboxId.asUuid()))
             .and(gte(IMAP_UID, uid));
     }
 
-    private Where selectRange(Mailbox<CassandraId> mailbox, long from, long to, FetchType fetchType) {
+    private Where selectRange(CassandraId mailboxId, long from, long to, FetchType fetchType) {
         return select(retrieveFields(fetchType))
             .from(TABLE_NAME)
-            .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid()))
+            .where(eq(MAILBOX_ID, mailboxId.asUuid()))
             .and(gte(IMAP_UID, from))
             .and(lte(IMAP_UID, to));
     }
 
-    private Where selectMessage(Mailbox<CassandraId> mailbox, long uid, FetchType fetchType) {
+    private Where selectMessage(CassandraId mailboxId, long uid, FetchType fetchType) {
         return select(retrieveFields(fetchType))
             .from(TABLE_NAME)
-            .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid()))
+            .where(eq(MAILBOX_ID, mailboxId.asUuid()))
             .and(eq(IMAP_UID, uid));
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
index a30e49b..361a564 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProvider.java
@@ -29,13 +29,14 @@ import static org.apache.james.mailbox.cassandra.table.CassandraMessageModseqTab
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageModseqTable.TABLE_NAME;
 
 import java.util.Optional;
+
 import javax.inject.Inject;
 
 import org.apache.james.backends.cassandra.utils.CassandraConstants;
+import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;
 import org.apache.james.backends.cassandra.utils.LightweightTransactionException;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.cassandra.CassandraId;
-import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.store.mail.ModSeqProvider;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
@@ -47,7 +48,7 @@ import com.datastax.driver.core.Session;
 import com.datastax.driver.core.querybuilder.BuiltStatement;
 import com.google.common.base.Throwables;
 
-public class CassandraModSeqProvider implements ModSeqProvider<CassandraId> {
+public class CassandraModSeqProvider implements ModSeqProvider {
 
     private static final int DEFAULT_MAX_RETRY = 100000;
     private static final Logger LOG = LoggerFactory.getLogger(CassandraModSeqProvider.class);
@@ -67,8 +68,9 @@ public class CassandraModSeqProvider implements ModSeqProvider<CassandraId> {
     }
 
     @Override
-    public long nextModSeq(MailboxSession mailboxSession, Mailbox<CassandraId> mailbox) throws MailboxException {
-        if (findHighestModSeq(mailboxSession, mailbox).isFirst()) {
+    public long nextModSeq(MailboxSession mailboxSession, Mailbox mailbox) throws MailboxException {
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
+        if (findHighestModSeq(mailboxSession, mailboxId).isFirst()) {
             Optional<ModSeq> optional = tryInsertModSeq(mailbox, FIRST_MODSEQ);
             if (optional.isPresent()) {
                 return optional.get().getValue();
@@ -79,7 +81,7 @@ public class CassandraModSeqProvider implements ModSeqProvider<CassandraId> {
             return runner.executeAndRetrieveObject(
                         () -> {
                             try {
-                                return tryUpdateModSeq(mailbox, findHighestModSeq(mailboxSession, mailbox))
+                                return tryUpdateModSeq(mailboxId, findHighestModSeq(mailboxSession, mailboxId))
                                         .map(ModSeq::getValue);
                             } catch (Exception exception) {
                                 LOG.error("Can not retrieve next ModSeq", exception);
@@ -92,15 +94,15 @@ public class CassandraModSeqProvider implements ModSeqProvider<CassandraId> {
     }
 
     @Override
-    public long highestModSeq(MailboxSession mailboxSession, Mailbox<CassandraId> mailbox) throws MailboxException {
-        return findHighestModSeq(mailboxSession, mailbox).getValue();
+    public long highestModSeq(MailboxSession mailboxSession, Mailbox mailbox) throws MailboxException {
+        return findHighestModSeq(mailboxSession, (CassandraId) mailbox.getMailboxId()).getValue();
     }
     
-    private ModSeq findHighestModSeq(MailboxSession mailboxSession, Mailbox<CassandraId> mailbox) throws MailboxException {
+    private ModSeq findHighestModSeq(MailboxSession mailboxSession, CassandraId mailboxId) throws MailboxException {
         ResultSet result = session.execute(
                 select(NEXT_MODSEQ)
                     .from(TABLE_NAME)
-                    .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid())));
+                    .where(eq(MAILBOX_ID, mailboxId.asUuid())));
         if (result.isExhausted()) {
             return FIRST_MODSEQ;
         } else {
@@ -108,22 +110,23 @@ public class CassandraModSeqProvider implements ModSeqProvider<CassandraId> {
         }
     }
 
-    private Optional<ModSeq> tryInsertModSeq(Mailbox<CassandraId> mailbox, ModSeq modSeq) {
+    private Optional<ModSeq> tryInsertModSeq(Mailbox mailbox, ModSeq modSeq) {
         ModSeq nextModSeq = modSeq.next();
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
         return transactionalStatementToOptionalModSeq(nextModSeq,
                 insertInto(TABLE_NAME)
                     .value(NEXT_MODSEQ, nextModSeq.getValue())
-                    .value(MAILBOX_ID, mailbox.getMailboxId().asUuid())
+                    .value(MAILBOX_ID, mailboxId.asUuid())
                     .ifNotExists());
     }
     
-    private Optional<ModSeq> tryUpdateModSeq(Mailbox<CassandraId> mailbox, ModSeq modSeq) {
+    private Optional<ModSeq> tryUpdateModSeq(CassandraId mailboxId, ModSeq modSeq) {
         ModSeq nextModSeq = modSeq.next();
         return transactionalStatementToOptionalModSeq(nextModSeq,
                 update(TABLE_NAME)
                     .onlyIf(eq(NEXT_MODSEQ, modSeq.getValue()))
                     .with(set(NEXT_MODSEQ, nextModSeq.getValue()))
-                    .where(eq(MAILBOX_ID, mailbox.getMailboxId().asUuid())));
+                    .where(eq(MAILBOX_ID, mailboxId.asUuid())));
     }
 
     private Optional<ModSeq> transactionalStatementToOptionalModSeq(ModSeq modSeq, BuiltStatement statement) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java
index 59e0ead..e41609e 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProvider.java
@@ -24,19 +24,17 @@ import static com.datastax.driver.core.querybuilder.QueryBuilder.insertInto;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.select;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.set;
 import static com.datastax.driver.core.querybuilder.QueryBuilder.update;
-import org.apache.james.backends.cassandra.utils.CassandraConstants;
 import static org.apache.james.mailbox.cassandra.table.CassandraMessageUidTable.NEXT_UID;
 
-import com.datastax.driver.core.querybuilder.BuiltStatement;
-import com.google.common.base.Throwables;
-import org.apache.james.backends.cassandra.utils.LightweightTransactionException;
-
 import java.util.Optional;
+
 import javax.inject.Inject;
 
+import org.apache.james.backends.cassandra.utils.CassandraConstants;
+import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;
+import org.apache.james.backends.cassandra.utils.LightweightTransactionException;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.cassandra.CassandraId;
-import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;
 import org.apache.james.mailbox.cassandra.table.CassandraMessageUidTable;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.store.mail.UidProvider;
@@ -46,8 +44,10 @@ import org.slf4j.LoggerFactory;
 
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Session;
+import com.datastax.driver.core.querybuilder.BuiltStatement;
+import com.google.common.base.Throwables;
 
-public class CassandraUidProvider implements UidProvider<CassandraId> {
+public class CassandraUidProvider implements UidProvider {
     public final static int DEFAULT_MAX_RETRY = 100000;
     private static final Logger LOG = LoggerFactory.getLogger(CassandraUidProvider.class);
     private static final Uid FIRST_UID = new Uid(0);
@@ -66,9 +66,10 @@ public class CassandraUidProvider implements UidProvider<CassandraId> {
     }
 
     @Override
-    public long nextUid(MailboxSession mailboxSession, Mailbox<CassandraId> mailbox) throws MailboxException {
-        if (findHighestUid(mailbox).isFirst()) {
-            Optional<Uid> optional = tryInsertUid(mailbox, FIRST_UID);
+    public long nextUid(MailboxSession mailboxSession, Mailbox mailbox) throws MailboxException {
+        CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
+        if (findHighestUid(mailboxId).isFirst()) {
+            Optional<Uid> optional = tryInsertUid(mailboxId, FIRST_UID);
             if (optional.isPresent()) {
                 return optional.get().getValue();
             }
@@ -78,7 +79,7 @@ public class CassandraUidProvider implements UidProvider<CassandraId> {
             return runner.executeAndRetrieveObject(
                 () -> {
                     try {
-                        return tryUpdateUid(mailbox, findHighestUid(mailbox))
+                        return tryUpdateUid(mailboxId, findHighestUid(mailboxId))
                             .map(Uid::getValue);
                     } catch (Exception exception) {
                         LOG.error("Can not retrieve next Uid", exception);
@@ -91,15 +92,15 @@ public class CassandraUidProvider implements UidProvider<CassandraId> {
     }
 
     @Override
-    public long lastUid(MailboxSession mailboxSession, Mailbox<CassandraId> mailbox) throws MailboxException {
-        return findHighestUid(mailbox).getValue();
+    public long lastUid(MailboxSession mailboxSession, Mailbox mailbox) throws MailboxException {
+        return findHighestUid((CassandraId) mailbox.getMailboxId()).getValue();
     }
 
-    private Uid findHighestUid(Mailbox<CassandraId> mailbox) throws MailboxException {
+    private Uid findHighestUid(CassandraId mailboxId) throws MailboxException {
         ResultSet result = session.execute(
             select(NEXT_UID)
                 .from(CassandraMessageUidTable.TABLE_NAME)
-                .where(eq(CassandraMessageUidTable.MAILBOX_ID, mailbox.getMailboxId().asUuid())));
+                .where(eq(CassandraMessageUidTable.MAILBOX_ID, mailboxId.asUuid())));
         if (result.isExhausted()) {
             return FIRST_UID;
         } else {
@@ -107,22 +108,22 @@ public class CassandraUidProvider implements UidProvider<CassandraId> {
         }
     }
 
-    private Optional<Uid> tryInsertUid(Mailbox<CassandraId> mailbox, Uid uid) {
+    private Optional<Uid> tryInsertUid(CassandraId mailboxId, Uid uid) {
         Uid nextUid = uid.next();
         return transactionalStatementToOptionalUid(nextUid,
             insertInto(CassandraMessageUidTable.TABLE_NAME)
                 .value(NEXT_UID, nextUid.getValue())
-                .value(CassandraMessageUidTable.MAILBOX_ID, mailbox.getMailboxId().asUuid())
+                .value(CassandraMessageUidTable.MAILBOX_ID, mailboxId.asUuid())
                 .ifNotExists());
     }
 
-    private Optional<Uid> tryUpdateUid(Mailbox<CassandraId> mailbox, Uid uid) {
+    private Optional<Uid> tryUpdateUid(CassandraId mailboxId, Uid uid) {
         Uid nextUid = uid.next();
         return transactionalStatementToOptionalUid(nextUid,
             update(CassandraMessageUidTable.TABLE_NAME)
                 .onlyIf(eq(NEXT_UID, uid.getValue()))
                 .with(set(NEXT_UID, nextUid.getValue()))
-                .where(eq(CassandraMessageUidTable.MAILBOX_ID, mailbox.getMailboxId().asUuid())));
+                .where(eq(CassandraMessageUidTable.MAILBOX_ID, mailboxId.asUuid())));
     }
 
     private Optional<Uid> transactionalStatementToOptionalUid(Uid uid, BuiltStatement statement) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
index 9e60854..9aa45d4 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxSessionMapperFactoryTest.java
@@ -63,7 +63,7 @@ public class CassandraMailboxSessionMapperFactoryTest {
         LOG.info("createMessageMapper");
         MailboxSession session = null;
         CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null, null, null, null);
-        MessageMapper<CassandraId> messageMapper = instance.createMessageMapper(session);
+        MessageMapper messageMapper = instance.createMessageMapper(session);
         assertNotNull(messageMapper);
         assertTrue(messageMapper instanceof MessageMapper);
     }
@@ -77,7 +77,7 @@ public class CassandraMailboxSessionMapperFactoryTest {
         LOG.info("createMailboxMapper");
         MailboxSession session = null;
         CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null, null, null, null);
-        MailboxMapper<CassandraId> mailboxMapper = instance.createMailboxMapper(session);
+        MailboxMapper mailboxMapper = instance.createMailboxMapper(session);
         assertNotNull(mailboxMapper);
         assertTrue(mailboxMapper instanceof MailboxMapper);
     }
@@ -103,9 +103,9 @@ public class CassandraMailboxSessionMapperFactoryTest {
     @Test
     public void testGetModSeqProvider() {
         LOG.info("getModSeqProvider");
-        ModSeqProvider<CassandraId> expResult = new CassandraModSeqProvider(CLUSTER.getConf());
+        ModSeqProvider expResult = new CassandraModSeqProvider(CLUSTER.getConf());
         CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory(null, expResult, null, null);
-        ModSeqProvider<CassandraId> result = instance.getModSeqProvider();
+        ModSeqProvider result = instance.getModSeqProvider();
         assertEquals(expResult, result);
     }
 
@@ -116,9 +116,9 @@ public class CassandraMailboxSessionMapperFactoryTest {
     @Test
     public void testGetUidProvider() {
         LOG.info("getUidProvider");
-        UidProvider<CassandraId> expResult = new CassandraUidProvider(CLUSTER.getConf());
+        UidProvider expResult = new CassandraUidProvider(CLUSTER.getConf());
         CassandraMailboxSessionMapperFactory instance = new CassandraMailboxSessionMapperFactory((CassandraUidProvider) expResult, null, null, null);
-        UidProvider<CassandraId> result = instance.getUidProvider();
+        UidProvider result = instance.getUidProvider();
         assertEquals(expResult, result);
     }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
index cb96d1a..6456f81 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/event/distributed/CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest.java
@@ -19,6 +19,10 @@
 
 package org.apache.james.mailbox.cassandra.event.distributed;
 
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.TreeMap;
+
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.mailbox.MailboxListener;
 import org.apache.james.mailbox.MailboxSession;
@@ -39,10 +43,6 @@ import org.apache.james.mailbox.util.EventCollector;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.TreeMap;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
 /**
  Integration tests for RegisteredDelegatingMailboxListener using a cassandra back-end.
 
@@ -77,8 +77,8 @@ public class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
                 CASSANDRA_TIME_OUT_IN_S),
             SCHEDULER_PERIOD_IN_S);
         registeredDelegatingMailboxListener1 = new RegisteredDelegatingMailboxListener(
-            new MessagePackEventSerializer<>(
-                new EventConverter<>(new MailboxConverter<>(new TestIdDeserializer()))
+            new MessagePackEventSerializer(
+                new EventConverter(new MailboxConverter(new TestIdDeserializer()))
             ),
             publisherReceiver,
             publisherReceiver,
@@ -90,8 +90,8 @@ public class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
                 CASSANDRA_TIME_OUT_IN_S),
             SCHEDULER_PERIOD_IN_S);
         registeredDelegatingMailboxListener2 = new RegisteredDelegatingMailboxListener(
-            new MessagePackEventSerializer<>(
-                new EventConverter<>(new MailboxConverter<>(new TestIdDeserializer()))
+            new MessagePackEventSerializer(
+                new EventConverter(new MailboxConverter(new TestIdDeserializer()))
             ),
             publisherReceiver,
             publisherReceiver,
@@ -103,8 +103,8 @@ public class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
                 CASSANDRA_TIME_OUT_IN_S),
             SCHEDULER_PERIOD_IN_S);
         registeredDelegatingMailboxListener3 = new RegisteredDelegatingMailboxListener(
-            new MessagePackEventSerializer<>(
-                new EventConverter<>(new MailboxConverter<>(new TestIdDeserializer()))
+            new MessagePackEventSerializer(
+                new EventConverter(new MailboxConverter(new TestIdDeserializer()))
             ),
             publisherReceiver,
             publisherReceiver,
@@ -126,9 +126,9 @@ public class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
 
     @Test
     public void mailboxEventListenersShouldBeTriggeredIfRegistered() throws Exception {
-        SimpleMailbox<TestId> simpleMailbox = new SimpleMailbox<>(MAILBOX_PATH_1, 42);
+        SimpleMailbox simpleMailbox = new SimpleMailbox(MAILBOX_PATH_1, 42);
         simpleMailbox.setMailboxId(TestId.of(52));
-        final MailboxListener.Event event = new EventFactory<TestId>().added(mailboxSession, new TreeMap<>(), simpleMailbox);
+        final MailboxListener.Event event = new EventFactory().added(mailboxSession, new TreeMap<>(), simpleMailbox);
 
         registeredDelegatingMailboxListener1.event(event);
 
@@ -139,9 +139,9 @@ public class CassandraBasedRegisteredDistributedMailboxDelegatingListenerTest {
 
     @Test
     public void onceEventListenersShouldBeTriggeredOnceAcrossTheCluster() {
-        SimpleMailbox<TestId> simpleMailbox = new SimpleMailbox<>(MAILBOX_PATH_1, 42);
+        SimpleMailbox simpleMailbox = new SimpleMailbox(MAILBOX_PATH_1, 42);
         simpleMailbox.setMailboxId(TestId.of(52));
-        final MailboxListener.Event event = new EventFactory<TestId>().added(mailboxSession, new TreeMap<>(), simpleMailbox);
+        final MailboxListener.Event event = new EventFactory().added(mailboxSession, new TreeMap<>(), simpleMailbox);
 
         registeredDelegatingMailboxListener1.event(event);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
index bc589b5..008bcdf 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java
@@ -49,7 +49,7 @@ public class CassandraACLMapperTest {
 
     private CassandraACLMapper cassandraACLMapper;
     private CassandraCluster cassandra;
-    private SimpleMailbox<CassandraId> mailbox;
+    private SimpleMailbox mailbox;
     private int uidValidity;
     private int maxRetry;
     private ExecutorService executor;
@@ -59,7 +59,7 @@ public class CassandraACLMapperTest {
         cassandra = CassandraCluster.create(new CassandraAclModule());
         cassandra.ensureAllTables();
         uidValidity = 10;
-        mailbox = new SimpleMailbox<>(new MailboxPath("#private", "benwa@linagora.com", "INBOX"), uidValidity);
+        mailbox = new SimpleMailbox(new MailboxPath("#private", "benwa@linagora.com", "INBOX"), uidValidity);
         mailbox.setMailboxId(CassandraId.of(UUID.fromString("464765a0-e4e7-11e4-aba4-710c1de3782b")));
         maxRetry = 100;
         cassandraACLMapper = new CassandraACLMapper(mailbox, cassandra.getConf(), maxRetry);
@@ -84,14 +84,14 @@ public class CassandraACLMapperTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void creatingACLMapperWithNoMailboxIdShouldFail() {
-        new CassandraACLMapper(new SimpleMailbox<>(new MailboxPath("#private", "user", "name"), uidValidity), cassandra.getConf(), maxRetry);
+        new CassandraACLMapper(new SimpleMailbox(new MailboxPath("#private", "user", "name"), uidValidity), cassandra.getConf(), maxRetry);
     }
 
     @Test
     public void retrieveACLWhenPresentInBaseShouldReturnCorrespondingACL() throws Exception {
         cassandra.getConf().execute(
             insertInto(CassandraACLTable.TABLE_NAME)
-                .value(CassandraACLTable.ID, mailbox.getMailboxId().asUuid())
+                .value(CassandraACLTable.ID, ((CassandraId) mailbox.getMailboxId()).asUuid())
                 .value(CassandraACLTable.ACL, "{\"entries\":{\"bob\":64}}")
                 .value(CassandraACLTable.VERSION, 1)
         );
@@ -107,7 +107,7 @@ public class CassandraACLMapperTest {
     public void retrieveACLWhenInvalidInBaseShouldReturnEmptyACL() throws Exception {
         cassandra.getConf().execute(
             insertInto(CassandraACLTable.TABLE_NAME)
-                .value(CassandraACLTable.ID, mailbox.getMailboxId().asUuid())
+                .value(CassandraACLTable.ID, ((CassandraId) mailbox.getMailboxId()).asUuid())
                 .value(CassandraACLTable.ACL, "{\"entries\":{\"bob\":invalid}}")
                 .value(CassandraACLTable.VERSION, 1)
         );
@@ -167,7 +167,7 @@ public class CassandraACLMapperTest {
     public void updateInvalidACLShouldBeBasedOnEmptyACL() throws Exception {
         cassandra.getConf().execute(
             insertInto(CassandraACLTable.TABLE_NAME)
-                .value(CassandraACLTable.ID, mailbox.getMailboxId().asUuid())
+                .value(CassandraACLTable.ID, ((CassandraId) mailbox.getMailboxId()).asUuid())
                 .value(CassandraACLTable.ACL, "{\"entries\":{\"bob\":invalid}}")
                 .value(CassandraACLTable.VERSION, 1)
         );

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
index 1106de4..a6b1291 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapperTest.java
@@ -18,10 +18,9 @@
  ****************************************************************/
 package org.apache.james.mailbox.cassandra.mail;
 
-import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.store.mail.model.AbstractMailboxMapperTest;
 
-public class CassandraMailboxMapperTest extends AbstractMailboxMapperTest<CassandraId> {
+public class CassandraMailboxMapperTest extends AbstractMailboxMapperTest {
     public CassandraMailboxMapperTest() {
         super(new CassandraMapperProvider());
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMessageMapperTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMessageMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMessageMapperTest.java
index 4dafcba..a656d28 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMessageMapperTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMessageMapperTest.java
@@ -18,10 +18,9 @@
  ****************************************************************/
 package org.apache.james.mailbox.cassandra.mail;
 
-import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.store.mail.model.AbstractMessageMapperTest;
 
-public class CassandraMailboxMessageMapperTest extends AbstractMessageMapperTest<CassandraId> {
+public class CassandraMailboxMessageMapperTest extends AbstractMessageMapperTest {
     public CassandraMailboxMessageMapperTest() {
         super(new CassandraMapperProvider());
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
index bc21830..6201a9e 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMapperProvider.java
@@ -16,7 +16,7 @@ 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;
 
-public class CassandraMapperProvider implements MapperProvider<CassandraId> {
+public class CassandraMapperProvider implements MapperProvider {
 
     private static final CassandraCluster cassandra = CassandraCluster.create(new CassandraModuleComposite(
         new CassandraAclModule(),
@@ -27,7 +27,7 @@ public class CassandraMapperProvider implements MapperProvider<CassandraId> {
         new CassandraUidModule()));
 
     @Override
-    public MailboxMapper<CassandraId> createMailboxMapper() throws MailboxException {
+    public MailboxMapper createMailboxMapper() throws MailboxException {
         return new CassandraMailboxSessionMapperFactory(
             new CassandraUidProvider(cassandra.getConf()),
             new CassandraModSeqProvider(cassandra.getConf()),
@@ -37,7 +37,7 @@ public class CassandraMapperProvider implements MapperProvider<CassandraId> {
     }
 
     @Override
-    public MessageMapper<CassandraId> createMessageMapper() throws MailboxException {
+    public MessageMapper createMessageMapper() throws MailboxException {
         return new CassandraMailboxSessionMapperFactory(
             new CassandraUidProvider(cassandra.getConf()),
             new CassandraModSeqProvider(cassandra.getConf()),

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java
index 51bc8c3..fbf7804 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageMoveTest.java
@@ -19,10 +19,9 @@
 
 package org.apache.james.mailbox.cassandra.mail;
 
-import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.store.mail.model.AbstractMessageMoveTest;
 
-public class CassandraMessageMoveTest extends AbstractMessageMoveTest<CassandraId> {
+public class CassandraMessageMoveTest extends AbstractMessageMoveTest {
 
     public CassandraMessageMoveTest() {
         super(new CassandraMapperProvider());

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
index f0d116a..4143cbc 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraModSeqProviderTest.java
@@ -25,7 +25,6 @@ import java.util.stream.LongStream;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
-import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule;
@@ -48,7 +47,7 @@ public class CassandraModSeqProviderTest {
     
     private CassandraModSeqProvider modSeqProvider;
     private CassandraMailboxMapper mapper;
-    private SimpleMailbox<CassandraId> mailbox;
+    private SimpleMailbox mailbox;
 
     @Before
     public void setUpClass() throws Exception {
@@ -56,7 +55,7 @@ public class CassandraModSeqProviderTest {
         modSeqProvider = new CassandraModSeqProvider(CASSANDRA.getConf());
         mapper = new CassandraMailboxMapper(CASSANDRA.getConf(), CASSANDRA.getTypesProvider(), MAX_RETRY);
         MailboxPath path = new MailboxPath("gsoc", "ieugen", "Trash");
-        mailbox = new SimpleMailbox<>(path, 1234);
+        mailbox = new SimpleMailbox(path, 1234);
         mapper.save(mailbox);
     }
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java
index 8b2bc24..568db73 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUidProviderTest.java
@@ -25,7 +25,6 @@ import java.util.stream.LongStream;
 
 import org.apache.james.backends.cassandra.CassandraCluster;
 import org.apache.james.backends.cassandra.init.CassandraModuleComposite;
-import org.apache.james.mailbox.cassandra.CassandraId;
 import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraMailboxModule;
 import org.apache.james.mailbox.cassandra.modules.CassandraUidModule;
@@ -48,7 +47,7 @@ public class CassandraUidProviderTest {
     
     private CassandraUidProvider uidProvider;
     private CassandraMailboxMapper mapper;
-    private SimpleMailbox<CassandraId> mailbox;
+    private SimpleMailbox mailbox;
 
     @Before
     public void setUpClass() throws Exception {
@@ -56,7 +55,7 @@ public class CassandraUidProviderTest {
         uidProvider = new CassandraUidProvider(CASSANDRA.getConf());
         mapper = new CassandraMailboxMapper(CASSANDRA.getConf(), CASSANDRA.getTypesProvider(), MAX_RETRY);
         MailboxPath path = new MailboxPath("gsoc", "ieugen", "Trash");
-        mailbox = new SimpleMailbox<>(path, 1234);
+        mailbox = new SimpleMailbox(path, 1234);
         mapper.save(mailbox);
     }
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
index 4e1ddec..ef053b5 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
@@ -36,7 +36,6 @@ import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.store.mail.MessageMapperFactory;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
 import org.slf4j.Logger;
@@ -44,18 +43,18 @@ import org.slf4j.LoggerFactory;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 
-public class ElasticSearchListeningMessageSearchIndex<Id extends MailboxId> extends ListeningMessageSearchIndex<Id> {
+public class ElasticSearchListeningMessageSearchIndex extends ListeningMessageSearchIndex {
 
     private final static Logger LOGGER = LoggerFactory.getLogger(ElasticSearchListeningMessageSearchIndex.class);
     private final static String ID_SEPARATOR = ":";
     
     private final ElasticSearchIndexer indexer;
-    private final ElasticSearchSearcher<Id> searcher;
+    private final ElasticSearchSearcher searcher;
     private final MessageToElasticSearchJson messageToElasticSearchJson;
 
     @Inject
-    public ElasticSearchListeningMessageSearchIndex(MessageMapperFactory<Id> factory, ElasticSearchIndexer indexer,
-        ElasticSearchSearcher<Id> searcher, MessageToElasticSearchJson messageToElasticSearchJson) {
+    public ElasticSearchListeningMessageSearchIndex(MessageMapperFactory factory, ElasticSearchIndexer indexer,
+        ElasticSearchSearcher searcher, MessageToElasticSearchJson messageToElasticSearchJson) {
         super(factory);
         this.indexer = indexer;
         this.messageToElasticSearchJson = messageToElasticSearchJson;
@@ -68,12 +67,12 @@ public class ElasticSearchListeningMessageSearchIndex<Id extends MailboxId> exte
     }
 
     @Override
-    public Iterator<Long> search(MailboxSession session, Mailbox<Id> mailbox, SearchQuery searchQuery) throws MailboxException {
+    public Iterator<Long> search(MailboxSession session, Mailbox mailbox, SearchQuery searchQuery) throws MailboxException {
         return searcher.search(mailbox, searchQuery);
     }
 
     @Override
-    public void add(MailboxSession session, Mailbox<Id> mailbox, MailboxMessage<Id> message) throws MailboxException {
+    public void add(MailboxSession session, Mailbox mailbox, MailboxMessage message) throws MailboxException {
         try {
             indexer.indexMessage(indexIdFor(mailbox, message.getUid()), messageToElasticSearchJson.convertToJson(message));
         } catch (Exception e) {
@@ -82,7 +81,7 @@ public class ElasticSearchListeningMessageSearchIndex<Id extends MailboxId> exte
     }
 
     @Override
-    public void delete(MailboxSession session, Mailbox<Id> mailbox, List<Long> expungedUids) throws MailboxException {
+    public void delete(MailboxSession session, Mailbox mailbox, List<Long> expungedUids) throws MailboxException {
         try {
             indexer.deleteMessages(expungedUids.stream()
                 .map(uid ->  indexIdFor(mailbox, uid))
@@ -93,7 +92,7 @@ public class ElasticSearchListeningMessageSearchIndex<Id extends MailboxId> exte
     }
 
     @Override
-    public void deleteAll(MailboxSession session, Mailbox<Id> mailbox) throws MailboxException {
+    public void deleteAll(MailboxSession session, Mailbox mailbox) throws MailboxException {
         try {
             indexer.deleteAllMatchingQuery(
                 termQuery(
@@ -105,7 +104,7 @@ public class ElasticSearchListeningMessageSearchIndex<Id extends MailboxId> exte
     }
 
     @Override
-    public void update(MailboxSession session, Mailbox<Id> mailbox, List<UpdatedFlags> updatedFlagsList) throws MailboxException {
+    public void update(MailboxSession session, Mailbox mailbox, List<UpdatedFlags> updatedFlagsList) throws MailboxException {
         try {
             indexer.updateMessages(updatedFlagsList.stream()
                 .map(updatedFlags -> createUpdatedDocumentPartFromUpdatedFlags(mailbox, updatedFlags))
@@ -115,7 +114,7 @@ public class ElasticSearchListeningMessageSearchIndex<Id extends MailboxId> exte
         }
     }
 
-    private ElasticSearchIndexer.UpdatedRepresentation createUpdatedDocumentPartFromUpdatedFlags(Mailbox<Id> mailbox, UpdatedFlags updatedFlags) {
+    private ElasticSearchIndexer.UpdatedRepresentation createUpdatedDocumentPartFromUpdatedFlags(Mailbox mailbox, UpdatedFlags updatedFlags) {
         try {
             return new ElasticSearchIndexer.UpdatedRepresentation(
                 indexIdFor(mailbox, updatedFlags.getUid()),
@@ -127,7 +126,7 @@ public class ElasticSearchListeningMessageSearchIndex<Id extends MailboxId> exte
         }
     }
 
-    private String indexIdFor(Mailbox<Id> mailbox, long messageId) {
+    private String indexIdFor(Mailbox mailbox, long messageId) {
         return String.join(ID_SEPARATOR, mailbox.getMailboxId().serialize(), String.valueOf(messageId));
     }
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
index db8fc15..9174dcd 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
@@ -19,30 +19,29 @@
 
 package org.apache.james.mailbox.elasticsearch.json;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Multimap;
-import org.apache.james.mailbox.elasticsearch.query.DateResolutionFormater;
-import org.apache.james.mailbox.store.extractor.TextExtractor;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
-import org.apache.james.mailbox.store.mail.model.MailboxMessage;
-import org.apache.james.mailbox.store.mail.model.Property;
-import org.apache.james.mime4j.MimeException;
-
 import java.io.IOException;
 import java.time.Instant;
 import java.time.ZoneId;
 import java.time.ZonedDateTime;
-
 import java.util.List;
 import java.util.Optional;
 import java.util.Set;
 import java.util.stream.Collectors;
 
+import org.apache.james.mailbox.elasticsearch.query.DateResolutionFormater;
+import org.apache.james.mailbox.store.extractor.TextExtractor;
+import org.apache.james.mailbox.store.mail.model.MailboxMessage;
+import org.apache.james.mailbox.store.mail.model.Property;
+import org.apache.james.mime4j.MimeException;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
+import com.google.common.collect.Multimap;
+
 public class IndexableMessage {
 
-    public static IndexableMessage from(MailboxMessage<? extends MailboxId> message, TextExtractor textExtractor, ZoneId zoneId) {
+    public static IndexableMessage from(MailboxMessage message, TextExtractor textExtractor, ZoneId zoneId) {
         Preconditions.checkNotNull(message.getMailboxId());
         IndexableMessage indexableMessage = new IndexableMessage();
         try {
@@ -73,7 +72,7 @@ public class IndexableMessage {
         this.sentDate = DateResolutionFormater.DATE_TIME_FOMATTER.format(headerCollection.getSentDate().orElse(internalDate));
     }
 
-    private void copyMessageFields(MailboxMessage<? extends MailboxId> message, ZoneId zoneId) {
+    private void copyMessageFields(MailboxMessage message, ZoneId zoneId) {
         this.id = message.getUid();
         this.mailboxId = message.getMailboxId().serialize();
         this.modSeq = message.getModSeq();
@@ -91,7 +90,7 @@ public class IndexableMessage {
         this.properties = message.getProperties();
     }
 
-    private static ZonedDateTime getSanitizedInternalDate(MailboxMessage<? extends MailboxId> message, ZoneId zoneId) {
+    private static ZonedDateTime getSanitizedInternalDate(MailboxMessage message, ZoneId zoneId) {
         if (message.getInternalDate() == null) {
             return ZonedDateTime.now();
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
index ce44ee2..01f8a00 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
@@ -19,18 +19,19 @@
 
 package org.apache.james.mailbox.elasticsearch.json;
 
+import java.time.ZoneId;
+
 import javax.inject.Inject;
 import javax.mail.Flags;
 
-import java.time.ZoneId;
+import org.apache.james.mailbox.store.extractor.TextExtractor;
+import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.datatype.guava.GuavaModule;
 import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
 import com.google.common.base.Preconditions;
-import org.apache.james.mailbox.store.extractor.TextExtractor;
-import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 
 public class MessageToElasticSearchJson {
 
@@ -51,7 +52,7 @@ public class MessageToElasticSearchJson {
         this(textExtractor, ZoneId.systemDefault());
     }
 
-    public String convertToJson(MailboxMessage<?> message) throws JsonProcessingException {
+    public String convertToJson(MailboxMessage message) throws JsonProcessingException {
         Preconditions.checkNotNull(message);
         return mapper.writeValueAsString(IndexableMessage.from(message, textExtractor, zoneId));
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
index 39e74c2..1042ec8 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
@@ -33,7 +33,6 @@ import org.apache.james.mailbox.elasticsearch.query.SortConverter;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.mail.model.MailboxId;
 import org.elasticsearch.action.search.SearchRequestBuilder;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.client.Client;
@@ -42,7 +41,7 @@ import org.elasticsearch.search.SearchHit;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class ElasticSearchSearcher<Id extends MailboxId> {
+public class ElasticSearchSearcher {
 
     private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchSearcher.class);
     private static final TimeValue TIMEOUT = new TimeValue(60000);
@@ -63,13 +62,13 @@ public class ElasticSearchSearcher<Id extends MailboxId> {
         this.size = size;
     }
 
-    public Iterator<Long> search(Mailbox<Id> mailbox, SearchQuery searchQuery) throws MailboxException {
+    public Iterator<Long> search(Mailbox mailbox, SearchQuery searchQuery) throws MailboxException {
         return new ScrollIterable(client, getSearchRequestBuilder(client, mailbox, searchQuery)).stream()
             .flatMap(this::transformResponseToUidStream)
             .iterator();
     }
 
-    private SearchRequestBuilder getSearchRequestBuilder(Client client, Mailbox<Id> mailbox, SearchQuery searchQuery) {
+    private SearchRequestBuilder getSearchRequestBuilder(Client client, Mailbox mailbox, SearchQuery searchQuery) {
         return searchQuery.getSorts()
             .stream()
             .reduce(

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
index 90f9844..bc82a95 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
@@ -32,14 +32,12 @@ import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
 import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
 import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
-import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
-import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
 import org.apache.james.mailbox.elasticsearch.query.CriterionConverter;
 import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
 import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.inmemory.InMemoryId;
+import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.SearchQuery;
@@ -48,6 +46,7 @@ import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.MockAuthenticator;
 import org.apache.james.mailbox.store.StoreMailboxManager;
 import org.apache.james.mailbox.store.StoreMessageManager;
+import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
 import org.apache.james.mailbox.store.mail.model.Mailbox;
 import org.elasticsearch.client.Client;
 import org.junit.Before;
@@ -73,20 +72,19 @@ public class ElasticSearchIntegrationTest {
     public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
 
 
-    private StoreMailboxManager<InMemoryId> storeMailboxManager;
-    private ElasticSearchListeningMessageSearchIndex<InMemoryId> elasticSearchListeningMessageSearchIndex;
-    private Mailbox<InMemoryId> mailbox;
+    private StoreMailboxManager storeMailboxManager;
+    private ElasticSearchListeningMessageSearchIndex elasticSearchListeningMessageSearchIndex;
+    private Mailbox mailbox;
     private MailboxSession session;
 
     @Before
-    @SuppressWarnings("unchecked")
     public void setUp() throws Exception {
         initializeMailboxManager();
 
         session = storeMailboxManager.createSystemSession("benwa", LOGGER);
 
         storeMailboxManager.createMailbox(new MailboxPath("#private", "benwa", "INBOX"), session);
-        StoreMessageManager<InMemoryId> messageManager = (StoreMessageManager<InMemoryId>) storeMailboxManager.getMailbox(new MailboxPath("#private", "benwa", "INBOX"), session);
+        StoreMessageManager messageManager = (StoreMessageManager) storeMailboxManager.getMailbox(new MailboxPath("#private", "benwa", "INBOX"), session);
         mailbox = messageManager.getMailboxEntity();
 
         // sentDate: Wed, 3 Jun 2015 09:05:46 +0000
@@ -169,10 +167,10 @@ public class ElasticSearchIntegrationTest {
         Client client = NodeMappingFactory.applyMapping(
             IndexCreationFactory.createIndex(new TestingClientProvider(embeddedElasticSearch.getNode()).get())
         );
-        MailboxSessionMapperFactory<InMemoryId> mapperFactory = new InMemoryMailboxSessionMapperFactory();
-        elasticSearchListeningMessageSearchIndex = new ElasticSearchListeningMessageSearchIndex<>(mapperFactory,
+        MailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
+        elasticSearchListeningMessageSearchIndex = new ElasticSearchListeningMessageSearchIndex(mapperFactory,
             new ElasticSearchIndexer(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor(), BATCH_SIZE)),
-            new ElasticSearchSearcher<>(client, new QueryConverter(new CriterionConverter()), SEARCH_SIZE),
+            new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), SEARCH_SIZE),
             new MessageToElasticSearchJson(new DefaultTextExtractor(), ZoneId.of("Europe/Paris")));
         storeMailboxManager = new InMemoryMailboxManager(
             mapperFactory,

http://git-wip-us.apache.org/repos/asf/james-project/blob/7015d946/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
index 64bb04c..0039eb9 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
@@ -58,35 +58,33 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest {
     private IMocksControl control;
 
     private ElasticSearchIndexer indexer;
-    private ElasticSearchListeningMessageSearchIndex<TestId> testee;
+    private ElasticSearchListeningMessageSearchIndex testee;
     
     @Before
-    @SuppressWarnings("unchecked")
     public void setup() throws JsonProcessingException {
         control = createControl();
 
-        MessageMapperFactory<TestId> mapperFactory = control.createMock(MessageMapperFactory.class);
+        MessageMapperFactory mapperFactory = control.createMock(MessageMapperFactory.class);
         MessageToElasticSearchJson messageToElasticSearchJson = control.createMock(MessageToElasticSearchJson.class);
-        ElasticSearchSearcher<TestId> elasticSearchSearcher = control.createMock(ElasticSearchSearcher.class);
+        ElasticSearchSearcher elasticSearchSearcher = control.createMock(ElasticSearchSearcher.class);
 
         indexer = control.createMock(ElasticSearchIndexer.class);
 
         expect(messageToElasticSearchJson.convertToJson(anyObject(MailboxMessage.class))).andReturn("json content").anyTimes();
         expect(messageToElasticSearchJson.getUpdatedJsonMessagePart(anyObject(Flags.class), anyLong())).andReturn("json updated content").anyTimes();
 
-        testee = new ElasticSearchListeningMessageSearchIndex<>(mapperFactory, indexer, elasticSearchSearcher, messageToElasticSearchJson);
+        testee = new ElasticSearchListeningMessageSearchIndex(mapperFactory, indexer, elasticSearchSearcher, messageToElasticSearchJson);
     }
     
     @Test
-    @SuppressWarnings("unchecked")
     public void addShouldIndex() throws Exception {
         MailboxSession session = control.createMock(MailboxSession.class);
-        Mailbox<TestId> mailbox = control.createMock(Mailbox.class);
+        Mailbox mailbox = control.createMock(Mailbox.class);
         
         long messageId = 1;
         TestId mailboxId = TestId.of(12);
         expect(mailbox.getMailboxId()).andReturn(mailboxId);
-        MailboxMessage<TestId> message = mockedMessage(messageId);
+        MailboxMessage message = mockedMessage(messageId);
         
         IndexResponse expectedIndexResponse = control.createMock(IndexResponse.class);
         expect(indexer.indexMessage(eq(mailboxId.serialize() + ":" + messageId), anyString()))
@@ -97,22 +95,20 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest {
         control.verify();
     }
 
-    @SuppressWarnings("unchecked")
-    private MailboxMessage<TestId> mockedMessage(long messageId) throws IOException {
-        MailboxMessage<TestId> message = control.createMock(MailboxMessage.class);
+    private MailboxMessage mockedMessage(long messageId) throws IOException {
+        MailboxMessage message = control.createMock(MailboxMessage.class);
         expect(message.getUid()).andReturn(messageId).anyTimes();
         return message;
     }
     
     @Test
-    @SuppressWarnings("unchecked")
     public void addShouldNotPropagateExceptionWhenExceptionOccurs() throws Exception {
         MailboxSession session = control.createMock(MailboxSession.class);
-        Mailbox<TestId> mailbox = control.createMock(Mailbox.class);
+        Mailbox mailbox = control.createMock(Mailbox.class);
         
         long messageId = 1;
         TestId mailboxId = TestId.of(12);
-        MailboxMessage<TestId> message = mockedMessage(messageId);
+        MailboxMessage message = mockedMessage(messageId);
         expect(mailbox.getMailboxId()).andReturn(mailboxId);
         
         expect(indexer.indexMessage(eq(mailboxId.serialize() + ":" + messageId), anyString()))
@@ -127,7 +123,7 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest {
     @SuppressWarnings("unchecked")
     public void deleteShouldWork() throws Exception {
         MailboxSession session = control.createMock(MailboxSession.class);
-        Mailbox<TestId> mailbox = control.createMock(Mailbox.class);
+        Mailbox mailbox = control.createMock(Mailbox.class);
         long messageId = 1;
         TestId mailboxId = TestId.of(12);
         expect(mailbox.getMailboxId()).andReturn(mailboxId);
@@ -145,7 +141,7 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest {
     @SuppressWarnings("unchecked")
     public void deleteShouldWorkWhenMultipleMessageIds() throws Exception {
         MailboxSession session = control.createMock(MailboxSession.class);
-        Mailbox<TestId> mailbox = control.createMock(Mailbox.class);
+        Mailbox mailbox = control.createMock(Mailbox.class);
         long messageId1 = 1;
         long messageId2 = 2;
         long messageId3 = 3;
@@ -167,7 +163,7 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest {
     @SuppressWarnings("unchecked")
     public void deleteShouldNotPropagateExceptionWhenExceptionOccurs() throws Exception {
         MailboxSession session = control.createMock(MailboxSession.class);
-        Mailbox<TestId> mailbox = control.createMock(Mailbox.class);
+        Mailbox mailbox = control.createMock(Mailbox.class);
         long messageId = 1;
         TestId mailboxId = TestId.of(12);
         expect(mailbox.getMailboxId()).andReturn(mailboxId).times(2);
@@ -185,7 +181,7 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest {
     public void updateShouldWork() throws Exception {
         MailboxSession session = control.createMock(MailboxSession.class);
 
-        Mailbox<TestId> mailbox = control.createMock(Mailbox.class);
+        Mailbox mailbox = control.createMock(Mailbox.class);
 
         Flags flags = new Flags();
         long messageId = 1;
@@ -209,7 +205,7 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest {
     public void updateShouldNotPropagateExceptionWhenExceptionOccurs() throws Exception {
         MailboxSession session = control.createMock(MailboxSession.class);
 
-        Mailbox<TestId> mailbox = control.createMock(Mailbox.class);
+        Mailbox mailbox = control.createMock(Mailbox.class);
         Flags flags = new Flags();
         long messageId = 1;
         UpdatedFlags updatedFlags = new UpdatedFlags(messageId, MODSEQ, flags, flags);
@@ -227,11 +223,10 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest {
     }
 
     @Test
-    @SuppressWarnings("unchecked")
     public void deleteAllShouldWork() throws Exception {
         MailboxSession session = control.createMock(MailboxSession.class);
 
-        Mailbox<TestId> mailbox = control.createMock(Mailbox.class);
+        Mailbox mailbox = control.createMock(Mailbox.class);
 
         TestId mailboxId = TestId.of(12);
 
@@ -247,11 +242,10 @@ public class ElasticSearchListeningMailboxMessageSearchIndexTest {
     }
 
     @Test
-    @SuppressWarnings("unchecked")
     public void deleteAllShouldNotPropagateExceptionWhenExceptionOccurs() throws Exception {
         MailboxSession session = control.createMock(MailboxSession.class);
 
-        Mailbox<TestId> mailbox = control.createMock(Mailbox.class);
+        Mailbox mailbox = control.createMock(Mailbox.class);
         TestId mailboxId = TestId.of(12);
 
         expectLastCall();


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