head	1.16;
access;
symbols
	TIGRIS_1_1_0RC2:1.9
	TIGRIS_1_1_0RC1:1.9
	TIGRIS_1_1:1.9.0.4
	TIGRIS_1_0_8:1.9
	TIGRIS_1_0_8RC3:1.9
	TIGRIS_1_0_8RC2:1.9
	TIGRIS_1_0_8RC1:1.9
	TIGRIS_1_0_7:1.9
	TIGRIS_1_0_7RC3:1.9
	TIGRIS_1_0_7RC2:1.9
	TIGRIS_1_0_7RC1:1.9
	TIGRIS_1_0_6:1.9
	TIGRIS_1_0_6RC5:1.9
	TIGRIS_1_0_6RC4:1.9
	TIGRIS_1_0_6RC3:1.9
	TIGRIS_1_0_6RC2:1.9
	TIGRIS_1_0_6RC1:1.9
	TIGRIS_1_0_5:1.9
	TIGRIS_1_0_5RC6:1.9
	TIGRIS_1_0_5RC5:1.9
	TIGRIS_1_0_5RC4:1.9
	TIGRIS_1_0_5RC3:1.9
	TIGRIS_1_0_5RC2:1.9
	TIGRIS_1_0_5RC1:1.9
	TIGRIS_1_0_4:1.9
	TIGRIS_1_0_3:1.9
	TIGRIS_1_0_2:1.9
	TIGRIS_1_0_1:1.9
	TIGRIS_1_0:1.9.0.6
	TIGRIS_1_0_0:1.9
	TIGRIS_1_0_0_RC1:1.9.0.2
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.4
	TIGRIS_0_9_2_3:1.4
	HELM_PEER_PORT_BRANCH:1.1.1.2
	TURBINE_PEER:1.7
	TIGRIS_0_9_2_1:1.7
	TIGRIS_0_9_2:1.4.0.4
	TIGRIS_0_9_0:1.4.0.2
	TIGRIS_0_8_4:1.3.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.16
date	2001.08.28.17.45.17;	author leonardr;	state Exp;
branches;
next	1.15;

1.15
date	2001.08.28.17.13.33;	author leonardr;	state Exp;
branches;
next	1.14;

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

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

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

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

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

1.9
date	2001.03.07.01.53.20;	author lucas;	state Exp;
branches;
next	1.8;

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

1.7
date	2001.01.26.18.29.02;	author edk;	state Exp;
branches
	1.7.2.1;
next	1.6;

1.6
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.5;

1.5
date	2001.01.25.02.07.09;	author stack;	state Exp;
branches;
next	1.4;

1.4
date	2000.12.14.03.04.17;	author edk;	state Exp;
branches;
next	1.3;

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

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

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

1.1.1.1
date	2000.11.12.21.15.45;	author dlr;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2001.02.21.00.32.35;	author dlr;	state Exp;
branches;
next	;

1.7.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	1.7.2.2;

1.7.2.2
date	2001.02.12.21.57.35;	author leonardr;	state Exp;
branches;
next	1.7.2.3;

1.7.2.3
date	2001.02.15.20.50.35;	author leonardr;	state Exp;
branches;
next	1.7.2.4;

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


desc
@@


1.16
log
@More methods migrated 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.util.*;
import java.sql.*;

import org.apache.velocity.context.Context;

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

import org.tigris.helm.om.*;
import org.tigris.helm.security.RedirectException;
import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.security.ACLException;
import org.tigris.helm.tool.ContextAPI;

public class UserRoleAdd extends org.tigris.helm.security.HelmServlet {
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.15 2001/08/28 17:13:33 leonardr Exp $";

    private static boolean DEBUG = true;

    private static final String GRANT_ROLES_ON_SELECTED_PROJECTS_ACTION =
        "Grant Roles on all Selected Projects";
    private static final String GRANT_SELECTED_ROLES_ACTION = 
        "Grant Selected Roles";
    private static final String ROLE_LIST_FIELD="roles";
    private static final String PROJECT_SELECT_PREFIX="Grant";
    private static final String ROLE_SELECT_PREFIX="RoleSelect";

    /**
     * Grant a role to a user in one or more project.
     */
    protected String
	processRequest(Context context)
	throws NestableException, RedirectException
    {
	String templateName = super.processRequest(context);
	
	String action = getAction(context);
        try 
        {
            if (action != null)
            {                             
                List projects = new ArrayList();
                String[] roles = ContextAPI.getParameterValues
                    (context, ROLE_LIST_FIELD);
                
                AccessControlList acl = getACL(context);
                
                //Get the User we're granting to.
                User currentUser = getCurrentUser(context);
                
                if (action.equals(GRANT_ROLES_ON_SELECTED_PROJECTS_ACTION))
                {
                    List projectIDs = ContextAPI.searchParamsForPrefix
                        (context, PROJECT_SELECT_PREFIX);

                    for (Iterator i = projectIDs.iterator(); i.hasNext();)
                    {
                        String projectID = (String)i.next();
                        Project project = ProjectPeer.getInstance(projectID);
                        
                        for (int j=0; j < roles.length; j++)
                        {
                            Role role = RolePeer.getInstance(roles[j]);
                            currentUser.grantRole(acl, role, project);
                        }
                    }
                } 
                else if (action.equals(GRANT_SELECTED_ROLES_ACTION)) 
                {
                    List projectsAndRoles = ContextAPI.
                        searchParamsForPrefixIncludeValue
                        (context, ROLE_SELECT_PREFIX);
                    
                    for (Iterator i = projectsAndRoles.iterator(); 
                         i.hasNext();)
                    {
                        String[] projectAndRole = (String[])i.next();
                        Project project = ProjectPeer
                            .getInstance(projectAndRole[0]);
                        Role role = RolePeer.getInstance(projectAndRole[0]);
                        currentUser.grantRole(acl, role, project); 
                    }
                }
            }
        } 
        catch (ACLException e) 
        {
            throw e;
        } 
        catch (RedirectException e) 
        {
            throw e;
        } 
        catch (Exception e) 
        {
            Log.error("Exception thrown in UserRoleAdd: ", e);
        }

        return templateName;
    }
  
} /* end class UserRoleAdd */
@


1.15
log
@Completed migration of more methods to ContextAPI.
@
text
@d65 1
a65 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.14 2001/08/28 00:56:12 leonardr Exp $";
d92 2
a93 1
                String[] roles = getParameterValues(context, ROLE_LIST_FIELD);
@


1.14
log
@Moved code out of BaseHelmServlet and into other classes which suit it better.
@
text
@d65 1
a65 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.13 2001/08/11 09:08:01 dlr Exp $";
d90 1
a90 5
            {                
                //Get the parameter names for later use.
                Enumeration paramNames = 
                    getRequest(context).getParameterNames();
                
@


1.13
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@a56 1
import org.apache.commons.util.exception.NestableException;
d58 1
d60 3
a63 3
import org.tigris.helm.security.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.*;
d65 1
a65 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.12 2001/07/18 10:05:12 dlr Exp $";
d105 1
a105 1
                    List projectIDs = searchParamsForPrefix
d122 2
a123 1
                    List projectsAndRoles = searchParamsForPrefixIncludeValue
@


1.12
log
@Ported Joist Redirect*Exception to Helm.
@
text
@d56 2
a57 2
import org.apache.turbine.util.TurbineException;
import org.apache.turbine.util.TurbineException;
d65 1
a65 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.11 2001/06/20 21:32:48 leonardr Exp $";
d82 1
a82 1
	throws TurbineException, RedirectException
@


1.11
log
@Converted to use the handy new HelmServlet methods.
@
text
@d59 1
a59 1
import org.joist.security.RedirectException;
d65 1
a65 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.10 2001/05/23 01:50:10 dlr Exp $";
@


1.10
log
@Ported Helm from WebMacro to Velocity.
@
text
@d65 1
a65 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.9 2001/03/07 01:53:20 lucas Exp $";
d105 4
a108 2
                    String paramName;
                    while (paramNames.hasMoreElements())
d110 2
a111 15
                        paramName = (String)paramNames.nextElement();
                        if (paramName.startsWith(PROJECT_SELECT_PREFIX))
                        {
                            StringTokenizer tok = 
                                new StringTokenizer(paramName);
                            tok.nextToken();
                            Project project = 
                                ProjectPeer.getInstance(tok.nextToken());
                            projects.add(project);
                        }
                    }
                    
                    for (Iterator i = projects.iterator(); i.hasNext();)
                    {
                        Project project = (Project)i.next();
d119 8
a126 3
                } else if (action.equals(GRANT_SELECTED_ROLES_ACTION)) {
                    String paramName;
                    while (paramNames.hasMoreElements())
d128 5
a132 15
                        paramName = (String) paramNames.nextElement();
                        if (paramName.startsWith(ROLE_SELECT_PREFIX))
                        {
                            String roleID = getParameter(context, paramName);
                            if (roleID != null && !roleID.equals(""))
                            {
                                Role role = RolePeer.getInstance(roleID);
                                StringTokenizer tok = 
                                    new StringTokenizer(paramName);
                                tok.nextToken();
                                Project project = 
                                    ProjectPeer.getInstance(tok.nextToken());
                                currentUser.grantRole(acl, role, project); 
                            }
                        }
d136 3
a138 1
        } catch (ACLException e) {
d140 3
a142 1
        } catch (RedirectException e) {
d144 3
a146 1
        } catch (Exception e) {
@


1.9
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d53 1
a53 1
import org.webmacro.servlet.*;
d56 2
d65 1
a65 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.8 2001/02/21 01:08:21 dlr Exp $";
d81 2
a82 2
	processRequest (Connection connection, WebContext context)
	throws HandlerException, RedirectException
d84 1
a84 1
	String templateName = super.processRequest(connection, context);
d92 2
a93 2
                Enumeration paramNames = context.getRequest()
                    .getParameterNames();
d96 1
a96 1
                String[] roles = context.getFormList(ROLE_LIST_FIELD);
d137 1
a137 1
                            String roleID = context.getForm(paramName);
@


1.8
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d61 1
a61 3
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;

d63 1
a63 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.7.2.4 2001/02/16 03:01:26 dlr Exp $";
@


1.7
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.
d17 1
a17 1
 * software developed by Collab.Net (http://www.Collab.Net/)."
d27 1
a27 1
 * permission of Collab.Net.
d32 1
a32 1
 * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
a51 2
import javax.servlet.*;
import javax.servlet.http.*;
a52 1
import org.webmacro.util.Log;
d55 1
a55 1
import com.workingdogs.village.*;
a56 3
import org.joist.*;
import org.joist.util.*;
import org.joist.session.*;
a57 2
import org.joist.database.DataManager;
import org.joist.database.JoistDatabaseException;
a58 1
import org.tigris.helm.DoesNotExist;
d60 3
a62 3
import org.tigris.helm.database.*;
import org.tigris.helm.project.Project;
import org.tigris.helm.domain.User;
d65 11
a75 3
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.4 2000/12/14 03:04:17 edk Exp $";
    private static Log log = new Log("UserRoleAdd", "Tigris StartPage");
    private static boolean debug = true;
d78 1
a78 1
     *  Display and process the login screen.
a83 2
	if (debug) log.info("started!");

d87 1
a87 26
	if (debug) log.info("action=" + action );
        
        //Get the parameter names for later use.
        Enumeration paramNames = context.getRequest().getParameterNames();
        
        ArrayList projects = new ArrayList();
        String[] roles = context.getFormList("roles");

        AccessControlList acl = null;
        try {
            acl = getACL(context, connection);
        } 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());
        }

        //Get the User we're granting to.
        User currentUser = getCurrentUser(context);

        if (action.equals("Grant Roles on all Selected Projects"))
d89 8
a96 4
            String paramName;
            while (paramNames.hasMoreElements())
            {
                paramName = (String) paramNames.nextElement();
d98 6
a103 1
                if (paramName.startsWith("Grant"))
d105 14
a118 12
		    StringTokenizer tok = new StringTokenizer(paramName);
                    tok.nextToken();
                    projects.add(tok.nextToken());
                }
            }
            
            try 
            {
                for (int i = 0;  i < projects.size(); i++)
                {
                    Project project = new Project(connection, dMgr, 
                                                  (String)projects.get(i));
d120 1
a120 1
                    for (int j=0; j < roles.length; j++)
d122 7
a128 2
                        Role role = new Role (connection, dMgr, roles[j]);
                        currentUser.grantRole(acl, role, project);
d130 3
a132 21
                }
            } 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());
            }
        } else if (action.equals("Grant Selected Roles")) {
            String paramName;
            try {
                while (paramNames.hasMoreElements())
                {
                    paramName = (String) paramNames.nextElement();
                    if (paramName.startsWith("RoleSelect"))
d134 2
a135 2
                        String roleID = context.getForm(paramName);
                        if (roleID != null && !roleID.equals(""))
d137 11
a147 9
                            Role role = new Role (connection, dMgr, roleID);
                            StringTokenizer tok = 
                                new StringTokenizer(paramName);
                            tok.nextToken();
                            String projectID = tok.nextToken();
                            Project project = new Project(connection, dMgr, 
                                                          projectID);
                            log.info("Granting " + roleID + "/" + projectID);
                            currentUser.grantRole(acl, role, project); 
a150 12
            } catch (DataSetException e) {
                log.exception(e);
                throw new HandlerException(e.getMessage());
            } catch (SQLException e) {
                log.exception(e);
                throw new HandlerException(e.getMessage());
            } catch (DoesNotExist e) {
                log.exception(e);
                throw new HandlerException(e.getMessage());
            } catch (JoistDatabaseException e) {
                log.exception(e);
                throw new HandlerException(e.getMessage());
d152 6
a158 2
                
	if (debug) log.info("done");
@


1.7.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d74 1
a74 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.7 2001/01/26 18:29:02 edk Exp $";
@


1.7.2.2
log
@Ported UserRoleAdd servlet.
@
text
@d2 1
a2 1
 * Copyright (c) 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
d52 2
d55 1
d58 1
a58 1
import org.apache.turbine.util.Log;
d60 3
d64 2
d67 1
d69 3
a71 2
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
d75 2
a76 10

    private static boolean DEBUG = true;

    private static final String GRANT_ROLES_ON_SELECTED_PROJECTS_ACTION =
        "Grant Roles on all Selected Projects";
    private static final String GRANT_SELECTED_ROLES_ACTION = 
        "Grant Selected Roles";
    private static final String ROLE_LIST_FIELD="roles";
    private static final String PROJECT_SELECT_PREFIX="Grant";
    private static final String ROLE_SELECT_PREFIX="RoleSelect";
d79 1
a79 1
     * Grant a role to a user in one or more project.
d85 2
d90 26
a115 1
        try 
d117 4
a120 5
            if (action != null)
            {                
                //Get the parameter names for later use.
                Enumeration paramNames = context.getRequest()
                    .getParameterNames();
d122 38
a159 9
                List projects = new ArrayList();
                String[] roles = context.getFormList(ROLE_LIST_FIELD);
                
                AccessControlList acl = getACL(context);
                
                //Get the User we're granting to.
                User currentUser = getCurrentUser(context);
                
                if (action.equals(GRANT_ROLES_ON_SELECTED_PROJECTS_ACTION))
d161 2
a162 2
                    String paramName;
                    while (paramNames.hasMoreElements())
d164 2
a165 2
                        paramName = (String)paramNames.nextElement();
                        if (paramName.startsWith(PROJECT_SELECT_PREFIX))
d167 1
d171 5
a175 34
                            Project project = 
                                ProjectPeer.getInstance(tok.nextToken());
                            projects.add(project);
                        }
                    }
                    
                    for (Iterator i = projects.iterator(); i.hasNext();)
                    {
                        Project project = (Project)i.next();
                        
                        for (int j=0; j < roles.length; j++)
                        {
                            Role role = RolePeer.getInstance(roles[j]);
                            currentUser.grantRole(acl, role, project);
                        }
                    }
                } else if (action.equals(GRANT_SELECTED_ROLES_ACTION)) {
                    String paramName;
                    while (paramNames.hasMoreElements())
                    {
                        paramName = (String) paramNames.nextElement();
                        if (paramName.startsWith(ROLE_SELECT_PREFIX))
                        {
                            String roleID = context.getForm(paramName);
                            if (roleID != null && !roleID.equals(""))
                            {
                                Role role = RolePeer.getInstance(roleID);
                                StringTokenizer tok = 
                                    new StringTokenizer(paramName);
                                tok.nextToken();
                                Project project = 
                                    ProjectPeer.getInstance(tok.nextToken());
                                currentUser.grantRole(acl, role, project); 
                            }
d179 12
a191 6
        } catch (ACLException e) {
            throw e;
        } catch (RedirectException e) {
            throw e;
        } catch (Exception e) {
            Log.error("Exception thrown in UserRoleAdd: ", e);
d193 2
@


1.7.2.3
log
@Normalized copyright dates.
@
text
@d2 1
a2 1
 * Copyright (c) 2000-2001 CollabNet.  All rights reserved.
d64 1
a64 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.7.2.2 2001/02/12 21:57:35 leonardr Exp $";
@


1.7.2.4
log
@Added new imports necessitated by Torque.
@
text
@a61 1
import org.tigris.helm.om.base.*;
d64 1
a64 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.7.2.3 2001/02/15 20:50:35 leonardr Exp $";
@


1.6
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
@d74 1
a74 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.5 2001/01/25 02:07:09 stack Exp $";
d101 7
a107 2
        } 
        catch (DBException e) {
d134 2
a135 2
                    Project project 
                        = new Project(dMgr, (String)projects.get(i));
d139 1
a139 1
                        Role role = new Role (dMgr, roles[j]);
d143 7
a149 1
            } catch (DBException e) {
d167 1
a167 1
                            Role role = new Role (dMgr, roleID);
d179 4
a182 1
            } catch (DBException e) {
d186 3
@


1.5
log
@Made new Role and Project calls match new connection-less signatures.  Killed DB exceptions and added DBException
@
text
@d74 1
a74 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.4 2000/12/14 03:04:17 edk Exp $";
@


1.4
log
@* adjust for corrections to Role constructor
* correct another Role constructor which listed the DataManager before
  the Connection
@
text
@d74 1
a74 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.3 2000/11/15 22:48:40 leonardr Exp $";
d101 2
a102 7
        } 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) {
d129 2
a130 2
                    Project project = new Project(connection, dMgr, 
                                                  (String)projects.get(i));
d134 1
a134 1
                        Role role = new Role (connection, dMgr, roles[j]);
d138 1
a138 7
            } 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) {
d156 1
a156 1
                            Role role = new Role (connection, dMgr, roleID);
d168 1
a168 4
            } catch (DataSetException e) {
                log.exception(e);
                throw new HandlerException(e.getMessage());
            } catch (SQLException e) {
a171 3
                log.exception(e);
                throw new HandlerException(e.getMessage());
            } catch (JoistDatabaseException e) {
@


1.3
log
@Got rid of more superfluous UpdateException throwage.
@
text
@d74 1
a74 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.2 2000/11/15 17:19:16 leonardr Exp $";
d139 1
a139 1
                        Role role = new Role (dMgr, connection, roles[j]);
d167 1
a167 1
                            Role role = new Role (dMgr, connection, roleID);
@


1.2
log
@Cleaned up UserRoleAdd; added column to display in servlet.
@
text
@a72 2
import org.tigris.helm.tool.UpdateException;

d74 1
a74 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.1.1.1 2000/11/12 21:15:45 dlr Exp $";
a151 3
            } catch (UpdateException e) {
                log.exception(e);
                throw new HandlerException(e.getMessage());
a188 3
                log.exception(e);
                throw new HandlerException(e.getMessage());
            } catch (UpdateException e) {
@


1.1
log
@Initial revision
@
text
@a49 1
import java.io.*;
d76 1
a76 1
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.13 2000/11/11 03:33:32 dlr Exp $";
d87 1
a87 1
	if (debug) log.debug("UserRoleAdd: started!");
d91 3
a93 3
	String action = (String)context.get("action");	
	if (debug) log.debug("UserRoleAdd: action=" + action );

d95 2
a96 2
        HttpServletRequest request = context.getRequest();
        Enumeration paramNames = request.getParameterNames();
a99 3
        UserRoleProjectManager urpMgr = (UserRoleProjectManager)
            dMgr.getManager("org.tigris.helm.database.UserRoleProjectManager");

d103 7
a109 1
        } catch (Exception e) {
d114 2
a115 13
        String userID = null;
        if (action != null)
        {
            //Get the User we're granting to, and the Role we're granting
            //them in all these projects.
            User user = getCurrentUser(context);
            try {
                userID = user.getUserID();
            } catch (DataSetException e) {
                log.exception(e);
                throw new HandlerException(e.getMessage());
            }
        }
d131 1
a131 1

a133 1
                User user = new User(connection, dMgr, userID);
d136 2
a137 6
                    String projectID = (String)projects.get(i);
                    
                    Project project = new Project(connection, dMgr, projectID);
                    
                    acl.assertPermissionForProject("Project Member - Approve", 
                                                   project.getID());
d142 1
a142 2
                        user.grantRole(acl, role, project);
                        user.grantRole(acl, role, project);
a163 2
                User user = new User(connection, dMgr, userID);

d173 2
a174 1
                            StringTokenizer tok = new StringTokenizer(paramName);
a178 3
                            acl.assertPermissionForProject
                                ("Project Member - Approve", project.getID());
                            
d180 1
a180 1
                            user.grantRole(acl, role, project); 
d190 3
a198 3
            } catch (DoesNotExist e) {
                log.exception(e);
                throw new HandlerException(e.getMessage());
d201 2
a202 3


	if (debug) log.debug("UserRoleAdd:  done");
@


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


1.1.1.2
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
d50 1
d53 2
d56 1
d59 1
a59 1
import org.apache.turbine.util.Log;
d61 3
d65 2
d68 1
d70 5
a74 3
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
import org.tigris.helm.om.base.*;
d77 3
a79 11
    public static final  String versionID = "$Id: UserRoleAdd.java,v 1.7.2.4 2001/02/16 03:01:26 dlr Exp $";

    private static boolean DEBUG = true;

    private static final String GRANT_ROLES_ON_SELECTED_PROJECTS_ACTION =
        "Grant Roles on all Selected Projects";
    private static final String GRANT_SELECTED_ROLES_ACTION = 
        "Grant Selected Roles";
    private static final String ROLE_LIST_FIELD="roles";
    private static final String PROJECT_SELECT_PREFIX="Grant";
    private static final String ROLE_SELECT_PREFIX="RoleSelect";
d82 1
a82 1
     * Grant a role to a user in one or more project.
d88 2
d92 35
a126 2
	String action = getAction(context);
        try 
d128 4
a131 5
            if (action != null)
            {                
                //Get the parameter names for later use.
                Enumeration paramNames = context.getRequest()
                    .getParameterNames();
d133 12
a144 9
                List projects = new ArrayList();
                String[] roles = context.getFormList(ROLE_LIST_FIELD);
                
                AccessControlList acl = getACL(context);
                
                //Get the User we're granting to.
                User currentUser = getCurrentUser(context);
                
                if (action.equals(GRANT_ROLES_ON_SELECTED_PROJECTS_ACTION))
d146 6
a151 14
                    String paramName;
                    while (paramNames.hasMoreElements())
                    {
                        paramName = (String)paramNames.nextElement();
                        if (paramName.startsWith(PROJECT_SELECT_PREFIX))
                        {
                            StringTokenizer tok = 
                                new StringTokenizer(paramName);
                            tok.nextToken();
                            Project project = 
                                ProjectPeer.getInstance(tok.nextToken());
                            projects.add(project);
                        }
                    }
d153 1
a153 1
                    for (Iterator i = projects.iterator(); i.hasNext();)
d155 3
a157 7
                        Project project = (Project)i.next();
                        
                        for (int j=0; j < roles.length; j++)
                        {
                            Role role = RolePeer.getInstance(roles[j]);
                            currentUser.grantRole(acl, role, project);
                        }
d159 26
a184 3
                } else if (action.equals(GRANT_SELECTED_ROLES_ACTION)) {
                    String paramName;
                    while (paramNames.hasMoreElements())
d186 2
a187 2
                        paramName = (String) paramNames.nextElement();
                        if (paramName.startsWith(ROLE_SELECT_PREFIX))
d189 11
a199 11
                            String roleID = context.getForm(paramName);
                            if (roleID != null && !roleID.equals(""))
                            {
                                Role role = RolePeer.getInstance(roleID);
                                StringTokenizer tok = 
                                    new StringTokenizer(paramName);
                                tok.nextToken();
                                Project project = 
                                    ProjectPeer.getInstance(tok.nextToken());
                                currentUser.grantRole(acl, role, project); 
                            }
d203 15
a218 6
        } catch (ACLException e) {
            throw e;
        } catch (RedirectException e) {
            throw e;
        } catch (Exception e) {
            Log.error("Exception thrown in UserRoleAdd: ", e);
d220 3
@

