head	1.25;
access;
symbols
	TIGRIS_1_1_0RC2:1.19
	TIGRIS_1_1_0RC1:1.19
	TIGRIS_1_1:1.19.0.4
	TIGRIS_1_0_8:1.19
	TIGRIS_1_0_8RC3:1.19
	TIGRIS_1_0_8RC2:1.19
	TIGRIS_1_0_8RC1:1.19
	TIGRIS_1_0_7:1.19
	TIGRIS_1_0_7RC3:1.19
	TIGRIS_1_0_7RC2:1.19
	TIGRIS_1_0_7RC1:1.19
	TIGRIS_1_0_6:1.19
	TIGRIS_1_0_6RC5:1.19
	TIGRIS_1_0_6RC4:1.19
	TIGRIS_1_0_6RC3:1.19
	TIGRIS_1_0_6RC2:1.19
	TIGRIS_1_0_6RC1:1.19
	TIGRIS_1_0_5:1.19
	TIGRIS_1_0_5RC6:1.19
	TIGRIS_1_0_5RC5:1.19
	TIGRIS_1_0_5RC4:1.19
	TIGRIS_1_0_5RC3:1.19
	TIGRIS_1_0_5RC2:1.19
	TIGRIS_1_0_5RC1:1.19
	TIGRIS_1_0_4:1.19
	TIGRIS_1_0_3:1.19
	TIGRIS_1_0_2:1.19
	TIGRIS_1_0_1:1.19
	TIGRIS_1_0:1.19.0.6
	TIGRIS_1_0_0:1.19
	TIGRIS_1_0_0_RC1:1.19.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.9
	TIGRIS_0_9_2_3:1.9
	HELM_PEER_PORT_BRANCH:1.1.1.1
	TURBINE_PEER:1.12
	TIGRIS_0_9_2_1:1.12
	TIGRIS_0_9_2:1.9.0.6
	TIGRIS_0_9_0:1.9.0.4
	TIGRIS_0_8_4:1.9.0.2;
locks; strict;
comment	@# @;


1.25
date	2001.08.28.17.13.33;	author leonardr;	state Exp;
branches;
next	1.24;

1.24
date	2001.08.11.09.08.01;	author dlr;	state Exp;
branches;
next	1.23;

1.23
date	2001.07.24.00.02.27;	author leonardr;	state Exp;
branches;
next	1.22;

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

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

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

1.19
date	2001.03.26.18.45.02;	author dlr;	state Exp;
branches;
next	1.18;

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

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

1.16
date	2001.03.07.01.53.20;	author lucas;	state Exp;
branches;
next	1.15;

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

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

1.13
date	2001.02.21.01.08.21;	author dlr;	state Exp;
branches;
next	1.12;

1.12
date	2001.01.26.18.29.02;	author edk;	state Exp;
branches
	1.12.2.1;
next	1.11;

1.11
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.10;

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

1.9
date	2000.11.28.21.08.23;	author leonardr;	state Exp;
branches;
next	1.8;

1.8
date	2000.11.28.00.47.42;	author leonardr;	state Exp;
branches;
next	1.7;

1.7
date	2000.11.22.23.50.13;	author leonardr;	state Exp;
branches;
next	1.6;

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

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

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

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

1.2
date	2000.11.21.20.56.55;	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.12.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	1.12.2.2;

1.12.2.2
date	2001.02.12.17.20.07;	author leonardr;	state Exp;
branches;
next	1.12.2.3;

1.12.2.3
date	2001.02.12.18.17.27;	author leonardr;	state Exp;
branches;
next	1.12.2.4;

1.12.2.4
date	2001.02.13.01.09.09;	author dlr;	state Exp;
branches;
next	1.12.2.5;

1.12.2.5
date	2001.02.13.23.57.26;	author dlr;	state Exp;
branches;
next	1.12.2.6;

1.12.2.6
date	2001.02.15.20.50.35;	author leonardr;	state Exp;
branches;
next	1.12.2.7;

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


desc
@@


1.25
log
@Completed migration of more methods to ContextAPI.
@
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.security.*;
import org.tigris.helm.om.*;
import org.tigris.helm.tool.ContextAPI;

/**
 * Changes the info for the selected user group. Also removes
 * users from the group.
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 */
public class UserGroupEdit extends org.tigris.helm.security.HelmServlet 
{
    private static final boolean DEBUG = true;
    
    private static String MAKE_CHANGES_ACTION = "Submit Changes";
    private static String REMOVE_ELEMENTS_ACTION = "Remove Elements";

    private static String GROUP_NAME_FIELD = "name";
    private static String GROUP_DESCRIPTION_FIELD = "description";
    private static String REMOVE_ELEMENT_FIELD_PREFIX = "Remove";

    /**
     *  If they've submitted changes, make them.
     */
    protected String processRequest(Context context)
	throws NestableException, RedirectException
    {
	String templateName = super.processRequest(context);
        
        try 
        {
            String action = getAction(context);
            Domain currentDomain = getCurrentDomain(context);
            UserGroup group = getCurrentUserGroup(context);
            AccessControlList acl = getLoginUser(context).getACL();
            
            if (MAKE_CHANGES_ACTION.equals(action))
            {
                String description  =
                    ContextAPI.processField(context, GROUP_DESCRIPTION_FIELD);
                group.updateInfo(acl, description);
                context.put("currentUserGroup", group);
                ContextAPI.addMessage(context, "Update succeeded.");
            }
            else if (REMOVE_ELEMENTS_ACTION.equals(action))
            {
                Enumeration paramNames = 
                    ContextAPI.getRequest(context).getParameterNames();
                List usersToRemove = new ArrayList();
                while (paramNames.hasMoreElements())
                {
                    String paramName = (String)paramNames.nextElement();
                    if (paramName.startsWith(REMOVE_ELEMENT_FIELD_PREFIX))
                    {
                        StringTokenizer tok = 
                            new StringTokenizer(paramName);
                        tok.nextToken();
                        String userID = tok.nextToken();
                        usersToRemove.add(UserPeer.getInstance(userID));
                    }
                }

                for (Iterator i = usersToRemove.iterator(); i.hasNext();)
                {
                    User user = (User)i.next();
                    group.removeUser(acl, user);
                }
                String msg = String.valueOf(usersToRemove.size())
                    + " user" + (usersToRemove.size() == 1?"":"s")
                    + " removed.";
                ContextAPI.addMessage(context, msg);
            }
        } 
        catch (ACLException e)
        {
            throw e;
        }
        catch (RedirectException e)
        {
            throw e;
        }
        catch (Exception e)
        {
            String msg = "Couldn't edit user group: " + e.getMessage();
            Log.error(msg, e);
            throw new NestableException(e);
        }
        return templateName;
    }
}
@


1.24
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@d107 1
a107 1
                    getRequest(context).getParameterNames();
@


1.23
log
@The final pieces of the error handling revolution.
@
text
@d56 1
a56 1
import org.apache.turbine.util.TurbineException;
d85 1
a85 1
	throws TurbineException, RedirectException
d145 1
a145 1
            throw new TurbineException(e);
@


1.22
log
@Ported Joist Redirect*Exception to Helm.
@
text
@d102 1
a102 1
                appendToMessage(context, "Update succeeded.");
@


1.21
log
@Porting of domain package to new error handling API.
@
text
@d58 1
a58 1
import org.joist.security.RedirectException;
@


1.20
log
@Ported Helm from WebMacro to Velocity.
@
text
@a56 1
import org.apache.turbine.util.TurbineException;
d63 2
a64 1
import org.tigris.helm.om.*;
d92 13
a104 1
            if (action != null)
d106 4
a109 20
                Domain currentDomain = getCurrentDomain(context);
                UserGroup group = getCurrentUserGroup(context);
                AccessControlList acl = getLoginUser(context).getACL();

                if (action.equals(MAKE_CHANGES_ACTION))
                {
                    List missingFields = new ArrayList();
                    List validationErrors = new ArrayList();
                    
                    /* Don't do name until it's supported.
                       String name =
                       processField(context, GROUP_NAME_FIELD, missingFields);
                    */
                    String description  =
                        processField(context, GROUP_DESCRIPTION_FIELD);
                    group.updateInfo(acl, description);
                    context.put("currentUserGroup", group);
                    appendToMessage(context, "Update succeeded.");
                }
                else if (action.equals(REMOVE_ELEMENTS_ACTION))
d111 2
a112 4
                    Enumeration paramNames = 
                        getRequest(context).getParameterNames();
                    List usersToRemove = new ArrayList();
                    while (paramNames.hasMoreElements())
d114 5
a118 9
                        String paramName = (String)paramNames.nextElement();
                        if (paramName.startsWith(REMOVE_ELEMENT_FIELD_PREFIX))
                        {
                            StringTokenizer tok = 
                                new StringTokenizer(paramName);
                            tok.nextToken();
                            String userID = tok.nextToken();
                            usersToRemove.add(UserPeer.getInstance(userID));
                        }
d120 1
d122 4
a125 9
                    for (Iterator i = usersToRemove.iterator(); i.hasNext();)
                    {
                        User user = (User)i.next();
                        group.removeUser(acl, user);
                    }
                    String msg = String.valueOf(usersToRemove.size())
                        + " user" + (usersToRemove.size() == 1?"":"s")
                        + " removed.";
                    appendToMessage(context, msg);
d127 6
a132 2
            } 
        }
@


1.19
log
@consistant
@
text
@d53 1
a53 1
import org.webmacro.servlet.*;
d56 2
d84 2
a85 2
    protected String processRequest (Connection connection, WebContext context)
	throws HandlerException, RedirectException
d87 1
a87 1
	String templateName = super.processRequest(connection, context);
d115 2
a116 2
                    Enumeration paramNames = context.getRequest()
                        .getParameterNames();
d155 1
a155 1
            throw new HandlerException(msg);
@


1.18
log
@extra line feeds dies
@
text
@d141 2
a142 1
        catch (ACLException e) {
d145 2
a146 1
        catch (RedirectException e) {
d149 2
a150 1
        catch (Exception e) {
@


1.17
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
@a139 1
            
@


1.16
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d73 1
a73 1
    private static String REMOVE_MEMBERS_ACTION = "Remove Members";
d77 1
a77 1
    private static String REMOVE_MEMBER_FIELD_PREFIX = "Remove";
d111 1
a111 1
                else if (action.equals(REMOVE_MEMBERS_ACTION))
d119 1
a119 1
                        if (paramName.startsWith(REMOVE_MEMBER_FIELD_PREFIX))
@


1.15
log
@Improved error messaging and removed unnecessary special "Error" query
string parameter check.
@
text
@d62 1
a62 3
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;

@


1.14
log
@Removed unneccessary debugging.
@
text
@a91 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);
                }*/

d147 3
d151 3
a153 2
            Log.error("Exception thrown in UserGroupEdit", e);
            throw new HandlerException(e.getMessage());
@


1.13
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d79 1
d131 1
a131 1
                        if (paramName.startsWith("Remove"))
d146 4
a149 1
                    appendToMessage(context, "Removal succeeded.");
@


1.12
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.
a52 1
import org.webmacro.util.*;
d55 2
a56 1
import com.workingdogs.village.*;
a57 1
import org.joist.database.JoistDatabaseException;
d60 4
a63 4
import org.tigris.helm.security.HelmServlet;
import org.joist.security.RedirectException;
import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.security.ACLException;
d72 1
a72 3
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.10 2001/01/22 22:56:00 leonardr Exp $";
    private static Log log = new Log("UsrGrpEdit", "User Group Edit");
    private static boolean debug = true;
d91 10
d106 1
d118 1
a118 1
                    group.updateInfo(acl, description, context);
d121 3
a123 1
                } else if (action.equals(REMOVE_MEMBERS_ACTION)) {
d126 1
a126 1
                    ArrayList usersToRemove = new ArrayList();
a129 1
                        log.info("Processing " +paramName);
a131 1
                            log.info("Aha! " +paramName);
d136 1
a136 2
                            usersToRemove.add(new User(connection, dMgr,
                                                       userID));
d149 6
a154 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);
d159 1
a159 2
  
} /* end class UserGroupEdit */
@


1.12.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.12 2001/01/26 18:29:02 edk Exp $";
@


1.12.2.2
log
@Ported UserGroupEdit servlet.
@
text
@d2 1
a2 1
 * Copyright (c) 2001 CollabNet.  All rights reserved.
d53 1
d56 1
a56 2
import org.apache.turbine.util.Log;

d58 1
d61 4
a64 3
import org.tigris.helm.security.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
d74 2
a75 2

    private static boolean DEBUG = true;
a93 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);
                }*/

a98 1

d110 1
a110 1
                    group.updateInfo(acl, description);
d116 1
a116 1
                    List usersToRemove = new ArrayList();
d120 1
d123 1
d128 2
a129 1
                            usersToRemove.add(UserPeer.getInstance(userID));
d142 11
a152 4
        } catch (ACLException e) {
            throw e;
        } catch (Exception e) {
            Log.error("Exception caught in UserGroupEdit: " + e);
@


1.12.2.3
log
@"thrown", not "caught".
@
text
@d71 1
a71 1
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.12.2.2 2001/02/12 17:20:07 leonardr Exp $";
d151 1
a151 1
            Log.error("Exception thrown in UserGroupEdit: " + e);
@


1.12.2.4
log
@* Removed useless versionID.
* Made debug var final.
* Corrected use of TurbineException.
@
text
@d71 3
a73 1
    private static final boolean DEBUG = true;
d148 1
a148 2
        }
        catch (ACLException e) {
d150 2
a151 3
        }
        catch (Exception e) {
            Log.error("Exception thrown in UserGroupEdit", e);
d156 2
a157 1
}
@


1.12.2.5
log
@formatting change to expunge the curse
@
text
@d120 1
a120 3
                }
                else if (action.equals(REMOVE_MEMBERS_ACTION))
                {
@


1.12.2.6
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
@


1.12.2.7
log
@Added new imports necessitated by Torque.
@
text
@a62 1
import org.tigris.helm.om.base.*;
@


1.11
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.10
log
@Added status messages on successful updates.
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.9 2000/11/28 21:08:23 leonardr Exp $";
@


1.9
log
@Mega patch providing more user group admin functionality.
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.8 2000/11/28 00:47:42 leonardr Exp $";
d112 1
d138 1
@


1.8
log
@Fixed user group member removal.
@
text
@d67 1
a67 1
 * Changes the info for the selected user group. Also adds and removes
d73 1
a73 1
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.7 2000/11/22 23:50:13 leonardr Exp $";
@


1.7
log
@Some preemptive button name changes.
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.6 2000/11/22 23:41:31 leonardr Exp $";
d78 1
a78 2
    private static String REMOVE_MEMBERS_ACTION = "Remove Members ";
    private static String DELETE_GROUP_ACTION = "Delete Group";
a93 1

d96 1
a96 1

a136 3

                } else if (action.equals(DELETE_GROUP_ACTION)) {

@


1.6
log
@More functionality for UserGroupEdit
@
text
@d73 1
a73 1
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.5 2000/11/22 21:16:13 leonardr Exp $";
d77 1
a77 1
    private static String MAKE_CHANGES_ACTION = "Edit Group";
@


1.5
log
@User group descriptions can now be changed.
@
text
@d63 1
d73 1
a73 1
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.4 2000/11/22 15:10:46 leonardr Exp $";
d98 3
a105 1
                    
d112 1
a112 4
                    
                    UserGroup group = getCurrentUserGroup(context);
                    group.updateInfo(getACL(context, connection), description, 
                                     context);
d115 24
d152 3
@


1.4
log
@Made code blocks for the other UserGroupEdit actions.
@
text
@d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.3 2000/11/22 02:42:26 leonardr Exp $";
d110 4
a113 3
                    User currentUser = getCurrentUser(context);
                    UserGroup group = new UserGroup(currentUser);
                    group.updateInfo(getACL(context, connection), description);
a127 3
            log.exception(e);
            throw new HandlerException(e.getMessage());
        } catch (DoesNotExist e) {
@


1.3
log
@Bugfixes and template changes related to UserGroupEdit.
@
text
@d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.2 2000/11/21 20:56:55 leonardr Exp $";
d95 1
a95 1
            if (action != null && action.equals(MAKE_CHANGES_ACTION))
d97 17
a113 3
                List missingFields = new ArrayList();
                List validationErrors = new ArrayList();
                
d115 4
a118 11
                /* Don't do name until it's supported.
                String name =
                    processField(context, GROUP_NAME_FIELD, missingFields);
                */
                String description  =
                    processField(context, GROUP_DESCRIPTION_FIELD);
                
                User currentUser = getCurrentUser(context);
                UserGroup group = new UserGroup(currentUser);
                group.updateInfo(getACL(context, connection), description);
            }
@


1.2
log
@Redirect properly on user group creation (thanks stack)
@
text
@d72 1
a72 1
    public static final  String versionID = "$Id: UserGroupEdit.java,v 1.1 2000/11/21 01:47:58 leonardr Exp $";
d76 3
a78 1
    private static String MAKE_CHANGES_ACTION = "Submit Changes";
@


1.1
log
@First stab at UserGroups.
@
text
@d66 2
a67 1
 * Changes the info for the selected user group.
d72 1
a72 1
    public static final  String versionID = "$Id: UserUserGroupEdit.java,v 1.1.1.1 2000/11/12 21:15:26 dlr 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.
d53 1
d56 1
a56 2
import org.apache.turbine.util.Log;

d58 1
d61 3
a63 4
import org.tigris.helm.security.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
d66 1
a66 2
 * Changes the info for the selected user group. Also removes
 * users from the group.
d71 3
a73 1
    private static final boolean DEBUG = true;
a75 1
    private static String REMOVE_MEMBERS_ACTION = "Remove Members";
a90 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);
                }*/
d92 1
a92 1
            if (action != null)
d94 15
a108 45
                Domain currentDomain = getCurrentDomain(context);
                UserGroup group = getCurrentUserGroup(context);
                AccessControlList acl = getLoginUser(context).getACL();

                if (action.equals(MAKE_CHANGES_ACTION))
                {
                    List missingFields = new ArrayList();
                    List validationErrors = new ArrayList();
                    
                    /* Don't do name until it's supported.
                       String name =
                       processField(context, GROUP_NAME_FIELD, missingFields);
                    */
                    String description  =
                        processField(context, GROUP_DESCRIPTION_FIELD);
                    group.updateInfo(acl, description);
                    context.put("currentUserGroup", group);
                    appendToMessage(context, "Update succeeded.");
                }
                else if (action.equals(REMOVE_MEMBERS_ACTION))
                {
                    Enumeration paramNames = context.getRequest()
                        .getParameterNames();
                    List usersToRemove = new ArrayList();
                    while (paramNames.hasMoreElements())
                    {
                        String paramName = (String)paramNames.nextElement();
                        if (paramName.startsWith("Remove"))
                        {
                            StringTokenizer tok = 
                                new StringTokenizer(paramName);
                            tok.nextToken();
                            String userID = tok.nextToken();
                            usersToRemove.add(UserPeer.getInstance(userID));
                        }
                    }

                    for (Iterator i = usersToRemove.iterator(); i.hasNext();)
                    {
                        User user = (User)i.next();
                        group.removeUser(acl, user);
                    }
                    appendToMessage(context, "Removal succeeded.");
                }
            } 
d110 11
a120 6
        }
        catch (ACLException e) {
            throw e;
        }
        catch (Exception e) {
            Log.error("Exception thrown in UserGroupEdit", e);
d125 2
a126 1
}
@


