You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by lh...@apache.org on 2008/11/26 23:16:27 UTC
svn commit: r721003 -
/servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java
Author: lhein
Date: Wed Nov 26 14:16:26 2008
New Revision: 721003
URL: http://svn.apache.org/viewvc?rev=721003&view=rev
Log:
changed the boolean flag with a list of properties to skip
Modified:
servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java
Modified: servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java?rev=721003&r1=721002&r2=721003&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java (original)
+++ servicemix/components/bindings/servicemix-mail/trunk/src/main/java/org/apache/servicemix/mail/MailSenderEndpoint.java Wed Nov 26 14:16:26 2008
@@ -16,6 +16,7 @@
*/
package org.apache.servicemix.mail;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -54,8 +55,8 @@
private String sender;
private String receiver;
private boolean debugMode;
- private boolean ignoreTOProperty;
private Map<String, String> customProperties;
+ private List<String> ignoreMessageProperties;
/*
* (non-Javadoc)
@@ -119,14 +120,8 @@
// Define message
MimeMessage msg = new MimeMessage(session);
- // check if ignore on TO property is enabled
- if (isIgnoreTOProperty()) {
- // we should preset TO property from NMSG
- if (in.getProperty(AbstractMailMarshaler.MSG_TAG_TO) != null) {
- // delete the property
- in.setProperty(AbstractMailMarshaler.MSG_TAG_TO, null);
- }
- }
+ // handle ignore properties
+ handleIgnoreProperties(in);
// let the marshaler to the conversion of message to mail
this.marshaler.convertJBIToMail(msg, exchange, in, this.sender, this.receiver);
@@ -194,14 +189,8 @@
// Define message
MimeMessage msg = new MimeMessage(session);
- // check if ignore on TO property is enabled
- if (isIgnoreTOProperty()) {
- // we should preset TO property from NMSG
- if (in.getProperty(AbstractMailMarshaler.MSG_TAG_TO) != null) {
- // delete the property
- in.setProperty(AbstractMailMarshaler.MAIL_TAG_TO, null);
- }
- }
+ // handle ignore properties
+ handleIgnoreProperties(in);
// let the marshaler to the conversion of message to mail
this.marshaler.convertJBIToMail(msg, exchange, in, this.sender, this.receiver);
@@ -225,6 +214,22 @@
}
/**
+ * handles the normalized messages ignored properties, means it will set every
+ * property value to null for each key inside the list of properties to ignore
+ *
+ * @param in the normalized message
+ */
+ private void handleIgnoreProperties(NormalizedMessage in) {
+ if (getIgnoreMessageProperties() != null && getIgnoreMessageProperties().size()>0) {
+ for (String key : getIgnoreMessageProperties()) {
+ if (in.getProperty(key) != null) {
+ in.setProperty(key, null);
+ }
+ }
+ }
+ }
+
+ /**
* this will apply the custom properties to the properties map used for
* connection to mail server
*
@@ -344,17 +349,17 @@
this.customProperties = customProperties;
}
- /**
- * @return the ignoreTOProperty
+ /**
+ * @return the ignoreMessageProperties
*/
- public boolean isIgnoreTOProperty() {
- return this.ignoreTOProperty;
+ public List<String> getIgnoreMessageProperties() {
+ return this.ignoreMessageProperties;
}
-
+
/**
- * @param ignoreTOProperty the ignoreTOProperty to set
+ * @param ignoreMessageProperties the ignoreMessageProperties to set
*/
- public void setIgnoreTOProperty(boolean ignoreTOProperty) {
- this.ignoreTOProperty = ignoreTOProperty;
+ public void setIgnoreMessageProperties(List<String> ignoreMessageProperties) {
+ this.ignoreMessageProperties = ignoreMessageProperties;
}
}