head	1.12;
access;
symbols
	TIGRIS_0_9_2_4:1.3
	TIGRIS_0_9_2_3:1.3
	HELM_PEER_PORT_BRANCH:1.11.0.2
	TURBINE_PEER:1.11
	TIGRIS_0_9_2_1:1.11
	TIGRIS_0_9_2:1.3.0.4
	TIGRIS_0_9_0:1.3.0.2
	TIGRIS_0_8_4:1.2.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.12
date	2001.02.21.03.23.56;	author edk;	state dead;
branches;
next	1.11;

1.11
date	2001.01.26.18.29.00;	author edk;	state Exp;
branches
	1.11.2.1;
next	1.10;

1.10
date	2001.01.26.05.24.05;	author edk;	state dead;
branches;
next	1.9;

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

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

1.7
date	2001.01.24.22.51.02;	author leonardr;	state Exp;
branches;
next	1.6;

1.6
date	2001.01.24.22.24.36;	author leonardr;	state Exp;
branches;
next	1.5;

1.5
date	2001.01.24.21.41.48;	author leonardr;	state Exp;
branches;
next	1.4;

1.4
date	2001.01.24.20.42.46;	author dlr;	state Exp;
branches;
next	1.3;

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

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

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

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

1.11.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	;


desc
@@


1.12
log
@delete stuff from the head which is obsolete in the branch (more changes
are still needed for a clean compile)
@
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.database;

import java.sql.*;

import org.webmacro.util.*;

import com.workingdogs.village.*;

import org.joist.database.*;
import org.joist.util.EscapedString;
import org.joist.util.QuotedString;

import org.tigris.helm.AlreadyExists;
import org.tigris.helm.tool.mail.MailingList;

/**
  * Manages the mailing list table.
 *
 * @@author <a href="mailto:edk@@collab.net">Ed Korthof</a>
 * @@version $Id: MailingListManager.java,v 1.11 2001/01/26 18:29:00 edk Exp $
 *
 * Copyright (c) 2000 CollabNet, Inc.
 */

public class MailingListManager extends TableManager
{
    /**
     * The name of the database table that this <code>TableManager</code>
     * manages. 
     */
    public static final String TABLE_NAME = "HELM_MAILINGLIST";

    /**
     * The fields in the database table which we use.
     */
    public static final String LIST_ID_COLNAME = "MAILING_LIST_ID";
    public static final String LIST_NAME_COLNAME = "LIST_NAME";
    public static final String PROJECT_ID_COLNAME = "PROJECT_ID";
    public static final String TYPE_COLNAME = "TYPE";
    public static final String DESCRIPTION_COLNAME = "DESCRIPTION";
    
    /**
     * The logger instance for all instances of this class.
     */
    private static Log log = new Log("mlMgr", "MailingListManager");

    /**
     * Whether we want debugging information.
     */
    private static boolean debug = true;

    /**
     * A general purpose DataManager
     */
    DataManager dMgr;

    /**
     * Creates a new instance.
     *
     * @@param dataMgr The manager of this instance.
     */
    public MailingListManager(DataManager dataMgr)
    {
        super(dataMgr);
        dMgr = dataMgr;
    }

// this will require getting the list of all projects in the domain,
// and then doing PROJECT_ID_COLNAME + " in (" & then adding the comma
// sepearated list of all the project ids.
//    /**
//     * Return the list of mailing lists associated with a domain.
//     */
//    public DataSet listDomainMailingLists (Connection connection,
//            String domainID) throws DataSetException, SQLException
//    {
//        String where = DOMAIN_ID_COLNAME + "=" + escapeAndQuoteSQL(domainID);
//        return getMailingLists(connection, where);
//    }

    /**
     * Return the list of mailing lists associated with a project.
     */
    public DataSet listProjectMailingLists (Connection connection,
            String projectID) throws DataSetException, SQLException
    {
        String where = PROJECT_ID_COLNAME + "=" + escapeAndQuoteSQL(projectID);
        return getMailingLists(connection, where);
    }


    /**
     * Get a mailing list by list ID
     */
    public Record getMailingListByID(Connection connection,
            String mailingListID) throws DataSetException, SQLException
    {
        String where = LIST_ID_COLNAME + "=" +
            escapeAndQuoteSQL(mailingListID);
        return getRecordOrNull(getMailingLists(connection, where));
    }

    /**
     * Get a mailing list by project and list name
     */
    public Record getMailingListByName(Connection connection, String projectID,
            String mailingListName) throws DataSetException, SQLException
    {
        String where = PROJECT_ID_COLNAME + "=" + escapeAndQuoteSQL(projectID)
            + " AND " + LIST_NAME_COLNAME + "=" +
            escapeAndQuoteSQL(mailingListName);
        return getRecordOrNull(getMailingLists(connection, where));
    }

    /**
     * Internal utility to retrieve the first record or null in a DataSet
     * @@param records The DataSet object
     * @@return either a Record object or null
     * @@exception DataSetException
     */
    private Record getRecordOrNull(DataSet ds) throws DataSetException {
        if (ds != null && ds.containsRecord(0))
            return ds.getRecord(0);
        return null;
    }

    /**
     * Used internally to get one or more mailing list records based
     * on projectID, and/or mailingListID.
     */
    private DataSet getMailingLists(Connection conn, String where)
         throws DataSetException, SQLException
    {
        String action = "Getting mailing list(s) with SQL WHERE "+where;
        TableDataSet mailingLists = null;
        try {
            mailingLists = new TableDataSet(conn, TABLE_NAME,
                    new KeyDef().addAttrib(LIST_ID_COLNAME));
            mailingLists.where(where);
            mailingLists.fetchRecords();
        } catch (DataSetException e) {
            log.exception(e);
            if (debug) log.debug(action + ": " + e.getMessage());
            throw e;
        } catch (SQLException e) {
            log.exception(e);
            if (debug) log.debug(action + ": " + e.getMessage());
            throw e;
        } finally {
            registerToClose(mailingLists);
        }

        return mailingLists;
    }

    /**
     * Adds a mailing list to the project database.
     *
     * @@param connection    The JDBC database connection to use
     * @@param projectID     The ID for the list's project
     * @@param name          The name for the list
     * @@param description   A short description of the list
     * @@param type          The type of the list
     *
     * @@exception SQLException
     * @@exception DataSetException
     */
    public void addMailingList(Connection connection, MailingList ml)
        throws DataSetException, SQLException, SecurityException, AlreadyExists
    {
        String projectID = ml.getProjectID();

        Record mailingListRecord = getMailingListByName(connection,
                projectID, ml.getName());
        if (mailingListRecord != null) {
            String what = "mailing list "+ml.getName();
            String where;
            try {
                ProjectManager projMgr =(ProjectManager)
                    dMgr.getManager("org.tigris.helm.database.ProjectManager");
                String projectName =
                    projMgr.getProjectName(connection,projectID);
                where = "project " + projectName;
            } catch (Exception e) {
                if (debug) log.debug("caught exception getting project name " +
                    "for error msg: " + e.getMessage() + " (" + e + ")");
                where = "this project";
            }
            throw new AlreadyExists(what, where);
        }

        Record r = ml.getRecord();
        r.save();
        String newID = getLastInsertedID(connection).toString();
        r.setValue(LIST_ID_COLNAME, newID);
    }

    /**
     * Updates a mailing list in the project database.
     *
     * @@param connection    The JDBC database connection to use
     * @@param projectID     The ID for the list's project
     * @@param name          The name for the list
     * @@param description   A short description of the list
     * @@param type          The type of the list
     *
     * @@exception SQLException
     * @@exception DataSetException
     */
    public void updateMailingList(Connection connection, MailingList ml)
        throws DataSetException, SQLException, SecurityException
    {
        Record mailingListRecord = getMailingListByName(connection,
                ml.getProjectID(), ml.getName());
        if (mailingListRecord == null)
            throw new DataSetException("update called on non-extant list");

        ml.getRecord().save();
    }

    public Record createRecord(Connection connection)
        throws SQLException, DataSetException
    {
        TableDataSet mailingLists = null;
        try {
            mailingLists = new TableDataSet(connection, TABLE_NAME,
                    new KeyDef().addAttrib(LIST_ID_COLNAME));
            return mailingLists.addRecord();
        } finally {  // even if we catch the exceptions, we can't add much info
            registerToClose(mailingLists);
        } 
    }

    /**
     * Remove an existing row
     */
    public void deleteMailingList(Connection connection, MailingList ml)
        throws SQLException, DataSetException
    {
        Record r = ml.getRecord();
        r.markToBeDeleted();
        r.save();
    }
}

 
@


1.11
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d65 1
a65 1
 * @@version $Id: MailingListManager.java,v 1.3 2000/12/14 02:50:36 edk Exp $
@


1.11.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d65 1
a65 1
 * @@version $Id: MailingListManager.java,v 1.11 2001/01/26 18:29:00 edk Exp $
@


1.10
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
@d32 1
a32 1
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
a57 3
import org.apache.turbine.services.db.TurbineDB;
import org.apache.turbine.util.db.pool.DBConnection;

a58 1
import org.tigris.helm.DoesNotExist;
d62 1
a62 1
 * Manages the mailing list table.
d65 1
a65 1
 * @@version $Id: MailingListManager.java,v 1.9 2001/01/25 02:42:47 edk Exp $
d81 5
a85 12
    public static final String LIST_ID = "MAILING_LIST_ID";
    public static final String LIST_NAME = "LIST_NAME";
    public static final String PROJECT_ID = "PROJECT_ID";
    public static final String TYPE = "TYPE";
    public static final String DESCRIPTION = "DESCRIPTION";

    /**
     * The default ordering of records from this table.
     */
    public static final String DEFAULT_ORDER_BY  =  
        TABLE_NAME + "." + PROJECT_ID + " ASC, " + TABLE_NAME + "." 
        + LIST_NAME + " DESC";
d95 1
a95 1
    private static final boolean debug = true;
d109 1
a109 1
        super(dataMgr, new KeyDef().addAttrib(LIST_ID));
a112 25
    ////////////////////////////////////////////////////////////////
    // Accessor methods.
    ////////////////////////////////////////////////////////////////

    /**
     * Throws an exception if the specified information corresponds to
     * an existing mailing list.
     *
     * @@param projectID       ID of the project to check
     * @@param mailingListName List name to check
     */
    public void assertMailingListNonexistence(String projectID,
            String mailingListName) throws DBException, AlreadyExists
    {
        Criterion c = new Criterion(PROJECT_ID, projectID);
        c.and(new Criterion(LIST_NAME, mailingListName));
        Record list = getFirstMatchingList(c);
        if (list != null)
        {
            throw new AlreadyExists
                ("Mailing list " + mailingListName + " in this project (" +
                 projectID + ")");
        }
    }

d114 1
a114 1
// and then doing PROJECT_ID + " in (" & then adding the comma
d119 2
a120 1
//    public DataSet listDomainMailingLists (String domainID) throws DBException
d122 2
a123 2
//        String where = DOMAIN_ID + "=" + escapeAndQuoteSQL(domainID);
//        return getMailingLists(where);
d129 2
a130 2
    public DataSet listProjectMailingLists (String projectID) 
        throws DBException
d132 2
a133 2
        Criterion c = new Criterion(PROJECT_ID, projectID);
        return getMailingLists(c);
d140 2
a141 2
    public Record getMailingListByID(String mailingListID) 
        throws DBException, DoesNotExist
d143 3
a145 8
        Criterion c = new Criterion(LIST_ID, mailingListID);
        Record r = getFirstMatchingList(c);
        if (r == null)
        {
            throw new DoesNotExist
                ("Mailing list with ID " + mailingListID);
        }
        return r;
d151 2
a152 3
    public Record getMailingListByName(String projectID, 
                                       String mailingListName) 
        throws DBException, DoesNotExist
d154 4
a157 10
        Criterion c = new Criterion(PROJECT_ID, projectID);
        c.and(new Criterion(LIST_NAME, mailingListName));
        Record r = getFirstMatchingList(c);
        if (r == null)
        {
            throw new DoesNotExist
                ("Mailing list " + mailingListName +
                 " in project " + projectID);
        }
        return r;
d161 4
a164 7
     * Returns the first list matching a given Criterion. 
     *
     * @@param criterion Criterion to use in select.
     *
     * @@exception DBException if a database error occurs.
     *
     * @@return Null if no matching list, first list in recordset otherwise.
d166 4
a169 15
    private Record getFirstMatchingList(Criterion criterion)
        throws DBException
    {
        Record r = null;
        try {
            DataSet s = getMailingLists(criterion);
            if (s != null && s.containsRecord(0))
            {
                r = s.getRecord(0);
            }
        } catch (DataSetException e) {
            throw new DBException(e);
        }

        return r;
d173 2
a174 5
     * Returns mailing lists matching a given criterion.
     *
     * @@param criterion Criterion to use in select.
     *
     * @@exception DBException if a database error occurs.
d176 2
a177 2
    private DataSet getMailingLists(Criterion criterion)
        throws DBException
d179 2
a180 1
        DataSet s = null;
d182 14
a195 3
            s = runSelect(TABLE_NAME, criterion, DEFAULT_ORDER_BY);
        } catch (Exception e) {
            throw new DBException(e);
d197 2
a198 1
        return s;
a200 4
    ////////////////////////////////////////////////////////////////
    // Mutator methods.
    ////////////////////////////////////////////////////////////////

d204 1
d213 2
a214 5
    public synchronized Record addMailingList(String projectID,
                                            String name,
                                            String description,
                                            String type)
        throws DBException, SecurityException, AlreadyExists
d216 19
a234 6
        assertMailingListNonexistence(projectID, name);
        Record ml = null;
        try {
            ml = updateMailingList(null, projectID, name, description, type);
        } catch (DoesNotExist ignore) {
            // "can't" happen on new ml creation
d236 5
a240 1
        return ml;
a242 1

d246 1
a246 1
     * @@param mailingListID The ID for this mailing list
d255 2
a256 6
    public Record updateMailingList(String mailingListID,
                                  String projectID,
                                  String name,
                                  String description,
                                  String type)
        throws DBException, SecurityException, DoesNotExist
d258 4
d263 1
a263 55
        DBConnection dbConn = null;
        Record list = null;
        TableDataSet lists = null;

        try
        {
            dbConn = TurbineDB.getConnection();
            Connection connection = dbConn.getConnection();

            if (mailingListID != null)
            {
                list = getMailingListByID(mailingListID);
            }
            else
            {
                lists = new TableDataSet(connection, TABLE_NAME, keydef);
                list = lists.addRecord();
            }

            // Do update
            if (projectID != null)   list.setValue(PROJECT_ID   , projectID);
            if (name != null)        list.setValue(LIST_NAME    , name);
            if (description != null) list.setValue(DESCRIPTION  , description);
            if (type != null)        list.setValue(TYPE         , type);

            list.save();

            if (mailingListID == null)
            {
                
                // NOTE: There is no way to refresh a Village Record which has
                // been created using TableDataSet.addRecord().

                mailingListID = getLastInsertedID(connection).toString();
                list.setValue(LIST_ID, mailingListID);
            }
        }
        catch (Exception e)
        {
            throw new DBException(e);
        }
        finally
        {
            registerToClose(lists);
            try
            {
                TurbineDB.releaseConnection(dbConn);
            }
            catch (Exception e)
            {
                throw new DBException(e);
            }
        }

        return list;
d266 2
a267 1
    public Record createRecord() throws DBException
a269 2
        DBConnection dbConn = null;
        Record list = null;
d271 2
a272 4
            dbConn = TurbineDB.getConnection();
            Connection connection = dbConn.getConnection();

            mailingLists = new TableDataSet(connection, TABLE_NAME, keydef);
d274 1
a274 10
        }
        catch (Exception e) { // TurbineDB.getConnection throws this
            throw new DBException(e);
        }
        finally {  // even if we catch the exceptions, we can't add much info
            try {
                TurbineDB.releaseConnection(dbConn);
            } catch (Exception e) {
                throw new DBException(e);
            }
d282 2
a283 2
    public void deleteMailingList(String mailingListID)
        throws DBException, DoesNotExist
d285 3
a287 11
        try {
            Record r = getMailingListByID(mailingListID);
            r.markToBeDeleted();
            r.save();
        }
        catch (DataSetException e) {
            throw new DBException(e);
        }
        catch (SQLException e) {
            throw new DBException(e);
        }
d290 2
@


1.9
log
@more changes to match the new pattern
@
text
@d69 1
a69 1
 * @@version $Id: MailingListManager.java,v 1.8 2001/01/25 00:26:07 edk Exp $
@


1.8
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
@d69 1
a69 1
 * @@version $Id: MailingListManager.java,v 1.7 2001/01/24 22:51:02 leonardr Exp $
d155 1
a155 2
//    public DataSet listDomainMailingLists (Connection connection,
//            String domainID) throws DBException
d158 1
a158 1
//        return getMailingLists(connection, where);
d234 1
a234 1
     * Returns users matching a given criterion.
d240 1
a240 1
    public DataSet getMailingLists(Criterion criterion)
a258 1
     * @@param connection    The JDBC database connection to use
d267 1
a267 1
    public synchronized void addMailingList(String projectID,
d280 1
a286 1
     * @@param connection    The JDBC database connection to use
d340 3
a342 1
        } catch (Exception e) {
d344 6
a349 2
        } finally {
            try {
d351 3
a353 1
            } catch (Exception e) {
a355 1
            registerToClose(lists);
d373 1
a373 4
        catch (SQLException e) {
            throw new DBException(e);
        }
        catch (DataSetException e) {
d389 2
a390 2
    public void deleteMailingList(Connection connection, MailingList ml)
        throws DBException
d393 1
a393 1
            Record r = ml.getRecord();
@


1.7
log
@Started on changes to this manager--checking in so that edk can see it.
@
text
@d58 3
d62 1
d69 1
a69 1
 * @@version $Id: MailingListManager.java,v 1.6 2001/01/24 22:24:36 leonardr Exp $
d85 5
a89 5
    public static final String LIST_ID_COLNAME = "MAILING_LIST_ID";
    public static final String LIST_NAME_COLNAME = "LIST_NAME";
    public static final String PROJECT_ID_COLNAME = "PROJECT_ID";
    public static final String TYPE_COLNAME = "TYPE";
    public static final String DESCRIPTION_COLNAME = "DESCRIPTION";
d96 1
a96 1
        + LIST_NAME_COLNAME + " DESC";
d120 1
a120 1
        super(dataMgr, new KeyDef().addAttrib(LIST_ID_COLNAME));
d128 21
d150 1
a150 1
// and then doing PROJECT_ID_COLNAME + " in (" & then adding the comma
d158 1
a158 1
//        String where = DOMAIN_ID_COLNAME + "=" + escapeAndQuoteSQL(domainID);
d168 1
a168 1
        Criterion c = new Criterion(PROJECT_ID_COLNAME, projectID);
d179 1
a179 1
        Criterion c = new Criterion(LIST_ID_COLNAME, mailingListID);
d196 2
a197 2
        Criterion c = new Criterion(PROJECT_ID_COLNAME, projectID);
        c.and(new Criterion(LIST_NAME_COLNAME, mailingListName));
d202 2
a203 1
                ("Mailing list " + mailingListname + " in project " + projectID);
d269 4
a272 1
    public void addMailingList(Connection connection, MailingList ml)
d275 6
a280 19
        String projectID = ml.getProjectID();

        Record mailingListRecord = getMailingListByName(connection,
                projectID, ml.getName());
        if (mailingListRecord != null) {
            String what = "mailing list "+ml.getName();
            String where;
            try {
                ProjectManager projMgr =(ProjectManager)
                    dMgr.getManager("org.tigris.helm.database.ProjectManager");
                String projectName =
                    projMgr.getProjectName(connection,projectID);
                where = "project " + projectName;
            } catch (Exception e) {
                if (debug) log.debug("caught exception getting project name " +
                    "for error msg: " + e.getMessage() + " (" + e + ")");
                where = "this project";
            }
            throw new AlreadyExists(what, where);
d282 1
a283 5
        Record r = ml.getRecord();
        r.save();
        String newID = getLastInsertedID(connection).toString();
        r.setValue(LIST_ID_COLNAME, newID);
    }
d289 1
d298 6
a303 2
    public void updateMailingList(Connection connection, MailingList ml)
        throws DBException, SecurityException
a304 4
        Record mailingListRecord = getMailingListByName(connection,
                ml.getProjectID(), ml.getName());
        if (mailingListRecord == null)
            throw new DBException("update called on non-extant list");
d306 48
a353 1
        ml.getRecord().save();
d356 1
a356 2
    public Record createRecord(Connection connection)
        throws DBException
d359 2
d362 3
d368 3
d375 5
d396 3
@


1.6
log
@Moved TableManagers to new keydef constructor and keydef-less runSelect.
@
text
@d65 1
a65 1
 * @@version $Id: MailingListManager.java,v 1.5 2001/01/24 21:41:48 leonardr Exp $
d86 7
d120 4
d140 2
a141 2
    public DataSet listProjectMailingLists (Connection connection,
            String projectID) throws DBException
d143 2
a144 2
        String where = PROJECT_ID_COLNAME + "=" + escapeAndQuoteSQL(projectID);
        return getMailingLists(connection, where);
d151 2
a152 2
    public Record getMailingListByID(Connection connection,
            String mailingListID) throws DBException
d154 8
a161 3
        String where = LIST_ID_COLNAME + "=" +
            escapeAndQuoteSQL(mailingListID);
        return getRecordOrNull(getMailingLists(connection, where));
d167 3
a169 2
    public Record getMailingListByName(Connection connection, String projectID,
            String mailingListName) throws DBException
d171 9
a179 4
        String where = PROJECT_ID_COLNAME + "=" + escapeAndQuoteSQL(projectID)
            + " AND " + LIST_NAME_COLNAME + "=" +
            escapeAndQuoteSQL(mailingListName);
        return getRecordOrNull(getMailingLists(connection, where));
d183 7
a189 4
     * Internal utility to retrieve the first record or null in a DataSet
     * @@param records The DataSet object
     * @@return either a Record object or null
     * @@exception DataSetException
d191 15
a205 4
    private Record getRecordOrNull(DataSet ds) throws DBException {
        if (ds != null && ds.containsRecord(0))
            return ds.getRecord(0);
        return null;
d209 5
a213 2
     * Used internally to get one or more mailing list records based
     * on projectID, and/or mailingListID.
d215 2
a216 2
    private DataSet getMailingLists(Connection conn, String where)
         throws DBException
d218 1
a218 2
        String action = "Getting mailing list(s) with SQL WHERE "+where;
        TableDataSet mailingLists = null;
d220 2
a221 6
            mailingLists = new TableDataSet(conn, TABLE_NAME, keydef);
            mailingLists.where(where);
            mailingLists.fetchRecords();
        } catch (DataSetException e) {
            throw new DBException(e);
        } catch (SQLException e) {
a222 2
        } finally {
            registerToClose(mailingLists);
d224 2
d227 3
a229 2
        return mailingLists;
    }
@


1.5
log
@Ported UserManager and RoleManager to Helm. Started moving other TableManagers toward a grab-connection-on-demand model. Massive breakage ensues. dlr and I are working on it.
@
text
@d65 1
a65 1
 * @@version $Id: MailingListManager.java,v 1.4 2001/01/24 20:42:46 dlr Exp $
d109 1
a109 1
        super(dataMgr);
d182 1
a182 2
            mailingLists = new TableDataSet(conn, TABLE_NAME,
                    new KeyDef().addAttrib(LIST_ID_COLNAME));
d266 1
a266 2
            mailingLists = new TableDataSet(connection, TABLE_NAME,
                    new KeyDef().addAttrib(LIST_ID_COLNAME));
@


1.4
log
@Making use of DBException.
@
text
@d32 1
a32 1
 * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
d62 1
a62 1
  * Manages the mailing list table.
d65 1
a65 1
 * @@version $Id: MailingListManager.java,v 1.3 2000/12/14 02:50:36 edk Exp $
@


1.3
log
@use delete rather than remove where appropriate
@
text
@d65 1
a65 1
 * @@version $Id: MailingListManager.java,v 1.2 2000/11/15 14:58:39 edk Exp $
d95 1
a95 1
    private static boolean debug = true;
d120 1
a120 1
//            String domainID) throws DataSetException, SQLException
d130 1
a130 1
            String projectID) throws DataSetException, SQLException
d141 1
a141 1
            String mailingListID) throws DataSetException, SQLException
d152 1
a152 1
            String mailingListName) throws DataSetException, SQLException
d166 1
a166 1
    private Record getRecordOrNull(DataSet ds) throws DataSetException {
d177 1
a177 1
         throws DataSetException, SQLException
d187 1
a187 3
            log.exception(e);
            if (debug) log.debug(action + ": " + e.getMessage());
            throw e;
d189 1
a189 3
            log.exception(e);
            if (debug) log.debug(action + ": " + e.getMessage());
            throw e;
d210 1
a210 1
        throws DataSetException, SQLException, SecurityException, AlreadyExists
d252 1
a252 1
        throws DataSetException, SQLException, SecurityException
d257 1
a257 1
            throw new DataSetException("update called on non-extant list");
d263 1
a263 1
        throws SQLException, DataSetException
d270 5
a274 1
        } finally {  // even if we catch the exceptions, we can't add much info
d283 1
a283 1
        throws SQLException, DataSetException
d285 8
a292 3
        Record r = ml.getRecord();
        r.markToBeDeleted();
        r.save();
a294 2

 
@


1.2
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
@d65 1
a65 1
 * @@version $Id: MailingListManager.java,v 1.1.1.1 2000/11/12 21:14:57 dlr Exp $
d282 1
a282 1
    public void removeMailingList(Connection connection, MailingList ml)
@


1.1
log
@Initial revision
@
text
@a58 1
import org.tigris.helm.security.AccessControlList;
d65 1
a65 1
 * @@version $Id: MailingListManager.java,v 1.9 2000/11/10 01:50:37 dlr Exp $
a204 1
     * @@param acl           The access control list for the current user
d213 1
a213 2
    public void addMailingList(Connection connection,
            AccessControlList acl, MailingList ml)
a216 4
        // TODO: Activate permission checking.
        if (false && !acl.hasPermissionForProject("MailingList - Add", 
                    projectID))
            throw new SecurityException("No permission to add a mailing list");
a246 1
     * @@param acl           The access control list for the current user
d255 1
a255 2
    public void updateMailingList(Connection connection,
            AccessControlList acl, MailingList ml)
a257 3
        if (false && !acl.hasPermissionForProject("MailingList - Add", 
                    ml.getProjectID()))
            throw new SecurityException("No permission to add a mailing list");
d282 3
a284 8
    public void removeMailingList(Connection connection, AccessControlList acl,
            MailingList ml)
        throws SQLException, DataSetException, SecurityException
    {
        if (false && !acl.hasPermissionForProject("MailingList - Delete",
                    ml.getProjectID()))
            throw new SecurityException();

@


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
@@
