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:50 UTC

svn commit: r225800 - in /cocoon: blocks/mail/trunk/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java trunk/status.xml

Author: sylvain
Date: Thu Jul 28 08:25:45 2005
New Revision: 225800

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

Modified:
    cocoon/blocks/mail/trunk/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
    cocoon/trunk/status.xml

Modified: cocoon/blocks/mail/trunk/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/mail/trunk/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java?rev=225800&r1=225799&r2=225800&view=diff
==============================================================================
--- cocoon/blocks/mail/trunk/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java (original)
+++ cocoon/blocks/mail/trunk/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java Thu Jul 28 08:25:45 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;
@@ -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/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=225800&r1=225799&r2=225800&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Thu Jul 28 08:25:45 2005
@@ -509,6 +509,10 @@
    </action>
   </release>
   <release version="2.1.8" date="TBD">
+    <action dev="SW" type="fix" fixes-bug="35618" due-to="Philippe Gassmann" due-to-email="phil@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: r225800 - in /cocoon: blocks/mail/trunk/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java trunk/status.xml

Posted by Sylvain Wallez <sy...@apache.org>.
Carsten Ziegeler wrote:

>sylvain@apache.org wrote:
>
>  
>
>>+    <action dev="SW" type="fix" fixes-bug="35618" due-to="Philippe Gassmann" due-to-email="phil@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>
>>    
>>
>
>I think now I remember why an external http request was used. It was not
>possible to include non xml attachments, as the Cocoon protocol did not
>use the serializer specified in the sitemap but always the xml serializer.
>So, adding a Cocoon generated PDF as an attachment was not possible.
>Using an external request of course worked.
>  
>

Ah ok, I see.

>I think, if this is now possible (looking at the source seems to say
>yes, but I haven't tested),
>

I use it a lot, so I can tell you it does work :-)

>then we don't need the external http
>requests anymore. In this case, sorry for the noise!
>  
>

No problem!

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


Re: svn commit: r225800 - in /cocoon: blocks/mail/trunk/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java trunk/status.xml

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

> +    <action dev="SW" type="fix" fixes-bug="35618" due-to="Philippe Gassmann" due-to-email="phil@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>

I think now I remember why an external http request was used. It was not
possible to include non xml attachments, as the Cocoon protocol did not
use the serializer specified in the sitemap but always the xml serializer.
So, adding a Cocoon generated PDF as an attachment was not possible.
Using an external request of course worked.

I think, if this is now possible (looking at the source seems to say
yes, but I haven't tested), then we don't need the external http
requests anymore. In this case, sorry for the noise!

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