Author: amilas
Date: Mon Nov 16 12:39:45 2009
New Revision: 880729

URL: http://svn.apache.org/viewvc?rev=880729&view=rev
Log:
committing some changes done to the trunk to branch

Modified:
    
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailConstants.java
    
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportSender.java
    
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/WSMimeMessage.java

Modified: 
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailConstants.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailConstants.java?rev=880729&r1=880728&r2=880729&view=diff
==============================================================================
--- 
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailConstants.java
 (original)
+++ 
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailConstants.java
 Mon Nov 16 12:39:45 2009
@@ -93,6 +93,7 @@
 
     // Custom headers
     /** @see org.apache.axis2.transport.mail.WSMimeMessage */
-    public static final String MAIL_HEADER_X_MESSAGE_ID= "X-Message-ID";
+    public static final String MAIL_HEADER_X_MESSAGE_ID = "X-Message-ID";
+    public static final String TRANSPORT_MAIL_CUSTOM_HEADERS  = 
"transport.mail.custom.headers";
     
 }

Modified: 
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportSender.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportSender.java?rev=880729&r1=880728&r2=880729&view=diff
==============================================================================
--- 
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportSender.java
 (original)
+++ 
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/MailTransportSender.java
 Mon Nov 16 12:39:45 2009
@@ -25,10 +25,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.axis2.context.ConfigurationContext;
 import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.description.TransportOutDescription;
-import org.apache.axis2.description.Parameter;
-import org.apache.axis2.description.OutOnlyAxisOperation;
-import org.apache.axis2.description.TransportInDescription;
+import org.apache.axis2.description.*;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.transport.OutTransportInfo;
@@ -194,7 +191,7 @@
     private void waitForReply(MessageContext msgContext, String mailMessageID) 
throws AxisFault {
         // piggy back message constant is used to pass a piggy back
         // message context in asnych model
-        if (msgContext.getAxisOperation() instanceof OutOnlyAxisOperation &&
+        if (!(msgContext.getAxisOperation() instanceof OutInAxisOperation) &&
                 
(msgContext.getProperty(org.apache.axis2.Constants.PIGGYBACK_MESSAGE) == null)) 
{
             return;
         }
@@ -252,7 +249,13 @@
                     messageFormatter.getClass().getSimpleName());
         }
 
-        WSMimeMessage message = new WSMimeMessage(session);
+        WSMimeMessage message = null;
+        if (outInfo.getFromAddress() != null) {
+            message = new WSMimeMessage(session, 
outInfo.getFromAddress().getAddress());
+        } else {
+            message = new WSMimeMessage(session, "");
+        }
+        
         Map trpHeaders = (Map) 
msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
         if (log.isDebugEnabled() && trpHeaders != null) {
             log.debug("Using transport headers: " + trpHeaders);
@@ -442,10 +445,24 @@
             // always use quoted-printable transfer encoding. Note that 
JavaMail is a bit smarter
             // here because it can choose between 7bit and quoted-printable 
automatically, but it
             // needs to scan the entire content to determine this.
-            String contentType = dataHandler.getContentType().toLowerCase();
-            if (!contentType.startsWith("multipart/") && 
CommonUtils.isTextualPart(contentType)) {
-                mainPart.setHeader("Content-Transfer-Encoding", 
"quoted-printable");
+            if 
(msgContext.getOptions().getProperty("Content-Transfer-Encoding") != null) {
+                mainPart.setHeader("Content-Transfer-Encoding",
+                        (String) 
msgContext.getOptions().getProperty("Content-Transfer-Encoding"));
+            } else {
+                String contentType = 
dataHandler.getContentType().toLowerCase();
+                if (!contentType.startsWith("multipart/") && 
CommonUtils.isTextualPart(contentType)) {
+                    mainPart.setHeader("Content-Transfer-Encoding", 
"quoted-printable");
+                }
             }
+
+            //setting any custom headers defined by the user
+            if 
(msgContext.getOptions().getProperty(MailConstants.TRANSPORT_MAIL_CUSTOM_HEADERS)
 != null) {
+                Map customTransportHeaders = (Map) 
msgContext.getOptions().getProperty(MailConstants.TRANSPORT_MAIL_CUSTOM_HEADERS);
+                for (Object header : customTransportHeaders.keySet()) {
+                    mainPart.setHeader((String) header, (String) 
customTransportHeaders.get(header));
+                }
+            }
+
             
             log.debug("Sending message");
             Transport.send(message);

Modified: 
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/WSMimeMessage.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/WSMimeMessage.java?rev=880729&r1=880728&r2=880729&view=diff
==============================================================================
--- 
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/WSMimeMessage.java
 (original)
+++ 
webservices/commons/branches/modules/transport/1.0.0/modules/mail/src/main/java/org/apache/axis2/transport/mail/WSMimeMessage.java
 Mon Nov 16 12:39:45 2009
@@ -38,15 +38,24 @@
  */
 public class WSMimeMessage extends MimeMessage {
     private long bytesSent = -1;
+    private String fromAddress;
 
-    WSMimeMessage(Session session) {
+
+    WSMimeMessage(Session session, String fromAddress) {
         super(session);
+        this.fromAddress = fromAddress;
     }
 
     @Override
     protected void updateMessageID() throws MessagingException {
-           if (getHeader(MailConstants.MAIL_HEADER_MESSAGE_ID) == null) {
-            setHeader(MailConstants.MAIL_HEADER_MESSAGE_ID, 
UUIDGenerator.getUUID());    
+        // although MailConstants.MAIL_HEADER_X_MESSAGE_ID solves the gmail 
problem with axis2-axis2
+        // invocations it is not a generic solution.
+        // we can over come gmail problem by setting the message id as follows 
with a valid gmail address
+        // <x...@gmail.com> this can be achived by appending from address at 
the end of uuid
+
+        if (getHeader(MailConstants.MAIL_HEADER_MESSAGE_ID) == null) {
+            String uuid = "<" + UUIDGenerator.getUUID().replaceAll(":",".") + 
fromAddress +">";
+            setHeader(MailConstants.MAIL_HEADER_MESSAGE_ID, uuid);
         }
     }
 


Reply via email to