james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [15/41] james-project git commit: JAMES-2082 Reindent some Cassandra related classes
Date Mon, 10 Jul 2017 17:54:27 GMT
JAMES-2082 Reindent some Cassandra related classes


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/0ecc48ae
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/0ecc48ae
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/0ecc48ae

Branch: refs/heads/master
Commit: 0ecc48aeee620d8e8215c65206bb1a3496b9a356
Parents: 6091e38
Author: benwa <btellier@linagora.com>
Authored: Thu Jul 6 16:47:19 2017 +0700
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Mon Jul 10 14:23:56 2017 +0200

----------------------------------------------------------------------
 .../cassandra/mail/CassandraMessageDAOV2.java   | 86 ++++++++++----------
 .../mail/CassandraMessageIdMapper.java          |  7 +-
 .../cassandra/mail/CassandraMessageMapper.java  | 24 +++---
 3 files changed, 59 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/0ecc48ae/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
index f9b3255..5fb4fed 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAOV2.java
@@ -121,16 +121,16 @@ public class CassandraMessageDAOV2 {
 
     private PreparedStatement prepareInsert(Session session) {
         return session.prepare(insertInto(TABLE_NAME)
-                .value(MESSAGE_ID, bindMarker(MESSAGE_ID))
-                .value(INTERNAL_DATE, bindMarker(INTERNAL_DATE))
-                .value(BODY_START_OCTET, bindMarker(BODY_START_OCTET))
-                .value(FULL_CONTENT_OCTETS, bindMarker(FULL_CONTENT_OCTETS))
-                .value(BODY_OCTECTS, bindMarker(BODY_OCTECTS))
-                .value(BODY_CONTENT, bindMarker(BODY_CONTENT))
-                .value(HEADER_CONTENT, bindMarker(HEADER_CONTENT))
-                .value(PROPERTIES, bindMarker(PROPERTIES))
-                .value(TEXTUAL_LINE_COUNT, bindMarker(TEXTUAL_LINE_COUNT))
-                .value(ATTACHMENTS, bindMarker(ATTACHMENTS)));
+            .value(MESSAGE_ID, bindMarker(MESSAGE_ID))
+            .value(INTERNAL_DATE, bindMarker(INTERNAL_DATE))
+            .value(BODY_START_OCTET, bindMarker(BODY_START_OCTET))
+            .value(FULL_CONTENT_OCTETS, bindMarker(FULL_CONTENT_OCTETS))
+            .value(BODY_OCTECTS, bindMarker(BODY_OCTECTS))
+            .value(BODY_CONTENT, bindMarker(BODY_CONTENT))
+            .value(HEADER_CONTENT, bindMarker(HEADER_CONTENT))
+            .value(PROPERTIES, bindMarker(PROPERTIES))
+            .value(TEXTUAL_LINE_COUNT, bindMarker(TEXTUAL_LINE_COUNT))
+            .value(ATTACHMENTS, bindMarker(ATTACHMENTS)));
     }
 
     private PreparedStatement prepareDelete(Session session) {
@@ -154,8 +154,8 @@ public class CassandraMessageDAOV2 {
                     message.getHeaderContent()));
 
             return bodyContent.thenCompose(bodyContentId ->
-                    headerContent.thenApply(headerContentId ->
-                            Pair.of(bodyContentId, headerContentId)));
+                headerContent.thenApply(headerContentId ->
+                    Pair.of(bodyContentId, headerContentId)));
         } catch (IOException e) {
             throw new MailboxException("Error saving mail content", e);
         }
@@ -164,24 +164,24 @@ public class CassandraMessageDAOV2 {
     private BoundStatement boundWriteStatement(MailboxMessage message, Pair<Optional<BlobId>,
Optional<BlobId>> pair) {
         CassandraMessageId messageId = (CassandraMessageId) message.getMessageId();
         return insert.bind()
-                .setUUID(MESSAGE_ID, messageId.get())
-                .setTimestamp(INTERNAL_DATE, message.getInternalDate())
-                .setInt(BODY_START_OCTET, (int) (message.getHeaderOctets()))
-                .setLong(FULL_CONTENT_OCTETS, message.getFullContentOctets())
-                .setLong(BODY_OCTECTS, message.getBodyOctets())
-                .setString(BODY_CONTENT, pair.getLeft().map(BlobId::getId).orElse(DEFAULT_OBJECT_VALUE))
-                .setString(HEADER_CONTENT, pair.getRight().map(BlobId::getId).orElse(DEFAULT_OBJECT_VALUE))
-                .setLong(TEXTUAL_LINE_COUNT, Optional.ofNullable(message.getTextualLineCount()).orElse(DEFAULT_LONG_VALUE))
-                .setList(PROPERTIES, message.getProperties().stream()
-                        .map(x -> typesProvider.getDefinedUserType(PROPERTIES)
-                                .newValue()
-                                .setString(Properties.NAMESPACE, x.getNamespace())
-                                .setString(Properties.NAME, x.getLocalName())
-                                .setString(Properties.VALUE, x.getValue()))
-                        .collect(Collectors.toList()))
-                .setList(ATTACHMENTS, message.getAttachments().stream()
-                        .map(this::toUDT)
-                        .collect(Guavate.toImmutableList()));
+            .setUUID(MESSAGE_ID, messageId.get())
+            .setTimestamp(INTERNAL_DATE, message.getInternalDate())
+            .setInt(BODY_START_OCTET, (int) (message.getHeaderOctets()))
+            .setLong(FULL_CONTENT_OCTETS, message.getFullContentOctets())
+            .setLong(BODY_OCTECTS, message.getBodyOctets())
+            .setString(BODY_CONTENT, pair.getLeft().map(BlobId::getId).orElse(DEFAULT_OBJECT_VALUE))
+            .setString(HEADER_CONTENT, pair.getRight().map(BlobId::getId).orElse(DEFAULT_OBJECT_VALUE))
+            .setLong(TEXTUAL_LINE_COUNT, Optional.ofNullable(message.getTextualLineCount()).orElse(DEFAULT_LONG_VALUE))
+            .setList(PROPERTIES, message.getProperties().stream()
+                .map(x -> typesProvider.getDefinedUserType(PROPERTIES)
+                    .newValue()
+                    .setString(Properties.NAMESPACE, x.getNamespace())
+                    .setString(Properties.NAME, x.getLocalName())
+                    .setString(Properties.VALUE, x.getValue()))
+                .collect(Collectors.toList()))
+            .setList(ATTACHMENTS, message.getAttachments().stream()
+                .map(this::toUDT)
+                .collect(Guavate.toImmutableList()));
     }
 
     private UDTValue toUDT(MessageAttachment messageAttachment) {
@@ -218,7 +218,7 @@ public class CassandraMessageDAOV2 {
     }
 
     private CompletableFuture<MessageResult>
-            message(ResultSet rows,ComposedMessageIdWithMetaData messageIdWithMetaData, FetchType
fetchType) {
+    message(ResultSet rows,ComposedMessageIdWithMetaData messageIdWithMetaData, FetchType
fetchType) {
         ComposedMessageId messageId = messageIdWithMetaData.getComposedMessageId();
 
         if (rows.isExhausted()) {
@@ -256,13 +256,13 @@ public class CassandraMessageDAOV2 {
 
     private Stream<MessageAttachmentRepresentation> getAttachments(Row row, FetchType
fetchType) {
         switch (fetchType) {
-        case Full:
-        case Body:
-            List<UDTValue> udtValues = row.getList(ATTACHMENTS, UDTValue.class);
+            case Full:
+            case Body:
+                List<UDTValue> udtValues = row.getList(ATTACHMENTS, UDTValue.class);
 
-            return attachmentByIds(udtValues);
-        default:
-            return Stream.of();
+                return attachmentByIds(udtValues);
+            default:
+                return Stream.of();
         }
     }
 
@@ -273,11 +273,11 @@ public class CassandraMessageDAOV2 {
 
     private MessageAttachmentRepresentation messageAttachmentByIdFrom(UDTValue udtValue)
{
         return MessageAttachmentRepresentation.builder()
-                .attachmentId(AttachmentId.from(udtValue.getString(Attachments.ID)))
-                .name(udtValue.getString(Attachments.NAME))
-                .cid(Optional.ofNullable(udtValue.getString(Attachments.CID)).map(Cid::from))
-                .isInline(udtValue.getBool(Attachments.IS_INLINE))
-                .build();
+            .attachmentId(AttachmentId.from(udtValue.getString(Attachments.ID)))
+            .name(udtValue.getString(Attachments.NAME))
+            .cid(Optional.ofNullable(udtValue.getString(Attachments.CID)).map(Cid::from))
+            .isInline(udtValue.getBool(Attachments.IS_INLINE))
+            .build();
     }
 
     private PreparedStatement retrieveSelect(FetchType fetchType) {
@@ -308,7 +308,7 @@ public class CassandraMessageDAOV2 {
                 return this::getHeaderContent;
             case Body:
                 return row -> getBodyContent(row)
-                        .thenApply(data -> Bytes.concat(new byte[row.getInt(BODY_START_OCTET)],
data));
+                    .thenApply(data -> Bytes.concat(new byte[row.getInt(BODY_START_OCTET)],
data));
             case Metadata:
                 return row -> CompletableFuture.completedFuture(EMPTY_BYTE_ARRAY);
             default:

http://git-wip-us.apache.org/repos/asf/james-project/blob/0ecc48ae/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
index ef5f954..95f0dd9 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageIdMapper.java
@@ -115,10 +115,11 @@ public class CassandraMessageIdMapper implements MessageIdMapper {
 
     private CompletableFuture<Stream<Pair<MessageWithoutAttachment, Stream<MessageAttachmentRepresentation>>>>
             retrieveMessages(FetchType fetchType, ImmutableList<ComposedMessageIdWithMetaData>
composedMessageIds) {
+
         return messageDAOV2.retrieveMessages(composedMessageIds, fetchType, Limit.unlimited())
-                .thenCompose(messageResults -> FluentFutureStream.of(messageResults
-                        .map(v1ToV2Migration::moveFromV1toV2))
-                        .completableFuture());
+            .thenCompose(messageResults -> FluentFutureStream.of(messageResults
+                .map(v1ToV2Migration::moveFromV1toV2))
+                .completableFuture());
     }
 
     private CompletableFuture<Stream<SimpleMailboxMessage>> filterMessagesWIthExistingMailbox(Stream<SimpleMailboxMessage>
stream) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/0ecc48ae/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 4b52806..1daa256 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
@@ -177,16 +177,16 @@ public class CassandraMessageMapper implements MessageMapper {
     public Iterator<MailboxMessage> findInMailbox(Mailbox mailbox, MessageRange messageRange,
FetchType ftype, int max) throws MailboxException {
         CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
         return retrieveMessages(retrieveMessageIds(mailboxId, messageRange), ftype, Limit.from(max))
-                .join()
-                .map(SimpleMailboxMessage -> (MailboxMessage) SimpleMailboxMessage)
-                .sorted(Comparator.comparing(MailboxMessage::getUid))
-                .iterator();
+            .join()
+            .map(SimpleMailboxMessage -> (MailboxMessage) SimpleMailboxMessage)
+            .sorted(Comparator.comparing(MailboxMessage::getUid))
+            .iterator();
     }
 
     private List<ComposedMessageIdWithMetaData> retrieveMessageIds(CassandraId mailboxId,
MessageRange messageRange) {
         return messageIdDAO.retrieveMessages(mailboxId, messageRange)
-                .join()
-                .collect(Guavate.toImmutableList());
+            .join()
+            .collect(Guavate.toImmutableList());
     }
 
     private CompletableFuture<Stream<SimpleMailboxMessage>> retrieveMessages(List<ComposedMessageIdWithMetaData>
messageIds, FetchType fetchType, Limit limit) {
@@ -203,8 +203,8 @@ public class CassandraMessageMapper implements MessageMapper {
     public List<MessageUid> findRecentMessageUidsInMailbox(Mailbox mailbox) throws
MailboxException {
         CassandraId mailboxId = (CassandraId) mailbox.getMailboxId();
         return mailboxRecentDAO.getRecentMessageUidsInMailbox(mailboxId)
-                .join()
-                .collect(Guavate.toImmutableList());
+            .join()
+            .collect(Guavate.toImmutableList());
     }
 
     @Override
@@ -239,11 +239,11 @@ public class CassandraMessageMapper implements MessageMapper {
     }
 
     private CompletableFuture<Stream<Pair<MessageWithoutAttachment, Stream<MessageAttachmentRepresentation>>>>
retrieveMessagesAndDoMigrationIfNeeded(
-            List<ComposedMessageIdWithMetaData> messageIds, FetchType fetchType, Limit
limit) {
+        List<ComposedMessageIdWithMetaData> messageIds, FetchType fetchType, Limit
limit) {
         return messageDAOV2.retrieveMessages(messageIds, fetchType, limit)
-                .thenCompose(messageResults -> FluentFutureStream.of(messageResults
-                        .map(v1ToV2Migration::moveFromV1toV2))
-                        .completableFuture());
+            .thenCompose(messageResults -> FluentFutureStream.of(messageResults
+                .map(v1ToV2Migration::moveFromV1toV2))
+                .completableFuture());
     }
 
     @Override


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