head	1.3;
access;
symbols
	NEWHELM:1.1.1.1 TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.3
date	2000.11.13.21.27.44;	author edk;	state dead;
branches;
next	1.2;

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

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

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


desc
@@


1.3
log
@SelfServeProjectAddStep([23]) => ProjectAddStep$1
@
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 Collab.Net.
 * 
 * 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.domain;

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

import org.webmacro.util.*;
import org.webmacro.servlet.*;

import org.joist.*;
import org.joist.util.*;
import org.joist.session.*;

import com.workingdogs.village.*;

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

import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.security.HelmServlet;
import org.tigris.helm.database.ProjectManager;
import org.tigris.helm.tool.Invitation;
import org.tigris.helm.project.Project;

/**
 * The second step in adding a new project.  Invite people to join.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 * @@version $Id: SelfServeProjectAddStep2.java,v 1.2 2000/11/13 21:16:52 edk Exp $
 */
public class SelfServeProjectAddStep2 extends HelmServlet
{
    public static final  String versionID = "$Id: SelfServeProjectAddStep2.java,v 1.2 2000/11/13 21:16:52 edk Exp $";

    /**
     * Open the log file.
     */
    private static Log log = new Log("sspa2", "SelfServeProjectAddStep2");

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

    /**
     * The value for the action CGI query parameter.
     */
    private static final String ACTION = "Next Step";

    /**
     * Display and process the project addition request, step 2.
     */
    protected String processRequest (Connection conn, WebContext context)
        throws HandlerException, RedirectException
    {
        if (debug) log.debug("started");
        String templateName = super.processRequest(conn, context);
    
        try
        {
            if (debug) log.debug("Checking inputs and adding to context");
            User loginUser = getLoginUser(context);
            String action = (String)context.get("action");

            if (debug)
            {
                log.info("userID=" + loginUser.getUserID());
                log.info("action=" + action);
            }

            List missingFields = new ArrayList();
            String inviteEmails = processField(context, "inviteEmails");
            String inviteMessage = processField(context, "inviteMessage");
            boolean isInviting = 
                (haveValue(inviteEmails) || haveValue(inviteMessage));
            if (debug) log.info("isInviting=" + isInviting);

            // If values are filled in for either field, require the other.
            if (isInviting)
            {
                requireValue(inviteEmails, "List of email addresses", 
                             missingFields);
                requireValue(inviteMessage, "Invitation message", 
                             missingFields);
            }

            Project project = getCurrentProject(context);
            context.put("project", project);

            if (action != null && action.equals(ACTION))
            {
                if (isInviting)
                {
                    if (isValidUserInput(missingFields, null))
                    {
                        // Send the invitation.
                        Domain domain = getCurrentDomain(context);
                        DataManager dMgr = getDataManager(context);
                        Invitation.sendInvitations(conn,
                                dMgr,
                                domain,
                                getRecipients(inviteEmails),
                                loginUser,
                                project,
                                inviteMessage);

                        redirectTo(myProperties.getProperty("nextStep"));
                    }
                    else
                    {
                        reportInvalidUserInput(context, missingFields, null);
                    }
                }
                else
                {
                    redirectTo(myProperties.getProperty("nextStep"));
                }
            }

            // Displaying the page.
            context.put("action", ACTION);
        }
        catch (RedirectException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            log.exception(e);
            String msg = "Could not send invitation: " + e.getMessage();
            appendToMessage(context, msg);
            throw new HandlerException(msg);
        }
    
        if (debug) log.debug("done");
        return templateName;
    }

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


1.2
log
@send out invitations with nonces during SSPAS2 (soon to be renamed)
@
text
@d79 1
a79 1
 * @@version $Id: SelfServeProjectAddStep2.java,v 1.27 2000/11/13 16:47:09 edk Exp $
d83 1
a83 1
    public static final  String versionID = "$Id: SelfServeProjectAddStep2.java,v 1.27 2000/11/13 16:47:09 edk Exp $";
@


1.1
log
@Initial revision
@
text
@d79 1
a79 1
 * @@version $Id: SelfServeProjectAddStep2.java,v 1.26 2000/11/06 22:42:52 dlr Exp $
d83 1
a83 1
    public static final  String versionID = "$Id: SelfServeProjectAddStep2.java,v 1.26 2000/11/06 22:42:52 dlr Exp $";
d148 8
a155 9
                        Invitation i = 
                            new Invitation(domain.getName(), 
                                           getRecipients(inviteEmails), 
                                           loginUser.getEmail(), 
                                           loginUser.getName(), 
                                           project.getName(), 
                                           project.getLongDescription(),
                                           inviteMessage);
                        i.send();
@


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