head	1.4;
access;
symbols
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1
	OLDHELM:1.1.0.2
	TIGRIS_NOV_11_2000:1.1;
locks; strict;
comment	@# @;


1.4
date	2000.11.16.23.34.19;	author leonardr;	state dead;
branches;
next	1.3;

1.3
date	2000.11.14.23.41.28;	author elicia;	state Exp;
branches;
next	1.2;

1.2
date	2000.11.12.22.57.33;	author dlr;	state Exp;
branches;
next	1.1;

1.1
date	2000.09.29.23.37.46;	author kmaples;	state Exp;
branches
	1.1.1.1;
next	;

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


desc
@@


1.4
log
@If we ever need this, we can bring it back.
@
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;

//Just for logging; get rid of later.
import org.webmacro.util.*;
import org.webmacro.servlet.*;
import org.webmacro.engine.*;
import org.webmacro.broker.*;


import javax.servlet.*;
import javax.servlet.http.*;

import java.sql.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.ListIterator;

import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.AlreadyExists;
import org.tigris.helm.database.ProjectManager;
import org.tigris.helm.tool.UpdateException;

import org.joist.database.DataManager;
import org.joist.database.UserManager;

import org.webmacro.servlet.HandlerException;

import com.workingdogs.village.*;

/**
 * Add a project.
 */
public class ProjectCreator extends Object {

    static public Log log = new Log("prjcrt", "ProjectCreator");
    static private boolean debug = true;

    public static Record createProject(DataManager dataMgr, 
                                       Connection connection,  
                                       AccessControlList acl, String domain,
                                       String projectName, String longName, 
                                       ArrayList owners)
	throws Exception, AlreadyExists {

 	String[] lists = { "announce", "dev" };

	UserManager userman = (UserManager) 
            dataMgr.getManager("org.joist.database.UserManager");

	if (debug) log.debug("About to run addproject script for project: " + 
                             projectName);
	    
	// Add the project to the database. This also runs the AddProject 
        // script.
        ProjectManager prjMgr = (ProjectManager)
            dataMgr.getManager("org.tigris.helm.database.ProjectManager");

        // TODO: get ProjectProfile
        Record project = prjMgr.addProject(connection, 
                                           null, 
                                           domain, 
                                           projectName, 
                                           null,
                                           longName,
                                           null,
                                           null,
                                           null,
                                           null,
                                           null);

	if (debug) log.debug("That's done.");

	StringBuffer buf = new StringBuffer();
	QueryDataSet qds;
	Record r;
	String i;
	String loginID;

	// Perform some tasks for each owner.
	ListIterator it = owners.listIterator(0);
	while (it.hasNext()) {
	    i = (String) it.next();
	    //Get the loginID of the user from the userID.
	    if (debug) log.debug("Processing owner " + i);
            //            loginID = sMgr.getLoginID(connection, i);
            //	    if (debug) log.debug("loginID " + loginID);


            //	    userman.setProjectOwner(connection, loginID, projectName, true);

	    if (debug) log.debug("Set module owner.");
	    
	    //Get the owner's email address and add it to the StringBuffer.
	    qds = userman.getContactInfoForUser(connection, i);
	    r = qds.getRecord(0);
	    buf.append(r.getValue("email").asString()).append(" ");
	}
	
	if (debug) log.debug("Arguments to addmailinglist: " + buf.toString());
	//Subscribe the owners to the mailing lists.
	String ownerlist = new String(buf.toString());
	for (int j = 0; j < lists.length; j++) {	    
	    //    new ProjMailFileEdit().doListCommand("list-subscribe", lists[j] + " " + ownerlist);
	}       

	return project;
    }
} /* end class ProjectCreator */

@


1.3
log
@removed argument for member policy
@
text
@@


1.2
log
@Resolved merge conflicts.
@
text
@a115 1
                                           null,
@


1.1
log
@Initial commit of self serve project add functionality.
@
text
@d62 2
a63 3
import com.sun.java.util.collections.ArrayList;
import com.sun.java.util.collections.ListIterator;
import gnu.regexp.RE;
d65 2
a67 2
import org.tigris.helm.database.TUserManager;
import org.tigris.helm.admin.ProjMailFileEdit;
d85 6
a90 5
    public static String createProject(DataManager dataman, 
				     Connection connection,  String domain,
				     String projectName, String long_name, 
				     ArrayList owners)
	throws Exception {
d94 2
a95 1
	TUserManager userman = (TUserManager) dataman.getManager("org.tigris.helm.database.TUserManager");
d97 2
a98 1
	if (debug) log.debug("About to run addproject script. Project: " + projectName);
d100 18
a117 3
	//Add the project to the database. This also runs the
	//AddProject script.
	String password = ProjectManager.addProject(connection, domain, projectName, long_name);
d127 1
a127 1
	//Do some stuff for each owner.
d133 2
a134 2
	    loginID = userman.getLoginID(connection, i);
	    if (debug) log.debug("loginID " + loginID);
d136 2
a137 1
	    userman.setProjectOwner(connection, loginID, projectName, true);
d154 1
a154 1
	return password;
@


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
@d62 3
a64 2
import java.util.ArrayList;
import java.util.ListIterator;
a65 2
import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.AlreadyExists;
d67 2
d86 5
a90 6
    public static Record createProject(DataManager dataMgr, 
                                       Connection connection,  
                                       AccessControlList acl, String domain,
                                       String projectName, String longName, 
                                       ArrayList owners)
	throws Exception, AlreadyExists {
d94 1
a94 2
	UserManager userman = (UserManager) 
            dataMgr.getManager("org.joist.database.UserManager");
d96 1
a96 2
	if (debug) log.debug("About to run addproject script for project: " + 
                             projectName);
d98 3
a100 18
	// Add the project to the database. This also runs the AddProject 
        // script.
        ProjectManager prjMgr = (ProjectManager)
            dataMgr.getManager("org.tigris.helm.database.ProjectManager");

        // TODO: get ProjectProfile
        Record project = prjMgr.addProject(connection, 
                                           null, 
                                           domain, 
                                           projectName, 
                                           null,
                                           longName,
                                           null,
                                           null,
                                           null,
                                           null,
                                           null,
                                           null);
d110 1
a110 1
	// Perform some tasks for each owner.
d116 2
a117 2
            //            loginID = sMgr.getLoginID(connection, i);
            //	    if (debug) log.debug("loginID " + loginID);
d119 1
a119 2

            //	    userman.setProjectOwner(connection, loginID, projectName, true);
d136 1
a136 1
	return project;
@

