head	1.31;
access;
symbols
	TIGRIS_0_9_2_4:1.23.2.1
	TIGRIS_0_9_2_3:1.23.2.1
	HELM_PEER_PORT_BRANCH:1.29.0.2
	TURBINE_PEER:1.29
	TIGRIS_0_9_2_1:1.29
	TIGRIS_0_9_2:1.23.0.2
	TIGRIS_0_9_0:1.21.0.2
	TIGRIS_0_8_4:1.13.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.31
date	2001.02.21.02.20.02;	author dlr;	state dead;
branches;
next	1.30;

1.30
date	2001.02.13.00.20.09;	author edk;	state Exp;
branches;
next	1.29;

1.29
date	2001.01.26.18.29.11;	author edk;	state Exp;
branches
	1.29.2.1;
next	1.28;

1.28
date	2001.01.26.05.24.08;	author edk;	state dead;
branches;
next	1.27;

1.27
date	2001.01.25.02.42.47;	author edk;	state Exp;
branches;
next	1.26;

1.26
date	2001.01.25.00.26.08;	author edk;	state Exp;
branches;
next	1.25;

1.25
date	2001.01.24.20.42.50;	author dlr;	state Exp;
branches;
next	1.24;

1.24
date	2001.01.19.07.06.46;	author edk;	state Exp;
branches;
next	1.23;

1.23
date	2000.12.23.00.48.20;	author dlr;	state Exp;
branches
	1.23.2.1;
next	1.22;

1.22
date	2000.12.22.03.03.00;	author dlr;	state Exp;
branches;
next	1.21;

1.21
date	2000.12.14.04.03.04;	author edk;	state Exp;
branches;
next	1.20;

1.20
date	2000.12.14.02.50.36;	author edk;	state Exp;
branches;
next	1.19;

1.19
date	2000.12.14.02.28.47;	author edk;	state Exp;
branches;
next	1.18;

1.18
date	2000.12.09.07.40.47;	author edk;	state Exp;
branches;
next	1.17;

1.17
date	2000.12.08.10.01.05;	author edk;	state Exp;
branches;
next	1.16;

1.16
date	2000.12.08.01.34.38;	author edk;	state Exp;
branches;
next	1.15;

1.15
date	2000.12.05.23.53.31;	author leonardr;	state Exp;
branches;
next	1.14;

1.14
date	2000.12.05.23.28.59;	author leonardr;	state Exp;
branches;
next	1.13;

1.13
date	2000.12.01.16.22.26;	author edk;	state Exp;
branches;
next	1.12;

1.12
date	2000.12.01.06.12.51;	author edk;	state Exp;
branches;
next	1.11;

1.11
date	2000.11.30.12.31.00;	author edk;	state Exp;
branches;
next	1.10;

1.10
date	2000.11.30.11.46.32;	author edk;	state Exp;
branches;
next	1.9;

1.9
date	2000.11.29.21.20.39;	author edk;	state Exp;
branches;
next	1.8;

1.8
date	2000.11.29.21.10.26;	author edk;	state Exp;
branches;
next	1.7;

1.7
date	2000.11.29.01.44.22;	author edk;	state Exp;
branches;
next	1.6;

1.6
date	2000.11.17.05.41.33;	author edk;	state Exp;
branches;
next	1.5;

1.5
date	2000.11.17.01.51.41;	author edk;	state Exp;
branches;
next	1.4;

1.4
date	2000.11.15.17.08.54;	author edk;	state Exp;
branches;
next	1.3;

1.3
date	2000.11.15.14.58.39;	author edk;	state Exp;
branches;
next	1.2;

1.2
date	2000.11.13.19.45.21;	author edk;	state Exp;
branches;
next	1.1;

1.1
date	2000.11.12.21.16.56;	author dlr;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.11.12.21.16.56;	author dlr;	state Exp;
branches;
next	;

1.23.2.1
date	2001.01.19.07.08.32;	author edk;	state Exp;
branches;
next	;

1.29.2.1
date	2001.01.28.01.02.20;	author dlr;	state dead;
branches;
next	;


desc
@@


1.31
log
@Moved by Peer port.
@
text
@/* ================================================================
 * Copyright (c) 2000 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by CollabNet (http://www.Collab.Net/)."
 * Alternately, this acknowlegement may appear in the software itself, if
 * and wherever such third-party acknowlegements normally appear.
 * 
 * 4. The hosted project names must not be used to endorse or promote
 * products derived from this software without prior written
 * permission. For written permission, please contact info@@collab.net.
 * 
 * 5. Products derived from this software may not use the "Tigris" name
 * nor may "Tigris" appear in their names without prior written
 * permission of CollabNet.
 * 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * ====================================================================
 * 
 * This software consists of voluntary contributions made by many
 * individuals on behalf of CollabNet.
 */

package org.tigris.helm.tool.mail;

import java.lang.reflect.*;
import java.io.InputStream;
import java.io.IOException;
import java.sql.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Properties;
import java.util.Map;
import java.util.Dictionary;

import com.workingdogs.village.*;

import org.webmacro.util.Log;
import org.webmacro.servlet.HandlerException;

import org.joist.database.*;
import org.joist.util.JoistProperties;

import org.tigris.helm.*;
import org.tigris.helm.database.*;
import org.tigris.helm.domain.BusinessObject;
import org.tigris.helm.domain.User;
import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.security.ACLException;

import org.tigris.helm.project.Project;

/**
 * A business object for MailingLists
 *
 * @@author <a href="mailto:elicia@@collab.net">Elicia David</a>
 * @@author <a href="mailto:edk@@collab.net">Ed Korthof</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: MailingList.java,v 1.30 2001/02/13 00:20:09 edk Exp $
 */
public class MailingList extends BusinessObject
{
    private static Log log = new Log("ml", "MailingList(helm)");
    private static final boolean debug = true;

    protected final String getTableName() { return MailingListManager.TABLE_NAME; }

    private MailingListManager mlMgr;
    private String project;
    private String domain;
    private Object mailingListSpec = null;
    private boolean exists = true;
    private static boolean anzu = false;
    private static boolean eyebrowse = false;

    private User owner = null;
    
    // TODO : we should get this via reflection from a class in anzu
    private final static String clientProperties = "anzu.properties";

    /**
     * Where should archive e-mail go
     */
    protected static String mailArchiveHost = null;

    /**
     * The prefix required for lists and addresses.
     */
    protected static String mailPrefix = null;

    static {
        try {
            InputStream is =
                org.tigris.helm.tool.mail.MailingList.class.
                getResourceAsStream('/' + clientProperties);
            if (is == null) {
                log.exception("unable to read "+clientProperties +
                        " to get information about mailArchiveHost");
            } else {
                Properties prop = new Properties();
                prop.load(is);
                mailArchiveHost = prop.getProperty("mail_archive_host");
                if (mailArchiveHost == null) {
                    log.exception("did not find archive_mail_host in init");
                } else {
                    if (debug) log.warning("got mailArchiveHost: " +
                            mailArchiveHost);
                }
                mailPrefix = prop.getProperty("mail_prefix", "");
                if (mailPrefix == null)
                    mailPrefix = "";
            }
        } catch (Exception e) {
            log.exception(e);
            log.exception("unable to read archive_mail_host in init");
            mailArchiveHost = null;
        }
        if (mailArchiveHost == null) {
            log.exception("archive_mail_host not found; archiver addresses "+
                    "will not be subscribed automatically.");
        }
    }

    /**
     * Constructor for a mailing list which already exists.
     */
    public MailingList(Connection c, DataManager dMgr, Record r)
        throws DoesNotExist, DataSetException
    {
        super(c, dMgr, r);
        try {
            getProjectDomain(getProjectID());
        } catch (DataSetException e) {
            log.exception(e);
            log.error("unable to get projectID for existing MailingList");
            project = "unknown_project";
        }
    }

    /**
     * Creates the necessary table managers.
     */
    protected void createManagers ()
    {
        if (mlMgr == null)
        {
            mlMgr = (MailingListManager)
                dMgr.getManager("org.tigris.helm.database.MailingListManager");
        }
    }

    /**
     * Constructor for a mailing list which already exists --
     * accessed by projectID and mailing list name
     */
    public MailingList(Connection c, DataManager dMgr, String projectID,
                       String list)
        throws DataSetException, SQLException, DoesNotExist
    {
        super(c, dMgr);
        setRecord(mlMgr.getMailingListByName(conn, projectID, list));
        getProjectDomain(projectID);
    }

    /**
     * Constructor for a mailing list which already exists --
     * accessed by mailing list ID and ensuring that the list is in
     * the project specified.
     */
    public MailingList(Connection c, DataManager dMgr,
            String mailingListID, Project project)
        throws DataSetException, SQLException, DoesNotExist, ACLException
    {
        super(c,dMgr);
        setRecord(mlMgr.getMailingListByID(conn, mailingListID));
        if (!getProjectID().equals(project.getID()))
            throw new DoesNotExist("mailing list not in specified project");
        getProjectDomain(getProjectID());
    }

    /**
     * Constructor for a mailing list which doesn't exist yet.
     */
    public MailingList(Connection c, DataManager dMgr, String name,
                       String description, String projectID, String type)
        throws HandlerException, DoesNotExist
    {
        super(c, dMgr);
        try {
            setRecord(mlMgr.createRecord(c));
            rec.setValue(MailingListManager.PROJECT_ID_COLNAME,  projectID);
            rec.setValue(MailingListManager.LIST_NAME_COLNAME,   name);
            rec.setValue(MailingListManager.DESCRIPTION_COLNAME, description);
            getProjectDomain(projectID);
            this.setType(type);
        } catch (SQLException e) {
            log.exception(e);
            if (debug) log.debug("SQLException creating new mailing list");
            throw new HandlerException("sql error: " + e.getMessage());
        } catch (DataSetException e) {
            log.exception(e);
            if (debug) log.info("DataSetException creating new mailing list");
            throw new HandlerException("DataSetException: " + e.getMessage());
        }
        this.exists = false;
    }

    private void getProjectDomain(String projectID) {
        ProjectManager projMgr = (ProjectManager)
            dMgr.getManager("org.tigris.helm.database.ProjectManager");
        try {
            project = projMgr.getProjectName(conn, projectID);
        }  catch (Exception e) {
            log.exception(e);
            if (debug) log.warning("unable to get proj name: "+e.getMessage());
            project = projectID;
        }
        try {
            domain = projMgr.getProjectDomain(conn, getProjectID());
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.warning("unable to get domain: " +e.getMessage());
            domain = "";
        }
    }

    public boolean exists() {
        return exists;
    }

    public String getID()
        throws DataSetException
    {
        return rec.getValue(MailingListManager.LIST_ID_COLNAME).toString();
    }

    public String getName()
        throws DataSetException
    {
        return rec.getValue(MailingListManager.LIST_NAME_COLNAME).toString();
    }

    public String getDescription()
        throws DataSetException
    {
        return rec.getValue(MailingListManager.DESCRIPTION_COLNAME).toString();
    }

    public String getProjectName()
    {
        return project;
    }
    
    /**
     * This is used by templates to get the appropriate domain for this
     * mailing list.  The logic has been moved here so as to make it
     * easier to change (eg. for supporting a "default" vhost like www),
     * and to make it easier to support both vhosted and non vhosted modes.
     */
    public String getEmailDomain()
    {
        if (!project.equals("www"))
            return project + '.' + domain;
        else
            return domain;
    }

    /**
     * This is used by templates to get the appropriate list prefix.
     * For vhosted lists, that's getName() ; but for non-vhosted list,
     * it'll be project-getName().
     */
    public String getEmailPrefix() throws DataSetException
    {
        return mailPrefix + getName();
    }

    /**
     * This should probably replace getEmailDomain/getEmailPrefix.
     * If used w/ a null argument or an empty String, it will return
     * the address to post to this list.  Otherwise, it'll return the
     * address for the given command.
     *
     * @@param command the command to run, or null for the posting address
     * @@return an e-mail address
     */
    public String getAddress(String command) throws DataSetException {
        if (command == null || command.equals(""))
            return getEmailPrefix() + "@@" + project + "." + domain;
        else
            return getEmailPrefix() + "-" + command + "@@" + project +
                "." + domain;
    }

    public String getProjectID() throws DataSetException
    {
        return rec.getValue(MailingListManager.PROJECT_ID_COLNAME).toString();
    }

    public String getType()
        throws DataSetException
    {
        return rec.getValue(MailingListManager.TYPE_COLNAME).toString();
    }

    public void setType(String type) throws DataSetException, HandlerException
    {
        rec.setValue(MailingListManager.TYPE_COLNAME,  type);
        if (anzuDisabled()) return;
        Object args[] = { type };
        try {
            MLS_setListType.invoke(mailingListSpec, args);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("anzu error: "+e.getMessage());
        }
        // This is part of the business logic -- it belongs here.  It
        // needs to be called every time setType is because setType
        // will overwrite all the current options ...
        if (mailPrefix != null)
            setStringOption("mail_prefix", mailPrefix);
    }

    public void setDescription(String description) throws DataSetException
    {
        rec.setValue(MailingListManager.DESCRIPTION_COLNAME, description);
    }

    public void setOwner(User owner) throws HandlerException, DataSetException
    {
        this.owner = owner;
        if (exists) {
            setStringOption("owner", owner.getEmail());
        }
    }

    protected static Constructor mailingListSpecConstructor = null;
    protected static Method MLS_create = null; // void
    protected static Method MLS_update = null; // void
    protected static Method MLS_delete = null; // void
    protected static Method MLS_setListType = null; //void
    protected static Method MLS_setBooleanOption = null; //void
    protected static Method MLS_setStringOption = null; //void
    protected static Method MLS_getBooleanOption = null; //void
    protected static Method MLS_getStringOption = null; //void
    protected static Method MLS_getListTypes = null; //List
    protected static Method MLS_getOptionTypes = null; //List
    protected static Method MLS_getOptionsMap = null; //List
    protected static Method MLS_getOptionsList = null; //List
    protected static Method MLS_subscribe = null; //void
    protected static Method MLS_unsubscribe = null; //void
    protected static Method MLS_listMembers = null; //List
    protected static Method ELM_deleteList = null; //void
    protected static Method ELM_addList = null; // void
    protected static Method ELM_addListFile = null; // void
    static {
        try {
            Class MLSClass =
                Class.forName("org.tigris.anzu.client.MailingListSpec");
            {
                Class argTypes[] = {
                        String.class, String.class, String.class
                };
                mailingListSpecConstructor =
                    MLSClass.getConstructor(argTypes);
            }

            {
                Class argTypes[] = {};
                MLS_create = MLSClass.getDeclaredMethod("create", argTypes);
                MLS_update = MLSClass.getDeclaredMethod("update", argTypes);
                MLS_delete = MLSClass.getDeclaredMethod("delete", argTypes);
                MLS_getOptionsList =
                    MLSClass.getDeclaredMethod("getOptionsList", argTypes);
                MLS_getOptionsMap =
                    MLSClass.getDeclaredMethod("getOptionsMap", argTypes);
                MLS_getOptionTypes =
                    MLSClass.getDeclaredMethod("getOptionTypes", argTypes);
                MLS_getListTypes =
                    MLSClass.getDeclaredMethod("getListTypes", argTypes);
            }

            {
                Class argTypes[] = {
                    List.class, String.class
                };
                MLS_subscribe =
                    MLSClass.getDeclaredMethod("subscribe", argTypes);
                MLS_unsubscribe =
                    MLSClass.getDeclaredMethod("unsubscribe", argTypes);
            }

            {
                Class argTypes[] = {
                    String.class
                };
                MLS_setListType =
                    MLSClass.getDeclaredMethod("setListType", argTypes);
                MLS_getBooleanOption =
                    MLSClass.getDeclaredMethod("getBooleanOption", argTypes);
                MLS_getStringOption =
                    MLSClass.getDeclaredMethod("getStringOption", argTypes);
                MLS_listMembers =
                    MLSClass.getDeclaredMethod("listMembers", argTypes);
            }

            {
                Class argTypes[] = {
                    String.class, String.class
                };
                MLS_setStringOption =
                    MLSClass.getDeclaredMethod("setStringOption", argTypes);
            }

            {
                Class argTypes[] = {
                    String.class, Boolean.class
                };
                MLS_setBooleanOption =
                    MLSClass.getDeclaredMethod("setBooleanOption", argTypes);
            }
            anzu = true;

            Class ELMClass =
                Class.forName("org.tigris.eyebrowse.ListMaint");
            {
                Class argTypes[] = {
                    String.class
                };
                ELM_deleteList =
                    ELMClass.getDeclaredMethod("deleteList", argTypes);
            }

            {
                Class argTypes[] = {
                    String.class, String.class
                };
                ELM_addListFile = // String list name, String filename
                    ELMClass.getDeclaredMethod("addListFile", argTypes);
            }
            {
                Class argTypes[] = {
                    String.class, String.class, Integer.class
                };
                ELM_addList = // String listName, String desc, String ID
                    ELMClass.getDeclaredMethod("addList", argTypes);
            }
            eyebrowse = true;

        } catch (ClassNotFoundException e) {
            if (!anzu)
                log.debug("anzu classes do not appear to be in the classpath");
            else
                log.debug("eyebrowse classes do not appear to be in cp");
        } catch (NoSuchMethodException e) {
            if (!anzu)
                log.debug("anzu classes missing expected method " +
                        e.getMessage());
            else
                log.debug("eyebrowse classes missing expected method " +
                        e.getMessage());
            e.printStackTrace();
            throw new RuntimeException("invalid version of anzu(missing)");
        } catch (SecurityException e) {
            if (!anzu)
                log.debug("anzu req method is not available" +
                        e.getMessage());
            else
                log.debug("eyebrowse req method is not available " +
                        e.getMessage());
            e.printStackTrace();
            throw new RuntimeException("invalid version of anzu(security)");
        }
    }

    /**
     * This method is used to connect with the anzu classes.  It does
     * implicitly connect to the remote anzu server.  It uses reflection
     * to avoid requiring anzu to compile.
     * 
     * @@return a boolean indicating whether or not the connection attempt
     * was successful
     */
    public boolean connect()
    {
        if (mailingListSpec != null) return true;
        try {
            Object args[] = {
                domain, project, getName()
            };
            mailingListSpec = mailingListSpecConstructor.newInstance(args);
            setStringOption("mail_prefix", mailPrefix);
        } catch (Exception e) {
            log.debug("got exception trying to connect");
            log.exception(e);
            mailingListSpec = null;
            return false;
        }
        return true;
    }

    /**
     * The MailingListManager needs to have access to the underlying
     * record.
     */
    public Record getRecord()
    {
        return rec;
    }

    private boolean anzuDisabled() throws HandlerException
    {
        if (!anzu) {
            log.error("anzu is not installed, so MailingList.* is noop");
            return true;
        } else if (!connect()) {
            log.error("unable to connect to anzu server; bailing out");
            throw new HandlerException("anzu is installed but the server " +
                    "is not running");
        }
        return false;
    }

    public String getArchiveAddress() throws DataSetException
    {
        if (mailArchiveHost == null) {
            log.warning("unable to determine archive address, since " +
                    "mail_archive_host was not set.");
            return null;
        }
        return mailPrefix + "archive=mail-" + project + '=' +
            getName() + '=' + domain + '@@' + mailArchiveHost;
    }

    void handleArchiveAddition() throws Exception
    {
        log.warning("trying to add archiver to list");
        if (mailArchiveHost == null) {
            log.warning("not adding archiver to list " + getName() +
                    " in project " + project);
            return;
        }

        ArrayList addrs = new ArrayList();

        addrs.add(getArchiveAddress());
        Object args[] = { addrs, ""};
        MLS_subscribe.invoke(mailingListSpec, args);

        eyebrowseAddList();
    }

    void eyebrowseAddList() throws Exception
    {
        log.warning("trying to add mailing list file with eyebrowse");
        String listName = getAddress(null);
        {
            Object args[] = { listName, getDescription(),
                Integer.valueOf(getID()) };
            ELM_addList.invoke(null, args);
        }
        {
            Object args[] = { listName,
                (String) JoistProperties.getProperty("SANDBOX") +
                "/data/eyebrowse/" + domain + "/" +
                project+"/"+getName()+"/0mbox" };
            ELM_addListFile.invoke(null, args);
        }
    }

    public void create(AccessControlList acl)
        throws ACLException, HandlerException, AlreadyExists
    {
        checkPermission(acl, "Add");
        create();
    }

    public void create() throws HandlerException, AlreadyExists {
        if (anzuDisabled()) return;
        if (owner != null) {
            try {
                setStringOption("owner", owner.getEmail());
            } catch (DataSetException e) {
                if (debug) log.exception("invalid user given to setOwner: " +
                        e.getMessage());
            }
        }

        try {
            mlMgr.addMailingList(conn, this);
        } catch (DataSetException e) {
            log.exception(e);
            if (debug) log.debug("DataSetException in mlMgr.addML");
            throw new HandlerException(e.getMessage());
        } catch (SQLException e) {
            log.exception(e);
            if (debug) log.debug("SQLException in mlMgr.addML");
            throw new HandlerException(e.getMessage());
        }
        try {

            MLS_create.invoke(mailingListSpec, null);
            try {
                handleArchiveAddition();
            } catch (Exception ignore) {
                log.exception("eyebrowse couldn't create archives.  oh well.");
                log.exception(ignore);
            }
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            try {
                mlMgr.deleteMailingList(conn, this);
            } catch (Exception e2) {
                log.exception(e2);
                log.error("error trying to roll back addition of mailing " +
                        "list to database after anzu error; the database " +
                        "may not be in a consistent state!");
                throw new HandlerException("ERROR : database may be in an " +
                        "invalid state after partial failure");
            }
            throw new HandlerException("anzu failed to create mailing list");
        }
        if (owner != null) {
            try {
                ArrayList autoSubscribe = new ArrayList();
                autoSubscribe.add(owner.getEmail());
                subscribe(autoSubscribe, "mod");
                subscribe(autoSubscribe, "allow");
            } catch (Exception e) {
                if (debug) log.exception("unable to add owner to mod/allow: " +
                        e.getMessage());
            }
        }
        exists = true;
    }

    public void update(AccessControlList acl)
        throws ACLException, HandlerException
    {
        checkPermission(acl, "Edit");
        update();
    }

    public void update() throws HandlerException {
        if (anzuDisabled()) return;
        try {
            mlMgr.updateMailingList(conn, this);
        } catch (DataSetException e) {
            log.exception(e);
            if (debug) log.debug("DataSetException in mlMgr.updateML");
            throw new HandlerException(e.getMessage());
        } catch (SQLException e) {
            log.exception(e);
            if (debug) log.debug("SQLException in mlMgr.updateML");
            throw new HandlerException(e.getMessage());
        }
        try {
            MLS_update.invoke(mailingListSpec, null);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("ERROR anzu update mailing list " +
                    "failed -- the database may be in an invalid state.");
        }
    }

    private void checkPermission(AccessControlList acl, String operation)
        throws ACLException, HandlerException
    {
        try {
            acl.assertPermissionForProject("Mailing List - " + operation,
                    //getName(),
                    getProjectID());
        } catch (DataSetException e) {
            log.exception(e);
            if (debug) log.info("datasetexception adding ml: "+e.getMessage());
            throw new HandlerException("unable to add ml: " + e.getMessage());
        }
    }



    public void delete(AccessControlList acl)
        throws ACLException, HandlerException
    {
        checkPermission(acl, "Delete");
        delete();
    }

    public void delete() throws HandlerException
    {
        if (anzuDisabled()) return;
        try {
            String listName = getAddress(null);
            Object args[] = { listName };
            ELM_deleteList.invoke(null, args);
        } catch (Exception e) {
            log.exception(e);
            log.warning("exception from EB: " + e.getMessage());
            throw new HandlerException("ERROR EB deleteList failed -- " +
                    "the database may be in an invalid state: " +
                    e.getMessage());
        }
        try {
            mlMgr.deleteMailingList(conn, this);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception in deleteML: " + e.getMessage());
            throw new HandlerException("ERROR MailingListManager.delete " +
                    "failed -- the database may be in an invalid state: " +
                    e.getMessage());
        }
        try {
            MLS_delete.invoke(mailingListSpec, null);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("ERROR anzu delete mailing list " +
                    "failed -- the database may be in an invalid state: " +
                    e.getMessage());
        }
    }

    public List listMembers(String group) throws HandlerException
    {
        if (anzuDisabled()) return null;
        Object args[] = { group };
        try {
            return (List)MLS_listMembers.invoke(mailingListSpec, args);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("unable to use anzu listMembers");
        }
    }

    public void subscribe(List addr, String group)
        throws HandlerException
    {
        if (anzuDisabled()) return;
        Object args[] = { addr, group };
        try {
            MLS_subscribe.invoke(mailingListSpec, args);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("unable to use anzu subscribe");
        }
    }

    public void unsubscribe(List addr, String group) 
        throws HandlerException
    {
        if (anzuDisabled()) return;
        Object args[] = { addr, group };
        try {
            MLS_unsubscribe.invoke(mailingListSpec, args);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("unable to use anzu unsubscribe");
        }
    }

    public void setBooleanOption(String option,
            Boolean value) throws HandlerException
    {
        if (anzuDisabled()) return;
        Object args[] = { option, value };
        try {
            MLS_setBooleanOption.invoke(mailingListSpec, args);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("anzu error: "+e.getMessage());
        }
    }


    public void setStringOption(String option,
            String value) throws HandlerException
    {
        if (anzuDisabled()) return;
        Object args[] = { option, value };
        try {
            MLS_setStringOption.invoke(mailingListSpec, args);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("anzu error: "+e.getMessage());
        }
    }

    public Boolean getBooleanOption(String option) throws HandlerException
    {
        if (anzuDisabled()) return null;
        Object args[] = { option };
        try {
            return (Boolean)MLS_getBooleanOption.invoke(mailingListSpec, args);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("anzu error: "+e.getMessage());
        }
    }

    public String getStringOption(String option) throws HandlerException
    {
        if (anzuDisabled()) return null;
        Object args[] = { option };
        try {
            return (String)MLS_getStringOption.invoke(mailingListSpec, args);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("anzu error: "+e.getMessage());
        }
    }

    public List getListTypes() throws HandlerException
    {
        if (anzuDisabled()) return null;
        try {
            return (List)MLS_getListTypes.invoke(mailingListSpec, null);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("anzu error: "+e.getMessage());
        }
    }

    public List getOptionsList() throws HandlerException
    {
        if (anzuDisabled()) return null;
        try {
            return (List)MLS_getOptionsList.invoke(mailingListSpec, null);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("anzu error: "+e.getMessage());
        }
    }

    public List getOptionTypes() throws HandlerException
    {
        if (anzuDisabled()) return null;
        try {
            return (List)MLS_getOptionTypes.invoke(mailingListSpec, null);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("anzu error: "+e.getMessage());
        }
    }

    public Map getOptionsMap() throws HandlerException
    {
        if (anzuDisabled()) return null;
        try {
            return (Map)MLS_getOptionsMap.invoke(mailingListSpec, null);
        } catch (Exception e) {
            log.exception(e);
            if (debug) log.debug("exception from anzu: "+e.getMessage());
            throw new HandlerException("anzu error: "+e.getMessage());
        }
    }
}
@


1.30
log
@switch from ArrayList to List where appropriate
@
text
@d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.29 2001/01/26 18:29:11 edk Exp $
@


1.29
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.24 2001/01/19 07:06:46 edk Exp $
d375 1
a375 1
    protected static Method MLS_subscribe = null; //ArrayList
d377 1
a377 1
    protected static Method MLS_listMembers = null; //void
d410 1
a410 1
                    ArrayList.class, String.class
d750 1
a750 1
    public ArrayList listMembers(String group) throws HandlerException
d755 1
a755 1
            return (ArrayList)MLS_listMembers.invoke(mailingListSpec, args);
d763 1
a763 1
    public void subscribe(ArrayList addr, String group)
d777 1
a777 1
    public void unsubscribe(ArrayList addr, String group) 
@


1.29.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.29 2001/01/26 18:29:11 edk Exp $
@


1.28
log
@revert this stuff to its state as of 2001/01/24 12:42:00 GMT -- with
the following exceptions, which have some different modifications so
they'll work with changes which have happened in joist:

ProjectNewsEdit.java
SkinManager.java
SkinStyleElementValueManager.java
StyleElementManager.java
StyleManager.java

it compiles.  i dunno if it works, though.
@
text
@d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.27 2001/01/25 02:42:47 edk Exp $
d151 2
a152 2
    public MailingList(DataManager dMgr, Record r)
        throws DoesNotExist, DBException
d154 8
a161 2
        super(dMgr, r);
        getProjectDomain(getProjectID());
d180 3
a182 2
    public MailingList(DataManager dMgr, String projectID, String list)
        throws DoesNotExist, DBException
d184 2
a185 2
        super(dMgr);
        setRecord(mlMgr.getMailingListByName(projectID, list));
d194 3
a196 2
    public MailingList(DataManager dMgr, String mailingListID, Project project)
        throws DoesNotExist, ACLException, DBException
d198 2
a199 2
        super(dMgr);
        setRecord(mlMgr.getMailingListByID(mailingListID));
d208 1
a208 1
    public MailingList(DataManager dMgr, String name,
d210 1
a210 1
        throws HandlerException
d212 1
a212 1
        super(dMgr);
d214 4
a217 4
            setRecord(mlMgr.createRecord());
            rec.setValue(MailingListManager.PROJECT_ID,  projectID);
            rec.setValue(MailingListManager.LIST_NAME,   name);
            rec.setValue(MailingListManager.DESCRIPTION, description);
d220 4
d226 2
a227 11
            if (debug) log.debug("DataSetException creating new mailing list");
            throw new HandlerException("DataSetException : " + e.getMessage());
        } catch (DoesNotExist what) {
            // err ... umm ... huh?
            log.exception(what);
            if (debug) log.info("DoesNotExist in creating new mailing list");
            throw new HandlerException("DoesNotExist : " + what.getMessage());
        } catch (DBException e) {
            log.exception(e);
            if (debug) log.debug("DBException creating new mailing list");
            throw new HandlerException("DBException error: " + e.getMessage());
d236 1
a236 1
            project = projMgr.getProjectName(projectID);
d243 1
a243 1
            domain = projMgr.getProjectDomain(getProjectID());
d255 2
a256 1
    public String getID() throws DBException
d258 1
a258 1
        return getField(MailingListManager.LIST_ID);
d261 2
a262 1
    public String getName() throws DBException
d264 1
a264 1
        return getField(MailingListManager.LIST_NAME);
d267 2
a268 1
    public String getDescription() throws DBException
d270 1
a270 1
        return getField(MailingListManager.DESCRIPTION);
d297 1
a297 1
    public String getEmailPrefix() throws DBException
d311 1
a311 1
    public String getAddress(String command) throws DBException {
d319 1
a319 1
    public String getProjectID() throws DBException
d321 1
a321 1
        return getField(MailingListManager.PROJECT_ID);
d324 2
a325 1
    public String getType() throws DBException
d327 1
a327 1
        return getField(MailingListManager.TYPE);
d330 1
a330 1
    public void setType(String type) throws DBException, HandlerException
d332 1
a332 5
        try {
            rec.setValue(MailingListManager.TYPE, type);
        } catch (DataSetException e) {
            throw new DBException(e);
        }
d349 1
a349 1
    public void setDescription(String description) throws DBException
d351 1
a351 5
        try {
            rec.setValue(MailingListManager.DESCRIPTION, description);
        } catch (DataSetException e) {
            throw new DBException(e);
        }
d354 1
a354 1
    public void setOwner(User owner) throws HandlerException, DBException
d549 1
a549 1
    public String getArchiveAddress() throws DBException
d608 2
a609 5
            } catch (DBException e) {
                log.exception(e);
                if (debug) log.info("unable to get owner email: " + 
                        e.getMessage());
                throw new HandlerException("unable to get owner email: " +
d615 6
a620 10
            setRecord(mlMgr.addMailingList(
                        getProjectID(),
                        getName(),
                        getDescription(),
                        getType()));
        } catch (DoesNotExist e) {
            log.exception(e);
            if (debug) log.debug("DoesNotExist " + e.getMessage());
            throw new HandlerException("DoesNotExist " + e.getMessage());
        } catch (DBException e) {
d622 1
a622 1
            if (debug) log.debug("DBException in mlMgr.addML");
d638 1
a638 1
                mlMgr.deleteMailingList(getID());
d673 2
a674 11
            setRecord(mlMgr.updateMailingList(
                        getID(),
                        getProjectID(),
                        getName(),
                        getDescription(),
                        getType()));
        } catch (DoesNotExist e) {
            log.exception(e);
            if (debug) log.debug("DoesNotExist " + e.getMessage());
            throw new HandlerException("DoesNotExist " + e.getMessage());
        } catch (DBException e) {
d676 5
a680 1
            if (debug) log.debug("DBException in mlMgr.updateML");
d700 1
a700 1
        } catch (DBException e) {
d702 1
a702 1
            if (debug) log.info("DBException adding ml: "+e.getMessage());
d731 1
a731 1
            mlMgr.deleteMailingList(getID());
@


1.27
log
@more changes to match the new pattern
@
text
@d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.26 2001/01/25 00:26:08 edk Exp $
@


1.26
log
@MailingList changes to more closely resemble other business objects (I
don't like certain parts of the pattern, but consistency is more important)
including changes to avoid keeping reference to Connections.
@
text
@d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.25 2001/01/24 20:42:50 dlr Exp $
d202 1
a202 1
        throws HandlerException, DoesNotExist
d212 9
d254 1
a254 1
        return getField(LIST_ID);
d259 1
a259 1
        return getField(LIST_NAME);
d264 1
a264 1
        return getField(DESCRIPTION);
d315 1
a315 1
        return getField(PROJECT_ID);
d320 1
a320 1
        return getField(TYPE);
d325 5
a329 1
        rec.setValue(MailingListManager.TYPE,  type);
d348 5
a352 1
        rec.setValue(MailingListManager.DESCRIPTION, description);
d355 1
a355 1
    public void setOwner(User owner) throws HandlerException, DataSetException
d609 5
a613 2
            } catch (DataSetException e) {
                if (debug) log.exception("invalid user given to setOwner: " +
d619 6
a624 6
            mlMgr.addMailingList(
                    getProjectID(),
                    getName(),
                    getDescription(),
                    getType());
        } catch (DataSetException e) {
d626 3
a628 3
            if (debug) log.debug("DataSetException in mlMgr.addML");
            throw new HandlerException(e.getMessage());
        } catch (SQLException e) {
d630 1
a630 1
            if (debug) log.debug("SQLException in mlMgr.addML");
d646 1
a646 1
                mlMgr.deleteMailingList(this);
d681 7
a687 7
            mlMgr.updateMailingList(
                    getID(),
                    getProjectID(),
                    getName(),
                    getDescription(),
                    getType());
        } catch (DataSetException e) {
d689 3
a691 3
            if (debug) log.debug("DataSetException in mlMgr.updateML");
            throw new HandlerException(e.getMessage());
        } catch (SQLException e) {
d693 1
a693 1
            if (debug) log.debug("SQLException in mlMgr.updateML");
d713 1
a713 1
        } catch (DataSetException e) {
d715 1
a715 1
            if (debug) log.info("datasetexception adding ml: "+e.getMessage());
d744 1
a744 1
            mlMgr.deleteMailingList(this);
@


1.25
log
@Making use of DBException.
@
text
@d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.24 2001/01/19 07:06:46 edk Exp $
d151 1
a151 1
    public MailingList(Connection c, DataManager dMgr, Record r)
d154 2
a155 8
        super(c, dMgr, r);
        try {
            getProjectDomain(getProjectID());
        } catch (DataSetException e) {
            log.exception(e);
            log.error("unable to get projectID for existing MailingList");
            project = "unknown_project";
        }
d174 2
a175 3
    public MailingList(Connection c, DataManager dMgr, String projectID,
                       String list)
        throws DataSetException, SQLException, DoesNotExist
d177 2
a178 2
        super(c, dMgr);
        setRecord(mlMgr.getMailingListByName(conn, projectID, list));
d187 2
a188 3
    public MailingList(Connection c, DataManager dMgr,
            String mailingListID, Project project)
        throws DataSetException, SQLException, DoesNotExist, ACLException
d190 2
a191 2
        super(c,dMgr);
        setRecord(mlMgr.getMailingListByID(conn, mailingListID));
d200 1
a200 1
    public MailingList(Connection c, DataManager dMgr, String name,
d204 1
a204 1
        super(c, dMgr);
d206 4
a209 4
            setRecord(mlMgr.createRecord(c));
            rec.setValue(MailingListManager.PROJECT_ID_COLNAME,  projectID);
            rec.setValue(MailingListManager.LIST_NAME_COLNAME,   name);
            rec.setValue(MailingListManager.DESCRIPTION_COLNAME, description);
d212 1
a212 5
        } catch (SQLException e) {
            log.exception(e);
            if (debug) log.debug("SQLException creating new mailing list");
            throw new HandlerException("sql error: " + e.getMessage());
        } catch (DataSetException e) {
d214 2
a215 2
            if (debug) log.info("DataSetException creating new mailing list");
            throw new HandlerException("DataSetException: " + e.getMessage());
d224 1
a224 1
            project = projMgr.getProjectName(conn, projectID);
d231 1
a231 1
            domain = projMgr.getProjectDomain(conn, getProjectID());
d243 1
a243 2
    public String getID()
        throws DBException
d245 1
a245 1
        return rec.getValue(MailingListManager.LIST_ID_COLNAME).toString();
d248 1
a248 2
    public String getName()
        throws DBException
d250 1
a250 1
        return rec.getValue(MailingListManager.LIST_NAME_COLNAME).toString();
d253 1
a253 2
    public String getDescription()
        throws DBException
d255 1
a255 1
        return rec.getValue(MailingListManager.DESCRIPTION_COLNAME).toString();
d306 1
a306 1
        return rec.getValue(MailingListManager.PROJECT_ID_COLNAME).toString();
d309 1
a309 2
    public String getType()
        throws DBException
d311 1
a311 1
        return rec.getValue(MailingListManager.TYPE_COLNAME).toString();
d316 1
a316 1
        rec.setValue(MailingListManager.TYPE_COLNAME,  type);
d335 1
a335 1
        rec.setValue(MailingListManager.DESCRIPTION_COLNAME, description);
d599 5
a603 1
            mlMgr.addMailingList(conn, this);
d626 1
a626 1
                mlMgr.deleteMailingList(conn, this);
d661 6
a666 1
            mlMgr.updateMailingList(conn, this);
d724 1
a724 1
            mlMgr.deleteMailingList(conn, this);
@


1.24
log
@special case for the 'www' project ... www. shouldn't be including in
the domain name for the email addresses.
@
text
@d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.23 2000/12/23 00:48:20 dlr Exp $
d152 1
a152 1
        throws DoesNotExist, DataSetException
d256 1
a256 1
        throws DataSetException
d262 1
a262 1
        throws DataSetException
d268 1
a268 1
        throws DataSetException
d297 1
a297 1
    public String getEmailPrefix() throws DataSetException
d311 1
a311 1
    public String getAddress(String command) throws DataSetException {
d319 1
a319 1
    public String getProjectID() throws DataSetException
d325 1
a325 1
        throws DataSetException
d330 1
a330 1
    public void setType(String type) throws DataSetException, HandlerException
d349 1
a349 1
    public void setDescription(String description) throws DataSetException
d549 1
a549 1
    public String getArchiveAddress() throws DataSetException
@


1.23
log
@Removed unnecessary getCache() implementations in BusinessObject subclasses and migrated to a factory method for User's primary database key ctor.
@
text
@d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.22 2000/12/22 03:03:00 dlr Exp $
d286 4
a289 1
        return project + '.' + domain;
@


1.23.2.1
log
@applying patch to special case the www project (so www. doesn't appear in
email address domain names) to this branch
@
text
@d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.24 2001/01/19 07:06:46 edk Exp $
d286 1
a286 4
        if (!project.equals("www"))
            return project + '.' + domain;
        else
            return domain;
@


1.22
log
@Propogated object cache interface.
@
text
@d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.21 2000/12/14 04:03:04 edk Exp $
a173 5
    }

    protected Dictionary getCache ()
    {
        return null;
@


1.21
log
@* handle deleting EB lists when it's time (unfortunately, this doesn't yet
  delete the archives themselves)
* minor argument changes (User to String userID)
@
text
@d58 1
d83 1
a83 1
 * @@version $Id: MailingList.java,v 1.20 2000/12/14 02:50:36 edk Exp $
d174 5
@


1.20
log
@use delete rather than remove where appropriate
@
text
@d82 1
a82 1
 * @@version $Id: MailingList.java,v 1.19 2000/12/14 02:28:47 edk Exp $
d716 11
d728 1
a728 1
        } catch (DataSetException e) {
d730 4
a733 6
            if (debug) log.debug("DataSetException in mlMgr.deleteML");
            throw new HandlerException(e.getMessage());
        } catch (SQLException e) {
            log.exception(e);
            if (debug) log.debug("SQLException in mlMgr.deleteML");
            throw new HandlerException(e.getMessage());
d741 2
a742 1
                    "failed -- the database may be in an invalid state");
@


1.19
log
@* handle project deletion w/ anzu
* switch some method signatures in AnzuTigrisTask and add deleteProject
* switch from remove to delete where appropriate (when removing an
  object entirely, rather than just removing it from a container)
@
text
@d82 1
a82 1
 * @@version $Id: MailingList.java,v 1.18 2000/12/09 07:40:47 edk Exp $
d361 1
a361 1
    protected static Method MLS_remove = null; // void
d393 1
a393 1
                MLS_remove = MLSClass.getDeclaredMethod("remove", argTypes);
d634 1
a634 1
                mlMgr.removeMailingList(conn, this);
d705 1
a705 1
    public void remove(AccessControlList acl)
d709 1
a709 1
        remove();
d712 1
a712 1
    public void remove() throws HandlerException
d716 1
a716 1
            mlMgr.removeMailingList(conn, this);
d719 1
a719 1
            if (debug) log.debug("DataSetException in mlMgr.removeML");
d723 1
a723 1
            if (debug) log.debug("SQLException in mlMgr.removeML");
d727 1
a727 1
            MLS_remove.invoke(mailingListSpec, null);
d731 1
a731 1
            throw new HandlerException("ERROR anzu remove mailing list " +
@


1.18
log
@make project addition a task so that better error reporting is possible.
@
text
@d82 1
a82 1
 * @@version $Id: MailingList.java,v 1.17 2000/12/08 10:01:05 edk Exp $
a373 1
    protected static Method MLS_addProject = null; //void
a433 2
                MLS_addProject =
                    MLSClass.getDeclaredMethod("addProject", argTypes);
a542 14
    }

    // TODO : move this out of this class -- it doesn't belong here
    public static void addProject(String domain, String project)
        throws ACLException, HandlerException
    {
        if (!anzu) return;
        try {
            Object args[] = { domain, project };
            MLS_addProject.invoke(null, args);
        } catch (Exception e) {
            e.printStackTrace();
            throw new HandlerException("unable to add domain");
        }
@


1.17
log
@change the mailing list constructor to take a Project -- to ensure that
the mailing list referenced by ID is actually from that Project.  this
sort of complication is another good reason to avoid using object IDs
externally if possible.
@
text
@d82 1
a82 1
 * @@version $Id: MailingList.java,v 1.16 2000/12/08 01:34:38 edk Exp $
d549 2
a550 2
    public static void addProject(AccessControlList acl, String domain,
            String project) throws ACLException, HandlerException
a551 1
        //TODO : check ACL
@


1.16
log
@provide a function for retrieving the archive address
@
text
@d74 2
d82 1
a82 1
 * @@version $Id: MailingList.java,v 1.15 2000/12/05 23:53:31 leonardr Exp $
d190 2
a191 1
     * accessed by mailing list ID
d193 3
a195 2
    public MailingList(Connection c, DataManager dMgr, String mailingListID)
        throws DataSetException, SQLException, DoesNotExist
d199 2
@


1.15
log
@Enabled security check of records passed into business objects.
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.14 2000/12/05 23:28:59 leonardr Exp $
d557 11
a577 6
        StringBuffer buff = new StringBuffer();
        if (mailPrefix != null) 
            buff.append(mailPrefix);
        buff.append("archive=mail-").append(project).append('=')
            .append(getName()).append('=').append(domain).append('@@')
            .append(mailArchiveHost);
d579 1
a579 1
        addrs.add(buff.toString());
@


1.14
log
@Added a check so that business objects cannot be created with records from the wrong table. Also added some new business objects.
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.13 2000/12/01 16:22:26 edk Exp $
d86 2
@


1.13
log
@take out needSave -- which isn't used -- and provide a new function
(setOwner) to encapsulate the business logic associated owning
a mailing list.  (this sets the owner e-mail address -- and it does
other things.  simply changing the owner e-mail address doesn't change
this -- right now anyway.)
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.11 2000/11/30 12:31:00 edk Exp $
d147 1
a147 1
        throws DoesNotExist
@


1.12
log
@use archive=mail- as the archive prefix -- so as to avoid name
space collisions w/ projects
@
text
@d94 2
a96 5
    /**
     * Do we need to save?
     */
    private boolean needSave;

a149 1
        this.needSave = false;
a180 1
        this.needSave = false;
a192 1
        this.needSave = false;
a219 1
        this.needSave = true;
d342 8
d606 9
d627 1
d650 12
@


1.11
log
@new constructor for MailingList biz objs
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.10 2000/11/30 11:46:32 edk Exp $
d567 3
a569 2
        buff.append("archive-").append(project).append('=').append(getName())
           .append('=').append(domain).append('@@').append(mailArchiveHost);
@


1.10
log
@use the version of eyebrowse's addList which allows us to explicitly
specify the ID
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.9 2000/11/29 21:20:39 edk Exp $
d187 13
@


1.9
log
@we need the domain and project before we can get a reference to the
mailing list spec object ...
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.8 2000/11/29 21:10:26 edk Exp $
d440 8
a447 1
                ELM_addList = // String list name, String description
a448 2
                ELM_addListFile = // String list name, String description
                    ELMClass.getDeclaredMethod("addListFile", argTypes);
d569 2
a570 1
            Object args[] = { listName, getDescription() };
@


1.8
log
@handle setting the type correctly when creating mailing lists.  this
involves changing the throws slightly ... hence the changes in
project/*Profile and project/Project  ... try to avoid unnecessary
additional exceptions when possible.
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.7 2000/11/29 01:44:22 edk Exp $
d202 1
a214 1
        getProjectDomain(projectID);
@


1.7
log
@clean error messages if the mailing list already exists
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.6 2000/11/17 05:41:33 edk Exp $
d194 1
a194 1
        throws DataSetException, DoesNotExist
a200 1
            rec.setValue(MailingListManager.TYPE_COLNAME,        type);
d202 1
d206 5
a210 1
            throw new DataSetException(e.getMessage());
@


1.6
log
@finish removing the hyphen from code -- if a mail prefix is used, it
will contain the hyphen
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.5 2000/11/17 01:51:41 edk Exp $
d573 1
a573 1
        throws ACLException, HandlerException
d579 1
a579 1
    public void create() throws HandlerException {
a589 4
            throw new HandlerException(e.getMessage());
        } catch (AlreadyExists e) {
            log.exception(e);
            if (debug) log.debug("AlreadyExists in mlMgr.addML");
@


1.5
log
@change to prefix should contain the hyphen
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.4 2000/11/15 17:08:54 edk Exp $
d277 1
a277 1
        return mailPrefix + "-" + getName();
@


1.4
log
@fix a typo, and reset the mail_prefix option after we've set the
list type (since that overwrites everything).
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.3 2000/11/15 14:58:39 edk Exp $
d132 2
a133 2
                if (mailPrefix.equals(""))
                    mailPrefix = null;
d277 1
a277 3
        if (mailPrefix != null)
            return mailPrefix + "-" + getName();
        return getName();
d485 1
a485 2
            if (mailPrefix != null)
                setStringOption("mail_prefix", mailPrefix);
d544 1
a544 1
            buff.append(mailPrefix).append("-");
@


1.3
log
@move access control checks into MailingList (there may bee issues with
this, but it works at least for root); and provide an api which doesn't
require ACLs for use by other business objects (Project is needs to
create, update and delete mailing lists).
@
text
@d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.2 2000/11/13 19:45:21 edk Exp $
d322 5
d658 3
a660 2
            acl.assertPermissionForProject("Mailing list - " + operation,
                    getName(), getProjectID());
@


1.2
log
@updates from last night: use ArrayList instead of String[]'s; and correct
Util's prefix pattern
@
text
@d72 1
d80 1
a80 1
 * @@version $Id: MailingList.java,v 1.9 2000/11/13 16:47:36 edk Exp $
d108 5
d131 3
d277 2
d293 1
a293 1
            return getName() + "@@" + project + "." + domain;
d295 2
a296 1
            return getName() + "-" + command + "@@" + project + "." + domain;
a298 1

d482 2
d517 1
a517 1
            String project) throws SecurityException, HandlerException
d540 7
a546 4
        StringBuffer buf = new StringBuffer("archive-");
        buf.append(project).append('=').append(getName()).append('=')
            .append(domain).append('@@').append(mailArchiveHost);
        addrs.add(buf.toString());
d571 1
a571 1
        throws SecurityException, HandlerException
d573 5
d580 1
a580 1
            mlMgr.addMailingList(conn, acl, this);
d606 1
a606 1
                mlMgr.removeMailingList(conn, acl, this);
d620 1
a620 1
        throws SecurityException, HandlerException
d622 5
d629 1
a629 1
            mlMgr.updateMailingList(conn, acl, this);
d649 15
d665 7
a671 1
        throws SecurityException, HandlerException
a672 1
        //TODO : check ACL
d675 1
a675 1
            mlMgr.removeMailingList(conn, acl, this);
@


1.1
log
@Initial revision
@
text
@d54 2
d79 1
a79 1
 * @@version $Id: MailingList.java,v 1.8 2000/11/10 01:50:38 dlr Exp $
d331 1
a331 1
    protected static Method MLS_subscribe = null; //String[]
d367 1
a367 1
                    String[].class, String.class
d526 1
a526 1
        String addrs[] = new String[1];
d530 1
a530 1
        addrs[0] = buf.toString();
d649 1
a649 1
    public String[] listMembers(String group) throws HandlerException
d654 1
a654 1
            return (String [])MLS_listMembers.invoke(mailingListSpec, args);
d662 1
a662 1
    public void subscribe(String addr[], String group)
d676 1
a676 1
    public void unsubscribe(String addr[], String group) 
@


1.1.1.1
log
@Merging newhelm tree into helm, as per IZ issue #557.  Previous major version of helm is tagged TIGRIS_NOV_11_2000.
@
text
@@
