org.apache.james.transport.mailets
Class AbstractNotify

java.lang.Object
  extended by org.apache.mailet.GenericMailet
      extended by org.apache.james.transport.mailets.AbstractRedirect
          extended by org.apache.james.transport.mailets.AbstractNotify
All Implemented Interfaces:
Mailet, MailetConfig
Direct Known Subclasses:
Bounce, DSNBounce, NotifyPostmaster, NotifySender

public abstract class AbstractNotify
extends AbstractRedirect

Abstract mailet providing configurable notification services.
This mailet can be subclassed to make authoring notification mailets simple.

Provides the following functionalities to all notification subclasses:

Sample configuration common to all notification mailet subclasses:


 <mailet match="All" class="a notification mailet">
   <sender>an address or postmaster or sender or unaltered, default=postmaster</sender>
   <attachError>true or false, default=false</attachError>
   <message>notice attached to the original message text (optional)</message>
   <prefix>optional subject prefix prepended to the original message</prefix>
   <inline>see Redirect, default=none</inline>
   <attachment>see Redirect, default=message</attachment>
   <passThrough>true or false, default=true</passThrough>
   <fakeDomainCheck>true or false, default=true</fakeDomainCheck>
   <debug>true or false, default=false</debug>
 </mailet>
 

notice and senderAddress can be used instead of message and sender; such names are kept for backward compatibility.

Since:
2.2.0
Version:
CVS $Revision: 494012 $ $Date: 2007-01-08 10:23:58 +0000 (lun, 08 gen 2007) $

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.james.transport.mailets.AbstractRedirect
AbstractRedirect.SpecialAddress
 
Field Summary
 
Fields inherited from class org.apache.james.transport.mailets.AbstractRedirect
ALL, BODY, HEADS, isDebug, isStatic, MESSAGE, NONE, UNALTERED
 
Constructor Summary
AbstractNotify()
           
 
Method Summary
protected  int getAttachmentType()
          Gets the attachment property.
protected  int getInLineType()
          Gets the inline property.
protected  java.lang.String getMessage()
          Gets the message property.
protected  java.lang.String getMessage(Mail originalMail)
          Gets the message property, built dynamically using the original Mail object.
protected  boolean getPassThrough()
          Gets the passThrough property.
protected abstract  java.util.Collection getRecipients()
          Gets the recipients property.
protected  MailAddress getReplyTo()
          Gets the replyto property.
protected  MailAddress getReversePath(Mail originalMail)
          Gets the reversePath property, built dynamically using the original Mail object.
protected  MailAddress getSender()
          Gets the sender property.
protected  java.lang.String getSubject()
          Gets the subject property.
protected  java.lang.String getSubjectPrefix()
          Gets the prefix property.
protected  javax.mail.internet.InternetAddress[] getTo()
          Gets the to property.
protected  boolean isReply()
          Gets the isReply property.
protected  void setSubjectPrefix(Mail newMail, java.lang.String subjectPrefix, Mail originalMail)
          Builds the subject of newMail appending the subject of originalMail to subjectPrefix, but avoiding a duplicate.
 
Methods inherited from class org.apache.james.transport.mailets.AbstractRedirect
attachError, attachError, buildAlteredMessage, changeSubject, getAllowedInitParameters, getAttachmentType, getFakeDomainCheck, getFakeDomainCheck, getInLineType, getMessageHeaders, getPassThrough, getRecipients, getReplyTo, getReversePath, getSender, getSpecialAddress, getSubject, getSubjectPrefix, getTo, getTypeCode, init, isReply, isStatic, replaceInternetAddresses, replaceMailAddresses, senderDomainIsValid, service, setIsReply, setRecipients, setReplyTo, setReversePath, setSender, setTo
 
Methods inherited from class org.apache.mailet.GenericMailet
destroy, getInitParameter, getInitParameter, getInitParameterNames, getMailetConfig, getMailetContext, getMailetInfo, getMailetName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractNotify

public AbstractNotify()
Method Detail

getPassThrough

protected boolean getPassThrough()
                          throws javax.mail.MessagingException
Description copied from class: AbstractRedirect
Gets the passThrough property. Return true to allow the original message to continue through the processor, false to GHOST it. Is a "getX()" method.

Overrides:
getPassThrough in class AbstractRedirect
Returns:
the passThrough init parameter, or true if missing
Throws:
javax.mail.MessagingException

getInLineType

protected int getInLineType()
                     throws javax.mail.MessagingException
Description copied from class: AbstractRedirect
Gets the inline property. May return one of the following values to indicate how to append the original message to build the new message: Is a "getX()" method.

Overrides:
getInLineType in class AbstractRedirect
Returns:
the inline init parameter, or NONE if missing
Throws:
javax.mail.MessagingException

getAttachmentType

protected int getAttachmentType()
                         throws javax.mail.MessagingException
Description copied from class: AbstractRedirect
Gets the attachment property. May return one of the following values to indicate how to attach the original message to the new message: Is a "getX()" method.

Overrides:
getAttachmentType in class AbstractRedirect
Returns:
the attachment init parameter, or MESSAGE if missing
Throws:
javax.mail.MessagingException

getMessage

protected java.lang.String getMessage()
Description copied from class: AbstractRedirect
Gets the message property. Returns a message to which the original message can be attached/appended to build the new message. Is a "getX()" method.

Overrides:
getMessage in class AbstractRedirect
Returns:
the notice init parameter, or the message init parameter if missing, or a default string if both are missing

getMessage

protected java.lang.String getMessage(Mail originalMail)
                               throws javax.mail.MessagingException
Description copied from class: AbstractRedirect
Gets the message property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Overrides:
getMessage in class AbstractRedirect
Returns:
the full message to append, built from the Mail object
Throws:
javax.mail.MessagingException

getRecipients

protected abstract java.util.Collection getRecipients()
                                               throws javax.mail.MessagingException
Description copied from class: AbstractRedirect
Gets the recipients property. Returns the collection of recipients of the new message, or null if no change is requested. Is a "getX()" method.

Overrides:
getRecipients in class AbstractRedirect
Returns:
the recipients init parameter or the postmaster address or SpecialAddress.SENDER or SpecialAddress.FROM or SpecialAddress.REPLY_TO or SpecialAddress.REVERSE_PATH or SpecialAddress.UNALTERED or SpecialAddress.RECIPIENTS or null if missing
Throws:
javax.mail.MessagingException

getTo

protected javax.mail.internet.InternetAddress[] getTo()
                                               throws javax.mail.MessagingException
Description copied from class: AbstractRedirect
Gets the to property. Returns the "To:" recipients of the new message. or null if no change is requested. Is a "getX()" method.

Overrides:
getTo in class AbstractRedirect
Returns:
null
Throws:
javax.mail.MessagingException

getReplyTo

protected MailAddress getReplyTo()
                          throws javax.mail.MessagingException
Description copied from class: AbstractRedirect
Gets the replyto property. Returns the Reply-To address of the new message, or null if no change is requested. Is a "getX()" method.

Overrides:
getReplyTo in class AbstractRedirect
Returns:
SpecialAddress.NULL, that will remove the "ReplyTo:" header
Throws:
javax.mail.MessagingException

getReversePath

protected MailAddress getReversePath(Mail originalMail)
                              throws javax.mail.MessagingException
Description copied from class: AbstractRedirect
Gets the reversePath property, built dynamically using the original Mail object. Is a "getX(Mail)" method.

Overrides:
getReversePath in class AbstractRedirect
Returns:
AbstractRedirect.getSender(Mail), meaning the new requested sender if any
Throws:
javax.mail.MessagingException

getSender

protected MailAddress getSender()
                         throws javax.mail.MessagingException
Description copied from class: AbstractRedirect
Gets the sender property. Returns the new sender as a MailAddress, or null if no change is requested. Is a "getX()" method.

Overrides:
getSender in class AbstractRedirect
Returns:
the value of the sendingAddress init parameter, or the value of the sender init parameter if missing, or the postmaster address if both are missing
Throws:
javax.mail.MessagingException

getSubject

protected java.lang.String getSubject()
                               throws javax.mail.MessagingException
Description copied from class: AbstractRedirect
Gets the subject property. Returns a string for the new message subject. Is a "getX()" method.

Overrides:
getSubject in class AbstractRedirect
Returns:
null
Throws:
javax.mail.MessagingException

getSubjectPrefix

protected java.lang.String getSubjectPrefix()
Description copied from class: AbstractRedirect
Gets the prefix property. Returns a prefix for the new message subject. Is a "getX()" method.

Overrides:
getSubjectPrefix in class AbstractRedirect
Returns:
the prefix init parameter or "Re:" if missing

setSubjectPrefix

protected void setSubjectPrefix(Mail newMail,
                                java.lang.String subjectPrefix,
                                Mail originalMail)
                         throws javax.mail.MessagingException
Builds the subject of newMail appending the subject of originalMail to subjectPrefix, but avoiding a duplicate.

Overrides:
setSubjectPrefix in class AbstractRedirect
Throws:
javax.mail.MessagingException

isReply

protected boolean isReply()
Description copied from class: AbstractRedirect
Gets the isReply property. Returns a boolean indicating whether the new message must be considered a reply to the original message, setting the IN_REPLY_TO header of the new message to the id of the original message. Is a "getX()" method.

Overrides:
isReply in class AbstractRedirect
Returns:
true


Copyright © 2002-2007 The Apache Software Foundation. All Rights Reserved.