camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [2/3] git commit: CAMEL-7311: camel-mail should not fetch attachments if mapMailMessage=false as part of message copy during UoW.
Date Wed, 19 Mar 2014 09:48:43 GMT
CAMEL-7311: camel-mail should not fetch attachments if mapMailMessage=false as part of message
copy during UoW.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8d83cbe5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8d83cbe5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8d83cbe5

Branch: refs/heads/camel-2.13.x
Commit: 8d83cbe57b36b1683c7e506114b579525f69ab05
Parents: d5e6e1d
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Mar 19 10:51:02 2014 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Mar 19 10:51:18 2014 +0100

----------------------------------------------------------------------
 .../apache/camel/component/mail/MailEndpoint.java |  2 +-
 .../apache/camel/component/mail/MailMessage.java  | 18 ++++++++++++++----
 2 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8d83cbe5/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
index bed5b3f..b4bd387 100644
--- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailEndpoint.java
@@ -119,7 +119,7 @@ public class MailEndpoint extends ScheduledPollEndpoint {
     private Exchange createExchange(ExchangePattern pattern, Message message) {
         Exchange exchange = new DefaultExchange(this, pattern);
         exchange.setProperty(Exchange.BINDING, getBinding());
-        exchange.setIn(new MailMessage(message));
+        exchange.setIn(new MailMessage(message, getConfiguration().isMapMailMessage()));
         return exchange;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/8d83cbe5/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
index 365ca29..7416a46 100644
--- a/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
+++ b/components/camel-mail/src/main/java/org/apache/camel/component/mail/MailMessage.java
@@ -35,12 +35,18 @@ public class MailMessage extends DefaultMessage {
     // mail content, see more in MailBinding
     private Message originalMailMessage;
     private Message mailMessage;
+    private boolean mapMailMessage;
 
     public MailMessage() {
     }
 
     public MailMessage(Message message) {
+        this(message, true);
+    }
+
+    public MailMessage(Message message, boolean mapMailMessage) {
         this.originalMailMessage = this.mailMessage = message;
+        this.mapMailMessage = mapMailMessage;
     }
 
     @Override
@@ -56,10 +62,13 @@ public class MailMessage extends DefaultMessage {
         MailMessage answer = (MailMessage)super.copy();
         answer.originalMailMessage = originalMailMessage;
         answer.mailMessage = mailMessage;
-        // force attachments to be created (by getting attachments) to ensure they are always
available due Camel error handler
-        // makes defensive copies, and we have optimized it to avoid populating initial attachments,
when not needed,
-        // as all other Camel components do not use attachments
-        getAttachments();
+
+        if (mapMailMessage) {
+            // force attachments to be created (by getting attachments) to ensure they are
always available due Camel error handler
+            // makes defensive copies, and we have optimized it to avoid populating initial
attachments, when not needed,
+            // as all other Camel components do not use attachments
+            getAttachments();
+        }
         return answer;
     }
 
@@ -132,6 +141,7 @@ public class MailMessage extends DefaultMessage {
             MailMessage mailMessage = (MailMessage) that;
             this.originalMailMessage = mailMessage.originalMailMessage;
             this.mailMessage = mailMessage.mailMessage;
+            this.mapMailMessage = mailMessage.mapMailMessage;
         }
     }
 


Mime
View raw message