You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/02/07 15:50:26 UTC
svn commit: r1443513 -
/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
Author: davsclaus
Date: Thu Feb 7 14:50:26 2013
New Revision: 1443513
URL: http://svn.apache.org/viewvc?rev=1443513&view=rev
Log:
CAMEL-6045: Fixed mail binding to extract attachments if disposition is null but fileName is given. Thanks to Christoph Giera for the patch.
Modified:
camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
Modified: camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java?rev=1443513&r1=1443512&r2=1443513&view=diff
==============================================================================
--- camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java (original)
+++ camel/trunk/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailBinding.java Thu Feb 7 14:50:26 2013
@@ -304,26 +304,25 @@ public class MailBinding {
extractAttachmentsFromMultipart((Multipart) part.getContent(), map);
} else {
String disposition = part.getDisposition();
+ String fileName = part.getFileName();
+
if (LOG.isTraceEnabled()) {
- LOG.trace("Part #{}: Disposition: {}", i, part.getDisposition());
+ LOG.trace("Part #{}: Disposition: {}", i, disposition);
LOG.trace("Part #{}: Description: {}", i, part.getDescription());
LOG.trace("Part #{}: ContentType: {}", i, part.getContentType());
- LOG.trace("Part #{}: FileName: {}", i, part.getFileName());
+ LOG.trace("Part #{}: FileName: {}", i, fileName);
LOG.trace("Part #{}: Size: {}", i, part.getSize());
LOG.trace("Part #{}: LineCount: {}", i, part.getLineCount());
}
- if (disposition != null && (disposition.equalsIgnoreCase(Part.ATTACHMENT) || disposition.equalsIgnoreCase(Part.INLINE))) {
- // only add named attachments
- String fileName = part.getFileName();
- if (fileName != null) {
- LOG.debug("Mail contains file attachment: " + fileName);
- if (!map.containsKey(fileName)) {
- // Parts marked with a disposition of Part.ATTACHMENT are clearly attachments
- map.put(fileName, part.getDataHandler());
- } else {
- LOG.warn("Cannot extract duplicate attachment: " + fileName);
- }
+ if ((disposition != null && (disposition.equalsIgnoreCase(Part.ATTACHMENT) || disposition.equalsIgnoreCase(Part.INLINE)))
+ || fileName != null) {
+ LOG.debug("Mail contains file attachment: {}", fileName);
+ if (!map.containsKey(fileName)) {
+ // Parts marked with a disposition of Part.ATTACHMENT are clearly attachments
+ map.put(fileName, part.getDataHandler());
+ } else {
+ LOG.warn("Cannot extract duplicate file attachment: {}.", fileName);
}
}
}