org.apache.james.transport.mailets
Class CommandListservProcessor

java.lang.Object
  extended by org.apache.mailet.GenericMailet
      extended by org.apache.james.transport.mailets.CommandListservProcessor
All Implemented Interfaces:
Mailet, MailetConfig

public class CommandListservProcessor
extends GenericMailet

CommandListservProcessor processes messages intended for the list serv mailing list. For command handling, see CommandListservManager
This class is based on the existing list serv processor shipped with James.

To configure the CommandListservProcessor place this configuratin in the root processor:

 <mailet match="RecipientIs=announce@localhost" class="CommandListservProcessor">
  <membersonly>false</membersonly>
  <attachmentsallowed>true</attachmentsallowed>
  <replytolist>true</replytolist>
  <repositoryName>list-announce</repositoryName>
  <subjectprefix>Announce</subjectprefix>
  <autobracket>true</autobracket>
  <listOwner>owner@localhost</listOwner>
  <listName>announce</listName>
 </mailet>

 

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

Field Summary
protected  java.util.Collection allowedPosters
           
protected  boolean attachmentsAllowed
          Whether attachments can be sent to the list specified by the config param: 'attachmentsallowed'.
protected  boolean autoBracket
          Whether the subject prefix should be bracketed with '[' and ']' specified by the config param: 'autoBracket'.
protected  CommandListservFooter commandListservFooter
          Mailet that will add the footer to the message
protected  ICommandListservManager commandListservManager
          The list serv manager
protected  java.lang.String listName
          Name of the mailing list specified by the config param: 'listName'.
protected  MailAddress listOwner
          The list owner specified by the config param: 'listOwner'.
protected  boolean membersOnly
          Whether only members can post to the list specified by the config param: 'membersonly'.
protected  boolean replyToList
          Whether the reply-to header should be set to the list address specified by the config param: 'replytolist'.
protected  boolean specificPostersOnly
           
protected  java.lang.String subjectPrefix
          A String to prepend to the subject of the message when it is sent to the list specified by the config param: 'subjectPrefix'.
protected  UsersRepository usersRepository
          The repository containing the users on this list specified by the config param: 'repositoryName'.
protected  XMLResources xmlResources
           
 
Constructor Summary
CommandListservProcessor()
           
 
Method Summary
protected  void addFooter(Mail mail)
          Add the footer using CommandListservFooter
protected  boolean checkAllowedPoster(Mail mail, java.util.Collection members)
          Returns true if this user is ok to send to the list
protected  boolean checkAnnouncements(Mail mail)
          Returns true if this is ok to send to the list
protected  boolean checkBeenThere(MailAddress listservAddr, Mail mail)
          return true if this is ok, false otherwise Check if the X-been-there header is set to the listserv's name (the address).
protected  boolean checkMembers(java.util.Collection members, Mail mail)
          Returns true if this user is ok to send to the list
protected  boolean getBoolean(java.lang.String attrName, boolean defValue)
          Get a configuration value
protected  CommandListservFooter getCommandListservFooter()
          Lazy init
protected  ICommandListservManager getCommandListservManager()
          lazy retrieval
protected static java.lang.Object getField(java.lang.Object instance, java.lang.String name)
          Retrieves a data field, potentially defined by a super class.
 java.util.Collection getMembers()
           
protected  java.lang.String getString(java.lang.String attrName, java.lang.String defValue)
          Get a configuration value
 void init()
          Initialize the mailet
protected  void initAllowedPosters(org.apache.avalon.framework.configuration.Configuration configuration)
           
protected  void initializeResources()
          initialize the resources
protected  void initUsersRepository()
          Fetch the repository of users
protected  javax.mail.internet.MimeMessage prepareListMessage(Mail mail, MailAddress listservAddr)
          Create a new message with some set headers
 void service(Mail mail)
          A message was sent to the list serv.
protected  void setSubject(javax.mail.internet.MimeMessage message)
           
 
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
 

Field Detail

membersOnly

protected boolean membersOnly
Whether only members can post to the list specified by the config param: 'membersonly'.
eg:
<membersonly>false</membersonly>
Defaults to false


attachmentsAllowed

protected boolean attachmentsAllowed
Whether attachments can be sent to the list specified by the config param: 'attachmentsallowed'.
eg:
<attachmentsallowed>true</attachmentsallowed>
Defaults to true


replyToList

protected boolean replyToList
Whether the reply-to header should be set to the list address specified by the config param: 'replytolist'.
eg:
<replytolist>true</replytolist>
Defaults to true


subjectPrefix

protected java.lang.String subjectPrefix
A String to prepend to the subject of the message when it is sent to the list specified by the config param: 'subjectPrefix'.
eg:
<subjectPrefix>MyList</subjectPrefix>
For example: MyList


autoBracket

protected boolean autoBracket
Whether the subject prefix should be bracketed with '[' and ']' specified by the config param: 'autoBracket'.
eg:
<autoBracket>true</autoBracket>
Defaults to true


usersRepository

protected UsersRepository usersRepository
The repository containing the users on this list specified by the config param: 'repositoryName'.
eg:
<repositoryName>list-announce</repositoryName>


listOwner

protected MailAddress listOwner
The list owner specified by the config param: 'listOwner'.
eg:
<listOwner>owner@localhost</listOwner>


listName

protected java.lang.String listName
Name of the mailing list specified by the config param: 'listName'.
eg:
<listName>announce</listName>


commandListservManager

protected ICommandListservManager commandListservManager
The list serv manager


commandListservFooter

protected CommandListservFooter commandListservFooter
Mailet that will add the footer to the message


xmlResources

protected XMLResources xmlResources
See Also:
XMLResources

specificPostersOnly

protected boolean specificPostersOnly

allowedPosters

protected java.util.Collection allowedPosters
Constructor Detail

CommandListservProcessor

public CommandListservProcessor()
Method Detail

init

public void init()
          throws javax.mail.MessagingException
Initialize the mailet

Overrides:
init in class GenericMailet
Throws:
javax.mail.MessagingException - if an exception occurs that interrupts the mailet's normal operation

service

public void service(Mail mail)
             throws javax.mail.MessagingException
A message was sent to the list serv. Broadcast if appropriate...

Specified by:
service in interface Mailet
Specified by:
service in class GenericMailet
Parameters:
mail -
Throws:
javax.mail.MessagingException

addFooter

protected void addFooter(Mail mail)
                  throws javax.mail.MessagingException
Add the footer using CommandListservFooter

Parameters:
mail -
Throws:
javax.mail.MessagingException

setSubject

protected void setSubject(javax.mail.internet.MimeMessage message)
                   throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

prepareListMessage

protected javax.mail.internet.MimeMessage prepareListMessage(Mail mail,
                                                             MailAddress listservAddr)
                                                      throws javax.mail.MessagingException
Create a new message with some set headers

Parameters:
mail -
listservAddr -
Returns:
a prepared List Message
Throws:
javax.mail.MessagingException

checkBeenThere

protected boolean checkBeenThere(MailAddress listservAddr,
                                 Mail mail)
                          throws javax.mail.MessagingException
return true if this is ok, false otherwise Check if the X-been-there header is set to the listserv's name (the address). If it has, this means it's a message from this listserv that's getting bounced back, so we need to swallow it

Parameters:
listservAddr -
mail -
Returns:
true if this message has already bounced, false otherwse
Throws:
javax.mail.MessagingException

checkAnnouncements

protected boolean checkAnnouncements(Mail mail)
                              throws java.io.IOException,
                                     javax.mail.MessagingException
Returns true if this is ok to send to the list

Parameters:
mail -
Returns:
true if this message is ok, false otherwise
Throws:
java.io.IOException
javax.mail.MessagingException

checkMembers

protected boolean checkMembers(java.util.Collection members,
                               Mail mail)
                        throws javax.mail.MessagingException
Returns true if this user is ok to send to the list

Parameters:
members -
mail -
Returns:
true if this message is ok, false otherwise
Throws:
javax.mail.MessagingException

getMembers

public java.util.Collection getMembers()
                                throws javax.mail.internet.ParseException
Throws:
javax.mail.internet.ParseException

getBoolean

protected boolean getBoolean(java.lang.String attrName,
                             boolean defValue)
Get a configuration value

Parameters:
attrName -
defValue -
Returns:
the value if found, defValue otherwise

getString

protected java.lang.String getString(java.lang.String attrName,
                                     java.lang.String defValue)
Get a configuration value

Parameters:
attrName -
defValue -
Returns:
the attrValue if found, defValue otherwise

initializeResources

protected void initializeResources()
                            throws java.lang.Exception
initialize the resources

Throws:
java.lang.Exception

initUsersRepository

protected void initUsersRepository()
                            throws java.lang.Exception
Fetch the repository of users

Throws:
java.lang.Exception

getCommandListservManager

protected ICommandListservManager getCommandListservManager()
lazy retrieval

Returns:
ICommandListservManager

getCommandListservFooter

protected CommandListservFooter getCommandListservFooter()
                                                  throws javax.mail.MessagingException
Lazy init

Throws:
javax.mail.MessagingException

getField

protected static java.lang.Object getField(java.lang.Object instance,
                                           java.lang.String name)
                                    throws java.lang.IllegalAccessException
Retrieves a data field, potentially defined by a super class.

Returns:
null if not found, the object otherwise
Throws:
java.lang.IllegalAccessException

initAllowedPosters

protected void initAllowedPosters(org.apache.avalon.framework.configuration.Configuration configuration)
                           throws java.lang.Exception
Throws:
java.lang.Exception

checkAllowedPoster

protected boolean checkAllowedPoster(Mail mail,
                                     java.util.Collection members)
                              throws javax.mail.MessagingException
Returns true if this user is ok to send to the list

Parameters:
mail -
Returns:
true if this message is ok, false otherwise
Throws:
javax.mail.MessagingException


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.