head	1.8;
access;
symbols
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.1
	TIGRIS_0_9_2_3:1.1
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.3
	TIGRIS_0_9_2_1:1.3
	TIGRIS_0_9_2:1.1.0.6
	TIGRIS_0_9_0:1.1.0.4
	TIGRIS_0_8_4:1.1.0.2;
locks; strict;
comment	@# @;


1.8
date	2001.03.08.19.05.37;	author leonardr;	state dead;
branches;
next	1.7;

1.7
date	2001.03.07.01.53.20;	author lucas;	state Exp;
branches;
next	1.6;

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

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

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

1.3
date	2001.01.26.18.29.02;	author edk;	state Exp;
branches
	1.3.2.1;
next	1.2;

1.2
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.1;

1.1
date	2000.11.28.21.08.23;	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.3.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	1.3.2.2;

1.3.2.2
date	2001.02.12.18.04.07;	author leonardr;	state Exp;
branches;
next	1.3.2.3;

1.3.2.3
date	2001.02.15.20.50.35;	author leonardr;	state Exp;
branches;
next	1.3.2.4;

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


desc
@@


1.8
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
@/* ================================================================
 * 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.webmacro.servlet.*;

import org.apache.turbine.util.Log;

import org.joist.security.RedirectException;

import org.tigris.helm.DoesNotExist;
import org.tigris.helm.security.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.*;
/**
 * Add users to a user group.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@version $Id: UserGroupMemberAdd.java,v 1.7 2001/03/07 01:53:20 lucas Exp $
 */
public class UserGroupMemberAdd extends org.tigris.helm.security.HelmServlet {
    public static final  String versionID = "$Id: UserGroupMemberAdd.java,v 1.7 2001/03/07 01:53:20 lucas Exp $";
    
    private static boolean DEBUG = true;

    private static String ADD_MEMBERS_ACTION="Add to Group";
    private static String ADD_MEMBER_FIELD_PREFIX="Add ";
    
    /**
     * Add some users to the group.
     */
    protected String processRequest (Connection connection, WebContext context)
	throws HandlerException, RedirectException
    {
	String templateName = super.processRequest(connection, context);
        try 
        {
            String action = getAction(context);

            // Gather any user input, adding it to the context as well.
            UserGroup group = getCurrentUserGroup(context);
            AccessControlList acl = getLoginUser(context).getACL();
            Domain currentDomain = getCurrentDomain(context);

            List missingFields = new ArrayList();
            List validationErrors = new ArrayList();

            if (action != null && action.equals(ADD_MEMBERS_ACTION))
            {
                Enumeration paramNames =
                    context.getRequest().getParameterNames();
                while (paramNames.hasMoreElements ())
                {
                    String paramName = (String) paramNames.nextElement ();
                    
                    if (paramName.startsWith(ADD_MEMBER_FIELD_PREFIX))
                    {
                        StringTokenizer tok = new StringTokenizer (paramName);
                        tok.nextToken ();
                        User user = UserPeer.getInstance(tok.nextToken());
                        group.addUser(acl, user);
                    }
                }    
                redirectToURL
                    (context, currentDomain.getDomainHomeServletURL
                     ("UserGroupEdit?userGroupID="+group.getID()));       
            }
        }
        catch (ACLException e) {
            throw e;
        }
        catch (RedirectException e) {
            throw e;
        }
        catch (Exception e) {
            String msg = "Unable to add member to user group: " +
                e.getMessage();
            Log.error(msg, e);
            throw new HandlerException(msg);
        }

        return templateName;  
    }
}
@


1.7
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d67 1
a67 1
 * @@version $Id: UserGroupMemberAdd.java,v 1.6 2001/02/27 01:52:33 dlr Exp $
d70 1
a70 1
    public static final  String versionID = "$Id: UserGroupMemberAdd.java,v 1.6 2001/02/27 01:52:33 dlr Exp $";
@


1.6
log
@More informative error message.
@
text
@d62 1
a62 3
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;

d67 1
a67 1
 * @@version $Id: UserGroupMemberAdd.java,v 1.5 2001/02/27 01:37:10 dlr Exp $
d70 1
a70 1
    public static final  String versionID = "$Id: UserGroupMemberAdd.java,v 1.5 2001/02/27 01:37:10 dlr Exp $";
@


1.5
log
@Improved error messaging and removed unnecessary special "Error" query
string parameter check.
@
text
@d69 1
a69 1
 * @@version $Id: UserGroupMemberAdd.java,v 1.4 2001/02/21 01:08:21 dlr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupMemberAdd.java,v 1.4 2001/02/21 01:08:21 dlr Exp $";
d126 1
a126 1
            String msg = "Exception caught in UserGroupEdit: " +
@


1.4
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: UserGroupMemberAdd.java,v 1.3.2.4 2001/02/16 03:01:26 dlr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupMemberAdd.java,v 1.3.2.4 2001/02/16 03:01:26 dlr Exp $";
a88 9
            // 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);
            }
d118 12
a129 5
        } catch (ACLException e) {
            throw (e);
        } catch (Exception e) {
            Log.error("Exception caught in UserGroupEdit: " + e);
            throw new HandlerException(e.getMessage());
d134 1
a134 4

} /* end class UserGroupMemberAdd */


@


1.3
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 5
a63 5
import org.tigris.helm.*;
import org.tigris.helm.domain.User;
import org.tigris.helm.domain.UserGroup;
import org.tigris.helm.security.HelmServlet;
import org.tigris.helm.security.AccessControlList;
d69 1
a69 1
 * @@version $Id: UserGroupMemberAdd.java,v 1.1 2000/11/28 21:08:23 leonardr Exp $
d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupMemberAdd.java,v 1.1 2000/11/28 21:08:23 leonardr Exp $";
d74 1
a74 2
    private static Log log = new Log("UGMemAdd", "User Group Member Add Servlet");
    private static boolean debug = true;
d104 2
a105 2
            ArrayList missingFields = new ArrayList();
            ArrayList validationErrors = new ArrayList();
d119 1
a119 2
                        User user = new User(connection, dMgr, tok.nextToken());
                        log.info("Adding user " + user.getName());
d127 4
a130 11
        } 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);
d137 1
a137 1
} /* end class UserGroupAdd */
@


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


1.3.2.2
log
@Ported UserGroupMemberAdd.java
@
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 5
a72 4
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.security.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
d83 2
a84 1
    private static boolean DEBUG = true;
d114 2
a115 2
            List missingFields = new ArrayList();
            List validationErrors = new ArrayList();
d129 2
a130 1
                        User user = UserPeer.getInstance(tok.nextToken());
d138 11
a148 4
        } catch (ACLException e) {
            throw (e);
        } catch (Exception e) {
            Log.error("Exception caught in UserGroupEdit: " + e);
d155 1
a155 1
} /* end class UserGroupMemberAdd */
@


1.3.2.3
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d68 1
a68 1
 * @@version $Id: UserGroupMemberAdd.java,v 1.3.2.2 2001/02/12 18:04:07 leonardr Exp $
d71 1
a71 1
    public static final  String versionID = "$Id: UserGroupMemberAdd.java,v 1.3.2.2 2001/02/12 18:04:07 leonardr Exp $";
@


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


1.2
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.1
log
@Mega patch providing more user group admin functionality.
@
text
@d78 1
a78 1
 * @@version $Id: UserGroupAdd.java,v 1.5 2000/11/21 20:56:55 leonardr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: UserGroupAdd.java,v 1.5 2000/11/21 20:56:55 leonardr Exp $";
@


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
d68 5
a72 5
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.security.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
d78 1
a78 1
 * @@version $Id: UserGroupMemberAdd.java,v 1.3.2.4 2001/02/16 03:01:26 dlr Exp $
d81 1
a81 1
    public static final  String versionID = "$Id: UserGroupMemberAdd.java,v 1.3.2.4 2001/02/16 03:01:26 dlr Exp $";
d83 2
a84 1
    private static boolean DEBUG = true;
d114 2
a115 2
            List missingFields = new ArrayList();
            List validationErrors = new ArrayList();
d129 2
a130 1
                        User user = UserPeer.getInstance(tok.nextToken());
d138 11
a148 4
        } catch (ACLException e) {
            throw (e);
        } catch (Exception e) {
            Log.error("Exception caught in UserGroupEdit: " + e);
d155 1
a155 1
} /* end class UserGroupMemberAdd */
@


