vincenzo 2003/07/07 03:04:38
Modified: src/java/org/apache/james/transport/mailets
AbstractRedirect.java Redirect.java Resend.java
Log:
Minor fix to "full name" support for compatibility with "old" redirect, and javadoc
enhancement.
Revision Changes Path
1.19 +18 -10
james-server/src/java/org/apache/james/transport/mailets/AbstractRedirect.java
Index: AbstractRedirect.java
===================================================================
RCS file:
/home/cvs/james-server/src/java/org/apache/james/transport/mailets/AbstractRedirect.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- AbstractRedirect.java 7 Jul 2003 06:16:21 -0000 1.18
+++ AbstractRedirect.java 7 Jul 2003 10:04:37 -0000 1.19
@@ -456,7 +456,7 @@
for (int i = 0; i < iaarray.length; i++) {
String addressString = iaarray[i].getAddress();
MailAddress specialAddress = getSpecialAddress(addressString,
- new String[] {"postmaster", "sender", "reversePath", "unaltered",
"recipients"});
+ new String[] {"postmaster", "sender", "from", "reversePath",
"unaltered", "recipients", "to", "null"});
if (specialAddress != null) {
newRecipients.add(specialAddress);
} else {
@@ -535,7 +535,7 @@
for(int i = 0; i < iaarray.length; ++i) {
String addressString = iaarray[i].getAddress();
MailAddress specialAddress = getSpecialAddress(addressString,
- new String[] {"postmaster",
"sender", "from", "reversePath", "unaltered", "to", "null"});
+ new String[] {"postmaster",
"sender", "from", "reversePath", "unaltered", "recipients", "to", "null"});
if (specialAddress != null) {
iaarray[i] = specialAddress.toInternetAddress();
}
@@ -1695,10 +1695,13 @@
/**
* Returns a new Collection built over <I>list</I> replacing special addresses
- * with real ones.
+ * with real <CODE>MailAddress</CODE>-es.
* Manages <CODE>SpecialAddress.SENDER</CODE>,
<CODE>SpecialAddress.REVERSE_PATH</CODE>,
- * <CODE>SpecialAddress.RECIPIENTS</CODE>,
+ * <CODE>SpecialAddress.FROM</CODE>, <CODE>SpecialAddress.RECIPIENTS</CODE>,
<CODE>SpecialAddress.TO</CODE>,
* <CODE>SpecialAddress.NULL</CODE> and <CODE>SpecialAddress.UNALTERED</CODE>.
+ * <CODE>SpecialAddress.FROM</CODE> is made equivalent to
<CODE>SpecialAddress.SENDER</CODE>;
+ * <CODE>SpecialAddress.TO</CODE> is made equivalent to
<CODE>SpecialAddress.RECIPIENTS</CODE>.
+ * <CODE>SpecialAddress.NULL</CODE> and <CODE>SpecialAddress.UNALTERED</CODE>
are ignored.
* Any other address is not replaced.
*/
protected Collection replaceMailAddresses(Mail mail, Collection list) {
@@ -1708,7 +1711,7 @@
MailAddress mailAddress = (MailAddress) iterator.next();
if (!mailAddress.getHost().equalsIgnoreCase("address.marker")) {
newList.add(mailAddress);
- } else if (mailAddress == SpecialAddress.SENDER) {
+ } else if (mailAddress == SpecialAddress.SENDER || mailAddress ==
SpecialAddress.FROM) {
MailAddress sender = mail.getSender();
if (sender != null) {
newList.add(sender);
@@ -1718,10 +1721,12 @@
if (reversePath != null) {
newList.add(reversePath);
}
- } else if (mailAddress == SpecialAddress.RECIPIENTS) {
+ } else if (mailAddress == SpecialAddress.RECIPIENTS || mailAddress ==
SpecialAddress.TO) {
newList.addAll(mail.getRecipients());
} else if (mailAddress == SpecialAddress.UNALTERED) {
continue;
+ } else if (mailAddress == SpecialAddress.NULL) {
+ continue;
} else {
newList.add(mailAddress);
}
@@ -1731,10 +1736,12 @@
/**
* Returns a new Collection built over <I>list</I> replacing special addresses
- * with real ones.
+ * with real <CODE>InternetAddress</CODE>-es.
* Manages <CODE>SpecialAddress.SENDER</CODE>,
<CODE>SpecialAddress.REVERSE_PATH</CODE>,
- * <CODE>SpecialAddress.FROM</CODE>, <CODE>SpecialAddress.TO</CODE>,
+ * <CODE>SpecialAddress.FROM</CODE>, <CODE>SpecialAddress.RECIPIENTS</CODE>,
<CODE>SpecialAddress.TO</CODE>,
* <CODE>SpecialAddress.NULL</CODE> and <CODE>SpecialAddress.UNALTERED</CODE>.
+ * <CODE>SpecialAddress.RECIPIENTS</CODE> is made equivalent to
<CODE>SpecialAddress.TO</CODE>
+ * <CODE>SpecialAddress.UNALTERED</CODE> is ignored.
* Any other address is not replaced.
*/
protected Collection replaceInternetAddresses(Mail mail, Collection list)
throws MessagingException {
@@ -1766,7 +1773,8 @@
} catch (AddressException ae) {
log("Unable to parse the \"FROM\" header in the original
message; ignoring.");
}
- } else if
(internetAddress.equals(SpecialAddress.TO.toInternetAddress())) {
+ } else if (internetAddress.equals(SpecialAddress.TO.toInternetAddress())
+ ||
internetAddress.equals(SpecialAddress.RECIPIENTS.toInternetAddress())) {
String[] toHeaders = mail.getMessage().getHeader(RFC2822Headers.TO);
if (toHeaders != null) {
for (int i = 0; i < toHeaders.length; i++) {
1.35 +13 -6
james-server/src/java/org/apache/james/transport/mailets/Redirect.java
Index: Redirect.java
===================================================================
RCS file:
/home/cvs/james-server/src/java/org/apache/james/transport/mailets/Redirect.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- Redirect.java 7 Jul 2003 06:16:21 -0000 1.34
+++ Redirect.java 7 Jul 2003 10:04:37 -0000 1.35
@@ -106,12 +106,16 @@
* <TR valign=top>
* <TD width="20%"><recipients></TD>
* <TD width="80%">
- * A comma delimited list of email addresses for recipients of
+ * A comma delimited list of addresses for recipients of
* this message; it will use the "to" list if not specified, and
"unaltered"
* if none of the lists is specified.<BR>
* These addresses will only appear in the To: header if no "to" list is
* supplied.<BR>
- * It can include constants "sender", "from",
"postmaster", "reversePath", "recipients" and
"unaltered".
+ * Such addresses can contain "full names", like
+ * <I>Mr. John D. Smith <[EMAIL PROTECTED]></I>.<BR>
+ * The list can include constants "sender", "from",
"postmaster", "reversePath", "recipients",
"to", "null" and "unaltered";
+ * "from" is made equivalent to "sender", and "to" is
made equivalent to "recipients";
+ * "null" is ignored.
* </TD>
* </TR>
* <TR valign=top>
@@ -122,7 +126,10 @@
* list.<BR>
* The recipients list will be used if this list is not supplied;
* if none of the lists is specified it will be "unaltered".<BR>
- * It can include constants "sender", "postmaster",
"reversePath", "recipients", "null" and
"unaltered";
+ * Such addresses can contain "full names", like
+ * <I>Mr. John D. Smith <[EMAIL PROTECTED]></I>.<BR>
+ * The list can include constants "sender", "from",
"postmaster", "reversePath", "recipients",
"to", "null" and "unaltered";
+ * "recipients" is made equivalent to "to";
* if "null" is specified alone it will remove this header.
* </TD>
* </TR>
@@ -390,7 +397,7 @@
for (int i = 0; i < iaarray.length; i++) {
String addressString = iaarray[i].getAddress();
MailAddress specialAddress = getSpecialAddress(addressString,
- new String[] {"postmaster", "sender", "reversePath", "unaltered",
"recipients"});
+ new String[] {"postmaster", "sender", "from", "reversePath",
"unaltered", "recipients", "to", "null"});
if (specialAddress != null) {
newRecipients.add(specialAddress);
} else {
@@ -432,7 +439,7 @@
for(int i = 0; i < iaarray.length; ++i) {
String addressString = iaarray[i].getAddress();
MailAddress specialAddress = getSpecialAddress(addressString,
- new String[] {"postmaster",
"sender", "from", "reversePath", "unaltered", "to", "null"});
+ new String[] {"postmaster",
"sender", "from", "reversePath", "unaltered", "recipients", "to", "null"});
if (specialAddress != null) {
iaarray[i] = specialAddress.toInternetAddress();
}
1.5 +13 -7
james-server/src/java/org/apache/james/transport/mailets/Resend.java
Index: Resend.java
===================================================================
RCS file:
/home/cvs/james-server/src/java/org/apache/james/transport/mailets/Resend.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Resend.java 7 Jul 2003 06:16:21 -0000 1.4
+++ Resend.java 7 Jul 2003 10:04:38 -0000 1.5
@@ -104,18 +104,24 @@
* <TR valign=top>
* <TD width="20%"><recipients></TD>
* <TD width="80%">
- * A comma delimited list of email addresses for recipients of
- * this message;.<BR>
- * It can include constants "sender", "postmaster",
"reversePath", "recipients" and "unaltered".<BR>
+ * A comma delimited list of addresses for recipients of this message.<BR>
+ * Such addresses can contain "full names", like
+ * <I>Mr. John D. Smith <[EMAIL PROTECTED]></I>.<BR>
+ * The list can include constants "sender", "from",
"postmaster", "reversePath", "recipients",
"to", "null" and "unaltered";
+ * "from" is made equivalent to "sender", and "to" is
made equivalent to "recipients";
+ * "null" is ignored.
* Default: "unaltered".
* </TD>
* </TR>
* <TR valign=top>
* <TD width="20%"><to></TD>
* <TD width="80%">
- * A comma delimited list of addresses to appear in the To: header;.<BR>
- * It can include constants "sender", "from",
"postmaster", "reversePath", "to", "null" and
"unaltered";
- * if "null" is specified alone it will remove this header.<BR>
+ * A comma delimited list of addresses to appear in the To: header.<BR>
+ * Such addresses can contain "full names", like
+ * <I>Mr. John D. Smith <[EMAIL PROTECTED]></I>.<BR>
+ * The list can include constants "sender", "from",
"postmaster", "reversePath", "recipients",
"to", "null" and "unaltered";
+ * "recipients" is made equivalent to "to";
+ * if "null" is specified alone it will remove this header.
* Default: "unaltered".
* </TD>
* </TR>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]