This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit d3cf49f82f9e2feb96db86e8f4a621f41b9b356c
Author: Benoit Tellier <btell...@linagora.com>
AuthorDate: Wed Jul 15 13:22:04 2020 +0700

    JAMES-2904 Remove unused MessageResult::hasAttachment
---
 .../apache/james/mailbox/model/MessageResult.java  |  5 ----
 .../apache/james/mailbox/MailboxManagerTest.java   | 31 ---------------------
 .../cassandra/mail/CassandraMessageDAO.java        |  6 ----
 .../cassandra/mail/MessageRepresentation.java      |  5 +---
 .../model/openjpa/AbstractJPAMailboxMessage.java   |  6 ----
 .../mailbox/maildir/mail/model/MaildirMessage.java |  5 ----
 .../james/mailbox/store/MessageResultImpl.java     |  5 ----
 .../mailbox/store/StoreMessageResultIterator.java  |  5 ----
 .../store/mail/model/DelegatingMailboxMessage.java |  5 ----
 .../james/mailbox/store/mail/model/Message.java    |  2 --
 .../mail/model/impl/SimpleMailboxMessage.java      | 29 ++------------------
 .../store/mail/model/impl/SimpleMessage.java       |  9 +-----
 .../store/AbstractMessageIdManagerStorageTest.java | 32 ----------------------
 13 files changed, 5 insertions(+), 140 deletions(-)

diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageResult.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageResult.java
index 0dabf05..515507b 100644
--- 
a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageResult.java
+++ 
b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MessageResult.java
@@ -163,9 +163,4 @@ public interface MessageResult extends 
Comparable<MessageResult> {
      */
     List<MessageAttachmentMetadata> getLoadedAttachments() throws 
MailboxException;
 
-    /**
-     * Indicates if the message have attachments, regardless of loaded 
attachments.
-     */
-    boolean hasAttachments() throws MailboxException;
-
 }
diff --git 
a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java 
b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
index c1692e9..78d528e 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
@@ -64,7 +64,6 @@ import 
org.apache.james.mailbox.exception.TooLongMailboxNameException;
 import org.apache.james.mailbox.extension.PreDeletionHook;
 import org.apache.james.mailbox.mock.DataProvisioner;
 import org.apache.james.mailbox.model.ComposedMessageId;
-import org.apache.james.mailbox.model.ComposedMessageIdWithMetaData;
 import org.apache.james.mailbox.model.FetchGroup;
 import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxAnnotation;
@@ -76,7 +75,6 @@ import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.model.MessageRange;
 import org.apache.james.mailbox.model.MessageResult;
-import org.apache.james.mailbox.model.MessageResultIterator;
 import org.apache.james.mailbox.model.MultimailboxesSearchQuery;
 import org.apache.james.mailbox.model.Quota;
 import org.apache.james.mailbox.model.QuotaRoot;
@@ -93,7 +91,6 @@ import org.junit.jupiter.api.Nested;
 import org.junit.jupiter.api.Test;
 import org.mockito.ArgumentCaptor;
 
-import com.github.fge.lambdas.Throwing;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
@@ -2721,34 +2718,6 @@ public abstract class MailboxManagerTest<T extends 
MailboxManager> {
                     .collectList().block())
                 .isEmpty();
         }
-
-        @Test
-        void getMessagesShouldIncludeHasAttachmentInformation() throws 
Exception {
-            ComposedMessageId composeId = 
inboxManager.appendMessage(AppendCommand.builder()
-                .withFlags(new Flags(Flags.Flag.DELETED))
-                
.build(ClassLoaderUtils.getSystemResourceAsSharedStream("eml/twoAttachmentsApi.eml")),
 session).getId();
-
-            MessageResultIterator messages = 
inboxManager.getMessages(MessageRange.one(composeId.getUid()), 
FetchGroup.MINIMAL, session);
-
-            assertThat(messages).toIterable()
-                .hasSize(1)
-                .first()
-                .satisfies(Throwing.consumer(messageResult -> 
assertThat(messageResult.hasAttachments()).isTrue()));
-        }
-
-        @Test
-        void getMessagesShouldNotIncludeAttachmentInformationWhenNone() throws 
Exception {
-            ComposedMessageId composeId = 
inboxManager.appendMessage(AppendCommand.builder()
-                .withFlags(new Flags(Flags.Flag.DELETED))
-                .build(message), session).getId();
-
-            MessageResultIterator messages = 
inboxManager.getMessages(MessageRange.one(composeId.getUid()), 
FetchGroup.MINIMAL, session);
-
-            assertThat(messages).toIterable()
-                .hasSize(1)
-                .first()
-                .satisfies(Throwing.consumer(messageResult -> 
assertThat(messageResult.hasAttachments()).isFalse()));
-        }
     }
 
     @Nested
diff --git 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
index 8c447d7..01ca6b9 100644
--- 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
+++ 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMessageDAO.java
@@ -263,7 +263,6 @@ public class CassandraMessageDAO {
                 row.getInt(BODY_START_OCTET),
                 new SharedByteArrayInputStream(content),
                 getPropertyBuilder(row),
-                hasAttachment(row),
                 getAttachments(row).collect(Guavate.toImmutableList())));
     }
 
@@ -285,11 +284,6 @@ public class CassandraMessageDAO {
         return attachmentByIds(udtValues);
     }
 
-    private boolean hasAttachment(Row row) {
-        List<UDTValue> udtValues = row.getList(ATTACHMENTS, UDTValue.class);
-        return !udtValues.isEmpty();
-    }
-
     private Stream<MessageAttachmentRepresentation> 
attachmentByIds(List<UDTValue> udtValues) {
         return udtValues.stream()
             .map(this::messageAttachmentByIdFrom);
diff --git 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageRepresentation.java
 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageRepresentation.java
index d627f2b..7a9a0b1 100644
--- 
a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageRepresentation.java
+++ 
b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/MessageRepresentation.java
@@ -37,18 +37,16 @@ public class MessageRepresentation {
     private final Integer bodySize;
     private final SharedByteArrayInputStream content;
     private final PropertyBuilder propertyBuilder;
-    private final boolean hasAttachment;
     private final List<MessageAttachmentRepresentation> attachments;
 
     public MessageRepresentation(MessageId messageId, Date internalDate, Long 
size, Integer bodySize, SharedByteArrayInputStream content,
-                                 PropertyBuilder propertyBuilder, boolean 
hasAttachment, List<MessageAttachmentRepresentation> attachments) {
+                                 PropertyBuilder propertyBuilder, 
List<MessageAttachmentRepresentation> attachments) {
         this.messageId = messageId;
         this.internalDate = internalDate;
         this.size = size;
         this.bodySize = bodySize;
         this.content = content;
         this.propertyBuilder = propertyBuilder;
-        this.hasAttachment = hasAttachment;
         this.attachments = attachments;
     }
 
@@ -65,7 +63,6 @@ public class MessageRepresentation {
             .flags(metadata.getFlags())
             .propertyBuilder(propertyBuilder)
             .addAttachments(attachments)
-            .hasAttachment(hasAttachment)
             .build();
     }
 
diff --git 
a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMessage.java
 
b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMessage.java
index 004c317..480989a 100644
--- 
a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMessage.java
+++ 
b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/openjpa/AbstractJPAMailboxMessage.java
@@ -523,10 +523,4 @@ public abstract class AbstractJPAMailboxMessage implements 
MailboxMessage {
     private AttachmentId generateFixedAttachmentId(int position) {
         return AttachmentId.from(getMailboxId().serialize() + "-" + 
getUid().asLong() + "-" + position);
     }
-
-    @Override
-    public boolean hasAttachment() {
-        return !getAttachments().isEmpty();
-    }
-
 }
diff --git 
a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java
 
b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java
index d094699..3861dd9 100644
--- 
a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java
+++ 
b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/model/MaildirMessage.java
@@ -292,9 +292,4 @@ public class MaildirMessage implements Message {
         return AttachmentId.from(messageName.getFullName() + "-" + position);
     }
 
-    @Override
-    public boolean hasAttachment() {
-        return !getAttachments().isEmpty();
-    }
-
 }
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageResultImpl.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageResultImpl.java
index 6d68e3d..b52a655 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageResultImpl.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/MessageResultImpl.java
@@ -310,11 +310,6 @@ public class MessageResultImpl implements MessageResult {
         return message.getAttachments();
     }
 
-    @Override
-    public boolean hasAttachments() {
-        return message.hasAttachment();
-    }
-
     private static final class HeadersImpl implements Headers {
 
         private final MailboxMessage msg;
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageResultIterator.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageResultIterator.java
index 02a3b19..2fcd537 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageResultIterator.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageResultIterator.java
@@ -227,11 +227,6 @@ public class StoreMessageResultIterator implements 
MessageResultIterator {
         }
 
         @Override
-        public boolean hasAttachments() throws MailboxException {
-            throw exception;
-        }
-
-        @Override
         public int compareTo(MessageResult that) {
             return getUid().compareTo(that.getUid());
         }
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessage.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessage.java
index 398ec51..cdd3ff2 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessage.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/DelegatingMailboxMessage.java
@@ -119,9 +119,4 @@ public abstract class DelegatingMailboxMessage implements 
MailboxMessage {
     public List<MessageAttachmentMetadata> getAttachments() {
         return message.getAttachments();
     }
-
-    @Override
-    public boolean hasAttachment() {
-        return message.hasAttachment();
-    }
 }
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Message.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Message.java
index c2e3fb8..9cacbfc 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Message.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/Message.java
@@ -109,6 +109,4 @@ public interface Message {
      */
     List<MessageAttachmentMetadata> getAttachments();
 
-    boolean hasAttachment();
-
 }
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
index c19d5c2..32be330 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMailboxMessage.java
@@ -65,7 +65,6 @@ public class SimpleMailboxMessage extends 
DelegatingMailboxMessage {
         private Optional<MessageUid> uid = Optional.empty();
         private Optional<ModSeq> modseq = Optional.empty();
         private ImmutableList.Builder<MessageAttachmentMetadata> attachments = 
ImmutableList.builder();
-        private Optional<Boolean> hasAttachment = Optional.empty();
 
         public Builder messageId(MessageId messageId) {
             this.messageId = messageId;
@@ -104,16 +103,6 @@ public class SimpleMailboxMessage extends 
DelegatingMailboxMessage {
             return this;
         }
 
-        public Builder hasAttachment() {
-            this.hasAttachment = Optional.of(true);
-            return this;
-        }
-
-        public Builder hasAttachment(boolean hasAttachment) {
-            this.hasAttachment = Optional.of(hasAttachment);
-            return this;
-        }
-
         public Builder flags(Flags flags) {
             this.flags = flags;
             return this;
@@ -145,9 +134,8 @@ public class SimpleMailboxMessage extends 
DelegatingMailboxMessage {
             Preconditions.checkNotNull(mailboxId, "mailboxId is required");
 
             ImmutableList<MessageAttachmentMetadata> attachments = 
this.attachments.build();
-            boolean hasAttachment = 
this.hasAttachment.orElse(!attachments.isEmpty());
             SimpleMailboxMessage simpleMailboxMessage = new 
SimpleMailboxMessage(messageId, internalDate, size,
-                bodyStartOctet, content, flags, propertyBuilder, mailboxId, 
attachments, hasAttachment);
+                bodyStartOctet, content, flags, propertyBuilder, mailboxId, 
attachments);
 
             uid.ifPresent(simpleMailboxMessage::setUid);
             modseq.ifPresent(simpleMailboxMessage::setModSeq);
@@ -175,7 +163,6 @@ public class SimpleMailboxMessage extends 
DelegatingMailboxMessage {
             .internalDate(original.getInternalDate())
             .size(original.getFullContentOctets())
             .flags(original.createFlags())
-            .hasAttachment(original.hasAttachment())
             .propertyBuilder(propertyBuilder);
     }
 
@@ -205,8 +192,7 @@ public class SimpleMailboxMessage extends 
DelegatingMailboxMessage {
 
     public SimpleMailboxMessage(MessageId messageId, Date internalDate, long 
size, int bodyStartOctet,
             SharedInputStream content, Flags flags,
-            PropertyBuilder propertyBuilder, MailboxId mailboxId, 
List<MessageAttachmentMetadata> attachments,
-            boolean hasAttachment) {
+            PropertyBuilder propertyBuilder, MailboxId mailboxId, 
List<MessageAttachmentMetadata> attachments) {
         super(new SimpleMessage(
                 messageId,
                 content, size, internalDate, propertyBuilder.getSubType(),
@@ -214,8 +200,7 @@ public class SimpleMailboxMessage extends 
DelegatingMailboxMessage {
                 bodyStartOctet,
                 propertyBuilder.getTextualLineCount(),
                 propertyBuilder.toProperties(),
-                attachments,
-                hasAttachment));
+                attachments));
 
             setFlags(flags);
             this.mailboxId = mailboxId;
@@ -223,14 +208,6 @@ public class SimpleMailboxMessage extends 
DelegatingMailboxMessage {
     }
 
     public SimpleMailboxMessage(MessageId messageId, Date internalDate, long 
size, int bodyStartOctet,
-            SharedInputStream content, Flags flags,
-            PropertyBuilder propertyBuilder, MailboxId mailboxId, 
List<MessageAttachmentMetadata> attachments) {
-        this(messageId, internalDate, size, bodyStartOctet,
-            content, flags,
-            propertyBuilder, mailboxId, attachments, !attachments.isEmpty());
-    }
-
-    public SimpleMailboxMessage(MessageId messageId, Date internalDate, long 
size, int bodyStartOctet,
                                 SharedInputStream content, Flags flags,
                                 PropertyBuilder propertyBuilder, MailboxId 
mailboxId) {
         this(messageId, internalDate, size, bodyStartOctet,
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
index 36042a3..62a5b86 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/SimpleMessage.java
@@ -42,9 +42,8 @@ public class SimpleMessage implements Message {
     private final Long textualLineCount;
     private final List<Property> properties;
     private final List<MessageAttachmentMetadata> attachments;
-    private final boolean hasAttachments;
 
-    public SimpleMessage(MessageId messageId, SharedInputStream content, long 
size, Date internalDate, String subType, String mediaType, int bodyStartOctet, 
Long textualLineCount, List<Property> properties, 
List<MessageAttachmentMetadata> attachments, boolean hasAttachments) {
+    public SimpleMessage(MessageId messageId, SharedInputStream content, long 
size, Date internalDate, String subType, String mediaType, int bodyStartOctet, 
Long textualLineCount, List<Property> properties, 
List<MessageAttachmentMetadata> attachments) {
         this.messageId = messageId;
         this.subType = subType;
         this.mediaType = mediaType;
@@ -55,7 +54,6 @@ public class SimpleMessage implements Message {
         this.textualLineCount = textualLineCount;
         this.properties = properties;
         this.attachments = attachments;
-        this.hasAttachments = hasAttachments;
     }
 
     @Override
@@ -126,9 +124,4 @@ public class SimpleMessage implements Message {
     public List<MessageAttachmentMetadata> getAttachments() {
         return attachments;
     }
-
-    @Override
-    public boolean hasAttachment() {
-        return hasAttachments;
-    }
 }
diff --git 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerStorageTest.java
 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerStorageTest.java
index 4c7f73a..8416d42 100644
--- 
a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerStorageTest.java
+++ 
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageIdManagerStorageTest.java
@@ -49,11 +49,9 @@ import org.apache.james.mailbox.model.MailboxACL.Right;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.model.MessageResult;
-import org.apache.james.util.ClassLoaderUtils;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import com.github.fge.lambdas.Throwing;
 import com.github.steveash.guavate.Guavate;
 import com.google.common.collect.ImmutableList;
 
@@ -981,34 +979,4 @@ public abstract class AbstractMessageIdManagerStorageTest {
             .extracting(MessageResult::getFlags)
             .containsOnly(flags);
     }
-
-    @Test
-    void getMessagesShouldIncludeAttachmentInformation() throws Exception {
-        MessageId messageId = 
testingData.getMailboxManager().getMailbox(bobMailbox1.getMailboxId(), 
bobSession)
-            .appendMessage(MessageManager.AppendCommand.builder()
-            .withFlags(new Flags(Flags.Flag.DELETED))
-            
.build(ClassLoaderUtils.getSystemResourceAsSharedStream("eml/twoAttachmentsApi.eml")),
 bobSession)
-            .getId()
-            .getMessageId();
-
-        List<MessageResult> messages = messageIdManager.getMessage(messageId, 
FetchGroup.MINIMAL, bobSession);
-
-        assertThat(messages)
-            .hasSize(1)
-            .first()
-            .satisfies(Throwing.consumer(messageResult -> 
assertThat(messageResult.hasAttachments()).isTrue()));
-    }
-
-    @Test
-    void getMessagesShouldNotIncludeAttachmentInformationWhenNone() throws 
Exception {
-        Flags flags = new Flags(Flags.Flag.FLAGGED);
-        MessageId messageId = testingData.persist(bobMailbox1.getMailboxId(), 
messageUid1, flags, bobSession);
-
-        List<MessageResult> messages = messageIdManager.getMessage(messageId, 
FetchGroup.MINIMAL, bobSession);
-
-        assertThat(messages)
-            .hasSize(1)
-            .first()
-            .satisfies(Throwing.consumer(messageResult -> 
assertThat(messageResult.hasAttachments()).isFalse()));
-    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to