MAILBOX-321 Factorize single attachment handling

We can rely on `isAttachment(...)` for attachment detection.


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

Branch: refs/heads/master
Commit: de10f8c1df49374f3e284b66bdf4ff78f9b2ac7c
Parents: 4189dda
Author: benwa <btell...@linagora.com>
Authored: Tue Nov 28 11:15:03 2017 +0700
Committer: Antoine Duprat <adup...@linagora.com>
Committed: Thu Nov 30 14:55:33 2017 +0100

----------------------------------------------------------------------
 .../james/mailbox/store/mail/model/impl/MessageParser.java   | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/de10f8c1/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
----------------------------------------------------------------------
diff --git 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
index 5494e29..cbde24a 100644
--- 
a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
+++ 
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/MessageParser.java
@@ -85,9 +85,7 @@ public class MessageParser {
         Message message = defaultMessageBuilder.parseMessage(fullContent);
         Body body = message.getBody();
         try {
-            Optional<ContentDispositionField> contentDisposition = 
readHeader(message, CONTENT_DISPOSITION, ContentDispositionField.class);
-
-            if (isMessageWithOnlyOneAttachment(contentDisposition)) {
+            if (isAttachment(message, Context.BODY)) {
                 return ImmutableList.of(retrieveAttachment(message));
             }
 
@@ -103,10 +101,6 @@ public class MessageParser {
         }
     }
 
-    private boolean 
isMessageWithOnlyOneAttachment(Optional<ContentDispositionField> 
contentDisposition) {
-        return contentDisposition.isPresent() && 
contentDisposition.get().isAttachment();
-    }
-
     private Stream<MessageAttachment> listAttachments(Multipart multipart, 
Context context) {
         return multipart.getBodyParts()
             .stream()


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