head	1.19;
access;
symbols
	TIGRIS_0_9_2_4:1.16
	TIGRIS_0_9_2_3:1.16
	HELM_PEER_PORT_BRANCH:1.18.0.2
	TURBINE_PEER:1.18
	TIGRIS_0_9_2_1:1.18
	TIGRIS_0_9_2:1.16.0.2
	TIGRIS_0_9_0:1.14.0.2
	TIGRIS_0_8_4:1.9.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.19
date	2001.02.21.03.49.24;	author edk;	state dead;
branches;
next	1.18;

1.18
date	2001.01.26.18.29.05;	author edk;	state Exp;
branches
	1.18.2.1;
next	1.17;

1.17
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.16;

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

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

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

1.13
date	2000.12.14.03.09.59;	author leonardr;	state Exp;
branches;
next	1.12;

1.12
date	2000.12.14.03.04.17;	author edk;	state Exp;
branches;
next	1.11;

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

1.10
date	2000.12.05.00.29.19;	author elicia;	state Exp;
branches;
next	1.9;

1.9
date	2000.12.01.23.01.20;	author elicia;	state Exp;
branches
	1.9.2.1;
next	1.8;

1.8
date	2000.12.01.22.15.41;	author elicia;	state Exp;
branches;
next	1.7;

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

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

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

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

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

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

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

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

1.9.2.1
date	2000.12.05.06.34.17;	author jrobbins;	state Exp;
branches;
next	;

1.18.2.1
date	2001.01.28.01.02.18;	author dlr;	state dead;
branches;
next	;


desc
@@


1.19
log
@renamed to ProjectMemberList
@
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 org.webmacro.servlet.*;
import org.webmacro.util.*;
import java.util.List;

import com.workingdogs.village.*;

import java.util.Enumeration;
import java.util.Vector;
import java.util.StringTokenizer;
import java.sql.*;
import javax.servlet.http.*;

import org.joist.database.*;

import org.tigris.helm.security.*;

import org.tigris.helm.domain.User;
import org.tigris.helm.domain.Role;
import org.tigris.helm.project.Project;
import org.tigris.helm.database.*;
import org.tigris.helm.tool.*;
import org.tigris.helm.tool.paginate.*;

import org.joist.security.RedirectException;
import org.joist.mail.Emailer;

/**
 * Display a summary of users who belong to this project.
 */
public class ProjectMembers extends org.tigris.helm.security.HelmServlet
{
    static private Log log = new Log ("prjMbs", "ProjectMembers");
    static private boolean debug = true;
    private static final String USERS_PER_PAGE = "nbrUsersPerPage";
    
    protected String processRequest (Connection connection, WebContext context)
        throws HandlerException, RedirectException
    {
        String templateName = super.processRequest (connection, context);
        Project currentProject = getCurrentProject(context);
        
        Enumeration paramNames = context.getRequest().getParameterNames ();
        String paramName;
        Vector newSet = new Vector (50);

        String action = getAction(context);
        if (debug) log.info("action = " + action);

        try
        {        
            AccessControlList acl = getLoginUser(context).getACL();

            if (action.equals ("Revoke Checked Roles"))
            {
                while (paramNames.hasMoreElements ())
                {
                    paramName = (String) paramNames.nextElement ();
                    if (paramName.startsWith ("Revoke"))
                        newSet.addElement (paramName);
                }
                if (debug) log.info ("checked: " + newSet.toString ());
                
                for (int i = 0; i < newSet.size (); i++)
                {
                    String element = (String)newSet.elementAt(i);
                    StringTokenizer tok = new StringTokenizer (element);
                    tok.nextToken();
                    User user = User.getInstance(connection, dMgr,
                                                 tok.nextToken());
                    Role role = new Role(connection, dMgr, tok.nextToken());
                    user.revokeRole(acl, role, currentProject);
                }
            
            } else if (action.equals ("Edit Roles")) {
            
                Vector values = new Vector ();
            
                while (paramNames.hasMoreElements ())
                {
                    paramName = (String) paramNames.nextElement ();
                    if (paramName.startsWith ("Pending"))
                    {
                        newSet.addElement (paramName);
                        values.addElement (context.getForm (paramName));
                    }
                }

                if (debug) log.info ("checked: " + newSet.toString ());
            
                Emailer emailer = new Emailer();
            
                for (int i = 0; i < newSet.size (); i++)
                {
                
                    String element = (String) newSet.elementAt (i);
                    StringTokenizer tok = new StringTokenizer (element);
                    tok.nextToken();
                    String userID = tok.nextToken();
                    User user = User.getInstance(connection, dMgr, userID);
                    String roleID = tok.nextToken();
                    Role role = new Role(connection, dMgr, roleID);
                    String value = (String) values.elementAt (i);                
                
                    if (debug)
                        log.info (value + " role " + role.getName() 
                                  + " for  user " + user.getName());
                
                    String subject;
                    String message;
                    StringBuffer messageBuf =
                        new StringBuffer ("You requested the role of ");
                    messageBuf.append (role.getName()).append (" on project '").
                        append (currentProject.getName()).append ("'. ");

                    if (value.equals ("Approve"))
                    {
                        user.grantRole(acl, role, currentProject);
                        subject = "Requested role has been granted";
                        messageBuf.append 
                            ("Congratulations! The role has been granted.");
                        message = messageBuf.toString();
                        emailer.sendEmail(user.getEmail(), subject, message);

                    } else if (value.equals ("Disapprove")) {
                        user.revokeRole(acl, role, currentProject);
                        subject = "Requested role has not been granted";
                        messageBuf.append
                            ("We regret to inform you that the role has not been granted.");
                        message = messageBuf.toString();
                        emailer.sendEmail(user.getEmail(), subject, message);
                    }
                }
            }

        } catch (Exception e) {
            log.exception (e);
            String message = "ProjectMembers: " + e.getMessage ();
            if (debug) log.info (message);
            context.put ("message", message);
        }
        
        return templateName;
    }
    
} /* end class ProjectMembers */
@


1.18
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@@


1.18.2.1
log
@Porting to the Turbine Peer system.  -dlr and leonardr
@
text
@@


1.17
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.16
log
@First use of PaginatablePrebuiltList
@
text
@@


1.15
log
@Removed unnecessary getCache() implementations in BusinessObject subclasses and migrated to a factory method for User's primary database key ctor.
@
text
@a182 12
            List userList = currentProject.getUsers();
            log.info("userList=" + userList);
            // Pagination 
            if (userList.size() > 0)
            {
                int nbrUsersPerPage =
                    Integer.parseInt(myProperties.getProperty(USERS_PER_PAGE));
                context.put
                    ("users", Paginator.paginate
                     (userList, nbrUsersPerPage, context));
            }
            
@


1.14
log
@How about putting the users in the context after deleting some of them.
@
text
@d116 2
a117 1
                    User user = new User(connection, dMgr, tok.nextToken());
d147 1
a147 1
                    User user = new User(connection, dMgr, userID);
@


1.13
log
@Moved paginator stuff to its own directory.
@
text
@d17 1
a17 1
 * software developed by CollabNet (http://www.Collab.Net/)."
d32 1
a32 1
 * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
a100 12
            List userList = currentProject.getUsers();
            log.info("userList=" + userList);
 
            // Pagination 
            if (userList.size() > 0)
            {
              int nbrUsersPerPage =
                 Integer.parseInt(myProperties.getProperty(USERS_PER_PAGE));
              context.put("users",
                 Paginator.paginate(userList, nbrUsersPerPage, context));
            }

d121 1
a121 1
        } else if (action.equals ("Edit Roles")) {
d123 1
a123 1
            Vector values = new Vector ();
d125 1
a125 4
            while (paramNames.hasMoreElements ())
            {
                paramName = (String) paramNames.nextElement ();
                if (paramName.startsWith ("Pending"))
d127 6
a132 2
                    newSet.addElement (paramName);
                    values.addElement (context.getForm (paramName));
a133 1
            }
d135 1
a135 1
            if (debug) log.info ("checked: " + newSet.toString ());
d137 1
a137 1
            Emailer emailer = new Emailer();
d139 2
a140 2
            for (int i = 0; i < newSet.size (); i++)
            {
d142 8
a149 8
                String element = (String) newSet.elementAt (i);
                StringTokenizer tok = new StringTokenizer (element);
                tok.nextToken();
                String userID = tok.nextToken();
                User user = new User(connection, dMgr, userID);
                String roleID = tok.nextToken();
                Role role = new Role(connection, dMgr, roleID);
                String value = (String) values.elementAt (i);                
d151 3
a153 3
                if (debug)
                    log.info (value + " role " + role.getName() 
                              + " for  user " + user.getName());
d155 26
a180 6
                String subject;
                String message;
                StringBuffer messageBuf =
                    new StringBuffer ("You requested the role of ");
                messageBuf.append (role.getName()).append (" on project '").
                    append (currentProject.getName()).append ("'. ");
d182 10
a191 17
                if (value.equals ("Approve"))
                {
                    user.grantRole(acl, role, currentProject);
                    subject = "Requested role has been granted";
                    messageBuf.append 
                        ("Congratulations! The role has been granted.");
                    message = messageBuf.toString();
                    emailer.sendEmail(user.getEmail(), subject, message);

                } else if (value.equals ("Disapprove")) {
                    user.revokeRole(acl, role, currentProject);
                    subject = "Requested role has not been granted";
                    messageBuf.append
                        ("We regret to inform you that the role has not been granted.");
                    message = messageBuf.toString();
                    emailer.sendEmail(user.getEmail(), subject, message);
                }
d193 6
d200 2
a201 5
    } catch (Exception e) {
        log.exception (e);
        String message = "ProjectMembers: " + e.getMessage ();
        if (debug) log.info (message);
        context.put ("message", message);
a203 3
    return templateName;
  }

@


1.12
log
@* adjust for corrections to Role constructor
* correct another Role constructor which listed the DataManager before
  the Connection
@
text
@d70 1
@


1.11
log
@Added support for resigning your own roles.
@
text
@d128 1
a128 1
                    Role role = new Role(dMgr, connection, tok.nextToken());
d159 1
a159 1
                Role role = new Role(dMgr, connection, roleID);
@


1.10
log
@added pagination
@
text
@d129 1
a129 1
                    user.revokeRole(acl, user, role, currentProject);
d183 1
a183 1
                    user.revokeRole(acl, user, role, currentProject);
@


1.9
log
@now sending email to users whose roles have been granted or rejected.
@
text
@d51 1
a51 2

//import java.util.*;
d69 1
d81 1
d87 1
d99 12
a110 1
            Project currentProject = getCurrentProject(context);
@


1.9.2.1
log
@merged in changes from HEAD
@
text
@d51 2
a52 1
import java.util.List;
a69 1
import org.tigris.helm.tool.*;
a80 1
    private static final String USERS_PER_PAGE = "nbrUsersPerPage";
a85 1
        Project currentProject = getCurrentProject(context);
d97 1
a97 12

            List userList = currentProject.getUsers();
            log.info("userList=" + userList);
 
            // Pagination 
            if (userList.size() > 0)
            {
              int nbrUsersPerPage =
                 Integer.parseInt(myProperties.getProperty(USERS_PER_PAGE));
              context.put("users",
                 Paginator.paginate(userList, nbrUsersPerPage, context));
            }
@


1.8
log
@user whose role was being revoked was missing from the method call to User.revokeRole
@
text
@d167 1
a167 1
                    //emailer.sendEmail(user.getEmail(), subject, message);
d175 1
a175 1
                    //emailer.sendEmail(user.getEmail(), subject, message);
@


1.7
log
@Changed action to sync w/ template.
@
text
@d92 1
d116 1
a116 1
                    user.revokeRole(acl, role, currentProject);
d168 1
d170 1
a170 1
                    user.revokeRole(acl, role, currentProject);
@


1.6
log
@Cop out of grantRole if they *don't* already have the role, not if they *do*
@
text
@d118 1
a118 1
        } else if (action.equals ("Perform Actions")) {
@


1.5
log
@Oops, other commit broke build.
@
text
@d142 4
a145 2
                User user = new User(connection, dMgr, tok.nextToken());
                Role role = new Role(dMgr, connection, tok.nextToken());
d148 4
a151 3
                if (debug) 
                    log.info (value + " role " + role + " for  user " + user);

@


1.4
log
@Don't put www in public projects group
@
text
@d115 1
a115 1
                    user.revoke(acl, role, currentProject);
@


1.3
log
@Cleanup.
@
text
@a76 1

d79 18
a96 20
  static private Log log = new Log ("prjMbs", "ProjectMembers");
  static private boolean debug = true;

  protected String processRequest (Connection connection, WebContext context)
    throws HandlerException, RedirectException
  {
    String templateName = super.processRequest (connection, context);

    Enumeration paramNames = context.getRequest().getParameterNames ();
    String paramName;
    Vector newSet = new Vector (50);

    UserRoleProjectManager urpMgr = (UserRoleProjectManager)
      dMgr.getManager ("org.tigris.helm.database.UserRoleProjectManager");
    ProjectManager pMgr = (ProjectManager)
      dMgr.getManager ("org.tigris.helm.database.ProjectManager");
    UserManager uMgr = (UserManager)
      dMgr.getManager ("org.joist.database.UserManager");
    RoleManager rMgr = (RoleManager)
      dMgr.getManager ("org.joist.database.RoleManager");
d98 1
a98 18
    String action = (String) context.get ("action");

    try
    {        
        AccessControlList acl = getLoginUser(context).getACL();
        Project currentProject = getCurrentProject(context);

        if (action.equals ("Revoke Checked Roles"))
        {
            while (paramNames.hasMoreElements ())
            {
                paramName = (String) paramNames.nextElement ();
                if (paramName.startsWith ("Revoke"))
                    newSet.addElement (paramName);
            }
            if (debug) log.info ("checked: " + newSet.toString ());
            
            for (int i = 0; i < newSet.size (); i++)
d100 17
a116 7
                String element = (String) newSet.elementAt (i);
                StringTokenizer tok = new StringTokenizer (element);
                tok.nextToken ();
                String user = tok.nextToken ();
                String role = tok.nextToken ();
                urpMgr.revoke (connection, user, role, currentProject.getID ());
            }
@


1.2
log
@Modernized ProjectMembers.
@
text
@d105 1
a105 1
        String loginUserID = getLoginUser(context).getUserID();
a106 1
        AccessControlList acl = getACL(context, connection, loginUserID);
@


1.1
log
@Initial revision
@
text
@d62 3
a64 2
import org.tigris.helm.security.HelmServlet;
import org.tigris.helm.security.AccessControlList;
d67 3
a69 7
import org.tigris.helm.domain.User;
import org.tigris.helm.database.UserRoleProjectManager;

import org.joist.database.RoleManager;
import org.joist.database.DataManager;
import org.joist.database.UserManager;
import org.tigris.helm.database.ProjectManager;
d87 2
a88 3
    Project project = (Project) context.get ("currentProject");
    HttpServletRequest request = context.getRequest ();
    Enumeration paramNames = request.getParameterNames ();
d103 87
a189 99
      try
    {

      String loginUserID = super.getLoginUser (context).getUserID ();
      if (debug)
	  log.debug ("loginID=" + loginUserID);

      if (action.equals ("Revoke Checked Roles"))
      {
	while (paramNames.hasMoreElements ())
	{
	  paramName = (String) paramNames.nextElement ();
	  if (paramName.startsWith ("Revoke"))
	    newSet.addElement (paramName);
	}
	if (debug)
	    log.debug ("checked: " + newSet.toString ());

	for (int i = 0; i < newSet.size (); i++)
	{
	  String element = (String) newSet.elementAt (i);
	  StringTokenizer tok = new StringTokenizer (element);
	    tok.nextToken ();
	  String user = tok.nextToken ();
	  String role = tok.nextToken ();
	    urpMgr.revoke (connection, user, role, project.getID ());
	}

      }
      else if (action.equals ("Perform Actions"))
      {

	Vector values = new Vector ();

	while (paramNames.hasMoreElements ())
	{
	  paramName = (String) paramNames.nextElement ();
	  if (paramName.startsWith ("Pending"))
	  {
	    newSet.addElement (paramName);
	    values.addElement (context.getForm (paramName));
	  }
	}
	if (debug)
	  log.debug ("checked: " + newSet.toString ());

	Emailer emailer = new Emailer ();

	for (int i = 0; i < newSet.size (); i++)
	{
	  String element = (String) newSet.elementAt (i);
	  StringTokenizer tok = new StringTokenizer (element);
	  tok.nextToken ();
	  String user = tok.nextToken ();
	  String role = tok.nextToken ();
	  String value = (String) values.elementAt (i);
	  String email = uMgr.getUserEmail (connection, user);
	  String roleName = rMgr.getRoleName (connection, role);
	  String projectName =
	    pMgr.getProjectName (connection, project.getID ());
	  StringBuffer messageBuf =
	    new StringBuffer ("You requested the role of ");
	  messageBuf.append (roleName).append (" on project '").
	    append (projectName).append ("'. ");
	  String subject;
	  String message;

	  if (debug)
	    log.debug (value + " role " + role + " for  user " + user);

	  if (value.equals ("Approve"))
	  {
	    urpMgr.updateField (connection, project.getID (),
				user, role, "approved_by", loginUserID);
	    subject = "Requested role has been granted";
	    messageBuf.append ("Congratulations! The role has been granted.");
	    message = messageBuf.toString ();
	    //emailer.sendEmail(email, subject, message);
	  }
	  else if (value.equals ("Disapprove"))
	  {
	    urpMgr.revoke (connection, user, role, project.getID ());
	    subject = "Requested role has not been granted";
	    messageBuf.
	      append
	      ("We regret to inform you that the role has not been granted.");
	    message = messageBuf.toString ();
	    //emailer.sendEmail(email, subject, message);
	  }
	}
      }
    }
    catch (Exception e)
    {
      log.exception (e);
      String message = "ProjectMembers: " + e.getMessage ();
      if (debug)
	log.debug (message);
      context.put ("message", message);
d191 1
a191 1

d195 1
a195 1
}				/* end class ProjectMembers */
@


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