Repository: james-project Updated Branches: refs/heads/master 3c2e5eddb -> a275f62d7
JAMES-1934 StoreMessageManager should position a property for non inline 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/de54a6ea Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/de54a6ea Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/de54a6ea Branch: refs/heads/master Commit: de54a6eaf73a90ce3cb9fa92ab22c731cceb7441 Parents: 3c2e5ed Author: Benoit Tellier <[email protected]> Authored: Wed Feb 8 10:41:29 2017 +0700 Committer: Benoit Tellier <[email protected]> Committed: Wed Feb 15 06:59:39 2017 +0700 ---------------------------------------------------------------------- .../james/mailbox/store/StoreMessageManager.java | 13 +++++++++++++ .../mailbox/store/mail/model/impl/PropertyBuilder.java | 10 ++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/de54a6ea/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java index a7febbe..60c7d19 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java @@ -94,6 +94,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.collect.FluentIterable; import com.google.common.collect.ImmutableList; /** @@ -398,6 +400,8 @@ public class StoreMessageManager implements org.apache.james.mailbox.MessageMana final int size = (int) file.length(); final List<MessageAttachment> attachments = extractAttachments(contentIn); + propertyBuilder.setHasAttachment(hasNonInlinedAttachment(attachments)); + final MailboxMessage message = createMessage(internalDate, size, bodyStartOctet, contentIn, flags, propertyBuilder, attachments); new QuotaChecker(quotaManager, quotaRootResolver, mailbox).tryAddition(1, size); @@ -439,6 +443,15 @@ public class StoreMessageManager implements org.apache.james.mailbox.MessageMana } + private boolean hasNonInlinedAttachment(List<MessageAttachment> attachments) { + return FluentIterable.from(attachments).anyMatch(new Predicate<MessageAttachment>() { + @Override + public boolean apply(MessageAttachment input) { + return !input.isInline(); + } + }); + } + private List<MessageAttachment> extractAttachments(SharedFileInputStream contentIn) { try { return messageParser.retrieveAttachments(contentIn); http://git-wip-us.apache.org/repos/asf/james-project/blob/de54a6ea/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java index deac8ed..c42aa0c 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/model/impl/PropertyBuilder.java @@ -53,8 +53,10 @@ import org.apache.james.mailbox.store.mail.model.Property; * Builds properties */ public class PropertyBuilder { - + private static final int INITIAL_CAPACITY = 32; + public static final String JAMES_INTERNALS = "JAMES_INTERNALS"; + public static final String HAS_ATTACHMENT = "HAS_ATTACHMENT"; private Long textualLineCount; private final List<SimpleProperty> properties; @@ -218,7 +220,11 @@ public class PropertyBuilder { public void setMediaType(String value) { setProperty(MIME_MIME_TYPE_SPACE, MIME_MEDIA_TYPE_NAME, value); } - + + public void setHasAttachment(boolean value) { + setProperty(JAMES_INTERNALS, HAS_ATTACHMENT, Boolean.toString(value)); + } + /** * Gets the MIME content subtype. * --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
