head	1.32;
access;
symbols
	TIGRIS_1_1_0RC2:1.23
	TIGRIS_1_1_0RC1:1.23
	TIGRIS_1_1:1.23.0.4
	TIGRIS_1_0_8:1.23
	TIGRIS_1_0_8RC3:1.23
	TIGRIS_1_0_8RC2:1.23
	TIGRIS_1_0_8RC1:1.23
	TIGRIS_1_0_7:1.23
	TIGRIS_1_0_7RC3:1.23
	TIGRIS_1_0_7RC2:1.23
	TIGRIS_1_0_7RC1:1.23
	TIGRIS_1_0_6:1.23
	TIGRIS_1_0_6RC5:1.23
	TIGRIS_1_0_6RC4:1.23
	TIGRIS_1_0_6RC3:1.23
	TIGRIS_1_0_6RC2:1.23
	TIGRIS_1_0_6RC1:1.23
	TIGRIS_1_0_5:1.23
	TIGRIS_1_0_5RC6:1.23
	TIGRIS_1_0_5RC5:1.23
	TIGRIS_1_0_5RC4:1.23
	TIGRIS_1_0_5RC3:1.23
	TIGRIS_1_0_5RC2:1.23
	TIGRIS_1_0_5RC1:1.23
	TIGRIS_1_0_4:1.23
	TIGRIS_1_0_3:1.23
	TIGRIS_1_0_2:1.23
	TIGRIS_1_0_1:1.23
	TIGRIS_1_0:1.23.0.6
	TIGRIS_1_0_0:1.23
	TIGRIS_1_0_0_RC1:1.23.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.15
	TIGRIS_0_9_2_3:1.15
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.17
	TIGRIS_0_9_2_1:1.17
	TIGRIS_0_9_2:1.15.0.2
	TIGRIS_0_9_0:1.14.0.2
	TIGRIS_0_8_4:1.10.0.2;
locks; strict;
comment	@# @;


1.32
date	2001.07.23.23.58.55;	author leonardr;	state dead;
branches;
next	1.31;

1.31
date	2001.07.18.10.05.12;	author dlr;	state Exp;
branches;
next	1.30;

1.30
date	2001.07.17.17.55.45;	author leonardr;	state Exp;
branches;
next	1.29;

1.29
date	2001.07.05.22.21.38;	author leonardr;	state Exp;
branches;
next	1.28;

1.28
date	2001.06.29.00.57.48;	author leonardr;	state Exp;
branches;
next	1.27;

1.27
date	2001.06.21.00.22.14;	author leonardr;	state Exp;
branches;
next	1.26;

1.26
date	2001.06.09.01.02.15;	author leonardr;	state Exp;
branches;
next	1.25;

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

1.24
date	2001.04.26.16.16.43;	author leonardr;	state Exp;
branches;
next	1.23;

1.23
date	2001.03.12.19.06.31;	author dlr;	state Exp;
branches;
next	1.22;

1.22
date	2001.03.10.02.23.58;	author leonardr;	state Exp;
branches;
next	1.21;

1.21
date	2001.03.07.01.53.20;	author lucas;	state Exp;
branches;
next	1.20;

1.20
date	2001.02.26.22.51.43;	author leonardr;	state Exp;
branches;
next	1.19;

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

1.18
date	2001.02.21.01.08.21;	author dlr;	state Exp;
branches;
next	1.17;

1.17
date	2001.01.26.18.29.02;	author edk;	state Exp;
branches
	1.17.2.1;
next	1.16;

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

1.15
date	2000.12.29.02.37.09;	author dlr;	state Exp;
branches;
next	1.14;

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

1.13
date	2000.12.14.00.12.15;	author leonardr;	state Exp;
branches;
next	1.12;

1.12
date	2000.12.13.19.07.48;	author leonardr;	state Exp;
branches;
next	1.11;

1.11
date	2000.12.13.02.57.37;	author leonardr;	state Exp;
branches;
next	1.10;

1.10
date	2000.12.02.01.45.41;	author leonardr;	state Exp;
branches;
next	1.9;

1.9
date	2000.11.29.08.59.28;	author dlr;	state Exp;
branches;
next	1.8;

1.8
date	2000.11.29.07.52.04;	author dlr;	state Exp;
branches;
next	1.7;

1.7
date	2000.11.28.23.27.07;	author dlr;	state Exp;
branches;
next	1.6;

1.6
date	2000.11.28.23.16.14;	author dlr;	state Exp;
branches;
next	1.5;

1.5
date	2000.11.28.00.15.10;	author dlr;	state Exp;
branches;
next	1.4;

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

1.3
date	2000.11.27.20.04.12;	author dlr;	state Exp;
branches;
next	1.2;

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

1.1
date	2000.11.14.22.49.28;	author elicia;	state Exp;
branches
	1.1.1.1;
next	;

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

1.17.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	1.17.2.2;

1.17.2.2
date	2001.02.09.02.38.26;	author dlr;	state Exp;
branches;
next	1.17.2.3;

1.17.2.3
date	2001.02.09.18.26.15;	author leonardr;	state Exp;
branches;
next	1.17.2.4;

1.17.2.4
date	2001.02.12.16.24.31;	author leonardr;	state Exp;
branches;
next	1.17.2.5;

1.17.2.5
date	2001.02.15.14.59.29;	author leonardr;	state Exp;
branches;
next	1.17.2.6;

1.17.2.6
date	2001.02.15.20.50.35;	author leonardr;	state Exp;
branches;
next	1.17.2.7;

1.17.2.7
date	2001.02.16.03.01.26;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.32
log
@Got rid of ugly multi-page project add in favor of lovely single-page project add. Those adjectives are not subjective in any way.
@
text
@/* ================================================================
 * Copyright (c) 2000-2001 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 COLLABNET 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.domain;

import java.util.*;
import java.sql.Connection;
import java.sql.SQLException;
import javax.servlet.http.*;

import org.apache.turbine.util.Log;
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.TurbineException;

import org.apache.velocity.context.Context;

import org.tigris.helm.security.RedirectException;

import org.tigris.helm.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.profile.*;
import org.tigris.helm.om.*;
import org.tigris.helm.security.*;
import org.tigris.helm.tool.*;
import org.tigris.helm.tool.audit.AuditLog;

/**
 * The last step in adding a new project.  Mostly just a confirmation for the 
 * user.
 *
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: ProjectAddStep4.java,v 1.31 2001/07/18 10:05:12 dlr Exp $
 */
public class ProjectAddStep4 extends ProjectAdd
{
    /**
     * The project approval time key.
     */
    private static final String APPROVAL_TIME = "approvalTime";

    /**
     * The mapped to value used in project creation which are temporarily 
     * stored in the session as the project creation wizard steps from screen
     * to screen.
     */
    private static final String[] SESSION_KEYS = 
    { 
        SEEN_SCREEN_2,
        PROJECT_NAME,
        SHORT_DESCRIP, 
        LONG_DESCRIP,
        USE_INDEX,
        URL,
        SELECTED_CATEGORIES_FIELD, 
        LICENSE_ID,
        PROJECT_OWNER,
        INVITE_EMAIL_ADDRS,
        INVITATION 
    };

    /**
     * Show the project approval message.
     */
    protected String processRequest(Context context)
        throws TurbineException, RedirectException
    {
        String templateName = super.processRequest(context);

        try
        {
            // Get the data necessary to add the project.
            User loginUser = getLoginUser(context);
            HttpSession session = getSessionManager(context).getSession();
            String newProjectName = (String)session.getValue(PROJECT_NAME);
            ContextAPI.requireValue(context, newProjectName, "Project name");
            String shortDescription = (String)session.getValue(SHORT_DESCRIP);
            ContextAPI.requireValue(context, shortDescription, 
                                    "Short description");    
            String isPublic = (String)session.getValue(IS_PUBLIC);
            String longDescription = (String)session.getValue(LONG_DESCRIP);
            String useIndex = (String)session.getValue(USE_INDEX);
            String url = (String)session.getValue(URL);
            String licenseID = (String)session.getValue(LICENSE_ID);
            License license = LicensePeer.getInstance(licenseID);
            String projectOwner = (String)session.getValue(PROJECT_OWNER);
            ContextAPI.requireValue(context, projectOwner, "Project owner");
            String[] selectedCategories = 
                (String[])session.getValue(SELECTED_CATEGORIES_FIELD);

            // Add the project.
            Project project = null;
            boolean ok = ContextAPI.isValidUserInput(context);
            if (ok)
            {
                Domain domain = getCurrentDomain(context);
                try
                {
                    User projectOwnerUser = UserPeer.getInstanceByIdentifier
                        (domain, projectOwner);
                    
                    project = Project.add(getACL(context),
                                          domain,
                                          newProjectName, 
                                          //projectProfile, 
                                          license,
                                          isPublic,
                                          shortDescription, 
                                          longDescription,
                                          useIndex, 
                                          "",  //status
                                          url, 
                                          loginUser, 
                                          projectOwnerUser);
                    if (project != null)
                    {
                        AccessControlList acl =
                            AccessControlList.getSuperUserACL();
                        for (int i = 0; i < selectedCategories.length; i++)
                        {
                            Category category = 
                                (Category)ProjectPeer.getInstance
                                (selectedCategories[i]);
                            category.associate(acl, project);
                        }

                        Boolean isInviting =
                            (Boolean)session.getValue(IS_INVITING);

                        if (isInviting != null && isInviting.booleanValue())
                        {
                            try
                            {
                                sendInvitations(context, project, session,
                                                loginUser);
                            }
                            catch (ACLException e)
                            {
                                appendToMessage(context, "Project created, but " +
                                                "invitations not sent due " +
                                                "to insufficent permission");
                            }
                        }
                        clearProjectCreationFields(session);
                        context.put("project", project);
                        context.put(APPROVAL_TIME, getApprovalTime());

                        AuditLog.logEvent
                            (loginUser, domain,
                             "Added " + project.getName() + " project.");
                    }
                    else
                    {
                        redirectToError(context, "Could not add project");
                    }
                }
                catch (DoesNotExist e)
                {
                    ContextAPI.addValidationError(context, e.getMessage());
                    ok = false;
                }
                catch (AlreadyExists e)
                {
                    addProjectNameJustRegistered(context);
                    ok = false;
                }                
            }
        }
        catch (RedirectException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            Log.error(e);
            throw new TurbineException(e);
        }

        return templateName;
    }

    /**
     * Parse the recipients from the provided address list text.
     *
     * @@param addresses The data to parse.
     * @@return          The recipients.
     */
    private List getRecipients (String addresses)
    {
        List recipients = new ArrayList(); 
        StringTokenizer tok = new StringTokenizer
            (addresses, myProperties.getProperty("recipientSeparators"));
        while (tok.hasMoreTokens())
        {
            recipients.add(tok.nextToken());
        }
        return recipients;
    }

    /**
     * Sends any invitations.
     */
    private void sendInvitations (Context context, Project project,
                                  HttpSession session, User loginUser)
        throws ACLException, Exception
    {
        getACL(context).assertPermission("Project - Invite", project);
        String inviteEmails = (String)session.getValue(INVITE_EMAIL_ADDRS);
        String inviteMessage = (String)session.getValue(INVITATION);
        Invitation.sendInvitations(getCurrentDomain(context),
                                   getRecipients(inviteEmails),
                                   loginUser,
                                   project,
                                   inviteMessage);
    }

    /**
     * Clears the fields used in project creation.
     *
     * @@param session The session to reset.
     */
    private final void clearProjectCreationFields (HttpSession session)
    {
        for (int i = 0; i < SESSION_KEYS.length; i++)
        {
            session.removeValue(SESSION_KEYS[i]);
        }
    }

    /**
     * Returns a description of the amount of time which approval usually 
     * takes.
     *
     * @@return The amount of time which approval usually takes.
     */
    private final String getApprovalTime ()
    {
        return myProperties.getProperty(APPROVAL_TIME);
    }
}
@


1.31
log
@Ported Joist Redirect*Exception to Helm.
@
text
@d75 1
a75 1
 * @@version $Id: ProjectAddStep4.java,v 1.30 2001/07/17 17:55:45 leonardr Exp $
@


1.30
log
@Porting of domain package to new error handling API.
@
text
@d60 1
a60 1
import org.joist.security.RedirectException;
d75 1
a75 1
 * @@version $Id: ProjectAddStep4.java,v 1.29 2001/07/05 22:21:38 leonardr Exp $
@


1.29
log
@Licenses are now contained in a database-managed table rather than in a custom Java class (yay!)
@
text
@d75 1
a75 1
 * @@version $Id: ProjectAddStep4.java,v 1.28 2001/06/29 00:57:48 leonardr Exp $
d107 1
a107 1
    protected String processRequest(Context ctx)
d110 1
a110 1
        String templateName = super.processRequest(ctx);
d115 2
a116 3
            User loginUser = getLoginUser(ctx);
            List missingFields = new ArrayList(); 
            HttpSession session = getSessionManager(ctx).getSession();
d118 1
a118 1
            requireValue(newProjectName, "Project name", missingFields);
d120 2
a121 2
            requireValue(shortDescription, "Short description",
                         missingFields);    
d129 1
a129 1
            requireValue(projectOwner, "Project owner", missingFields);
a131 2
            //ProjectProfile projectProfile =
            //(ProjectProfile)session.getValue(PROJECT_PROFILE);
a133 1
            List validationErrors = new ArrayList();
d135 1
a135 1
            boolean ok = isValidUserInput(missingFields, null);
d138 1
a138 1
                Domain domain = getCurrentDomain(ctx);
d143 2
a144 2

                    project = Project.add(getACL(ctx),
d176 1
a176 1
                                sendInvitations(ctx, project, session,
d181 1
a181 1
                                appendToMessage(ctx, "Project created, but " +
d187 2
a188 2
                        ctx.put("project", project);
                        ctx.put(APPROVAL_TIME, getApprovalTime());
d196 1
a196 1
                        redirectToError(ctx, "Could not add project");
d201 1
a201 1
                    validationErrors.add(e.getMessage());
d206 1
a206 1
                    addProjectNameJustRegistered(validationErrors);
a209 5

            if (!ok)
            {
                reportInvalidUserInput(ctx, missingFields, validationErrors);
            }
d245 1
a245 1
    private void sendInvitations (Context ctx, Project project,
d249 1
a249 1
        getACL(ctx).assertPermission("Project - Invite", project);
d252 1
a252 1
        Invitation.sendInvitations(getCurrentDomain(ctx),
@


1.28
log
@Implemented basic project group and category nesting.
@
text
@d75 1
a75 1
 * @@version $Id: ProjectAddStep4.java,v 1.27 2001/06/21 00:22:14 leonardr Exp $
d97 2
a98 1
        LICENSE,
d127 2
a128 2
            String license = (String)session.getValue(LICENSE);
            requireValue(license, "License", missingFields);
@


1.27
log
@Projects can now belong to more than one category.
@
text
@d75 1
a75 1
 * @@version $Id: ProjectAddStep4.java,v 1.26 2001/06/09 01:02:15 leonardr Exp $
d169 1
a169 1
                            category.addProject(acl, project);
@


1.26
log
@Got rid of the ugly and unneccessary asGroup() and getGroupInstance() methods.
@
text
@d75 1
a75 1
 * @@version $Id: ProjectAddStep4.java,v 1.25 2001/05/23 01:50:09 dlr Exp $
d130 2
a131 2
            String catTypeID = (String)session.getValue(CAT_TYPE_ID);
            requireValue(catTypeID, "Category", missingFields);
d162 9
a170 3
                        // TODO: FIXME; better way of getting a Category?
                        project.changeCategory
                            ((Category)ProjectPeer.getInstance(catTypeID));
@


1.25
log
@Ported Helm from WebMacro to Velocity.
@
text
@d75 1
a75 1
 * @@version $Id: ProjectAddStep4.java,v 1.24 2001/04/26 16:16:43 leonardr Exp $
d164 1
a164 1
                            ((Category)ProjectPeer.getGroupInstance(catTypeID));
@


1.24
log
@Patches I forgot to commit before, for decoupling privateness from proprietariness.
@
text
@d55 2
d58 1
a58 1
import org.webmacro.servlet.*;
d75 1
a75 1
 * @@version $Id: ProjectAddStep4.java,v 1.23 2001/03/12 19:06:31 dlr Exp $
d106 2
a107 2
    protected String processRequest (Connection conn, WebContext ctx)
        throws HandlerException, RedirectException
d109 1
a109 1
        String templateName = super.processRequest(conn, ctx);
d220 1
a220 1
            throw new HandlerException(e.getMessage());
d247 1
a247 1
    private void sendInvitations (WebContext ctx, Project project,
@


1.23
log
@Set status to the empty string.
@
text
@d73 1
a73 1
 * @@version $Id: ProjectAddStep4.java,v 1.22 2001/03/10 02:23:58 leonardr Exp $
d87 13
a99 9
    private static final String[] SESSION_KEYS = { PROJECT_NAME,
                                                   SHORT_DESCRIP, 
                                                   LONG_DESCRIP,
                                                   USE_INDEX,
                                                   URL,
                                                   LICENSE,
                                                   PROJECT_OWNER,
                                                   INVITE_EMAIL_ADDRS,
                                                   INVITATION };
d120 1
d150 1
@


1.22
log
@Don't do the audit log if the add failed.
@
text
@d73 1
a73 1
 * @@version $Id: ProjectAddStep4.java,v 1.21 2001/03/07 01:53:20 lucas Exp $
d148 1
a148 1
                                          null, //status
@


1.21
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d73 1
a73 1
 * @@version $Id: ProjectAddStep4.java,v 1.20 2001/02/26 22:51:43 leonardr Exp $
d178 4
a197 2
                AuditLog.logEvent(loginUser, domain,
                                 "Added " + project.getName() + " project.");
@


1.20
log
@Commented out confusing and as-yet-unneccessary project profile selection *again*
@
text
@d63 1
a63 2
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
d73 1
a73 1
 * @@version $Id: ProjectAddStep4.java,v 1.19 2001/02/21 06:55:40 edk Exp $
@


1.19
log
@rename projectName to newProjectName to avoid conflicts with HelmServlet's
heuristics for determining the current project
@
text
@d74 1
a74 1
 * @@version $Id: ProjectAddStep4.java,v 1.18 2001/02/21 01:08:21 dlr Exp $
d126 2
a127 2
            ProjectProfile projectProfile =
                (ProjectProfile)session.getValue(PROJECT_PROFILE);
a141 1
                                          projectProfile, 
d144 1
@


1.18
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d74 1
a74 1
 * @@version $Id: ProjectAddStep4.java,v 1.17.2.7 2001/02/16 03:01:26 dlr Exp $
d112 2
a113 2
            String projectName = (String)session.getValue(PROJECT_NAME);
            requireValue(projectName, "Project name", missingFields);
d144 1
a144 1
                                          projectName, 
@


1.17
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d2 1
a2 1
 * Copyright (c) 2000 CollabNet.  All rights reserved.
d54 2
a55 1
import org.webmacro.util.*;
a57 3
import com.workingdogs.village.DataSetException;

import org.joist.JoistException;
a58 2
import org.joist.database.DataManager;
import org.joist.database.JoistDatabaseException;
d60 6
a65 5
import org.tigris.helm.AlreadyExists;
import org.tigris.helm.security.HelmServlet;
import org.tigris.helm.security.ACLException;
import org.tigris.helm.project.Project;
import org.tigris.helm.project.ProjectProfile;
d74 1
a74 1
 * @@version $Id: ProjectAddStep4.java,v 1.15 2000/12/29 02:37:09 dlr Exp $
a77 2
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.15 2000/12/29 02:37:09 dlr Exp $";

a83 10
     * Open the log file.
     */
    private static Log log = new Log("projAdd4", "ProjectAddStep4");

    /**
     * Whether to log debugging information.
     */
    private static final boolean debug = true;

    /**
d138 4
a141 1
                    project = new Project(conn, dMgr, getACL(ctx, conn),
d143 1
a143 1
                                          domain.getID(), 
d151 2
a152 2
                                          loginUser.getID(), 
                                          projectOwner);
d155 1
d157 1
a157 1
                            (new Category(conn, dMgr, catTypeID));
d166 1
a166 1
                                sendInvitations(ctx, conn, project, session,
d185 5
d195 1
a195 1
                AuditLog.logItem(conn, dMgr, loginUser.getID(), domain,
d204 1
a204 1
        catch (ACLException e)
d210 1
a210 1
            log.exception(e);
d223 1
a223 1
    private ArrayList getRecipients (String addresses)
d225 1
a225 1
        ArrayList recipients = new ArrayList(); 
d238 3
a240 5
    private void sendInvitations (WebContext ctx, Connection conn,
                                  Project project, HttpSession session,
                                  User loginUser)
        throws ACLException, SQLException, DataSetException,
               JoistDatabaseException, JoistException
d242 1
a242 2
        getACL(ctx, conn).assertPermissionForProject("Project - Invite",
                                                     project.getID());
d245 1
a245 3
        Invitation.sendInvitations(conn,
                                   super.dMgr,
                                   getCurrentDomain(ctx),
@


1.17.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d77 1
a77 1
 * @@version $Id: ProjectAddStep4.java,v 1.17 2001/01/26 18:29:02 edk Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.17 2001/01/26 18:29:02 edk Exp $";
@


1.17.2.2
log
@Beginnings of porting.
@
text
@d54 2
a55 1
import org.apache.turbine.util.Log;
d57 1
a57 1
import org.webmacro.servlet.*;
d59 1
d61 2
d64 5
a68 5
import org.tigris.helm.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.profile.*;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.security.*;
d81 2
d89 10
a150 1
                /* FIXME: We need this.
d153 1
a153 1
                    project = new Project(getACL(ctx),
d155 1
a155 1
                                          domain,
d167 2
a168 2
                        // TODO: FIXME
                        //project.changeCategory(new Category(catTypeID));
d177 1
a177 1
                                sendInvitations(ctx, project, session,
d200 2
a201 3
                }
                */
                AuditLog.logItem(loginUser.getID(), domain,
a209 1
        /* TODO: FIXME
a213 5
        catch (RedirectException e)
        {
            throw e;
        }
        */
d216 1
a216 1
            Log.error(e);
d244 5
a248 3
    private void sendInvitations (WebContext ctx, Project project,
                                  HttpSession session, User loginUser)
        throws ACLException, Exception
d250 2
a251 1
        getACL(ctx).assertPermissionForProject("Project - Invite", project);
d254 3
a256 1
        Invitation.sendInvitations(getCurrentDomain(ctx),
@


1.17.2.3
log
@Ported audit log functionality.
@
text
@d73 1
a73 1
 * @@version $Id: ProjectAddStep4.java,v 1.17.2.2 2001/02/09 02:38:26 dlr Exp $
d187 1
a187 1
                AuditLog.logEvent(loginUser, domain,
@


1.17.2.4
log
@Changed code to no longer use deprecated methods.
@
text
@d73 1
a73 1
 * @@version $Id: ProjectAddStep4.java,v 1.17.2.3 2001/02/09 18:26:15 leonardr Exp $
d240 1
a240 1
        getACL(ctx).assertPermission("Project - Invite", project);
@


1.17.2.5
log
@Ported some more project add functionality.
@
text
@d73 1
a73 1
 * @@version $Id: ProjectAddStep4.java,v 1.17.2.4 2001/02/12 16:24:31 leonardr Exp $
d135 1
d138 1
a138 4
                    User projectOwnerUser = UserPeer.getInstanceByIdentifier
                        (domain, projectOwner);

                    project = Project.add(getACL(ctx),
d148 2
a149 2
                                          loginUser, 
                                          projectOwnerUser);
d152 2
a153 3
                        // TODO: FIXME; better way of getting a Category?
                        project.changeCategory
                            ((Category)ProjectPeer.getGroupInstance(catTypeID));
a180 5
                catch (DoesNotExist e)
                {
                    validationErrors.add(e.getMessage());
                    ok = false;
                }
d185 2
a186 1
                }                
d196 5
d205 1
d221 1
a221 1
    private List getRecipients (String addresses)
d223 1
a223 1
        List recipients = new ArrayList(); 
@


1.17.2.6
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d73 1
a73 1
 * @@version $Id: ProjectAddStep4.java,v 1.17.2.5 2001/02/15 14:59:29 leonardr Exp $
@


1.17.2.7
log
@Added new imports necessitated by Torque.
@
text
@a63 1
import org.tigris.helm.om.base.*;
d73 1
a73 1
 * @@version $Id: ProjectAddStep4.java,v 1.17.2.6 2001/02/15 20:50:35 leonardr Exp $
@


1.16
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.15
log
@Updated to support new HELM_PROJECT.USE_INDEX field (may make use of new DBFlag class to do so).
@
text
@d77 1
a77 1
 * @@version $Id: ProjectAddStep4.java,v 1.14 2000/12/19 00:51:32 leonardr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.14 2000/12/19 00:51:32 leonardr Exp $";
@


1.14
log
@Run ProjectCreate before MemberAdd.
@
text
@d77 1
a77 1
 * @@version $Id: ProjectAddStep4.java,v 1.13 2000/12/14 00:12:15 leonardr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.13 2000/12/14 00:12:15 leonardr Exp $";
d105 2
a106 1
                                                   LONG_DESCRIP, 
d133 1
a133 1
            requireValue(longDescription, "Long description", missingFields);
d159 2
a160 1
                                          longDescription, 
@


1.13
log
@Project creation is a domain action.
@
text
@d17 1
a17 1
 * software developed by CollabNet (http://www.Collab.Net/)."
d32 1
a32 1
 * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
d77 1
a77 1
 * @@version $Id: ProjectAddStep4.java,v 1.12 2000/12/13 19:07:48 leonardr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.12 2000/12/13 19:07:48 leonardr Exp $";
@


1.12
log
@Moved AuditLog to its own directory, where it will be joined by servlets.
@
text
@d77 1
a77 1
 * @@version $Id: ProjectAddStep4.java,v 1.11 2000/12/13 02:57:37 leonardr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.11 2000/12/13 02:57:37 leonardr Exp $";
d149 1
d154 1
a154 1
                                          getCurrentDomain(ctx).getID(), 
d199 1
a199 1
                AuditLog.logItem(conn, dMgr, loginUser.getID(), project, 
@


1.11
log
@Corrected bugs in and wrote first usage of audit logging.
@
text
@d70 1
d77 1
a77 1
 * @@version $Id: ProjectAddStep4.java,v 1.10 2000/12/02 01:45:41 leonardr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.10 2000/12/02 01:45:41 leonardr Exp $";
@


1.10
log
@Changes to fix horrible mistakes in removing projects from project groups, among other things.
@
text
@d69 1
a69 1
import org.tigris.helm.tool.Invitation;
d76 1
a76 1
 * @@version $Id: ProjectAddStep4.java,v 1.9 2000/11/29 08:59:28 dlr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.9 2000/11/29 08:59:28 dlr Exp $";
d197 2
@


1.9
log
@Refactored to make use of missing field data in final sanity check.
@
text
@d76 1
a76 1
 * @@version $Id: ProjectAddStep4.java,v 1.8 2000/11/29 07:52:04 dlr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.8 2000/11/29 07:52:04 dlr Exp $";
d196 1
a196 1
                }
@


1.8
log
@No need to call processField() in this servlet--use HttpSession
directly instead.
@
text
@d76 1
a76 1
 * @@version $Id: ProjectAddStep4.java,v 1.7 2000/11/28 23:27:07 dlr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.7 2000/11/28 23:27:07 dlr Exp $";
a140 1
            Boolean isInviting = (Boolean)session.getValue(IS_INVITING);
d145 2
a146 2
            boolean isUnusedName = false;
            try
d148 17
a164 17
                project = new Project(conn, dMgr, getACL(ctx, conn),
                                      projectProfile, 
                                      getCurrentDomain(ctx).getID(), 
                                      projectName, 
                                      license,
                                      shortDescription, 
                                      longDescription, 
                                      null, //status
                                      url, 
                                      loginUser.getID(), 
                                      projectOwner);
                isUnusedName = true;
            }
            catch (AlreadyExists e)
            {
                addProjectNameJustRegistered(validationErrors);
            }
d166 2
a167 6
            if (isValidUserInput(missingFields, validationErrors))
            {
                if (isUnusedName && project != null)
                {
                    project.changeCategory
                        (new Category(conn, dMgr, catTypeID));
d169 1
a169 3
                    if (isInviting != null && isInviting.booleanValue())
                    {
                        try
d171 11
a181 8
                            sendInvitations(ctx, conn, project, session,
                                            loginUser);
                        }
                        catch (ACLException e)
                        {
                            appendToMessage(ctx, "Project created, but " +
                                            "invitations not sent due to " +
                                            "insufficent permission");
d183 7
a190 3
                    clearProjectCreationFields(session);
                    ctx.put("project", project);
                    ctx.put(APPROVAL_TIME, getApprovalTime());
d192 1
a192 1
                else
d194 2
a195 1
                    redirectToError(ctx, "Could not add project");
d198 2
a199 1
            else
@


1.7
log
@pluralized
@
text
@d76 1
a76 1
 * @@version $Id: ProjectAddStep4.java,v 1.6 2000/11/28 23:16:14 dlr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.6 2000/11/28 23:16:14 dlr Exp $";
d244 2
a245 2
        String inviteEmails = processField(ctx, INVITE_EMAIL_ADDRS, session);
        String inviteMessage = processField(ctx, INVITATION, session);
@


1.6
log
@- Added some Exception imports.
- Encapsulated invitation mailing as a method, added ACL checking.
- Used new sendInvitation() method with ACL invitation send failure
  wrapper.
@
text
@d76 1
a76 1
 * @@version $Id: ProjectAddStep4.java,v 1.5 2000/11/28 00:15:10 dlr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.5 2000/11/28 00:15:10 dlr Exp $";
d178 2
a179 2
                            sendInvitation(ctx, conn, project, session,
                                           loginUser);
d236 3
a238 3
    private void sendInvitation (WebContext ctx, Connection conn,
                                 Project project, HttpSession session,
                                 User loginUser)
@


1.5
log
@Handle session values used in step 4 correctly.
@
text
@d17 1
a17 1
 * software developed by Collab.Net (http://www.Collab.Net/)."
d27 1
a27 1
 * permission of Collab.Net.
d51 1
d53 1
a53 1
    
d57 3
d62 1
d66 1
d76 1
a76 1
 * @@version $Id: ProjectAddStep4.java,v 1.4 2000/11/27 20:46:07 dlr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.4 2000/11/27 20:46:07 dlr Exp $";
d176 11
a186 12
                        String inviteEmails = processField(ctx,
                                                           INVITE_EMAIL_ADDRS,
                                                           session);
                        String inviteMessage = processField(ctx, INVITATION,
                                                            session);
                        Invitation.sendInvitations(conn,
                                                   super.dMgr,
                                                   getCurrentDomain(ctx),
                                                   getRecipients(inviteEmails),
                                                   loginUser,
                                                   project,
                                                   inviteMessage);
d202 4
d231 22
@


1.4
log
@Corrected build errors.
@
text
@d70 1
a70 1
 * @@version $Id: ProjectAddStep4.java,v 1.3 2000/11/27 20:04:12 dlr Exp $
d74 1
a74 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.3 2000/11/27 20:04:12 dlr Exp $";
d119 14
a132 16
            String projectName = processField(ctx, PROJECT_NAME, session, 
                                              "Project name", missingFields);
            String shortDescription = processField(ctx, SHORT_DESCRIP,
                                                   session,
                                                   "Short description",
                                                   missingFields);    
            String longDescription = processField(ctx, LONG_DESCRIP,
                                                  session, "Long description", 
                                                  missingFields);
            String url = processField(ctx, URL, session);
            String license = processField(ctx, LICENSE, "License", 
                                          missingFields);
            String projectOwner = processField(ctx, PROJECT_OWNER,
                                               loginUser.getLoginID());
            String catTypeID = processField(ctx, "catTypeID", "Category", 
                                            missingFields);
d166 2
a167 1
                        (new Category(conn, dMgr, catTypeID.toString()));
@


1.3
log
@Modifications to make project addition more wizard-like...small breakage on this commit, will fix immediatly.
@
text
@d51 2
a52 2
import javax.servlet.*;

a55 1
import org.tigris.helm.security.HelmServlet;
d59 6
d70 1
a70 1
 * @@version $Id: ProjectAddStep4.java,v 1.2 2000/11/23 09:22:57 dlr Exp $
d74 1
a74 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.2 2000/11/23 09:22:57 dlr Exp $";
a112 4
        // Add the project.
        List validationErrors = new ArrayList();
        Project project = null;
        boolean isUnusedName = false;
d115 47
a161 17
            project = new Project(conn, dMgr, getACL(ctx, conn),
                                  projectType, 
                                  currentDomain.getID(), 
                                  projectName, 
                                  license,
                                  shortDescription, 
                                  longDescription, 
                                  null, //status
                                  url, 
                                  userID, 
                                  projectOwner);
            isUnusedName = true;
        }
        catch (AlreadyExists e)
        {
            addProjectNameJustRegistered(validationErrors);
        }
d163 1
a163 3
        if (isValidUserInput(null, validationErrors))
        {
            if (isUnusedName && project != null)
d165 27
a191 12
                project.changeCategory
                    (new Category(conn, dMgr, catTypeID.toString()));
                Invitation.sendInvitations(conn,
                                           super.dMgr,
                                           getCurrentDomain(ctx),
                                           getRecipients(inviteEmails),
                                           loginUser,
                                           project,
                                           inviteMessage);
                clearProjectCreationFields(session);
                ctx.put("project", project);
                ctx.put(APPROVAL_TIME, getApprovalTime());
d195 1
a195 1
                redirectToError(ctx, "Could not add project");
d198 1
a198 1
        else
d200 2
a201 1
            reportInvalidUserInput(null, validationErrors);
@


1.2
log
@Made use of new super class.
@
text
@d49 1
d65 1
a65 1
 * @@version $Id: ProjectAddStep4.java,v 1.1 2000/11/14 22:49:28 elicia Exp $
d69 7
a75 2
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.1 2000/11/14 22:49:28 elicia Exp $";
        
d87 14
d103 1
a103 1
    protected String processRequest (Connection conn, WebContext context)
d106 53
a158 2
        String templateName = super.processRequest(conn, context);
        context.put(APPROVAL_TIME, getApprovalTime());
d160 31
@


1.1
log
@broke up ProjectAdd into ProjectAdd and ProjectAddStep2.  Renamed later steps. Removed Member Policy field.
@
text
@d49 1
a49 1
import java.sql.*;
d60 1
a60 1
 * The third step in adding a new project.  Mostly just a confirmation for the 
d64 1
a64 1
 * @@version $Id: ProjectAddStep4.java,v 1.1 2000/11/13 21:27:44 edk Exp $
d66 1
a66 1
public class ProjectAddStep4 extends HelmServlet
d68 1
a68 1
    public static final  String versionID = "$Id: ProjectAddStep4.java,v 1.1 2000/11/13 21:27:44 edk Exp $";
d73 1
a73 1
    private static Log log = new Log("sspa4", "ProjectAddStep4");
d87 1
a87 1
        context.put("approvalTime", getApprovalTime());
d99 1
a99 1
        return myProperties.getProperty("approvalTime");
@


1.1.1.1
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d17 1
a17 1
 * software developed by CollabNet (http://www.collab.net/)."
d27 1
a27 1
 * permission of CollabNet.
d32 1
a32 1
 * IN NO EVENT SHALL COLLABNET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
d49 2
a50 6
import java.util.*;
import java.sql.Connection;
import java.sql.SQLException;
import javax.servlet.http.*;

import org.apache.turbine.util.Log;
d52 1
d55 1
d57 1
a57 9

import org.tigris.helm.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.profile.*;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
import org.tigris.helm.security.*;
import org.tigris.helm.tool.*;
import org.tigris.helm.tool.audit.AuditLog;
d60 1
a60 1
 * The last step in adding a new project.  Mostly just a confirmation for the 
d64 1
a64 1
 * @@version $Id: ProjectAddStep4.java,v 1.17.2.7 2001/02/16 03:01:26 dlr Exp $
d66 1
a66 1
public class ProjectAddStep4 extends ProjectAdd
d68 2
d71 1
a71 1
     * The project approval time key.
d73 1
a73 1
    private static final String APPROVAL_TIME = "approvalTime";
d76 1
a76 3
     * The mapped to value used in project creation which are temporarily 
     * stored in the session as the project creation wizard steps from screen
     * to screen.
d78 1
a78 9
    private static final String[] SESSION_KEYS = { PROJECT_NAME,
                                                   SHORT_DESCRIP, 
                                                   LONG_DESCRIP,
                                                   USE_INDEX,
                                                   URL,
                                                   LICENSE,
                                                   PROJECT_OWNER,
                                                   INVITE_EMAIL_ADDRS,
                                                   INVITATION };
d83 1
a83 1
    protected String processRequest (Connection conn, WebContext ctx)
d86 2
a87 110
        String templateName = super.processRequest(conn, ctx);

        try
        {
            // Get the data necessary to add the project.
            User loginUser = getLoginUser(ctx);
            List missingFields = new ArrayList(); 
            HttpSession session = getSessionManager(ctx).getSession();
            String projectName = (String)session.getValue(PROJECT_NAME);
            requireValue(projectName, "Project name", missingFields);
            String shortDescription = (String)session.getValue(SHORT_DESCRIP);
            requireValue(shortDescription, "Short description",
                         missingFields);    
            String longDescription = (String)session.getValue(LONG_DESCRIP);
            String useIndex = (String)session.getValue(USE_INDEX);
            String url = (String)session.getValue(URL);
            String license = (String)session.getValue(LICENSE);
            requireValue(license, "License", missingFields);
            String projectOwner = (String)session.getValue(PROJECT_OWNER);
            requireValue(projectOwner, "Project owner", missingFields);
            String catTypeID = (String)session.getValue(CAT_TYPE_ID);
            requireValue(catTypeID, "Category", missingFields);
            ProjectProfile projectProfile =
                (ProjectProfile)session.getValue(PROJECT_PROFILE);

            // Add the project.
            List validationErrors = new ArrayList();
            Project project = null;
            boolean ok = isValidUserInput(missingFields, null);
            if (ok)
            {
                Domain domain = getCurrentDomain(ctx);
                try
                {
                    User projectOwnerUser = UserPeer.getInstanceByIdentifier
                        (domain, projectOwner);

                    project = Project.add(getACL(ctx),
                                          projectProfile, 
                                          domain,
                                          projectName, 
                                          license,
                                          shortDescription, 
                                          longDescription,
                                          useIndex, 
                                          null, //status
                                          url, 
                                          loginUser, 
                                          projectOwnerUser);
                    if (project != null)
                    {
                        // TODO: FIXME; better way of getting a Category?
                        project.changeCategory
                            ((Category)ProjectPeer.getGroupInstance(catTypeID));

                        Boolean isInviting =
                            (Boolean)session.getValue(IS_INVITING);

                        if (isInviting != null && isInviting.booleanValue())
                        {
                            try
                            {
                                sendInvitations(ctx, project, session,
                                                loginUser);
                            }
                            catch (ACLException e)
                            {
                                appendToMessage(ctx, "Project created, but " +
                                                "invitations not sent due " +
                                                "to insufficent permission");
                            }
                        }
                        clearProjectCreationFields(session);
                        ctx.put("project", project);
                        ctx.put(APPROVAL_TIME, getApprovalTime());
                    }
                    else
                    {
                        redirectToError(ctx, "Could not add project");
                    }
                }
                catch (DoesNotExist e)
                {
                    validationErrors.add(e.getMessage());
                    ok = false;
                }
                catch (AlreadyExists e)
                {
                    addProjectNameJustRegistered(validationErrors);
                    ok = false;
                }                
                AuditLog.logEvent(loginUser, domain,
                                 "Added " + project.getName() + " project.");
            }

            if (!ok)
            {
                reportInvalidUserInput(ctx, missingFields, validationErrors);
            }
        }
        catch (RedirectException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            Log.error(e);
            throw new HandlerException(e.getMessage());
        }

a91 48
     * Parse the recipients from the provided address list text.
     *
     * @@param addresses The data to parse.
     * @@return          The recipients.
     */
    private List getRecipients (String addresses)
    {
        List recipients = new ArrayList(); 
        StringTokenizer tok = new StringTokenizer
            (addresses, myProperties.getProperty("recipientSeparators"));
        while (tok.hasMoreTokens())
        {
            recipients.add(tok.nextToken());
        }
        return recipients;
    }

    /**
     * Sends any invitations.
     */
    private void sendInvitations (WebContext ctx, Project project,
                                  HttpSession session, User loginUser)
        throws ACLException, Exception
    {
        getACL(ctx).assertPermission("Project - Invite", project);
        String inviteEmails = (String)session.getValue(INVITE_EMAIL_ADDRS);
        String inviteMessage = (String)session.getValue(INVITATION);
        Invitation.sendInvitations(getCurrentDomain(ctx),
                                   getRecipients(inviteEmails),
                                   loginUser,
                                   project,
                                   inviteMessage);
    }

    /**
     * Clears the fields used in project creation.
     *
     * @@param session The session to reset.
     */
    private final void clearProjectCreationFields (HttpSession session)
    {
        for (int i = 0; i < SESSION_KEYS.length; i++)
        {
            session.removeValue(SESSION_KEYS[i]);
        }
    }

    /**
d99 1
a99 1
        return myProperties.getProperty(APPROVAL_TIME);
@


