head	1.27;
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.2
	TURBINE_PEER:1.11
	TIGRIS_0_9_2_1:1.11
	TIGRIS_0_9_2:1.9.0.2
	TIGRIS_0_9_0:1.8.0.2
	TIGRIS_0_8_4:1.6.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.27
date	2001.08.28.17.45.17;	author leonardr;	state Exp;
branches;
next	1.26;

1.26
date	2001.08.28.00.56.12;	author leonardr;	state Exp;
branches;
next	1.25;

1.25
date	2001.08.11.09.08.07;	author dlr;	state Exp;
branches;
next	1.24;

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

1.23
date	2001.07.18.10.05.14;	author dlr;	state Exp;
branches;
next	1.22;

1.22
date	2001.07.17.20.10.49;	author leonardr;	state Exp;
branches;
next	1.21;

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

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

1.19
date	2001.03.27.08.40.07;	author jrobbins;	state Exp;
branches;
next	1.18;

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

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

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

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

1.14
date	2001.03.07.08.32.42;	author dlr;	state Exp;
branches;
next	1.13;

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

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

1.11
date	2001.01.26.18.29.05;	author edk;	state Exp;
branches
	1.11.2.1;
next	1.10;

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

1.9
date	2000.12.23.00.48.19;	author dlr;	state Exp;
branches;
next	1.8;

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

1.7
date	2000.12.14.03.04.17;	author edk;	state Exp;
branches;
next	1.6;

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

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

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

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

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

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

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

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

1.11.2.1
date	2001.01.28.01.02.18;	author dlr;	state dead;
branches;
next	1.11.2.2;

1.11.2.2
date	2001.02.16.19.54.52;	author jody;	state Exp;
branches;
next	1.11.2.3;

1.11.2.3
date	2001.02.17.00.15.41;	author elicia;	state Exp;
branches;
next	;


desc
@@


1.27
log
@More methods migrated to ContextAPI.
@
text
@/* ================================================================
 * Copyright (c) 2000 CollabNet.  All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 * 
 * 1. Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 * 
 * 2. Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * 
 * 3. The end-user documentation included with the redistribution, if
 * any, must include the following acknowlegement: "This product includes
 * software developed by 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.project;

import java.io.*;
import java.util.*;

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

import org.apache.velocity.context.Context;

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

/**
 * A servlet for assigning roles to users in projects.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 */
public class ProjectMemberAdd extends HelmServlet
{
    private static final boolean DEBUG = true;
    
    /**
     * The properties file key used to retrieve the number of users to display
     * per page.
     */
    private static final String USERS_PER_PAGE = "nbrUsersPerPage";

    /**
     * The name of the button which grants roles.
     */
    private static final String GRANT_ROLES_ACTION = "Grant Roles";
        
    /**
     * The prefix of fields which designate the granting of a role.
     */
    private static final String GRANT_PREFIX = "Grant";

    /**
     * The field containing hand-entered user designants for a mass add.
     */
    private static final String MASS_ADD_FIELD = "massAdd";

    /**
     * The name of the checkbox used to indicate a redirect.
     */
    private static final String DONE_GRANTING_ROLES = "done";

    /**
     * Process the member addition request and show the UI.
     */
    protected String processRequest(Context context)
        throws NestableException, RedirectException
    {
        String templateName = super.processRequest(context);
        String action = getAction(context);       
        String[] selectedRoles = ContextAPI.getParameterValues
            (context, "roles");

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

        try
        {
            Domain domain = getCurrentDomain(context);
            AccessControlList acl = getLoginUser(context).getACL();        
            Project project = getCurrentProject(context);

            String massAddUsers = ContextAPI.processField
                (context, MASS_ADD_FIELD);

            //Make sure the user can grant roles in this project.
            acl.assertPermission(project.requiredRoleGrantAction(),
                                 project);            

            if (GRANT_ROLES_ACTION.equals(action))
            {
                //Find each user to which we are granting a role.
                List users = UserPeer.getInstances
                    (ContextAPI.searchParamsForPrefix(context, GRANT_PREFIX));

                //Add users designated in a user add.
                Log.debug("Parsing designants: " + massAddUsers);
                users.addAll(UserPeer.parseDesignantList
                             (massAddUsers, domain, validationErrors));

                if (users.isEmpty() && ContextAPI.isValidUserInput(context))
                {
                    ContextAPI.addValidationError
                        (context, "You must select at least one user.");
                }

                if (selectedRoles == null)
                {
                    ContextAPI.addValidationError
                        (context, 
                         "You must select at least one role to grant.");
                }

                if (ContextAPI.isValidUserInput(context))
                {
                    //For each user...
                    for (Iterator i = users.iterator(); i.hasNext();)
                    {
                        User user = (User)i.next();
                        //For each role...
                        for (int j = 0; j < selectedRoles.length; j++)
                        {
                            Role role =
                                (Role)RolePeer.getInstance(selectedRoles[j]);
                            if (DEBUG)
                            {
                                Log.debug("Grant to user=" 
                                          + user.getLoginName()
                                          + " role=" + role.getName());
                            }
                            user.grantRole(acl, role, project);
                        }
                    }                        
                    reportSuccess(context, selectedRoles.length, users.size());

                    // Possibly send the user to the next servlet in
                    // the site flow.
                    String done = ContextAPI.getParameter
                        (context, DONE_GRANTING_ROLES);
                    if (haveValue(done))
                    {
                        redirectTo("ProjectMemberList");
                    }
                }
            }

        }
        catch (RedirectException e) 
        { 
            throw e;
        }
        catch (Exception e) 
        { 
            Log.error(e); 
            throw new NestableException(e);
        }

        return templateName;
    }
    
    /**
     * Reports the successful addition of roles to users in a project.
     */
    private void reportSuccess(Context context, int nbrRoles, int nbrUsers)
    {
        StringBuffer msg = new StringBuffer("Granted ").append(nbrRoles)
            .append(" role");
        if (nbrRoles != 1)
        {
            msg.append('s');
        }
        msg.append(" to ").append(nbrUsers).append(" user");
        if (nbrUsers != 1)
        {
            msg.append('s');
        }
        ContextAPI.addMessage(context, msg.toString());
    }
}
@


1.26
log
@Moved code out of BaseHelmServlet and into other classes which suit it better.
@
text
@d107 2
a108 1
        String[] selectedRoles = getParameterValues(context, "roles");
d174 2
a175 1
                    String done = getParameter(context, DONE_GRANTING_ROLES);
@


1.25
log
@Upgrading to Turbine 3.0-dev, Fulcrum 1.0, and Torque 1.0.
@
text
@d129 1
a129 1
                    (searchParamsForPrefix(context, GRANT_PREFIX));
@


1.24
log
@Removed Joist references.
@
text
@d54 1
a54 1
import org.apache.turbine.util.TurbineException;
d103 1
a103 1
        throws TurbineException, RedirectException
d189 1
a189 1
            throw new TurbineException(e);
@


1.23
log
@Ported Joist Redirect*Exception to Helm.
@
text
@a57 2
import org.joist.util.*;

@


1.22
log
@Ported servlets to new error-handling mechanism.
@
text
@a51 4
import java.util.List;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
a54 1
import org.apache.turbine.util.TurbineException;
a58 1
import org.joist.security.*;
@


1.21
log
@Added mass member add capability.
@
text
@d69 1
d126 2
a127 1
            String massAddUsers = processField(context, MASS_ADD_FIELD);
d144 1
a144 1
                if (users.isEmpty() && validationErrors.isEmpty())
d146 2
a147 1
                    validationErrors.add("You must select at least one user.");
d152 3
a154 2
                    validationErrors.add
                        ("You must select at least one role to grant.");
d157 1
a157 1
                if (validationErrors.isEmpty())
a186 5
                else
                {
                    reportInvalidUserInput(context, missingFields, 
                                           validationErrors);
                }
a193 5
        catch (DoesNotExist e) 
        { 
            Log.error(e); 
            appendToMessage(context, e.getMessage());
        }
d219 1
a219 1
        appendToMessage(context, msg.toString());
@


1.20
log
@Ported Helm from WebMacro to Velocity.
@
text
@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
d70 6
d85 5
d92 10
d109 1
a109 1
    protected String processRequest(Context ctx)
d112 3
a114 7
        String templateName = super.processRequest(ctx);
        String action = getAction(ctx);
        if (DEBUG) Log.debug("ProjectMemberAdd: action=" + action);
        
        // Get parameter names
        HttpServletRequest request = getRequest(ctx);
        Enumeration paramNames = request.getParameterNames();
d116 2
a117 2
        List users = new ArrayList();
        String[] selectedRoles = getParameterValues(ctx, "roles");
d121 5
a125 4
            Domain currentDomain = getCurrentDomain(ctx);
            User loginUser = getLoginUser(ctx);       
            AccessControlList acl = loginUser.getACL();        
            Project project = getCurrentProject(ctx);
d127 1
a127 1
            //Make sure they can grant roles in this project.
d129 1
a129 2
                                 project);
            
d131 5
a135 3
            int rowsToShow = getHost(ctx).getRequestableProjectRoles().size();
            if (rowsToShow > 10) rowsToShow = 10;
            ctx.put("rowsToShow", new Integer(rowsToShow));
d137 4
a140 7
            if (action != null && action.equals("Grant Roles"))
            {
                if (selectedRoles == null)
                {
                    appendToMessage(ctx, "Please select at least one role.");
                    return templateName;
                }
d142 1
a142 3
                //Find each user to which we are granting a role.
                String paramName;
                while (paramNames.hasMoreElements())
d144 1
a144 8
                    paramName = (String) paramNames.nextElement();
                    
                    if (paramName.startsWith("Grant"))
                    {
                        StringTokenizer tok = new StringTokenizer(paramName);
                        tok.nextToken();
                        users.add((User)UserPeer.getInstance(tok.nextToken()));
                    }
d147 1
a147 1
                if (users.size() == 0)
d149 2
a150 2
                    appendToMessage(ctx, "Please select at least one user.");
                    return templateName;
d153 1
a153 2
                //For each user...
                for (int i = 0; i < users.size(); i++)
d155 2
a156 4
                    User user = (User)users.get(i);
                    Log.debug("Checking user " + user.getLoginName());
                    //For each role...
                    for (int j = 0; j < selectedRoles.length; j++)
d158 3
a160 3
                        Role role =
                            (Role)RolePeer.getInstance(selectedRoles[j]);
                        if (DEBUG)
d162 9
a170 2
                            Log.debug("Grant to user=" + user.getLoginName() +
                                      " role=" + role.getName());
d172 9
a180 1
                        user.grantRole(acl, role, project);
d183 1
a183 5
                reportSuccess(ctx, selectedRoles.length, users.size());

                // Possibly send the user to the next servlet in the site flow.
                String done = getParameter(ctx, DONE_GRANTING_ROLES);
                if (haveValue(done))
d185 2
a186 1
                    redirectTo("ProjectMemberList");
d191 2
a192 1
        catch (RedirectException e) { 
d195 2
a196 1
        catch (DoesNotExist e) { 
d198 1
a198 1
            appendToMessage(ctx, e.getMessage());
d200 2
a201 1
        catch (Exception e) { 
d212 1
a212 1
    private void reportSuccess(Context ctx, int nbrRoles, int nbrUsers)
d225 1
a225 1
        appendToMessage(ctx, msg.toString());
@


1.19
log
@added a little logic to make ProjectMemberAdd more usable on sites that refine their own roles
@
text
@d58 2
d61 1
a61 1
import org.webmacro.servlet.*;
d88 2
a89 2
    protected String processRequest(Connection conn, WebContext ctx)
        throws HandlerException, RedirectException
d91 1
a91 1
        String templateName = super.processRequest(conn, ctx);
d96 1
a96 1
        HttpServletRequest request = ctx.getRequest();
d100 1
a100 1
        String[] selectedRoles = ctx.getFormList("roles");
d167 1
a167 1
                String done = ctx.getForm(DONE_GRANTING_ROLES);
d184 1
a184 1
            throw new HandlerException(e.getMessage());
d193 1
a193 1
    private void reportSuccess(WebContext ctx, int nbrRoles, int nbrUsers)
@


1.18
log
@Complain if they don't select any users.
@
text
@d111 5
d171 1
d184 1
a184 1
 
@


1.17
log
@Put hard numbers on number of roles granted.
@
text
@d115 1
a115 1
                    appendToMessage(ctx, "Please select a role.");
d131 6
@


1.16
log
@Redirect to the next servlet in the flow when desired (IZ# 2489).
@
text
@d181 3
a183 2
        StringBuffer msg = new StringBuffer("Granted role");
        if (nbrRoles > 0)
d187 2
a188 2
        msg.append(" to user");
        if (nbrUsers > 0)
@


1.15
log
@Added success report to user.
@
text
@d79 5
d152 7
d160 3
@


1.14
log
@Cleaned up file.
@
text
@d57 2
a59 2
import com.workingdogs.village.*;
import org.apache.turbine.util.Log;
d62 1
a63 1
import org.joist.security.*;
a64 1

d67 1
a67 1
import org.tigris.helm.om.*;
d92 1
a92 1
        ArrayList users = new ArrayList();
d136 2
a137 2
                        Role role = (Role)RolePeer.getInstance(selectedRoles[j]);
                        Log.debug("Checking role " + role.getName());
d139 1
d142 1
d146 1
d161 17
@


1.13
log
@Corrected regex madness for Torque upgrade.  -dlr
@
text
@d71 1
a71 5

    public static final String versionID =
        "$Id: ProjectMemberAdd.java,v 1.12 2001/02/21 01:08:23 dlr Exp $";

    private static boolean debug = true;
d79 4
a82 1
    protected String processRequest (Connection conn, WebContext ctx)
d85 3
a87 6
        if (debug) Log.debug ("ProjectMemberAdd: started!");
        
        String templateName = super.processRequest (conn, ctx);
        
        String action = (String) ctx.get ("action");
        if (debug) Log.debug ("ProjectMemberAdd: action=" + action);
d90 2
a91 2
        HttpServletRequest request = ctx.getRequest ();
        Enumeration paramNames = request.getParameterNames ();
d93 2
a94 2
        ArrayList users = new ArrayList ();
        String[] selectedRoles = ctx.getFormList ("roles");
d105 1
a105 1
                                           project);
d107 1
a107 1
            if (action != null && action.equals ("Grant Roles"))
d117 1
a117 1
                while (paramNames.hasMoreElements ())
d119 1
a119 1
                    paramName = (String) paramNames.nextElement ();
d121 1
a121 1
                    if (paramName.startsWith ("Grant"))
d123 3
a125 3
                        StringTokenizer tok = new StringTokenizer (paramName);
                        tok.nextToken ();
			            users.add((User)UserPeer.getInstance(tok.nextToken()));
d128 1
a128 1
            
d130 1
a130 1
                for (int i = 0; i < users.size (); i++)
d139 2
a140 2
                        if (debug)
                            Log.debug ("Grant to user=" + user.getLoginName() +
d146 2
a147 1
	} catch (DoesNotExist e) { 
d149 3
a151 4
            String message = "" + e.getMessage(); 
            if(debug) Log.debug(message); 
            appendToMessage(ctx, message);             
        } catch (Exception e) { 
d153 1
a153 3
            String message = "" + e.getMessage(); 
            if(debug) Log.debug(message); 
            appendToMessage(ctx, message);             
a155 2
        if (debug) Log.debug ("ProjectMemberAdd:  done");
        
a159 3

/* end class ProjectMemberAdd */

@


1.12
log
@This is the highest revision from the HELM_PEER_PORT_BRANCH.  The previous import caused too many conflicts to resolve manually
@
text
@d68 1
a68 2
import org.tigris.helm.om.peer.*;

d73 1
a73 1
        "$Id: ProjectMemberAdd.java,v 1.11.2.3 2001/02/17 00:15:41 elicia Exp $";
@


1.11
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@a56 1
import org.webmacro.util.*;
d58 2
a59 3
import org.webmacro.engine.*;
import org.webmacro.broker.*;
import org.webmacro.resource.*;
a60 1
import org.joist.*;
a61 1
import org.joist.session.*;
d63 1
a63 1
import com.workingdogs.village.*;
a64 2
import org.joist.security.RedirectException;
import org.joist.database.JoistDatabaseException;
d67 2
a68 2
import org.tigris.helm.database.UserRoleProjectManager;
import org.tigris.helm.tool.paginate.*;
d70 2
a71 3
import org.tigris.helm.domain.User;
import org.tigris.helm.domain.Role;
import org.tigris.helm.domain.Domain;
a72 2
public class ProjectMemberAdd extends org.tigris.helm.security.HelmServlet
{
d74 2
a75 2
        "$Id: ProjectMemberAdd.java,v 1.9 2000/12/23 00:48:19 dlr Exp $";
    private static Log log = new Log ("ProjectMemberAdd", "Project Member Add Servlet");
d84 1
a84 1
    protected String processRequest (Connection connection, WebContext context)
d87 1
a87 1
        if (debug) log.info ("ProjectMemberAdd: started!");
d89 1
a89 1
        String templateName = super.processRequest (connection, context);
d91 2
a92 2
        String action = (String) context.get ("action");
        if (debug) log.info ("ProjectMemberAdd: action=" + action);
d95 1
a95 1
        HttpServletRequest request = context.getRequest ();
d99 1
a99 1
        String[] selectedRoles = context.getFormList ("roles");
d103 2
a104 2
            Domain currentDomain = getCurrentDomain(context);
            User loginUser = getLoginUser(context);       
d106 1
a106 1
            Project project = getCurrentProject(context);
d109 2
a110 2
            acl.assertPermissionForProject(project.requiredRoleGrantAction(),
                                           project.getID());
d116 1
a116 1
                    appendToMessage(context, "Please select a role.");
d130 1
a130 2
                        users.add(User.getInstance(connection, dMgr,
                                                   tok.nextToken()));
d138 1
a138 1
                    log.info("Checking user " + user.getLoginID());
d142 2
a143 2
                        Role role = new Role(connection, dMgr,selectedRoles[j]);
                        log.info("Checking role " + role.getName());
d145 1
a145 1
                            log.info ("Grant to user=" + user.getLoginID() +
d151 10
a160 12
        } 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());
d162 2
a163 2
        
        if (debug) log.info ("ProjectMemberAdd:  done");
d171 1
@


1.11.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@d83 1
a83 1
        "$Id: ProjectMemberAdd.java,v 1.11 2001/01/26 18:29:05 edk Exp $";
@


1.11.2.2
log
@first compiled port to turbine of ProjectMemberAdd.java :jody
PR:
Obtained from:
Submitted by:
Reviewed by:
@
text
@d57 1
a57 1

d59 3
a61 4

import com.workingdogs.village.*;

import org.apache.turbine.util.Log; 
d67 1
d70 1
a70 1

d73 1
a73 2
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;
d76 4
d84 1
a84 1

d93 1
a93 1
    protected String processRequest (Connection conn, WebContext ctx)
d96 1
a96 1
        if (debug) Log.info ("ProjectMemberAdd: started!");
d98 1
a98 1
        String templateName = super.processRequest (conn, ctx);
d100 2
a101 2
        String action = (String) ctx.get ("action");
        if (debug) Log.info ("ProjectMemberAdd: action=" + action);
d104 1
a104 1
        HttpServletRequest request = ctx.getRequest ();
d108 1
a108 1
        String[] selectedRoles = ctx.getFormList ("roles");
d112 2
a113 2
            Domain currentDomain = getCurrentDomain(ctx);
            User loginUser = getLoginUser(ctx);       
d115 1
a115 1
            Project project = getCurrentProject(ctx);
d118 2
a119 2
            acl.assertPermission(project.requiredRoleGrantAction(),
                                           project);
d125 1
a125 1
                    appendToMessage(ctx, "Please select a role.");
d139 2
a140 3
		        //users.add(User.getInstance(conn, dMgr,
                        //                           tok.nextToken()));
			users.add((User)UserPeer.getInstance(tok.nextToken()));
d148 1
a148 1
                    Log.info("Checking user " + user.getLoginName());
d152 2
a153 3
			/*Role role = new Role(conn, dMgr,selectedRoles[j]);*/
                        Role role = (Role)RolePeer.getInstance(selectedRoles[j]);
                        Log.info("Checking role " + role.getName());
d155 1
a155 1
                            Log.info ("Grant to user=" + user.getLoginName() +
d161 12
a172 10
	} catch (DoesNotExist e) { 
            Log.error(e); 
            String message = "" + e.getMessage(); 
            if(debug) Log.info(message); 
            appendToMessage(ctx, message);             
        } catch (Exception e) { 
            Log.error(e); 
            String message = "" + e.getMessage(); 
            if(debug) Log.info(message); 
            appendToMessage(ctx, message);             
d174 2
a175 2
 
        if (debug) Log.info ("ProjectMemberAdd:  done");
a182 1

@


1.11.2.3
log
@cleanup
@
text
@d57 1
d59 1
a60 1
import org.apache.turbine.util.Log;
d62 3
d66 1
a67 1
import org.joist.security.*;
d69 2
d75 1
d77 1
a77 1
public class ProjectMemberAdd extends HelmServlet
a78 1

d80 1
a80 1
        "$Id: ProjectMemberAdd.java,v 1.11.2.2 2001/02/16 19:54:52 jody Exp $";
d93 1
a93 1
        if (debug) Log.debug ("ProjectMemberAdd: started!");
d98 1
a98 1
        if (debug) Log.debug ("ProjectMemberAdd: action=" + action);
d136 3
a138 1
			            users.add((User)UserPeer.getInstance(tok.nextToken()));
d146 1
a146 1
                    Log.debug("Checking user " + user.getLoginName());
d150 1
d152 1
a152 1
                        Log.debug("Checking role " + role.getName());
d154 1
a154 1
                            Log.debug ("Grant to user=" + user.getLoginName() +
d163 1
a163 1
            if(debug) Log.debug(message); 
d168 1
a168 1
            if(debug) Log.debug(message); 
d172 1
a172 1
        if (debug) Log.debug ("ProjectMemberAdd:  done");
@


1.10
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.9
log
@Removed unnecessary getCache() implementations in BusinessObject subclasses and migrated to a factory method for User's primary database key ctor.
@
text
@d83 1
a83 1
        "$Id: ProjectMemberAdd.java,v 1.8 2000/12/14 03:09:59 leonardr Exp $";
@


1.8
log
@Moved paginator stuff to its own directory.
@
text
@d83 1
a83 1
        "$Id: ProjectMemberAdd.java,v 1.7 2000/12/14 03:04:17 edk Exp $";
d139 2
a140 1
                        users.add(new User(connection, dMgr, tok.nextToken()));
@


1.7
log
@* adjust for corrections to Role constructor
* correct another Role constructor which listed the DataManager before
  the Connection
@
text
@d74 1
d83 1
a83 1
        "$Id: ProjectMemberAdd.java,v 1.6 2000/11/29 17:29:50 leonardr Exp $";
@


1.6
log
@First stab at role grant to uesr groups.
@
text
@d82 1
a82 1
        "$Id: ProjectMemberAdd.java,v 1.5 2000/11/27 18:17:45 leonardr Exp $";
d150 1
a150 1
                        Role role = new Role(dMgr, connection, selectedRoles[j]);
@


1.5
log
@More Paginator changes.
@
text
@a73 1
import org.tigris.helm.tool.UserPaginator;
d82 1
a82 1
        "$Id: ProjectMemberAdd.java,v 1.4 2000/11/27 16:23:04 leonardr Exp $";
a118 8
            
            // Get the list of all users in the domain.
            int nbrUsersPerPage =
                Integer.parseInt(myProperties.getProperty(USERS_PER_PAGE));
            context.put("userList",
                        UserPaginator.paginate(connection, dMgr, context,
                                               currentDomain));
            context.put("maxUsersPerPage", Integer.toString(nbrUsersPerPage));
@


1.4
log
@Added user search capabilities (swiped from Joist) to UserPaginator, an almost-drop-in replacement for Paginator. Changed servlets that were paginating users to use UserPaginator
@
text
@d83 1
a83 1
        "$Id: ProjectMemberAdd.java,v 1.3 2000/11/22 17:22:23 leonardr Exp $";
d126 1
a126 1
                                               currentDomain, nbrUsersPerPage));
@


1.3
log
@The app should now respect the Unapproved Project Role - Grant action properly.
@
text
@d74 1
a74 1
import org.tigris.helm.tool.Paginator;
d83 1
a83 1
        "$Id: ProjectMemberAdd.java,v 1.2 2000/11/21 17:46:42 leonardr Exp $";
a121 2
            List allUsers = currentDomain.getUsers();
            
d125 2
a126 1
                        Paginator.paginate(allUsers, nbrUsersPerPage, context));
@


1.2
log
@Only grant requestable roles--reasonable people may differ but I think this is the way to go.
@
text
@d70 3
d83 2
a84 2
        "$Id: ProjectMemberAdd.java,v 1.1.1.1 2000/11/12 21:16:10 dlr Exp $";
    private static Log log = new Log ("ProjectMemberAdd", "Tigris StartPage");
d92 1
a92 2
    
    
d116 5
a120 1
        
d130 1
a130 1
            if (action.equals ("Grant Roles"))
d169 12
a180 8
        }
        
        catch (Exception e)
        {
            log.exception (e);
            String message = "ProjectMemberAdd: " + e.getMessage ();
            if (debug) log.info (message);
            context.put ("message", message);
@


1.1
log
@Initial revision
@
text
@d80 1
a80 1
        "$Id: ProjectMemberAdd.java,v 1.17 2000/11/11 04:43:58 leonardr Exp $";
a114 4
            // Put list of all roles in the context
            List roles = currentDomain.getProjectRoles();
            context.put ("roles", roles);
            
@


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
@d57 1
d59 3
a61 2
import com.workingdogs.village.*;
import org.apache.turbine.util.Log;
d63 1
d65 1
d67 1
a67 1
import org.joist.security.*;
d69 7
d77 1
a77 5
import org.tigris.helm.*;
import org.tigris.helm.om.*;
import org.tigris.helm.om.peer.*;

public class ProjectMemberAdd extends HelmServlet
a78 1

d80 2
a81 2
        "$Id: ProjectMemberAdd.java,v 1.11.2.3 2001/02/17 00:15:41 elicia Exp $";

d89 3
a91 2
        
    protected String processRequest (Connection conn, WebContext ctx)
d94 1
a94 1
        if (debug) Log.debug ("ProjectMemberAdd: started!");
d96 1
a96 1
        String templateName = super.processRequest (conn, ctx);
d98 2
a99 2
        String action = (String) ctx.get ("action");
        if (debug) Log.debug ("ProjectMemberAdd: action=" + action);
d102 1
a102 1
        HttpServletRequest request = ctx.getRequest ();
d106 1
a106 1
        String[] selectedRoles = ctx.getFormList ("roles");
d110 2
a111 2
            Domain currentDomain = getCurrentDomain(ctx);
            User loginUser = getLoginUser(ctx);       
d113 14
a126 5
            Project project = getCurrentProject(ctx);

            //Make sure they can grant roles in this project.
            acl.assertPermission(project.requiredRoleGrantAction(),
                                           project);
d128 1
a128 1
            if (action != null && action.equals ("Grant Roles"))
d132 1
a132 1
                    appendToMessage(ctx, "Please select a role.");
d146 1
a146 1
			            users.add((User)UserPeer.getInstance(tok.nextToken()));
d154 1
a154 1
                    Log.debug("Checking user " + user.getLoginName());
d158 2
a159 2
                        Role role = (Role)RolePeer.getInstance(selectedRoles[j]);
                        Log.debug("Checking role " + role.getName());
d161 1
a161 1
                            Log.debug ("Grant to user=" + user.getLoginName() +
a166 10
	} catch (DoesNotExist e) { 
            Log.error(e); 
            String message = "" + e.getMessage(); 
            if(debug) Log.debug(message); 
            appendToMessage(ctx, message);             
        } catch (Exception e) { 
            Log.error(e); 
            String message = "" + e.getMessage(); 
            if(debug) Log.debug(message); 
            appendToMessage(ctx, message);             
d168 10
a177 2
 
        if (debug) Log.debug ("ProjectMemberAdd:  done");
a184 1

@

