You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2004/07/22 17:03:31 UTC
cvs commit: cocoon-2.1/src/blocks/mail/java/org/apache/cocoon/mail/transformation SendMailTransformer.java
cziegeler 2004/07/22 08:03:31
Modified: . status.xml
src/blocks/mail/java/org/apache/cocoon/mail/transformation
SendMailTransformer.java
Log:
<action dev="CZ" type="fix">
Mail block: The mail transformer ignored configured toAddresses from a pipeline parameter. This is fixed now.
</action>
and small code cleanups
Revision Changes Path
1.401 +4 -1 cocoon-2.1/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/status.xml,v
retrieving revision 1.400
retrieving revision 1.401
diff -u -r1.400 -r1.401
--- status.xml 15 Jul 2004 12:49:48 -0000 1.400
+++ status.xml 22 Jul 2004 15:03:30 -0000 1.401
@@ -204,6 +204,9 @@
<changes>
<release version="@version@" date="@date@">
+ <action dev="CZ" type="fix">
+ Mail block: The mail transformer ignored configured toAddresses from a pipeline parameter. This is fixed now.
+ </action>
<action dev="SW" type="update">
Move the sitemap engine to Serviceable (in replacement of Composable) and remove
SitemapComponentSelector and OutputComponentSelector that were no more needed.
1.12 +29 -29 cocoon-2.1/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java
Index: SendMailTransformer.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/mail/java/org/apache/cocoon/mail/transformation/SendMailTransformer.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- SendMailTransformer.java 26 May 2004 01:46:53 -0000 1.11
+++ SendMailTransformer.java 22 Jul 2004 15:03:31 -0000 1.12
@@ -220,6 +220,7 @@
* communication parameters, which will be used to send mails
*/
protected Vector toAddresses;
+ protected Vector defaultToAddresses;
protected Vector attachments;
protected StringBuffer subject;
protected StringBuffer body;
@@ -244,7 +245,7 @@
*/
public void setup(SourceResolver resolver, Map objectModel, String src,
Parameters par)
- throws ProcessingException, SAXException, IOException {
+ throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectModel, src, par);
this.mailHost = par.getParameter(PARAM_SMTPHOST, "");
this.fromAddress = par.getParameter(PARAM_FROM, "");
@@ -258,20 +259,19 @@
fromAddress);
}
- String s = par.getParameter(PARAM_TO, "");
- this.toAddresses = new Vector();
this.attachments = new Vector();
- this.appendToAddress(s, ";");
-
- try {
- this.subject = new StringBuffer(par.getParameter(PARAM_SUBJECT));
- } catch (ParameterException pe) {
- this.getLogger().debug("Parameter <subject> not set.");
- } try {
- this.body = new StringBuffer(par.getParameter(PARAM_BODY));
- } catch (ParameterException pe) {
- this.getLogger().debug("Parameter <body> not set.");
- }
+ this.defaultToAddresses = new Vector();
+ appendToAddress(this.defaultToAddresses, par.getParameter(PARAM_TO, ""));
+
+ try {
+ this.subject = new StringBuffer(par.getParameter(PARAM_SUBJECT));
+ } catch (ParameterException pe) {
+ this.getLogger().debug("Parameter <subject> not set.");
+ } try {
+ this.body = new StringBuffer(par.getParameter(PARAM_BODY));
+ } catch (ParameterException pe) {
+ this.getLogger().debug("Parameter <body> not set.");
+ }
this.defaultNamespaceURI = NAMESPACE;
}
@@ -296,7 +296,7 @@
if (name.equals(ELEMENT_SENDMAIL) == true) {
// Clean from possible previous usage
- this.toAddresses.clear();
+ this.toAddresses = new Vector(this.defaultToAddresses);
this.attachments.clear();
} else if (name.equals(ELEMENT_SMTPHOST) == true) {
this.startTextRecording();
@@ -407,12 +407,11 @@
}
}
- private void appendToAddress(String s, String delim) {
- StringTokenizer t = null;
- t = new StringTokenizer(s.trim(), delim);
+ private static void appendToAddress(Vector addresses, String s) {
+ StringTokenizer t = new StringTokenizer(s.trim(), ";");
while (t.hasMoreElements()) {
- this.toAddresses.add(t.nextToken());
+ addresses.add(t.nextToken());
}
}
@@ -466,7 +465,7 @@
trans.close();
super.sendEndElementEventNS(ELEMENT_RESULT);
- this.ignoreHooksCount--;
+ this.ignoreHooksCount--;
} catch (Exception sE) {
this.getLogger().error("sendMail-Error", sE);
this.sendExceptionElement(sE);
@@ -474,7 +473,7 @@
}
/**
- * <a href="http://java.sun.com/products/javamail/1.3/docs/javadocs/com/sun/mail/smtp/package-summary.html">Java Mail API</a>
+ * @link http://java.sun.com/products/javamail/1.3/docs/javadocs/com/sun/mail/smtp/package-summary.html
* @throws Exception
*/
private void sendMail(Vector newAddresses, Transport trans)
@@ -674,6 +673,7 @@
public void recycle() {
this.toAddresses = null;
+ this.defaultToAddresses = null;
this.attachments = null;
this.subject = null;
this.body = null;
@@ -689,11 +689,11 @@
}
class AttachmentDescriptor {
- String strAttrName = null;
- String strAttrMimeType = null;
- String strAttrSrc = null;
- String strAttrFile = null;
- StringBuffer strBufContent = null;
+ String strAttrName;
+ String strAttrMimeType;
+ String strAttrSrc;
+ String strAttrFile;
+ StringBuffer strBufContent;
protected AttachmentDescriptor(String newAttrName,
String newAttrMimeType,
@@ -705,7 +705,7 @@
}
protected void setContent(StringBuffer newContent) {
- strBufContent = newContent;
+ this.strBufContent = newContent;
}
protected AttachmentDescriptor copy() {
@@ -732,8 +732,8 @@
}
class AddressHandler {
- private InternetAddress address = null;
- private String sendMailResult = null;
+ private InternetAddress address;
+ private String sendMailResult;
protected AddressHandler(InternetAddress newAddress) {
this.address = newAddress;