head	1.22;
access;
symbols
	TIGRIS_1_1_0RC2:1.15
	TIGRIS_1_1_0RC1:1.15
	TIGRIS_1_1:1.15.0.4
	TIGRIS_1_0_8:1.15
	TIGRIS_1_0_8RC3:1.15
	TIGRIS_1_0_8RC2:1.15
	TIGRIS_1_0_8RC1:1.15
	TIGRIS_1_0_7:1.15
	TIGRIS_1_0_7RC3:1.15
	TIGRIS_1_0_7RC2:1.15
	TIGRIS_1_0_7RC1:1.15
	TIGRIS_1_0_6:1.15
	TIGRIS_1_0_6RC5:1.15
	TIGRIS_1_0_6RC4:1.15
	TIGRIS_1_0_6RC3:1.15
	TIGRIS_1_0_6RC2:1.15
	TIGRIS_1_0_6RC1:1.15
	TIGRIS_1_0_5:1.15
	TIGRIS_1_0_5RC6:1.15
	TIGRIS_1_0_5RC5:1.15
	TIGRIS_1_0_5RC4:1.15
	TIGRIS_1_0_5RC3:1.15
	TIGRIS_1_0_5RC2:1.15
	TIGRIS_1_0_5RC1:1.15
	TIGRIS_1_0_4:1.15
	TIGRIS_1_0_3:1.15
	TIGRIS_1_0_2:1.15
	TIGRIS_1_0_1:1.15
	TIGRIS_1_0:1.15.0.6
	TIGRIS_1_0_0:1.15
	TIGRIS_1_0_0_RC1:1.15.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.7
	TIGRIS_0_9_2_3:1.7
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.9
	TIGRIS_0_9_2_1:1.9
	TIGRIS_0_9_2:1.7.0.2
	TIGRIS_0_9_0:1.6.0.2
	TIGRIS_0_8_4:1.5.0.2;
locks; strict;
comment	@# @;


1.22
date	2001.08.11.09.08.01;	author dlr;	state Exp;
branches;
next	1.21;

1.21
date	2001.07.25.19.39.26;	author leonardr;	state Exp;
branches;
next	1.20;

1.20
date	2001.07.18.10.05.12;	author dlr;	state Exp;
branches;
next	1.19;

1.19
date	2001.07.17.20.54.06;	author leonardr;	state Exp;
branches;
next	1.18;

1.18
date	2001.07.17.17.55.45;	author leonardr;	state Exp;
branches;
next	1.17;

1.17
date	2001.06.04.15.09.27;	author leonardr;	state Exp;
branches;
next	1.16;

1.16
date	2001.05.23.01.50.10;	author dlr;	state Exp;
branches;
next	1.15;

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

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

1.13
date	2001.03.07.01.53.20;	author lucas;	state Exp;
branches;
next	1.12;

1.12
date	2001.02.27.01.54.43;	author dlr;	state Exp;
branches;
next	1.11;

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

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

1.9
date	2001.01.26.18.29.02;	author edk;	state Exp;
branches
	1.9.2.1;
next	1.8;

1.8
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.7;

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

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

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

1.4
date	2000.11.21.20.23.39;	author leonardr;	state Exp;
branches;
next	1.3;

1.3
date	2000.11.21.19.38.57;	author leonardr;	state Exp;
branches;
next	1.2;

1.2
date	2000.11.21.18.48.51;	author leonardr;	state Exp;
branches;
next	1.1;

1.1
date	2000.11.21.01.47.58;	author leonardr;	state Exp;
branches
	1.1.1.1;
next	;

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

1.9.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	1.9.2.2;

1.9.2.2
date	2001.02.12.15.09.53;	author leonardr;	state Exp;
branches;
next	1.9.2.3;

1.9.2.3
date	2001.02.15.14.41.27;	author leonardr;	state Exp;
branches;
next	1.9.2.4;

1.9.2.4
date	2001.02.15.20.50.35;	author leonardr;	state Exp;
branches;
next	1.9.2.5;

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


desc
@@


1.22
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
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.sql.*;
import java.util.*;

import org.apache.velocity.context.Context;

import org.apache.turbine.util.Log;
import org.apache.commons.util.exception.NestableException;

import org.tigris.helm.security.RedirectException;

import org.tigris.helm.DoesNotExist;
import org.tigris.helm.om.*;
import org.tigris.helm.security.HelmServlet;
import org.tigris.helm.tool.ContextAPI;

/**
 * Create a new user group.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@version $Id: UserGroupAdd.java,v 1.21 2001/07/25 19:39:26 leonardr Exp $
 */
public class UserGroupAdd extends org.tigris.helm.security.HelmServlet {
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.21 2001/07/25 19:39:26 leonardr Exp $";

    private static boolean DEBUG = true;

    private static String CREATE_GROUP_ACTION="Create Group";
    private static String GROUP_NAME_FIELD="name";
    private static String GROUP_DESCRIPTION_FIELD="description";
    private static String GROUP_ELEMENTS_FIELD="elements";
    
    /**
     *  Create a group with some initial users, after doing data
     *  validation.
     */
    protected String processRequest(Context context)
	throws NestableException, RedirectException
    {
	String templateName = super.processRequest(context);
        try 
        {
            String action = getAction(context);
            User loginUser = getLoginUser(context);
            Domain domain = getCurrentDomain(context);
                
            // Gather any user input, adding it to the context as well.
            List missingFields = new ArrayList();
            List validationErrors = new ArrayList();
            String groupName = ContextAPI.processRequiredField
                (context, GROUP_NAME_FIELD, "Group name");
            String description = ContextAPI.processRequiredField
                (context, GROUP_DESCRIPTION_FIELD, "Description");
            String elements = ContextAPI.processField
                (context, GROUP_ELEMENTS_FIELD);
            
            if (CREATE_GROUP_ACTION.equals(action))
            {
                if (!User.isValidLoginName(groupName))
                {
                    ContextAPI.addValidationError
                        (context, "Invalid user group name: " + groupName);
                }

                List initialElements = UserPeer.parseDesignantList
                    (elements, domain, validationErrors);
                
                if (ContextAPI.isValidUserInput(context))
                {
                    UserGroup g = UserGroup.add
                        (loginUser.getACL(), domain, groupName, 
                         description, initialElements);
                    redirectToURL
                        (context, domain.getDomainHomeServletURL
                         ("UserGroupList"));
                } 
            }
        }
        catch (RedirectException e) 
        {
            throw e;
        }
        catch (Exception e) 
        {
            String msg = "Unable to add user group: " + e.getMessage();
            Log.error(msg, e);
            throw new NestableException(e);
        }

        return templateName;  
    }
}
@


1.21
log
@User deletes are now soft deletes which change the user type to 'deleted' (a minimal type of user which has user information but is not allowed associations with roles or user groups). Includes some other miscellaneous bug fixes.
@
text
@d56 1
a56 1
import org.apache.turbine.util.TurbineException;
d69 1
a69 1
 * @@version $Id: UserGroupAdd.java,v 1.20 2001/07/18 10:05:12 dlr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.20 2001/07/18 10:05:12 dlr Exp $";
d86 1
a86 1
	throws TurbineException, RedirectException
d135 1
a135 1
            throw new TurbineException(e);
@


1.20
log
@Ported Joist Redirect*Exception to Helm.
@
text
@d69 1
a69 1
 * @@version $Id: UserGroupAdd.java,v 1.19 2001/07/17 20:54:06 leonardr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.19 2001/07/17 20:54:06 leonardr Exp $";
d100 1
a100 1
            String description = ContextAPI.processField
@


1.19
log
@Cleanup for port to new error handling system.
@
text
@d58 1
a58 1
import org.joist.security.RedirectException;
d69 1
a69 1
 * @@version $Id: UserGroupAdd.java,v 1.18 2001/07/17 17:55:45 leonardr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.18 2001/07/17 17:55:45 leonardr Exp $";
@


1.18
log
@Porting of domain package to new error handling API.
@
text
@d69 1
a69 1
 * @@version $Id: UserGroupAdd.java,v 1.17 2001/06/04 15:09:27 leonardr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.17 2001/06/04 15:09:27 leonardr Exp $";
d116 1
a116 1
                if (isValidUserInput(missingFields, validationErrors))
@


1.17
log
@Factored out code for turning strings into lists of users.
@
text
@a56 1
import org.apache.turbine.util.TurbineException;
d63 1
d69 1
a69 1
 * @@version $Id: UserGroupAdd.java,v 1.16 2001/05/23 01:50:10 dlr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.16 2001/05/23 01:50:10 dlr Exp $";
d98 6
a103 5
            String groupName = processField(context, GROUP_NAME_FIELD, 
                                            "Group name", missingFields);
            String description = processField(context, GROUP_DESCRIPTION_FIELD,
                                              "Description", missingFields);
            String elements = processField(context, GROUP_ELEMENTS_FIELD);
d105 1
a105 1
            if (action != null && action.equals(CREATE_GROUP_ACTION))
d109 2
a110 2
                    validationErrors.add
                        ("Invalid user group name: " + groupName);
d116 1
a116 1
                if (action != null && action.equals(CREATE_GROUP_ACTION))
d118 7
a124 16
                    if (isValidUserInput(missingFields, validationErrors))
                    {
                        UserGroup g = UserGroup.add
                            (loginUser.getACL(), domain, groupName, 
                             description, initialElements);
                        redirectToURL
                            (context, domain.getDomainHomeServletURL
                             ("UserGroupList"));
                    } 
                    else 
                    {
                        // Report missing fields and validation errors.
                        reportInvalidUserInput(context, missingFields, 
                                               validationErrors);
                    }
                }
d127 2
a128 1
        catch (RedirectException e) {
d131 2
a132 1
        catch (Exception e) {
@


1.16
log
@Ported Helm from WebMacro to Velocity.
@
text
@d69 1
a69 1
 * @@version $Id: UserGroupAdd.java,v 1.15 2001/03/22 23:19:09 dlr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.15 2001/03/22 23:19:09 dlr Exp $";
d112 2
a113 26
                // Turn the list of elements they want to add into User objects.
                List initialElements = new ArrayList();
                List elementDesignants = new ArrayList();
                StringTokenizer tok = new StringTokenizer(elements);
                while (tok.hasMoreTokens())
                {
                    elementDesignants.add(tok.nextToken());
                }

                for (Iterator i = elementDesignants.iterator(); i.hasNext();)
                {
                    //Get a record for the supposed user any way we can think
                    //of--by login ID, email, and name. If all these fail,
                    //add the nonexistant user to the validation errors.
                    String element = (String)i.next();
                    try
                    {
                        User u =
                            UserPeer.getInstanceByIdentifier(domain, element);
                        initialElements.add(u);
                    }
                    catch (DoesNotExist e)
                    {
                        validationErrors.add(e.getMessage());
                    }
                }
d125 3
a127 1
                    } else {
@


1.15
log
@It helps to actually add the user (IZ #33240).
@
text
@d53 1
a53 1
import org.webmacro.servlet.*;
d56 2
d69 1
a69 1
 * @@version $Id: UserGroupAdd.java,v 1.14 2001/03/08 19:05:37 leonardr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.14 2001/03/08 19:05:37 leonardr Exp $";
d85 2
a86 2
    protected String processRequest (Connection connection, WebContext context)
	throws HandlerException, RedirectException
d88 1
a88 1
	String templateName = super.processRequest(connection, context);
d163 1
a163 1
            throw new HandlerException(msg);
@


1.14
log
@Political correctness strikes Tigris.org! The components of project and user groups no longer wish to be called "members", as that causes them to be confused with users who have roles in projects. The new, approved term is "elements".
@
text
@d67 1
a67 1
 * @@version $Id: UserGroupAdd.java,v 1.13 2001/03/07 01:53:20 lucas Exp $
d70 1
a70 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.13 2001/03/07 01:53:20 lucas Exp $";
d125 8
a132 4
                    User u = null;
                    try {
                        UserPeer.getInstanceByIdentifier(domain, element);
                    } catch (DoesNotExist e) {
a134 4
                    if (u != null)
                    {
                        initialElements.add(u);
                    }                
@


1.13
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d67 1
a67 1
 * @@version $Id: UserGroupAdd.java,v 1.12 2001/02/27 01:54:43 dlr Exp $
d70 1
a70 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.12 2001/02/27 01:54:43 dlr Exp $";
d77 1
a77 1
    private static String GROUP_MEMBERS_FIELD="members";
d80 1
a80 1
     *  Create a group with some initial members, after doing data
d100 1
a100 1
            String members = processField(context, GROUP_MEMBERS_FIELD);
d110 4
a113 4
                // Turn the list of members they want to add into User objects.
                List initialMembers = new ArrayList();
                List memberDesignants = new ArrayList();
                StringTokenizer tok = new StringTokenizer(members);
d116 1
a116 1
                    memberDesignants.add(tok.nextToken());
d119 1
a119 1
                for (Iterator i = memberDesignants.iterator(); i.hasNext();)
d124 1
a124 1
                    String member = (String)i.next();
d127 1
a127 1
                        UserPeer.getInstanceByIdentifier(domain, member);
d133 1
a133 1
                        initialMembers.add(u);
d143 1
a143 1
                             description, initialMembers);
@


1.12
log
@Improved error messaging and rethrow RedirectException.
@
text
@a60 2
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
d67 1
a67 1
 * @@version $Id: UserGroupAdd.java,v 1.11 2001/02/27 01:39:55 dlr Exp $
d70 1
a70 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.11 2001/02/27 01:39:55 dlr Exp $";
@


1.11
log
@Improved error messaging and removed unnecessary special "Error" query
string parameter check.
@
text
@d69 1
a69 1
 * @@version $Id: UserGroupAdd.java,v 1.10 2001/02/21 01:08:21 dlr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.10 2001/02/21 01:08:21 dlr Exp $";
d156 8
a163 3
        } catch (Exception e) {
            Log.error("Error in UserGroupAdd: ", e);
            throw new HandlerException(e.getMessage());
@


1.10
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d69 1
a69 1
 * @@version $Id: UserGroupAdd.java,v 1.9.2.5 2001/02/16 03:01:26 dlr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.9.2.5 2001/02/16 03:01:26 dlr Exp $";
a94 10
            // If we are returning to this page as a result of an
            // error, we just want to refresh the display, without
            // doing any further action.
            String errorMessage = (String)context.get("Error");
            if (errorMessage != null)
            {
                action = null;
                appendToMessage(context, errorMessage);
            }

d163 1
a163 4

} /* end class UserGroupAdd */


@


1.9
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.
d50 1
a50 1
import java.io.*;
a51 3
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
a52 1
import org.webmacro.util.*;
d55 1
a55 5
import org.joist.*;
import org.joist.util.*;
import org.joist.session.*;

import com.workingdogs.village.*;
a57 1
import org.joist.database.*;
d59 4
a62 3
import org.tigris.helm.*;
import org.tigris.helm.domain.User;
import org.tigris.helm.domain.UserGroup;
d66 1
a66 1
 * Create a new project group.
d69 1
a69 1
 * @@version $Id: UserGroupAdd.java,v 1.7 2001/01/11 19:26:55 dlr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.7 2001/01/11 19:26:55 dlr Exp $";
d74 1
a74 2
    private static Log log = new Log("UsrGrpAdd", "User Group Add Servlet");
    private static boolean debug = true;
d92 3
d106 2
a107 2
            ArrayList missingFields = new ArrayList();
            ArrayList validationErrors = new ArrayList();
d111 1
a111 2
                                              "Description", 
                                              missingFields);    
d116 1
a116 1
                if (!User.isValidUserName(groupName))
d123 2
a124 2
                ArrayList initialMembers = new ArrayList();
                ArrayList memberDesignants = new ArrayList();
a130 1
                String domainID = getCurrentDomain(context).getID();
d136 1
d138 4
a141 24
                    String member = (String)i.next();
                    try
                    {
                        u = new User(connection, dMgr, domainID, member);
                    }
                    catch (DoesNotExist loginIDEx)
                    {
                        try 
                        {
                            u = new User(connection, member, dMgr, domainID);
                        }
                        catch (DoesNotExist emailEx) 
                        {
                            try 
                            {
                                u = new User(member, connection, dMgr,
                                             domainID);
                            }
                            catch (DoesNotExist nameEx)
                            {
                                validationErrors.add("No such user on system: "
                                                     + member);
                            }
                        }
a148 3
                User loginUser = getLoginUser(context);
                Domain currentDomain = getCurrentDomain(context);
                
d153 3
a155 4
                        UserGroup g = new UserGroup
                            (connection, dMgr, loginUser.getACL(), context,
                             currentDomain.getID(), groupName, description, 
                             initialMembers);
d157 1
a157 1
                            (context, currentDomain.getDomainHomeServletURL
d166 2
a167 14
        } catch (DataSetException e) {
            log.exception(e);
            throw new HandlerException(e.getMessage());
        } catch (SQLException e) {
            log.exception(e);
            throw new HandlerException(e.getMessage());
        } catch (JoistDatabaseException e) {
            log.exception(e);
            throw new HandlerException(e.getMessage());
        } catch (DoesNotExist e) {
            log.exception(e);
            throw new HandlerException(e.getMessage());
        } catch (AlreadyExists e) {
            log.exception(e);
@


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


1.9.2.2
log
@Ported UserGroupAdd and UserGroupList servlets.
@
text
@d2 1
a2 1
 * Copyright (c) 2001 CollabNet.  All rights reserved.
d50 2
d53 2
a54 1
import java.util.*;
d56 1
d59 5
a63 1
import org.apache.turbine.util.Log;
d66 1
d68 3
a70 3
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
d74 1
a74 1
 * Create a new user group.
d82 2
a83 1
    private static boolean DEBUG = true;
a100 3
            User loginUser = getLoginUser(context);
            Domain domain = getCurrentDomain(context);
                
d112 2
a113 2
            List missingFields = new ArrayList();
            List validationErrors = new ArrayList();
d117 2
a118 1
                                              "Description", missingFields);
d123 1
a123 1
                if (!User.isValidLoginName(groupName))
d130 2
a131 2
                List initialMembers = new ArrayList();
                List memberDesignants = new ArrayList();
d138 1
d148 1
a148 1
                        u =  UserPeer.getInstanceByLoginName(domain, member);
d150 1
a150 1
                    catch (DoesNotExist loginNameEx)
d154 1
a154 1
                            u =  UserPeer.getInstanceByEmail(domain, member);
d160 2
a161 1
                                u =  UserPeer.getInstanceByRealName(domain, member);
d176 3
d183 4
a186 3
                        UserGroup g = UserGroup.add
                            (loginUser.getACL(), domain, groupName, 
                             description, initialMembers);
d188 1
a188 1
                            (context, domain.getDomainHomeServletURL
d197 14
a210 2
        } catch (Exception e) {
            Log.error("Error in UserGroupAdd: ", e);
@


1.9.2.3
log
@Code factored out into UserPeer.getInstanceByIdentifier.
@
text
@d68 1
a68 1
 * @@version $Id: UserGroupAdd.java,v 1.9.2.2 2001/02/12 15:09:53 leonardr Exp $
d71 1
a71 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.9.2.2 2001/02/12 15:09:53 leonardr Exp $";
d135 1
d137 22
a158 5
                    User u = null;
                    try {
                        UserPeer.getInstanceByIdentifier(domain, member);
                    } catch (DoesNotExist e) {
                        validationErrors.add(e.getMessage());
@


1.9.2.4
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d68 1
a68 1
 * @@version $Id: UserGroupAdd.java,v 1.9.2.3 2001/02/15 14:41:27 leonardr Exp $
d71 1
a71 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.9.2.3 2001/02/15 14:41:27 leonardr Exp $";
@


1.9.2.5
log
@Added new imports necessitated by Torque.
@
text
@a61 1
import org.tigris.helm.om.base.*;
d68 1
a68 1
 * @@version $Id: UserGroupAdd.java,v 1.9.2.4 2001/02/15 20:50:35 leonardr Exp $
d71 1
a71 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.9.2.4 2001/02/15 20:50:35 leonardr Exp $";
@


1.8
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.7
log
@Servlets must not use TableManagers directly.
@
text
@d77 1
a77 1
 * @@version $Id: UserGroupAdd.java,v 1.6 2000/12/14 21:03:48 leonardr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.6 2000/12/14 21:03:48 leonardr Exp $";
@


1.6
log
@Verify project and user group names.
@
text
@d77 1
a77 1
 * @@version $Id: UserGroupAdd.java,v 1.5 2000/11/21 20:56:55 leonardr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.5 2000/11/21 20:56:55 leonardr Exp $";
d137 2
a140 2
                    String member = (String)i.next();
                    Record r = null;
d144 7
a150 1
                    try 
a151 3
                        r = userMgr.getUserForLoginID(connection, 
                                                      member);
                    } catch (JoistDatabaseException e) {
d154 4
a157 2
                            r = userMgr.getUserForEmail(connection, member);
                        } catch (JoistDatabaseException f) {
d160 6
a165 3
                                r = userMgr.getUserForName(connection, member);
                            } catch (JoistDatabaseException g) {
                                validationErrors.add("No such user on system: " 
a166 1
                                r = null;
d170 1
a170 1
                    if (r != null)
d172 1
a172 1
                        initialMembers.add(new User(connection, dMgr, r));
@


1.5
log
@Redirect properly on user group creation (thanks stack)
@
text
@d77 1
a77 1
 * @@version $Id: UserGroupAdd.java,v 1.4 2000/11/21 20:23:39 leonardr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.4 2000/11/21 20:23:39 leonardr Exp $";
d123 6
@


1.4
log
@Fixed up display of user groups.
@
text
@d77 1
a77 1
 * @@version $Id: UserGroupAdd.java,v 1.3 2000/11/21 19:38:57 leonardr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.3 2000/11/21 19:38:57 leonardr Exp $";
d174 3
a176 1
                        //TODO: redirect to UserGroupList
@


1.3
log
@Groups can now be added.
@
text
@d77 1
a77 1
 * @@version $Id: UserGroupAdd.java,v 1.2 2000/11/21 18:48:51 leonardr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.2 2000/11/21 18:48:51 leonardr Exp $";
d174 1
@


1.2
log
@Give registered users the project member list permission in public projects.
@
text
@d77 1
a77 1
 * @@version $Id: UserGroupAdd.java,v 1.1 2000/11/21 01:47:58 leonardr Exp $
d80 1
a80 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.1 2000/11/21 01:47:58 leonardr Exp $";
a97 1
        
d111 10
a122 11
                // Gather any user input, adding it to the context as well.
                ArrayList missingFields = new ArrayList();
                ArrayList validationErrors = new ArrayList();
                String groupName = processField(context, GROUP_NAME_FIELD, 
                                                "Group name", missingFields);
                String description = processField(context, GROUP_DESCRIPTION_FIELD,
                                                  "Description", 
                                                  missingFields);    
                String members = processField(context, GROUP_MEMBERS_FIELD, 
                                              "Initial Members");

d171 1
a171 1
                            (connection, dMgr, loginUser.getACL(), 
@


1.1
log
@First stab at UserGroups.
@
text
@d68 3
a71 1
import org.tigris.helm.database.UserUserGroupManager;
d77 1
a77 1
 * @@version $Id: GroupAdd.java,v 1.2 2000/11/20 20:07:32 leonardr Exp $
d80 3
a82 2
    public static final  String versionID = "$Id: GroupAdd.java,v 1.2 2000/11/20 20:07:32 leonardr Exp $";
    private static Log log = new Log("GroupAdd", "Group Add Servlet");
d85 5
d91 2
a92 1
     *  Display and process the login screen.
d94 1
a94 2
    protected String
	processRequest (Connection connection, WebContext context)
a96 2
	if (debug) log.debug("GroupAdd: started!");

d98 1
a98 3
	
	String action = getAction(context);

d101 1
d112 1
a112 12
            // Gather any user input, adding it to the context as well.
            ArrayList missingFields = new ArrayList();
            ArrayList validationErrors = new ArrayList();
            String groupName = processField(context, "groupName", 
                                            "Group name", missingFields);
            String description = processField(context, "description",
                                              "Short description", 
                                              missingFields);    
            String members = processField(context, "members", 
                                          "Initial Members", missingFields);

            if (action != null && action.equals("Create Group"))
d114 20
a133 1
                if (isValidUserInput(missingFields, validationErrors))
d135 6
a140 9
                    // Add the user group.
                    String groupID = uugMgr.addUserGroup
                        (connection, groupName, description, UserType.DOMAIN)
                        .toString();
                    
                    // Add members to the newly formed group.
                    ArrayList memberList = new ArrayList();
                    StringTokenizer tok = new StringTokenizer(members);
                    while (tok.hasMoreTokens())
d142 16
a157 1
                        memberList.add(tok.nextToken());
d159 1
a159 1
                    for (Iterator i = memberList.iterator(); i.hasNext();)
d161 19
a179 8
                        String member = (String)i.next();
                        //This should be replaced with one call.
                        Record r = userMgr.getUserForLoginID(connection, 
                                                             member);
                        String userID = r.getValue(UserManager.USER_ID)
                            .toString();
                        uugMgr.addBaseToComposite(connection, userID,
                                                     groupID);
a180 4
                } else {
                    // Report missing fields and validation errors.
                    reportInvalidUserInput(context, missingFields, 
                                           validationErrors);
d183 13
a195 4

        }
        catch (Exception e)
        {
d197 1
a197 3
            String message = e.getMessage();
            if (debug) log.debug(message);
            appendToMessage(context, message);
d200 5
a205 4
        return templateName;
    }
  
} /* end class GroupAdd */
@


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.
d50 2
d53 2
a54 1
import java.util.*;
d56 1
d59 5
a63 1
import org.apache.turbine.util.Log;
d66 1
a67 4
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
d69 1
d72 1
a72 1
 * Create a new user group.
d75 1
a75 1
 * @@version $Id: UserGroupAdd.java,v 1.9.2.5 2001/02/16 03:01:26 dlr Exp $
d78 3
a80 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.9.2.5 2001/02/16 03:01:26 dlr Exp $";
a81 7
    private static boolean DEBUG = true;

    private static String CREATE_GROUP_ACTION="Create Group";
    private static String GROUP_NAME_FIELD="name";
    private static String GROUP_DESCRIPTION_FIELD="description";
    private static String GROUP_MEMBERS_FIELD="members";
    
d83 1
a83 2
     *  Create a group with some initial members, after doing data
     *  validation.
d85 2
a86 1
    protected String processRequest (Connection connection, WebContext context)
d89 2
d92 3
a96 4
            String action = getAction(context);
            User loginUser = getLoginUser(context);
            Domain domain = getCurrentDomain(context);
                
d108 3
a110 3
            List missingFields = new ArrayList();
            List validationErrors = new ArrayList();
            String groupName = processField(context, GROUP_NAME_FIELD, 
d112 7
a118 5
            String description = processField(context, GROUP_DESCRIPTION_FIELD,
                                              "Description", missingFields);
            String members = processField(context, GROUP_MEMBERS_FIELD);
            
            if (action != null && action.equals(CREATE_GROUP_ACTION))
d120 1
a120 1
                if (!User.isValidLoginName(groupName))
d122 11
a132 24
                    validationErrors.add
                        ("Invalid user group name: " + groupName);
                }

                // Turn the list of members they want to add into User objects.
                List initialMembers = new ArrayList();
                List memberDesignants = new ArrayList();
                StringTokenizer tok = new StringTokenizer(members);
                while (tok.hasMoreTokens())
                {
                    memberDesignants.add(tok.nextToken());
                }

                for (Iterator i = memberDesignants.iterator(); i.hasNext();)
                {
                    //Get a record for the supposed user any way we can think
                    //of--by login ID, email, and name. If all these fail,
                    //add the nonexistant user to the validation errors.
                    String member = (String)i.next();
                    User u = null;
                    try {
                        UserPeer.getInstanceByIdentifier(domain, member);
                    } catch (DoesNotExist e) {
                        validationErrors.add(e.getMessage());
d134 1
a134 9
                    if (u != null)
                    {
                        initialMembers.add(u);
                    }                
                }
                
                if (action != null && action.equals(CREATE_GROUP_ACTION))
                {
                    if (isValidUserInput(missingFields, validationErrors))
d136 8
a143 10
                        UserGroup g = UserGroup.add
                            (loginUser.getACL(), domain, groupName, 
                             description, initialMembers);
                        redirectToURL
                            (context, domain.getDomainHomeServletURL
                             ("UserGroupList"));
                    } else {
                        // Report missing fields and validation errors.
                        reportInvalidUserInput(context, missingFields, 
                                               validationErrors);
d145 4
d151 1
a151 3
        } catch (Exception e) {
            Log.error("Error in UserGroupAdd: ", e);
            throw new HandlerException(e.getMessage());
d153 8
d162 1
a162 1
        return templateName;  
d164 2
a165 4

} /* end class UserGroupAdd */


@


