head	1.16;
access;
symbols
	TIGRIS_0_9_2_4:1.13
	TIGRIS_0_9_2_3:1.13
	HELM_PEER_PORT_BRANCH:1.15.0.2
	TURBINE_PEER:1.15
	TIGRIS_0_9_2_1:1.15
	TIGRIS_0_9_2:1.13.0.4
	TIGRIS_0_9_0:1.13.0.2
	TIGRIS_0_8_4:1.7.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.16
date	2001.02.21.03.39.03;	author edk;	state dead;
branches;
next	1.15;

1.15
date	2001.01.26.18.29.04;	author edk;	state Exp;
branches
	1.15.2.1;
next	1.14;

1.14
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.13;

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

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

1.11
date	2000.12.14.00.30.54;	author dlr;	state Exp;
branches;
next	1.10;

1.10
date	2000.12.13.22.50.48;	author dlr;	state Exp;
branches;
next	1.9;

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

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

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

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

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

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

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

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

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

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

1.15.2.1
date	2001.01.28.01.02.18;	author dlr;	state dead;
branches;
next	;


desc
@@


1.16
log
@these have been moved to om/profile
@
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 Collab.Net (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.project;

import java.sql.*;
import java.util.ArrayList;

import com.workingdogs.village.DataSetException;

import org.joist.database.DataManager;
import org.joist.database.JoistDatabaseException;

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

import org.tigris.helm.database.ProjectManager;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.tool.mail.MailingList;
import org.tigris.helm.tool.*;
import org.tigris.helm.domain.User;

/**
 * Base class for project types.  All implementations should subclass.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: BaseProfile.java,v 1.15 2001/01/26 18:29:04 edk Exp $
 */
abstract class BaseProfile implements ProjectProfile
{
    /**
     * Enforces use of the <code>ProjectProfiles</code> container to get an 
     * instance of this class.
     */
    protected BaseProfile ()
    {
        // No op.
    }

    private static Log log = new Log("ml", "MailingList");
    public static final boolean debug = true;

    /**
     * Gets the key of the <code>ProjectProfile</code> implementation.  
     * This is the name used to identify the <code>ProjectProfile</code> in 
     * servlet and template code.
     *
     * @@return The key.
     */
    public abstract String getKey ();

    /**
     * Gets the name of the <code>ProjectProfile</code>.
     *
     * @@return The name.
     */
    public abstract String getName ();

    /**
     * Gets the description of the <code>ProjectProfile</code>.
     *
     * @@return The description.
     */
    public abstract String getDescription ();

    /**
     * Gets the mailing lists that projects of the <code>ProjectProfile</code> 
     * begins life with.
     *
     * @@return Default mailing lists, as an array of string arrays.
     */
    public abstract Object getDefaultMailingLists (Connection conn,
                                                   DataManager dMgr, 
                                                   String projectID,
                                                   boolean isProprietary)
        throws HandlerException, DoesNotExist;

    /**
     * The default implementation does indeed auto-publish.
     */
    public boolean isAutoPublishedToWeb ()
    {
        return true;
    }

    /**
     * Indicates whether the <code>ProjectProfile</code> is a
     * composite project.  Most will not be composites, so the default
     * behavior will be to return <code>false</code>.  Over ride this
     * behavior as necessary.
     *
     * @@return Whether a composite project.  
     */
    public boolean isComposite ()
    {
        return false;
    }

    /**
     * Adds the default mailing lists.
     *
     * @@param conn        The JDBC database connection to use.
     * @@param projectID   The database key of the project to add the lists to.
     */
    public void addDefaultMailingLists (Connection conn, DataManager dMgr,
                                        String projectID, User user,
                                        boolean isProprietary)
        throws HandlerException, DoesNotExist
    {
        // First: try to create the project entry.
        ProjectManager projMgr = (ProjectManager)
            dMgr.getManager("org.tigris.helm.database.ProjectManager");

        String[][] lists =
            (String [][])getDefaultMailingLists(conn, dMgr, projectID,
                                                isProprietary);
        if (lists != null)
        {
            try
            {
                ArrayList autoSubscribe = new ArrayList();
                autoSubscribe.add(user.getEmail());
                for (int i = 0; i < lists.length; i++)
                {
                    // TODO : MailingList & MailingListManager
                    // really want ACLs.  Right now, we're not checking
                    // permission there, but that should be added
                    // soon (so this'll need to be dealt with somehow)
                    AnzuTigrisTask.addMailingList(conn, dMgr,
                            user.getID(), lists[i][0], projectID,
                            lists[i][1], lists[i][2]);
                }
            }
            catch (Exception e)
            {
                log.exception(e);
                log.error("failed to add default mailing lists to project " +
                        projectID);
                // right now, we should continue even if anzu fails
            }
        }
    }
}
@


1.15
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d70 1
a70 1
 * @@version $Id: BaseProfile.java,v 1.13 2000/12/14 04:03:03 edk Exp $
@


1.15.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d70 1
a70 1
 * @@version $Id: BaseProfile.java,v 1.15 2001/01/26 18:29:04 edk Exp $
@


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


1.13
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
@d70 1
a70 1
 * @@version $Id: BaseProfile.java,v 1.12 2000/12/14 02:28:47 edk Exp $
@


1.12
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
@d70 1
a70 1
 * @@version $Id: BaseProfile.java,v 1.11 2000/12/14 00:30:54 dlr Exp $
d173 1
a173 1
                            user, lists[i][0], projectID,
@


1.11
log
@Death to project modules!
@
text
@d70 1
a70 1
 * @@version $Id: BaseProfile.java,v 1.10 2000/12/13 22:50:48 dlr Exp $
a155 6
        try {
            AnzuTigrisTask.addProject(conn, dMgr, user, projectID);
        } catch (Exception e) {
            log.exception(e);
            log.error("addproject exception: " + e.getMessage());
        }
@


1.10
log
@removed linefeed
@
text
@d70 1
a70 1
 * @@version $Id: BaseProfile.java,v 1.9 2000/12/09 07:40:47 edk Exp $
d122 8
a190 15
    }

    /**
     * Adds the default modules.
     *
     * @@param projectID   The database key of the project to add the 
     *                    modules to.
     */
    public void addDefaultModules (Connection conn, DataManager dMgr,
                                   String domainName, String projectName,
                                   String projectID, String brandName)
        throws UpdateException, DataSetException, JoistDatabaseException, 
               SQLException, DoesNotExist
    {
        Module[] modules = (Module [])getDefaultModules(conn, dMgr, projectID);
@


1.9
log
@make project addition a task so that better error reporting is possible.
@
text
@d70 1
a70 1
 * @@version $Id: BaseProfile.java,v 1.8 2000/12/09 06:38:17 edk Exp $
a199 1

@


1.8
log
@don't construct MailingList objects until we really do want to create
them (that's much more efficient, and avoids any dependency on the
anzu server actually being running when this happens -- if it's not,
project creation won't work correctly -- but that's something for the
site admins to deal with.
@
text
@d70 1
a70 1
 * @@version $Id: BaseProfile.java,v 1.7 2000/12/01 18:46:46 edk Exp $
d149 1
a149 7
            String domain =
                projMgr.getProjectDomain(conn, projectID);
            String project =
                projMgr.getProjectName(conn, projectID);
            // TODO : deal w/ ACLs (as below)
            // TODO : should do this through a class other than MailingList
            MailingList.addProject(null, domain, project);
d151 2
a152 2
            e.printStackTrace();
            // right now, we want to ignore anzu exceptions
@


1.7
log
@use AnzuTigrisTask for mailing list additions during project creation
@
text
@d70 1
a70 1
 * @@version $Id: BaseProfile.java,v 1.6 2000/11/29 21:10:26 edk Exp $
d113 1
a113 1
     * @@return Default mailing lists.
d161 3
a163 3
        MailingList[] lists =
            (MailingList [])getDefaultMailingLists(conn, dMgr, projectID,
                                                   isProprietary);
d177 2
a178 2
                            user, lists[i].getName(), projectID,
                            lists[i].getType(), lists[i].getDescription());
@


1.6
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
@d70 1
a70 1
 * @@version $Id: BaseProfile.java,v 1.5 2000/11/23 03:49:28 edk Exp $
d176 3
a178 4
                    lists[i].setStringOption("owner", user.getEmail());
                    lists[i].create();
                    lists[i].subscribe(autoSubscribe, "mod");
                    lists[i].subscribe(autoSubscribe, "allow");
@


1.5
log
@subscribe the owner to the moderator list (which shouldn't be empty
in the discussion type lists) and the allowed posters (not that it
does much good there so long as ezmlm uses envelope sender, but whatever).
@
text
@d57 1
d70 1
a70 1
 * @@version $Id: BaseProfile.java,v 1.4 2000/11/17 05:45:54 edk Exp $
d119 1
a119 1
        throws DataSetException, DoesNotExist;
d143 1
a143 1
        throws SQLException, DataSetException, DoesNotExist
@


1.4
log
@set the owner for all the mailing lists created to the owner of this
project.  we might need to worry about this if there's any again
if there's any way to change the owner of a project via the sourcecast
ui
@
text
@d50 1
d69 1
a69 1
 * @@version $Id: BaseProfile.java,v 1.3 2000/11/15 15:00:04 edk Exp $
d167 2
d177 2
@


1.3
log
@set the list type to a "private" version when the license is set to a
proprietary license; set it to a non-private version when the license is
set to an open source version.
@
text
@d56 2
d62 1
d68 1
a68 1
 * @@version $Id: BaseProfile.java,v 1.2 2000/11/15 11:24:40 edk Exp $
d81 3
d139 2
a140 1
                                        String projectID, boolean isProprietary)
d172 1
d178 4
a181 2
                e.printStackTrace();
                // right now, we want to ignore anzu exceptions
@


1.2
log
@avoid excessive object creation: there's no point in constructing Integers
if all we're going to do is construct Strings from them via toString().
@
text
@d65 1
a65 1
 * @@version $Id: BaseProfile.java,v 1.1.1.1 2000/11/12 21:15:48 dlr Exp $
d109 2
a110 1
                                                   String projectID)
d133 1
a133 1
                                        String projectID)
d153 2
a154 1
            (MailingList [])getDefaultMailingLists(conn, dMgr, projectID);
d165 1
a165 1
                    lists[i].create(null);
@


1.1
log
@Initial revision
@
text
@d65 1
a65 1
 * @@version $Id: BaseProfile.java,v 1.9 2000/11/10 01:50:37 dlr Exp $
d109 1
a109 1
                                                   Integer projectID)
d132 1
a132 1
                                        Integer projectID)
d140 1
a140 1
                projMgr.getProjectDomain(conn, projectID.toString());
d142 1
a142 1
                projMgr.getProjectName(conn, projectID.toString());
d182 1
a182 1
                                   Integer projectID, String brandName)
@


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