You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2005/07/28 17:25:33 UTC

svn commit: r225799 - in /cocoon/branches/BRANCH_2_1_X: src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java status.xml

Author: sylvain
Date: Thu Jul 28 08:25:27 2005
New Revision: 225799

URL: http://svn.apache.org/viewcvs?rev=225799&view=rev
Log:
Fix bug #35618

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java?rev=225799&r1=225798&r2=225799&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java Thu Jul 28 08:25:27 2005
@@ -17,7 +17,6 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -27,7 +26,6 @@
 
 import javax.activation.DataHandler;
 import javax.activation.DataSource;
-import javax.activation.URLDataSource;
 import javax.mail.Address;
 import javax.mail.BodyPart;
 import javax.mail.Message;
@@ -45,6 +43,7 @@
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.mail.datasource.SourceDataSource;
 import org.apache.cocoon.transformation.AbstractSAXTransformer;
 import org.apache.excalibur.source.Source;
 import org.xml.sax.Attributes;
@@ -176,7 +175,7 @@
  * <li>No support for smtp user/password
  * <li>No support for different mail servers, first one will always be used
  * </ul></p>
- *
+ * 
  * @author <a href="mailto:pklassen@s-und-n.de">Peter Klassen</a>
  * @version CVS $Id$
  */
@@ -256,7 +255,6 @@
     protected int defaultSmtpPort;
     protected String defaultFromAddress;
 
-    protected boolean useExternalRequests = true;
     protected List    usedSources = new ArrayList();
 
     /**
@@ -275,7 +273,6 @@
         this.defaultSmtpHost = configuration.getChild("smtphost").getValue("");
         this.defaultSmtpPort = configuration.getChild("smtpport").getValueAsInteger(25);
         this.defaultFromAddress = configuration.getChild("from").getValue("");
-        this.useExternalRequests = configuration.getChild("use-external-requests").getValueAsBoolean(this.useExternalRequests);
     }
 
     /**
@@ -584,40 +581,14 @@
                 Source inputSource = null;
                 DataSource dataSource = null;
 
-                if (aD.isURLSource()) {
-                    inputSource = resolver.resolveURI(aD.strAttrSrc);
-                    this.usedSources.add(inputSource);
-
-                    String iSS = inputSource.getURI();
-                    if (iSS.startsWith("cocoon:") && this.useExternalRequests) {
-                        iSS = iSS.substring(7, iSS.length());
-
-                        if (this.contextPath != null) {
-                            iSS = "http://localhost:" + this.port +
-                                  this.contextPath + iSS;
-                        } else {
-                            iSS = "http://localhost:" + this.port + iSS;
-                        }
-
-                        if (getLogger().isDebugEnabled()) {
-                            getLogger().debug("cocoon-URI changed to " + iSS);
-                        }
-
-                        dataSource = new URLDataSource(new URL(iSS));
-                    } else {
-                        dataSource = new URLDataSource(new URL(inputSource.getURI()));
-                    }
+                inputSource = resolver.resolveURI(aD.isURLSource() ? aD.strAttrSrc : aD.strAttrFile);
+                this.usedSources.add(inputSource);
+                
+                dataSource = new SourceDataSource(inputSource, aD.strAttrMimeType, aD.strAttrName);
 
-                    messageBodyPart.setDataHandler(new DataHandler(dataSource));
-                } else if (aD.isFileSource()) {
-                    inputSource = resolver.resolveURI(aD.strAttrFile);
-                    this.usedSources.add(inputSource);
-                    dataSource  = new URLDataSource(new URL(inputSource.getURI()));
-                    messageBodyPart.setDataHandler(new DataHandler(dataSource));
-                }
+                messageBodyPart.setDataHandler(new DataHandler(dataSource));
             } else {
-                messageBodyPart.setContent(aD.strContent,
-                                           aD.strAttrMimeType);
+                messageBodyPart.setContent(aD.strContent, aD.strAttrMimeType);
             }
 
             messageBodyPart.setFileName(aD.strAttrName);

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/status.xml?rev=225799&r1=225798&r2=225799&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Thu Jul 28 08:25:27 2005
@@ -196,6 +196,10 @@
 
   <changes>
   <release version="@version@" date="@date@">
+    <action dev="SW" type="fix" fixes-bug="35618" due-to="Jean-Baptiste Quenot" due-to-email="jbq@anyware-tech.com">
+      Mail block: Allow any of the Cocoon-provided protocols to be used for attachments in SendMailTransformer.
+      This means that "cocoon:" URLs are no more rewritten as external http requests.
+    </action>
     <action dev="CZ" type="add" fixes-bug="35521" due-to="Mark Lundquist" due-to-email="mlundquist2@comcast.net">
       Added the create-document source than either generates empty documents or documents containing
       just a root node.



Re: svn commit: r225799 - in /cocoon/branches/BRANCH_2_1_X: src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java status.xml

Posted by Carsten Ziegeler <cz...@apache.org>.
sylvain@apache.org wrote:

> +    <action dev="SW" type="fix" fixes-bug="35618" due-to="Jean-Baptiste Quenot" due-to-email="jbq@anyware-tech.com">
> +      Mail block: Allow any of the Cocoon-provided protocols to be used for attachments in SendMailTransformer.
> +      This means that "cocoon:" URLs are no more rewritten as external http requests.
> +    </action>
Why did you remove the old behaviour? It is useful for some people and
maintaining it doesn't really hurt.

Carsten

-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/