FileDocCategorySizeDatePackage
AvalonListserv.javaAPI DocApache James 2.3.18110Fri Jan 12 12:56:28 GMT 2007org.apache.james.transport.mailets

AvalonListserv

public class AvalonListserv extends GenericListserv
MailingListServer capability.

Requires a configuration element in the config.xml file of the form:
<mailet match="RecipientIs=LIST-ADDRESS" class="AvalonListserv">
<repositoryName>LIST-NAME</repositoryName>
<membersonly>[true|false]</membersonly>
<attachmentsallowed>[true|false]</attachmentsallowed>
<replytolist>[true|false]</replytolist>
<autobracket>[true|false]</autobracket>
<subjectprefix [xml:space="preserve"]>SUBJECT-PREFIX</subjectprefix>
</mailet>

repositoryName - the name of a user repository configured in the UsersStore block, e.g.,
<repository name="list-name" class="org.apache.james.userrepository.ListUsersJdbcRepository" destinationURL="db://maildb/lists/list-name">
<sqlFile>file://conf/sqlResources.xml</sqlFile>
</repository>

or
<repository name="list-name" class="org.apache.james.userrepository.UsersFileRepository">
<destination URL="file://var/lists/list-name/"/>
</repository>

membersonly - if true only members can post to the list

attachmentsallowed - if false attachments are not allowed

replytolist - if true, replies go back to the list address; if false they go to the sender.

subjectprefix - a prefix that will be inserted at the front of the subject. If autobracketing is disabled (see below), the xml:space="preserve" attribute can be used to precisely control the prefix.

autobracket - if true the subject prefix will be rendered as "[PREFIX] ", if false, the prefix will be used literally.

version
This is $Revision: 494012 $

Fields Summary
protected boolean
membersOnly
Whether only members can post to the list
protected boolean
attachmentsAllowed
Whether attachments can be sent to the list
protected boolean
replyToList
Whether the reply-to header should be set to the list address
protected String
subjectPrefix
A String to prepend to the subject of the message when it is sent to the list
protected boolean
autoBracket
Whether the subject prefix should be bracketed with '[' and ']'
private org.apache.james.services.UsersRepository
members
The repository containing the users on this list
Constructors Summary
Methods Summary
public java.lang.StringgetMailetInfo()
Return a string describing this mailet.

return
a string describing this mailet

        return "AvalonListserv Mailet";
    
public java.util.CollectiongetMembers()

        Collection reply = new ArrayList();
        for (Iterator it = members.list(); it.hasNext(); ) {
            String member = it.next().toString();
            try {
                reply.add(new MailAddress(member));
            }
            catch(Exception e) {
                // Handle an invalid subscriber address by logging it and
                // proceeding to the next member.
                StringBuffer logBuffer =
                    new StringBuffer(1024)
                            .append("Invalid subscriber address: ")
                            .append(member)
                            .append(" caused: ")
                            .append(e.getMessage());
                log(logBuffer.toString());
            }
        }
        return reply;
    
public java.lang.StringgetSubjectPrefix()
Get the prefix prepended to the subject line

return
whether the prefix for subjects on this list will be bracketed.

        return subjectPrefix;
    
public voidinit()
Initialize the mailet


            
       
        try {
            membersOnly = new Boolean(getInitParameter("membersonly")).booleanValue();
        } catch (Exception e) {
            // Ignore any exceptions, default to false
        }
        try {
            attachmentsAllowed = new Boolean(getInitParameter("attachmentsallowed")).booleanValue();
        } catch (Exception e) {
            // Ignore any exceptions, default to true
        }
        try {
            replyToList = new Boolean(getInitParameter("replytolist")).booleanValue();
        } catch (Exception e) {
            // Ignore any exceptions, default to true
        }
        subjectPrefix = getInitParameter("subjectprefix");

        try {
            autoBracket = new Boolean(getInitParameter("autobracket")).booleanValue();
        } catch (Exception e) {
            // Ignore any exceptions, default to true
        }

        ServiceManager compMgr = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
        try {
            UsersStore usersStore = (UsersStore)compMgr.lookup(UsersStore.ROLE);
            String repName = getInitParameter("repositoryName");

            members = (UsersRepository)usersStore.getRepository( repName );
        } catch (ServiceException cnfe) {
            log("Failed to retrieve Store component:" + cnfe.getMessage());
        } catch (Exception e) {
            log("Failed to retrieve Store component:" + e.getMessage());
        }
    
public booleanisAttachmentsAllowed()
Get whether attachments can be sent to this list

return
whether attachments can be sent to this list

        return attachmentsAllowed;
    
public booleanisMembersOnly()
Get whether posting to this list is restricted to list members

return
whether posting to this list is restricted to list members

        return membersOnly;
    
public booleanisPrefixAutoBracketed()
Return whether the prefix for subjects on this list will be bracketed.

return
whether the prefix for subjects on this list will be bracketed.

        return autoBracket;
    
public booleanisReplyToList()
Get whether the reply-to header for messages sent to this list will be replaced with the list address

return
whether replies to messages posted to this list will go to the entire list

        return replyToList;