cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anathan...@apache.org
Subject svn commit: r674112 - /cocoon/trunk/blocks/cocoon-mail/cocoon-mail-impl/src/main/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
Date Fri, 04 Jul 2008 20:09:41 GMT
Author: anathaniel
Date: Fri Jul  4 13:09:40 2008
New Revision: 674112

URL: http://svn.apache.org/viewvc?rev=674112&view=rev
Log:
Apply patches http://issues.apache.org/jira/browse/COCOON-1622 and http://issues.apache.org/jira/browse/COCOON-2213

Modified:
    cocoon/trunk/blocks/cocoon-mail/cocoon-mail-impl/src/main/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java

Modified: cocoon/trunk/blocks/cocoon-mail/cocoon-mail-impl/src/main/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-mail/cocoon-mail-impl/src/main/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java?rev=674112&r1=674111&r2=674112&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-mail/cocoon-mail-impl/src/main/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
(original)
+++ cocoon/trunk/blocks/cocoon-mail/cocoon-mail-impl/src/main/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
Fri Jul  4 13:09:40 2008
@@ -38,6 +38,7 @@
 import javax.mail.internet.MimeBodyPart;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.MimeMultipart;
+import javax.xml.transform.OutputKeys;
 
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
@@ -373,7 +374,12 @@
                 this.bodyMimeType = DEFAULT_BODY_MIMETYPE;
             }
 
-            startTextRecording();
+            Properties outputProperties = new Properties();
+            if (this.bodyMimeType.startsWith("text/plain"))
+            	outputProperties.put(OutputKeys.METHOD, "text");
+            else if (this.bodyMimeType.startsWith("text/html"))
+            	outputProperties.put(OutputKeys.METHOD, "html");
+            startSerializedXMLRecording(outputProperties);
             this.mode = MODE_BODY;
         } else if (name.equals(ELEMENT_ATTACHMENT)) {
             this.attachmentDescriptor = new AttachmentDescriptor(attr.getValue("name"),
@@ -433,7 +439,7 @@
         } else if (name.equals(ELEMENT_MAILBODY)) {
             String strB = null;
             try {
-                strB = endTextRecording();
+                strB = endSerializedXMLRecording();
             } catch (Exception e) {
                 if (getLogger().isDebugEnabled()) {
                     getLogger().debug("Mail: No Body as String in config-file available");
@@ -586,9 +592,9 @@
             InputStream inStr   = inSrc.getInputStream();
             byte[]      byteArr = new byte[inStr.available()];
             inStr.read(byteArr);
-            
+
             messageString = new String(byteArr);
-            
+
             // String mailBody = new String(byteArr);
             // this.setMessageBody(messageBodyPart, mailBody, this.bodyMimeType);
         } else {
@@ -596,9 +602,9 @@
             // this.setMessageBody(messageBodyPart, this.body, this.bodyMimeType);      
     
         }
 
-        // make it a simple plain text message in the case of a set plain/text 
+        // make it a simple plain text message in the case of a set plain/text
         // mime-type and any attachements
-        if("text/plain".equals(this.bodyMimeType) && this.attachments.size() == 0)
{     
+        if (this.bodyMimeType.startsWith("text/plain") && this.attachments.size()
== 0) {
             sm.setText(messageString);
         }
         // add message as message body part
@@ -612,18 +618,18 @@
             while (i.hasNext()) {
                 AttachmentDescriptor aD = (AttachmentDescriptor) i.next();
                 messageBodyPart = new MimeBodyPart();
-    
+
                 if (!aD.isTextContent()) {
                     Source inputSource = resolver.resolveURI(aD.isURLSource() ? aD.strAttrSrc
: aD.strAttrFile);
                     this.usedSources.add(inputSource);
-    
+
                     DataSource dataSource = new SourceDataSource(inputSource, aD.strAttrMimeType,
aD.strAttrName);
 
                     messageBodyPart.setDataHandler(new DataHandler(dataSource));
                 } else {
                     messageBodyPart.setContent(aD.strContent, aD.strAttrMimeType);
                 }
-    
+
                 messageBodyPart.setFileName(aD.strAttrName);
                 multipart.addBodyPart(messageBodyPart);
             }



Mime
View raw message