james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vince...@apache.org
Subject cvs commit: jakarta-james/src/java/org/apache/james/transport/mailets AbstractNotify.java AbstractRedirect.java Bounce.java Forward.java NotifyPostmaster.java NotifySender.java Redirect.java
Date Wed, 25 Jun 2003 22:00:39 GMT
vincenzo    2003/06/25 15:00:39

  Modified:    src/java/org/apache/james/transport/mailets
                        AbstractNotify.java AbstractRedirect.java
                        Bounce.java Forward.java NotifyPostmaster.java
                        NotifySender.java Redirect.java
  Log:
  1) Added consistent usage of the "unaltered" init parameter value.
  2) getSender, setSender, getReplyTo and setReplyTo handle safely messages with null sender.
  3) Javadoc heavily modified, specially description of default behaviours.
  
  Revision  Changes    Path
  1.6       +2 -3      jakarta-james/src/java/org/apache/james/transport/mailets/AbstractNotify.java
  
  Index: AbstractNotify.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/AbstractNotify.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractNotify.java	16 Jun 2003 03:35:07 -0000	1.5
  +++ AbstractNotify.java	25 Jun 2003 22:00:37 -0000	1.6
  @@ -102,7 +102,7 @@
    * <P>Sample configuration common to all notification mailet subclasses:</P>
    * <PRE><CODE>
    * &lt;mailet match="All" class="<I>a notification mailet</I>">
  - *   &lt;sendingAddress&gt;<I>an address or postmaster</I>&lt;/sendingAddress&gt;
  + *   &lt;sendingAddress&gt;<I>an address or postmaster or sender or unaltered,
default=postmaster</I>&lt;/sendingAddress&gt;
    *   &lt;attachStackTrace&gt;<I>true or false, default=false</I>&lt;/attachStackTrace&gt;
    *   &lt;notice&gt;<I>notice attached to the message (optional)</I>&lt;/notice&gt;
    *   &lt;prefix&gt;<I>optional subject prefix prepended to the original message</I>&lt;/prefix&gt;
  @@ -115,8 +115,7 @@
    * <I>message</I> and <I>attachError</I> can be used instead of
    * <I>notice and </I> and <I>attachStackTrace</I>.
    *
  - * <P>CVS $Id$</P>
  - * @version 2.2.0
  + * @version CVS $Revision$ $Date$
    * @since 2.2.0
    */
   public abstract class AbstractNotify extends AbstractRedirect {
  
  
  
  1.12      +121 -18   jakarta-james/src/java/org/apache/james/transport/mailets/AbstractRedirect.java
  
  Index: AbstractRedirect.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/AbstractRedirect.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AbstractRedirect.java	20 Jun 2003 16:49:27 -0000	1.11
  +++ AbstractRedirect.java	25 Jun 2003 22:00:37 -0000	1.12
  @@ -115,14 +115,15 @@
    * a "setX(Mail, Tx, Mail)" method.<BR>
    * The roles are the following:</P>
    * <UL>
  - * <LI>a "setX()" method returns the correspondent "X" value that can be evaluated
"statically"
  + * <LI>a "getX()" method returns the correspondent "X" value that can be evaluated
"statically"
    * once at init time and then stored in a variable and made available for later use by
a
    * "getX(Mail)" method;</LI>
    * <LI>a "getX(Mail)" method is the one called to return the correspondent "X" value
    * that can be evaluated "dynamically", tipically based on the currently serviced mail;
  - * the default behaviour is to return the value of getX().</LI>
  + * the default behaviour is to return the value of getX();</LI>
    * <LI>a "setX(Mail, Tx, Mail)" method is called to change the correspondent "X"
value
  - * of the redirected Mail object, using the value returned by "gexX(Mail)".</LI>
  + * of the redirected Mail object, using the value returned by "gexX(Mail)";
  + * if such value is null, it does nothing.</LI>
    * </UL>
    * <P>Here follows the typical pattern of those methods:</P>
    * <PRE><CODE>
  @@ -426,12 +427,16 @@
        * built dynamically using the original Mail object.
        * Is a "getX(Mail)" method.
        *
  -     * @return {@link #getRecipients()}, replacing <CODE>SpecialAddress.SENDER</CODE>
if applicable
  +     * @return {@link #getRecipients()},
  +     * replacing <CODE>SpecialAddress.SENDER</CODE> if applicable with the
original sender
  +     * and <CODE>SpecialAddress.UNALTERED</CODE> if applicable with null
        */
       protected Collection getRecipients(Mail originalMail) throws MessagingException {
           Collection recipients = (isStatic()) ? this.recipients : getRecipients();
           if (recipients != null && recipients.size() == 1) {
  -            if (recipients.contains(SpecialAddress.SENDER)) {
  +            if (recipients.contains(SpecialAddress.UNALTERED)) {
  +                recipients = null;
  +            } else if (recipients.contains(SpecialAddress.SENDER)) {
                   recipients = new ArrayList();
                   recipients.add(originalMail.getSender());
               } else if (recipients.contains(SpecialAddress.RETURN_PATH)) {
  @@ -453,6 +458,8 @@
   
       /**
        * Sets the recipients of <I>newMail</I> to <I>recipients</I>.
  +     * If the requested value is null does nothing.
  +     * Is a "setX(Mail, Tx, Mail)" method.
        */
       protected void setRecipients(Mail newMail, Collection recipients, Mail originalMail)
throws MessagingException {
           if (recipients != null) {
  @@ -557,6 +564,8 @@
   
       /**
        * Sets the "To:" header of <I>newMail</I> to <I>to</I>.
  +     * If the requested value is null does nothing.
  +     * Is a "setX(Mail, Tx, Mail)" method.
        */
       protected void setTo(Mail newMail, InternetAddress[] to, Mail originalMail) throws
MessagingException {
           if (to != null) {
  @@ -585,20 +594,42 @@
        * Is a "getX(Mail)" method.
        *
        * @return {@link #getReplyTo()}
  +     * replacing <CODE>SpecialAddress.UNALTERED</CODE> if applicable with null
        */
       protected MailAddress getReplyTo(Mail originalMail) throws MessagingException {
           MailAddress replyTo = (isStatic()) ? this.replyTo : getReplyTo();
  +        if (replyTo != null) {
  +            if (replyTo == SpecialAddress.UNALTERED) {
  +                replyTo = null;
  +            }
  +        }
           return replyTo;
       }
   
       /**
  -     * Sets the "Reply-To:" header of <I>newMail</I> to <I>replyTo</I>.
  +     * <P>Sets the "Reply-To:" header of <I>newMail</I> to <I>replyTo</I>.</P>
  +     * <P>If the requested value is <CODE>SpecialAddress.SENDER</CODE>
will use the original "From:" header;
  +     * if this header is empty will use the original "Sender:" header;
  +     * if this header is empty will use the original sender.
  +     * If the requested value is null does nothing.</P>
  +     * Is a "setX(Mail, Tx, Mail)" method.
        */
       protected void setReplyTo(Mail newMail, MailAddress replyTo, Mail originalMail) throws
MessagingException {
           if(replyTo != null) {
  +            if (replyTo == SpecialAddress.SENDER) {
  +                replyTo = getSafeApparentSender(originalMail);
  +
  +                // if still null give up.
  +                if (replyTo == null) {
  +                    return;
  +                }
  +            }
  +            
  +            // do the job
               InternetAddress[] iart = new InternetAddress[1];
               iart[0] = replyTo.toInternetAddress();
               newMail.getMessage().setReplyTo(iart);
  +            
               if (isDebug) {
                   log("replyTo set to: " + replyTo);
               }
  @@ -622,12 +653,18 @@
        * built dynamically using the original Mail object.
        * Is a "getX(Mail)" method.
        *
  -     * @return {@link #getReturnPath()}, replacing <CODE>SpecialAddress.SENDER</CODE>
if applicable, but not replacing <CODE>SpecialAddress.NULL</CODE>
  +     * @return {@link #getReturnPath()},
  +     * replacing <CODE>SpecialAddress.SENDER</CODE> if applicable with the
original sender,
  +     * replacing <CODE>SpecialAddress.UNALTERED</CODE> if applicable with null,
  +     * but not replacing <CODE>SpecialAddress.NULL</CODE>
        */
       protected MailAddress getReturnPath(Mail originalMail) throws MessagingException {
           MailAddress returnPath = (isStatic()) ? this.returnPath : getReturnPath();
           if (returnPath != null) {
  -            if (returnPath == SpecialAddress.SENDER) {
  +            if (returnPath == SpecialAddress.UNALTERED) {
  +                returnPath = null;
  +            }
  +            else if (returnPath == SpecialAddress.SENDER) {
                   returnPath = originalMail.getSender();
               }
           }
  @@ -636,6 +673,9 @@
   
       /**
        * Sets the "Return-Path:" header of <I>newMail</I> to <I>returnPath</I>.
  +     * If the requested value is <CODE>SpecialAddress.NULL</CODE> sets it to
"<>".
  +     * If the requested value is null does nothing.
  +     * Is a "setX(Mail, Tx, Mail)" method.
        */
       protected void setReturnPath(Mail newMail, MailAddress returnPath, Mail originalMail)
throws MessagingException {
           if(returnPath != null) {
  @@ -670,28 +710,91 @@
        * Is a "getX(Mail)" method.
        *
        * @return {@link #getSender()}
  +     * replacing <CODE>SpecialAddress.UNALTERED</CODE> if applicable with null
        */
       protected MailAddress getSender(Mail originalMail) throws MessagingException {
           MailAddress sender = (isStatic()) ? this.sender : getSender();
  +        if (sender != null) {
  +            if (sender == SpecialAddress.UNALTERED) {
  +                sender = null;
  +            }
  +        }
           return sender;
       }
   
       /**
  -     * Sets the sender and the "From:" header of <I>newMail</I> to <I>sender</I>.
  -     * If sender is null will set such values to the ones in <I>originalMail</I>.
  +     * <P>Sets the sender and the "From:" header of <I>newMail</I> to
<I>sender</I>.</P>
  +     * <P>If the requested value is <CODE>SpecialAddress.SENDER</CODE>
will use the original "From:" header;
  +     * if this header is empty will use the original "Sender:" header;
  +     * if this header is empty will use the original sender.
  +     * If the requested value is null does nothing.</P>
  +     * Is a "setX(Mail, Tx, Mail)" method.
        */
       protected void setSender(Mail newMail, MailAddress sender, Mail originalMail) throws
MessagingException {
  -        if (sender == null) {
  -            MailAddress originalSender = new MailAddress(((InternetAddress) originalMail.getMessage().getFrom()[0]).getAddress());
  -            newMail.getMessage().setHeader(RFC2822Headers.FROM, originalMail.getMessage().getHeader(RFC2822Headers.FROM,
","));
  -            ((MailImpl) newMail).setSender(originalSender);
  -        } else {
  -            newMail.getMessage().setFrom(sender.toInternetAddress());
  -            ((MailImpl) newMail).setSender(sender);
  +        if (sender != null) {
  +            if (sender == SpecialAddress.SENDER) {
  +                MailAddress newSender = getSafeApparentSender(originalMail);
  +                String newFromHeader = getSafeFromHeader(originalMail);
  +                
  +                if (!newFromHeader.trim().equals("")) {
  +                    newMail.getMessage().setHeader(RFC2822Headers.FROM, newFromHeader);
  +                }
  +                
  +                if (newSender != null) {
  +                    ((MailImpl) newMail).setSender(newSender);
  +                }
  +                
  +                // The new code should be compatible with and extend the previous code:
  +//                MailAddress originalSender = new MailAddress(((InternetAddress) originalMail.getMessage().getFrom()[0]).getAddress());
  +//                newMail.getMessage().setHeader(RFC2822Headers.FROM, originalMail.getMessage().getHeader(RFC2822Headers.FROM,
","));
  +//                ((MailImpl) newMail).setSender(originalSender);
  +            } else {
  +                newMail.getMessage().setFrom(sender.toInternetAddress());
  +                ((MailImpl) newMail).setSender(sender);
  +            }
  +            
               if (isDebug) {
                   log("sender set to: " + sender);
               }
           }
  +    }
  +    
  +    /**
  +     * <P>Gets a safe "apparent" sender using the original "From:" header if possible.</P>
  +     * <P>Will use the original "From:" header;
  +     * if this header is empty will use the original "Sender:" header;
  +     * if this header is empty will use the original sender.</P>
  +     */
  +    private MailAddress getSafeApparentSender(Mail originalMail) throws MessagingException
{
  +        MailAddress sender = null;
  +        InternetAddress from = (InternetAddress) originalMail.getMessage().getFrom()[0];
  +        
  +        if (from == null) {
  +            // perhaps this is redundant, but just in case ...
  +            from = originalMail.getSender().toInternetAddress();
  +        }
  +        if (from != null) {
  +            sender = new MailAddress(from.getAddress());
  +        }
  +        
  +        return sender;
  +    }
  +
  +    /**
  +     * <P>Gets a safe "From:" header using the original if possible.</P>
  +     * <P>Will use the original "From:" header;
  +     * if this header is empty will use the original "Sender:" header;
  +     * if this header is empty will use the original sender.</P>
  +     */
  +    private String getSafeFromHeader(Mail originalMail) throws MessagingException {
  +        MailAddress sender = getSafeApparentSender(originalMail);
  +        String fromHeader = originalMail.getMessage().getHeader(RFC2822Headers.FROM, ",");
  +        
  +        if (fromHeader.trim().equals("") && sender != null) {
  +            fromHeader = sender.toInternetAddress().toString();
  +        }
  +
  +        return fromHeader;
       }
   
       /**
  
  
  
  1.6       +8 -9      jakarta-james/src/java/org/apache/james/transport/mailets/Bounce.java
  
  Index: Bounce.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/Bounce.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Bounce.java	16 Jun 2003 03:35:07 -0000	1.5
  +++ Bounce.java	25 Jun 2003 22:00:38 -0000	1.6
  @@ -103,7 +103,7 @@
    * <P>Sample configuration:</P>
    * <PRE><CODE>
    * &lt;mailet match="All" class="Bounce">
  - *   &lt;sendingAddress&gt;<I>an address or postmaster</I>&lt;/sendingAddress&gt;
  + *   &lt;sendingAddress&gt;<I>an address or postmaster or sender or unaltered,
default=postmaster</I>&lt;/sendingAddress&gt;
    *   &lt;attachStackTrace&gt;<I>true or false, default=false</I>&lt;/attachStackTrace&gt;
    *   &lt;notice&gt;<I>notice attached to the message (optional)</I>&lt;/notice&gt;
    *   &lt;prefix&gt;<I>optional subject prefix prepended to the original message</I>&lt;/prefix&gt;
  @@ -118,23 +118,22 @@
    * configuration:</P>
    * <PRE><CODE>
    * &lt;mailet match="All" class="Redirect">
  - *   &lt;sender&gt;<I>an address or postmaster</I>&lt;/sender&gt;
  - *   &lt;attachError&gt;<I>true or false, default=false</I>&lt;/attachError&gt;
  + *   &lt;sender&gt;<I>an address or postmaster or sender or unaltered</I>&lt;/sender&gt;
  + *   &lt;attachError&gt;<I>true or false</I>&lt;/attachError&gt;
    *   &lt;message&gt;<I><B>dynamically built</B></I>&lt;/message&gt;
    *   &lt;prefix&gt;<I>a string</I>&lt;/prefix&gt;
  - *   &lt;passThrough&gt;true or false, default=true&lt;/passThrough&gt;
  - *   &lt;fakeDomainCheck&gt;<I>true or false, default=true</I>&lt;/fakeDomainCheck&gt;
  + *   &lt;passThrough&gt;true or false&lt;/passThrough&gt;
  + *   &lt;fakeDomainCheck&gt;<I>true or false</I>&lt;/fakeDomainCheck&gt;
    *   &lt;recipients&gt;<B>sender</B>&lt;/recipients&gt;
    *   &lt;returnPath&gt;null&lt;/returnPath&gt;
  - *   &lt;inline&gt;see {@link Redirect}, default=NONE&lt;/inline&gt;
  - *   &lt;attachment&gt;see {@link Redirect}, default=message&lt;/attachment&gt;
  + *   &lt;inline&gt;see {@link Redirect}&lt;/inline&gt;
  + *   &lt;attachment&gt;see {@link Redirect}&lt;/attachment&gt;
    *   &lt;isReply&gt;true&lt;/isReply&gt;
    *   &lt;static&gt;true&lt;/static&gt;
    * &lt;/mailet&gt;
    * </CODE></PRE>
    *
  - * <P>CVS $Id$</P>
  - * @version 2.2.0
  + * @version CVS $Revision$ $Date$
    * @since 2.2.0
    */
   public class Bounce extends AbstractNotify {
  
  
  
  1.14      +3 -3      jakarta-james/src/java/org/apache/james/transport/mailets/Forward.java
  
  Index: Forward.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/Forward.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Forward.java	15 Jun 2003 18:44:03 -0000	1.13
  +++ Forward.java	25 Jun 2003 22:00:38 -0000	1.14
  @@ -75,6 +75,7 @@
    * &lt;mailet match="All" class="Forward">
    *   &lt;forwardto&gt;<I>comma delimited list of email addresses</I>&lt;/forwardto&gt;
    *   &lt;passThrough&gt;<I>true or false, default=false</I>&lt;/passThrough&gt;
  + *   &lt;fakeDomainCheck&gt;<I>true or false, default=true</I>&lt;/fakeDomainCheck&gt;
    * &lt;/mailet&gt;
    * </CODE></PRE>
    *
  @@ -83,14 +84,13 @@
    * <PRE><CODE>
    * &lt;mailet match="All" class="Redirect">
    *   &lt;passThrough&gt;true or false&lt;/passThrough&gt;
  - *   &lt;fakeDomainCheck&gt;<I>true or false, default=true</I>&lt;/fakeDomainCheck&gt;
  + *   &lt;fakeDomainCheck&gt;<I>true or false</I>&lt;/fakeDomainCheck&gt;
    *   &lt;recipients&gt;comma delimited list of email addresses&lt;/recipients&gt;
    *   &lt;inline&gt;unaltered&lt;/inline&gt;
    * &lt;/mailet&gt;
    * </CODE></PRE>
    *
  - * <P>CVS $Id$</P>
  - * @version 2.2.0
  + * @version CVS $Revision$ $Date$
    */
   public class Forward extends AbstractRedirect {
   
  
  
  
  1.18      +8 -9      jakarta-james/src/java/org/apache/james/transport/mailets/NotifyPostmaster.java
  
  Index: NotifyPostmaster.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/NotifyPostmaster.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- NotifyPostmaster.java	15 Jun 2003 18:44:03 -0000	1.17
  +++ NotifyPostmaster.java	25 Jun 2003 22:00:38 -0000	1.18
  @@ -98,7 +98,7 @@
    * <P>Sample configuration:</P>
    * <PRE><CODE>
    * &lt;mailet match="All" class="NotifyPostmaster">
  - *   &lt;sendingAddress&gt;<I>an address or postmaster</I>&lt;/sendingAddress&gt;
  + *   &lt;sendingAddress&gt;<I>an address or postmaster or sender or unaltered,
default=postmaster</I>&lt;/sendingAddress&gt;
    *   &lt;attachStackTrace&gt;<I>true or false, default=false</I>&lt;/attachStackTrace&gt;
    *   &lt;notice&gt;<I>notice attached to the message (optional)</I>&lt;/notice&gt;
    *   &lt;prefix&gt;<I>optional subject prefix prepended to the original message,
default="Re:"</I>&lt;/prefix&gt;
  @@ -114,23 +114,22 @@
    * configuration:</P>
    * <PRE><CODE>
    * &lt;mailet match="All" class="Redirect">
  - *   &lt;sender&gt;<I>an address or postmaster or sender, default=postmaster</I>&lt;/sender&gt;
  - *   &lt;attachError&gt;<I>true or false, default=false</I>&lt;/attachError&gt;
  + *   &lt;sender&gt;<I>an address or postmaster or sender or unaltered</I>&lt;/sender&gt;
  + *   &lt;attachError&gt;<I>true or false</I>&lt;/attachError&gt;
    *   &lt;message&gt;<I><B>dynamically built</B></I>&lt;/message&gt;
    *   &lt;prefix&gt;<I>a string</I>&lt;/prefix&gt;
  - *   &lt;passThrough&gt;<I>true or false, default=true</I>&lt;/passThrough&gt;
  - *   &lt;fakeDomainCheck&gt;<I>true or false, default=true</I>&lt;/fakeDomainCheck&gt;
  + *   &lt;passThrough&gt;<I>true or false</I>&lt;/passThrough&gt;
  + *   &lt;fakeDomainCheck&gt;<I>true or false</I>&lt;/fakeDomainCheck&gt;
    *   &lt;to&gt;<I><B>unaltered or postmaster</B></I>&lt;/to&gt;
    *   &lt;recipients&gt;<B>postmaster</B>&lt;/recipients&gt;
  - *   &lt;inline&gt;see {@link Redirect}, default=none&lt;/inline&gt;
  - *   &lt;attachment&gt;see {@link Redirect}, default=message&lt;/attachment&gt;
  + *   &lt;inline&gt;see {@link Redirect}&lt;/inline&gt;
  + *   &lt;attachment&gt;see {@link Redirect}&lt;/attachment&gt;
    *   &lt;isReply&gt;true&lt;/isReply&gt;
    *   &lt;static&gt;true&lt;/static&gt;
    * &lt;/mailet&gt;
    * </CODE></PRE>
    *
  - * <P>CVS $Id$</P>
  - * @version 2.2.0
  + * @version CVS $Revision$ $Date$
    */
   public class NotifyPostmaster extends AbstractNotify {
   
  
  
  
  1.21      +5 -6      jakarta-james/src/java/org/apache/james/transport/mailets/NotifySender.java
  
  Index: NotifySender.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/NotifySender.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- NotifySender.java	15 Jun 2003 18:44:03 -0000	1.20
  +++ NotifySender.java	25 Jun 2003 22:00:38 -0000	1.21
  @@ -98,7 +98,7 @@
    * <P>Sample configuration:</P>
    * <PRE><CODE>
    * &lt;mailet match="All" class="NotifySender">
  - *   &lt;sendingAddress&gt;<I>an address or postmaster</I>&lt;/sendingAddress&gt;
  + *   &lt;sendingAddress&gt;<I>an address or postmaster or sender or unaltered,
default=postmaster</I>&lt;/sendingAddress&gt;
    *   &lt;attachStackTrace&gt;<I>true or false, default=false</I>&lt;/attachStackTrace&gt;
    *   &lt;notice&gt;<I>notice attached to the message (optional)</I>&lt;/notice&gt;
    *   &lt;prefix&gt;<I>optional subject prefix prepended to the original message</I>&lt;/prefix&gt;
  @@ -114,12 +114,12 @@
    * configuration:</P>
    * <PRE><CODE>
    * &lt;mailet match="All" class="Redirect">
  - *   &lt;sender&gt;<I>an address or postmaster</I>&lt;/sender&gt;
  - *   &lt;attachError&gt;<I>true or false, default=false</I>&lt;/attachError&gt;
  + *   &lt;sender&gt;<I>an address or postmaster or sender or unaltered</I>&lt;/sender&gt;
  + *   &lt;attachError&gt;<I>true or false</I>&lt;/attachError&gt;
    *   &lt;message&gt;<I><B>dynamically built</B></I>&lt;/message&gt;
    *   &lt;prefix&gt;<I>a string</I>&lt;/prefix&gt;
    *   &lt;passThrough&gt;true&lt;/passThrough&gt;
  - *   &lt;fakeDomainCheck&gt;<I>true or false, default=true</I>&lt;/fakeDomainCheck&gt;
  + *   &lt;fakeDomainCheck&gt;<I>true or false</I>&lt;/fakeDomainCheck&gt;
    *   &lt;to&gt;<I>unaltered or sender&lt</I>;/to&gt;
    *   &lt;recipients&gt;<B>sender</B>&lt;/recipients&gt;
    *   &lt;inline&gt;none&lt;/inline&gt;
  @@ -129,8 +129,7 @@
    * &lt;/mailet&gt;
    * </CODE></PRE>
    *
  - * <P>CVS $Id$</P>
  - * @version 2.2.0
  + * @version CVS $Revision$ $Date$
    */
   public class NotifySender extends AbstractNotify {
   
  
  
  
  1.30      +122 -72   jakarta-james/src/java/org/apache/james/transport/mailets/Redirect.java
  
  Index: Redirect.java
  ===================================================================
  RCS file: /home/cvs/jakarta-james/src/java/org/apache/james/transport/mailets/Redirect.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- Redirect.java	15 Jun 2003 18:44:03 -0000	1.29
  +++ Redirect.java	25 Jun 2003 22:00:38 -0000	1.30
  @@ -87,38 +87,55 @@
   
   
   /**
  - * <P>A mailet providing configurable redirection services<BR>
  + * <P>A mailet providing configurable redirection services.<BR>
    * This mailet can produce listserver, forward and notify behaviour, with the original
    * message intact, attached, appended or left out altogether.<BR>
  - * This built in functionality is controlled by the configuration as laid out below.</P>
  + * This built in functionality is controlled by the configuration as laid out below.
  + * In the table please note that the parameters controlling message headers
  + * accept the <B>&quot;unaltered&quot;</B> value, whose meaning is
to keep the associated
  + * header unchanged and, unless stated differently, corresponds to the assumed default
  + * if the parameter is missing. 
    * <P>The configuration parameters are:</P>
  - * <TABLE width="75%" border="0" cellspacing="2" cellpadding="2">
  - * <TR>
  + * <TABLE width="75%" border="1" cellspacing="2" cellpadding="2">
  + * <TR valign=top>
    * <TD width="20%">&lt;recipients&gt;</TD>
  - * <TD width="80%">A comma delimited list of email addresses for recipients of
  - * this message, it will use the &quot;to&quot; list if not specified. These
  - * addresses will only appear in the To: header if no &quot;to&quot; list is
  + * <TD width="80%">
  + * A comma delimited list of email addresses for recipients of
  + * this message; it will use the &quot;to&quot; list if not specified, and &quot;unaltered&quot;
  + * if none of the lists is specified.<BR>
  + * These addresses will only appear in the To: header if no &quot;to&quot; list
is
    * supplied.<BR>
  - * It can include constants &quot;sender&quot;, &quot;postmaster&quot;
and &quot;returnPath&quot;</TD>
  + * It can include constants &quot;sender&quot;, &quot;postmaster&quot;,
&quot;returnPath&quot; and &quot;unaltered&quot;
  + * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;to&gt;</TD>
  - * <TD width="80%">A comma delimited list of addresses to appear in the To: header,
  - * the email will only be delivered to these addresses if they are in the recipients
  + * <TD width="80%">
  + * A comma delimited list of addresses to appear in the To: header;
  + * the email will be delivered to any of these addresses if it is also in the recipients
    * list.<BR>
  - * The recipients list will be used if this is not supplied.<BR>
  - * It can include constants &quot;sender&quot;, &quot;postmaster&quot;,
&quot;returnPath&quot; and &quot;unaltered&quot;</TD>
  + * The recipients list will be used if this list is not supplied;
  + * if none of the lists is specified it will be &quot;unaltered&quot;.<BR>
  + * It can include constants &quot;sender&quot;, &quot;postmaster&quot;,
&quot;returnPath&quot; and &quot;unaltered&quot;
  + * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;sender&gt;</TD>
  - * <TD width="80%">A single email address to appear in the From: header <BR>
  - * It can include constants &quot;sender&quot; and &quot;postmaster&quot;</TD>
  + * <TD width="80%">
  + * A single email address to appear in the From: header and become the sender.<BR>
  + * It can include constants &quot;sender&quot;, &quot;postmaster&quot;
and &quot;unaltered&quot;;
  + * if &quot;sender&quot; is specified then it will follow a safe procedure from
the 
  + * original From: header (see {@link AbstractRedirect#setSender} and {@link AbstractRedirect#getSender(Mail)}).<BR>
  + * Default: &quot;unaltered&quot;.
  + * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;message&gt;</TD>
  - * <TD width="80%">A text message to be the body of the email. Can be omitted.</TD>
  + * <TD width="80%">
  + * A text message to be the body of the email. Can be omitted.
  + * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;inline&gt;</TD>
    * <TD width="80%">
    * <P>One of the following items:</P>
  @@ -134,9 +151,10 @@
    * <LI>none&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Neither
    * body nor headers are appended</LI>
    * </UL>
  + * Default: &quot;body&quot;.
    * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;attachment&gt;</TD>
    * <TD width="80%">
    * <P>One of the following items:</P>
  @@ -152,57 +170,78 @@
    * this means that it can, in many cases, be opened, resent, fw'd, replied
    * to etc by email client software.</LI>
    * </UL>
  + * Default: &quot;none&quot;.
    * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;passThrough&gt;</TD>
  - * <TD width="80%">true or false, if true the original message continues in the
  + * <TD width="80%">
  + * true or false, if true the original message continues in the
    * mailet processor after this mailet is finished. False causes the original
  - * to be stopped. The default is false.</TD>
  + * to be stopped.<BR>
  + * Default: false.
  + * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;fakeDomainCheck&gt;</TD>
  - * <TD width="80%">TRUE or FALSE, if true will check if the sender domain is valid.
  - * The default is true.</TD>
  + * <TD width="80%">
  + * true or false, if true will check if the sender domain is valid.<BR>
  + * Default: true.
  + * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;attachError&gt;</TD>
  - * <TD width="80%">TRUE or FALSE, if true any error message available to the
  + * <TD width="80%">
  + * true or false, if true any error message available to the
    * mailet is appended to the message body (except in the case of inline ==
  - * unaltered)</TD>
  + * unaltered).<BR>
  + * Default: false.
  + * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;replyto&gt;</TD>
  - * <TD width="80%">A single email address to appear in the Reply-To: header, can
  - * also be &quot;sender&quot; or &quot;postmaster&quot;, this header is
not
  - * set if this is omitted.</TD>
  + * <TD width="80%">
  + * A single email address to appear in the Reply-To: header.<BR>
  + * It can include constants &quot;sender&quot;, &quot;postmaster&quot;
and &quot;unaltered&quot;;
  + * if &quot;sender&quot; is specified then it will follow a safe procedure from
the 
  + * original From: header (see {@link AbstractRedirect#setReplyTo} and {@link AbstractRedirect#getReplyTo(Mail)}).<BR>
  + * Default: &quot;unaltered&quot;.
  + * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;returnPath&gt;</TD>
  - * <TD width="80%">A single email address to appear in the Return-Path: header, can
  - * also be &quot;sender&quot; or &quot;postmaster&quot; or &quot;null&quot;;
this header is not
  - * set if this parameter is omitted.</TD>
  + * <TD width="80%">
  + * A single email address to appear in the Return-Path: header.<BR>
  + * It can include constants &quot;sender&quot;, &quot;postmaster&quot;
&quot;null&quot;and &quot;unaltered&quot;;
  + * if &quot;null&quot; is specified then it will set it to <>, meaning &quot;null
return path&quot;.<BR>
  + * Default: &quot;unaltered&quot;.
  + * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;prefix&gt;</TD>
  - * <TD width="80%">An optional subject prefix prepended to the original message
  - * subject, for example:<BR>
  - * Undeliverable mail: </TD>
  + * <TD width="80%">
  + * An optional subject prefix prepended to the original message
  + * subject, for example: <I>[Undeliverable mail]</I>.<BR>
  + * Default: &quot;&quot;.
  + * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;isReply&gt;</TD>
  - * <TD width="80%">TRUE or FALSE, if true the IN_REPLY_TO header will be set to the
  - * id of the current message.</TD>
  + * <TD width="80%">
  + * true or false, if true the IN_REPLY_TO header will be set to the
  + * id of the current message.<BR>
  + * Default: false.
  + * </TD>
    * </TR>
  - * <TR>
  + * <TR valign=top>
    * <TD width="20%">&lt;static&gt;</TD>
    * <TD width="80%">
  - * <P>TRUE or FALSE.  If this is TRUE it tells the mailet that it can
  + * true or false.  If this is true it tells the mailet that it can
    * reuse all the initial parameters (to, from, etc) without re-calculating
    * their values.  This will boost performance where a redirect task
  - * doesn't contain any dynamic values.  If this is FALSE, it tells the
  - * mailet to recalculate the values for each e-mail processed.</P>
  - * <P>This defaults to false.<BR>
  + * doesn't contain any dynamic values.  If this is false, it tells the
  + * mailet to recalculate the values for each e-mail processed.<BR>
  + * Default: false.
    * </TD>
    * </TR>
    * </TABLE>
  @@ -236,8 +275,7 @@
    * &lt;static&gt;TRUE&lt;/static&gt;<BR>
    * &lt;/mailet&gt;</P>
    *
  - * <P>CVS $Id$</P>
  - * @version 2.2.0
  + * @version CVS $Revision$ $Date$
    */
   
   public class Redirect extends AbstractRedirect {
  @@ -296,21 +334,25 @@
       }
   
       /**
  -     * @return the <CODE>recipients</CODE> init parameter or <CODE>SpecialAddress.SENDER</CODE>
  -     * or <CODE>SpecialAddress.RETURN_PATH</CODE> or null if missing
  +     * @return the <CODE>recipients</CODE> init parameter
  +     * or the postmaster address
  +     * or <CODE>SpecialAddress.SENDER</CODE>
  +     * or <CODE>SpecialAddress.RETURN_PATH</CODE>
  +     * or <CODE>SpecialAddress.UNALTERED</CODE>
  +     * or <CODE>null</CODE> if missing
        */
       protected Collection getRecipients() throws MessagingException {
           Collection newRecipients = new HashSet();
           String addressList = (getInitParameter("recipients") == null)
                                    ? getInitParameter("to")
                                    : getInitParameter("recipients");
  -        // if nothing was specified, return null meaning no change
  +        // if nothing was specified, return <CODE>null</CODE> meaning no change
           if (addressList == null) {
               return null;
           }
   
           MailAddress specialAddress = getSpecialAddress(addressList,
  -                                        new String[] {"postmaster", "sender", "returnPath"});
  +                                        new String[] {"postmaster", "sender", "returnPath",
"unaltered"});
           if (specialAddress != null) {
               newRecipients.add(specialAddress);
               return newRecipients;
  @@ -328,8 +370,12 @@
       }
   
       /**
  -     * @return the <CODE>to</CODE> init parameter or <CODE>SpecialAddress.SENDER</CODE>
  -     * or S<CODE>pecialAddress.RETURN_PATH</CODE> or <CODE>SpecialAddress.UNALTERED</CODE>
or null if missing
  +     * @return the <CODE>to</CODE> init parameter
  +     * or the postmaster address
  +     * or <CODE>SpecialAddress.SENDER</CODE>
  +     * or <CODE>SpecialAddress.RETURN_PATH</CODE>
  +     * or <CODE>SpecialAddress.UNALTERED</CODE>
  +     * or <CODE>null</CODE> if missing
        */
       protected InternetAddress[] getTo() throws MessagingException {
           String addressList = (getInitParameter("to") == null)
  @@ -364,18 +410,18 @@
       }
   
       /**
  -     * @return the <CODE>replyto</CODE> init parameter or null if missing or
== "sender"
  +     * @return the <CODE>replyto</CODE> init parameter
  +     * or the postmaster address
  +     * or <CODE>SpecialAddress.SENDER</CODE>
  +     * or <CODE>SpecialAddress.UNALTERED</CODE>
  +     * or <CODE>null</CODE> if missing
        */
       protected MailAddress getReplyTo() throws MessagingException {
           String addressString = getInitParameter("replyto");
           if(addressString != null) {
               MailAddress specialAddress = getSpecialAddress(addressString,
  -                                            new String[] {"postmaster", "sender"});
  +                                            new String[] {"postmaster", "sender", "unaltered"});
               if (specialAddress != null) {
  -                if (specialAddress == SpecialAddress.SENDER) {
  -                    // means no change
  -                    return null;
  -                }
                   return specialAddress;
               }
   
  @@ -390,14 +436,18 @@
       }
   
       /**
  -     * @return the <CODE>returnPath</CODE> init parameter or <CODE>SpecialAddress.NULL</CODE>
  -     * or <CODE>SpecialAddress.SENDER</CODE> or null if missing
  +     * @return the <CODE>returnPath</CODE> init parameter 
  +     * or the postmaster address
  +     * or <CODE>SpecialAddress.SENDER</CODE>
  +     * or <CODE>SpecialAddress.NULL</CODE>
  +     * or <CODE>SpecialAddress.UNALTERED</CODE>
  +     * or <CODE>null</CODE> if missing
        */
       protected MailAddress getReturnPath() throws MessagingException {
           String addressString = getInitParameter("returnPath");
           if(addressString != null) {
               MailAddress specialAddress = getSpecialAddress(addressString,
  -                                            new String[] {"postmaster", "sender", "null"});
  +                                            new String[] {"postmaster", "sender", "null",
"unaltered"});
               if (specialAddress != null) {
                   return specialAddress;
               }
  @@ -413,18 +463,18 @@
       }
   
       /**
  -     * @return the <CODE>sender</CODE> init parameter or null if missing or
== "sender"
  +     * @return the <CODE>sender</CODE> init parameter
  +     * or the postmaster address
  +     * or <CODE>SpecialAddress.SENDER</CODE>
  +     * or <CODE>SpecialAddress.UNALTERED</CODE>
  +     * or <CODE>null</CODE> if missing
        */
       protected MailAddress getSender() throws MessagingException {
           String addressString = getInitParameter("sender");
           if(addressString != null) {
               MailAddress specialAddress = getSpecialAddress(addressString,
  -                                            new String[] {"postmaster", "sender"});
  +                                            new String[] {"postmaster", "sender", "unaltered"});
               if (specialAddress != null) {
  -                if (specialAddress == SpecialAddress.SENDER) {
  -                    // means no change: use FROM header; kept as is for compatibility
  -                    return null;
  -                }
                   return specialAddress;
               }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: james-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: james-dev-help@jakarta.apache.org


Mime
View raw message