org.apache.james.transport.mailets
Class CommandListservProcessor

java.lang.Object
  extended byorg.apache.mailet.GenericMailet
      extended byorg.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: 382444 $ $Date: 2006-03-02 11:56:32 -0500 (Thu, 02 Mar 2006) $

Field Summary
protected  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  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  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, 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(Collection members, Mail mail)
          Returns true if this user is ok to send to the list
protected  boolean getBoolean(String attrName, boolean defValue)
          Get a configuration value
protected  CommandListservFooter getCommandListservFooter()
          Lazy init
protected  ICommandListservManager getCommandListservManager()
          lazy retrieval
protected static Object getField(Object instance, String name)
          Retrieves a data field, potentially defined by a super class.
 Collection getMembers()
           
protected  String getString(String attrName, 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  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(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 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 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 Collection allowedPosters
Constructor Detail

CommandListservProcessor

public CommandListservProcessor()
Method Detail

init

public void init()
          throws MessagingException
Initialize the mailet

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

service

public void service(Mail mail)
             throws 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:
MessagingException

addFooter

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

Parameters:
mail -
Throws:
MessagingException

setSubject

protected void setSubject(MimeMessage message)
                   throws MessagingException
Throws:
MessagingException

prepareListMessage

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

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

checkBeenThere

protected boolean checkBeenThere(MailAddress listservAddr,
                                 Mail mail)
                          throws 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:
MessagingException

checkAnnouncements

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

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

checkMembers

protected boolean checkMembers(Collection members,
                               Mail mail)
                        throws 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:
MessagingException

getMembers

public Collection getMembers()
                      throws ParseException
Throws:
ParseException

getBoolean

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

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

getString

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

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

initializeResources

protected void initializeResources()
                            throws Exception
initialize the resources

Throws:
Exception

initUsersRepository

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

Throws:
Exception

getCommandListservManager

protected ICommandListservManager getCommandListservManager()
lazy retrieval

Returns:
ICommandListservManager

getCommandListservFooter

protected CommandListservFooter getCommandListservFooter()
                                                  throws MessagingException
Lazy init

Throws:
MessagingException

getField

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

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

initAllowedPosters

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

checkAllowedPoster

protected boolean checkAllowedPoster(Mail mail,
                                     Collection members)
                              throws 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:
MessagingException


"Copyright © 1999-2006 Apache Jakarta Project. All Rights Reserved."