<commit_before>/*****************************************************************************
 * Copyright (C) The Apache Software Foundation. All rights reserved.        *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Apache Software License *
 * version 1.1, a copy of which has been included  with this distribution in *
 * the LICENSE file.                                                         *
 *****************************************************************************/

package org.apache.james.transport.servlet;

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import org.apache.arch.*;
import org.apache.james.*;
import org.apache.avalon.blocks.*;
import org.apache.mail.*;
import org.apache.james.transport.*;

/**
 * Routes a given email address to a list of members, based on simple
 * listserv settings
 *
 * @author  <NAME> <<EMAIL>>
 */
public class MiniListserv extends GenericListserv {
    protected boolean membersOnly = false;
    protected boolean attachmentsAllowed = true;
    protected boolean replyToList = true;
    protected String subject = null;
    protected String listservAddress = null;
    protected Vector members = null;

    public void init () {
        listservAddress = getConfiguration ("listservaddress").getValue();
        subject = getConfiguration ("subject").getValue();
        membersOnly = getConfiguration("membersonly", "false").getValueAsBoolean();
        attachmentsAllowed = getConfiguration("attachmentsallowed", "true").getValueAsBoolean ();
        replyToList = getConfiguration("replytolist", "true").getValueAsBoolean ();
        members = new Vector();
        for (Enumeration e = getConfigurations("member"); e.hasMoreElements(); ) {
            Configuration c = (Configuration) e.nextElement();
            members.addElement(c.getValue());
        }
    }

    protected Vector getMembers() {
        return members;
    }

    protected boolean isMembersOnly() {
        return membersOnly;
    }

    protected boolean isAttachmentsAllowed() {
        return attachmentsAllowed;
    }

    protected boolean isReplyToList() {
        return replyToList;
    }

    protected String getSubject() {
        return subject;
    }

    protected String getListservAddress() {
        return listservAddress;
    }

    public String getServletInfo() {
        return "MiniListserv Servlet";
    }
}

<commit_msg>Added a sample avalon.conf.xml configuration for this servlet in the javadoc for the class.<commit_after>/*****************************************************************************
 * Copyright (C) The Apache Software Foundation. All rights reserved.        *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Apache Software License *
 * version 1.1, a copy of which has been included  with this distribution in *
 * the LICENSE file.                                                         *
 *****************************************************************************/

package org.apache.james.transport.servlet;

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import org.apache.arch.*;
import org.apache.james.*;
import org.apache.avalon.blocks.*;
import org.apache.mail.*;
import org.apache.james.transport.*;

/**
 * Routes a given email address to a list of members, based on simple
 * listserv settings.
 *
 * Sample configuration in avalon.conf.xml:
 * <pre>
 * <servlet match="RecipientIs=<EMAIL>" class="MiniListserv">
 *     <listservaddress><EMAIL></listservaddress> <!--this will likely be removed shortly-->
 *     <subject>Test</subject>
 *     <membersonly>true</membersonly>
 *     <attachmentsallowed>false</attachmentsallowed>
 *     <replytolist>true</replytolist>
 *     <member><EMAIL></member>
 *     <member><EMAIL></member>
 * </servlet>
 * </pre>
 * @author  <NAME> <<EMAIL>>
 */
public class MiniListserv extends GenericListserv {
    protected boolean membersOnly = false;
    protected boolean attachmentsAllowed = true;
    protected boolean replyToList = true;
    protected String subject = null;
    protected String listservAddress = null;
    protected Vector members = null;

    public void init () {
        listservAddress = getConfiguration ("listservaddress").getValue();
        subject = getConfiguration ("subject").getValue();
        membersOnly = getConfiguration("membersonly", "false").getValueAsBoolean();
        attachmentsAllowed = getConfiguration("attachmentsallowed", "true").getValueAsBoolean ();
        replyToList = getConfiguration("replytolist", "true").getValueAsBoolean ();
        members = new Vector();
        for (Enumeration e = getConfigurations("member"); e.hasMoreElements(); ) {
            Configuration c = (Configuration) e.nextElement();
            members.addElement(c.getValue());
        }
    }

    protected Vector getMembers() {
        return members;
    }

    protected boolean isMembersOnly() {
        return membersOnly;
    }

    protected boolean isAttachmentsAllowed() {
        return attachmentsAllowed;
    }

    protected boolean isReplyToList() {
        return replyToList;
    }

    protected String getSubject() {
        return subject;
    }

    protected String getListservAddress() {
        return listservAddress;
    }

    public String getServletInfo() {
        return "MiniListserv Servlet";
    }
}


{'fraction_non_alphanumeric': 0.17908827785817655, 'fraction_numerical': 0.000723589001447178, 'mean_word_length': 2.8502785515320332, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4438245', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1277, 'n_words': 376}