head	1.25;
access;
symbols
	TIGRIS_0_9_2_4:1.19.2.1
	TIGRIS_0_9_2_3:1.19.2.1
	HELM_PEER_PORT_BRANCH:1.23.0.2
	TURBINE_PEER:1.23
	TIGRIS_0_9_2_1:1.23
	TIGRIS_0_9_2:1.19.0.2
	TIGRIS_0_9_0:1.15.0.2
	TIGRIS_0_8_4:1.13.0.2;
locks; strict;
comment	@# @;


1.25
date	2001.02.21.02.19.01;	author dlr;	state dead;
branches;
next	1.24;

1.24
date	2001.01.30.18.04.20;	author leonardr;	state Exp;
branches;
next	1.23;

1.23
date	2001.01.26.18.29.02;	author edk;	state Exp;
branches
	1.23.2.1;
next	1.22;

1.22
date	2001.01.26.05.24.06;	author edk;	state dead;
branches;
next	1.21;

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

1.20
date	2001.01.24.21.41.49;	author leonardr;	state Exp;
branches;
next	1.19;

1.19
date	2001.01.05.21.42.38;	author leonardr;	state Exp;
branches
	1.19.2.1;
next	1.18;

1.18
date	2001.01.05.00.13.13;	author kmaples;	state Exp;
branches;
next	1.17;

1.17
date	2000.12.23.00.48.18;	author dlr;	state Exp;
branches;
next	1.16;

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

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

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

1.13
date	2000.11.30.23.56.41;	author leonardr;	state Exp;
branches
	1.13.2.1;
next	1.12;

1.12
date	2000.11.29.01.16.32;	author leonardr;	state Exp;
branches;
next	1.11;

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

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

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

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

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

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

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

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

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

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

1.1
date	2000.11.20.21.43.16;	author leonardr;	state Exp;
branches;
next	;

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

1.19.2.1
date	2001.01.31.03.55.31;	author leonardr;	state Exp;
branches;
next	;

1.23.2.1
date	2001.01.28.01.02.17;	author dlr;	state dead;
branches;
next	;


desc
@@


1.25
log
@Moved to om package by Peer port.
@
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 Collab.Net (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 Collab.Net.
 * 
 * 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 COLLAB.NET 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.webmacro.util.*;
import org.webmacro.servlet.*;

import com.workingdogs.village.*;

import org.joist.database.JoistDatabaseException;
import org.joist.database.DataManager;
import org.joist.database.UserManager;

import org.tigris.helm.DoesNotExist;
import org.tigris.helm.AlreadyExists;
import org.tigris.helm.security.AccessControlList;
import org.tigris.helm.security.ACLException;
import org.tigris.helm.database.*;
import org.tigris.helm.domain.User;
import org.tigris.helm.tool.IssueTrackingAccountDescriptor;
import org.tigris.helm.project.Project;

public class UserGroup extends User
{
    private static Log log = new Log("userGrp", "UserGroup");

    ////////////////////////////////////////////////////////////////////
    // Constructors.
    ////////////////////////////////////////////////////////////////////

    public UserGroup(Connection c, DataManager dMgr, Record r)
        throws DoesNotExist, DataSetException
    {
        super(c, dMgr, r);
    }

    public UserGroup(User u)
        throws DoesNotExist, DataSetException
    {
        super(u.conn, u.dMgr, u.rec);
    }
    
    public UserGroup(Connection c, DataManager dMgr, String uID)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        super(c, dMgr, uID);
    }

    public UserGroup(Connection c, DataManager dMgr, String domainID,
                     String name)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        super(c, dMgr, domainID, name);
    }

    public UserGroup(Connection c, DataManager dMgr, 
                     AccessControlList acl, WebContext context,
                     String domainID, String name, String description, 
                     ArrayList members)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist, AlreadyExists, ACLException
    {
        super(c, dMgr);
        acl.assertPermissionForDomain("UserGroup - Add", domainID);
        Integer userID = uMgr.addUser(conn, context, description, name, 
                                      "");
        PreparedStatement stmt = null;
        try
        {
            stmt = conn.prepareStatement
                ("update User set domainID=?, type='group' where userID=?");
            stmt.setInt(1, Integer.parseInt(domainID));
            stmt.setInt(2, userID.intValue());
            stmt.executeUpdate();
        } finally {
            if (stmt != null) stmt.close();
        }
        setRecord(uMgr.getUser(conn, userID.toString()));
        
        //Add the group to the group of all users in the domain. (?)
        usrGrpMgr.addUserToDomainGroup(conn, getID(), domainID);
        
        //Add the initial members to the group.
        if (members != null)
        {
            for (Iterator i = members.iterator(); i.hasNext();)
            {
                User u = (User)i.next();
                addUser(acl, u);
            }        
        }
    }


    ////////////////////////////////////////////////////////////////////
    // Static methods for obtaining special groups.
    ////////////////////////////////////////////////////////////////////
    
    public static UserGroup getDomainUserGroup(Connection conn,
                                               DataManager dMgr,
                                               String domainID)
        throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
    {
        UserUserGroupManager usrGrpMgr = (UserUserGroupManager) dMgr.getManager
            ("org.tigris.helm.database.UserUserGroupManager");

        String domainUserID = usrGrpMgr
            .getUserIDForDomainUserGroup(conn, domainID);
        return new UserGroup(conn, dMgr, domainUserID);
    }

    ////////////////////////////////////////////////////////////////////
    // Read-write methods.
    ////////////////////////////////////////////////////////////////////

    public void addUser(AccessControlList acl, User user)
        throws SQLException, DataSetException, JoistDatabaseException,
               ACLException, DoesNotExist
    {
        acl.assertPermissionForDomain("UserGroup Member - Add", getDomainID());
        addUserBypassingPermissions(user);
    }

    public static void addUserToDomainUserGroup
        (Connection conn, DataManager dMgr, String domainID, User user)
        throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
    {
        getDomainUserGroup(conn, dMgr, domainID)
            .addUserBypassingPermissions(user);
    }

    private void addUserBypassingPermissions(User user)
        throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
    {
        IssueTrackingAccountDescriptor before = getDescriptorForUser(user);

        usrGrpMgr.addUserToGroup(conn, user.getID(), getID());

        AccessControlList.buildUserGroups(conn, dMgr);
        AccessControlList.rebuildACL(conn, dMgr, user.getID());               
        IssueTrackingAccountDescriptor after = getDescriptorForUser(user);
        before.syncTo(conn, dMgr, after);
    }

    public void removeUser(AccessControlList acl, User user)
        throws SQLException, DataSetException, JoistDatabaseException,
               ACLException, DoesNotExist
    {
        log.info("Removing user " + user.getName());
        acl.assertPermissionForDomain
            ("UserGroup Member - Delete", getDomainID());
        IssueTrackingAccountDescriptor before = getDescriptorForUser(user);

        usrGrpMgr.removeUserFromGroup(conn, user.getID(), getID());
        AccessControlList.buildUserGroups(conn, dMgr);        

        //Invalidate the removed user's ACL, and run scripts.
        AccessControlList.rebuildACL(conn, dMgr, user.getID());
        IssueTrackingAccountDescriptor after = getDescriptorForUser(user);
        before.syncTo(conn, dMgr, after, acl.getUser());

    }            

    public void updateInfo(AccessControlList acl, String description, 
                           WebContext context)
        throws ACLException, DataSetException, SQLException,
               JoistDatabaseException
    {
        acl.assertPermissionForDomain("UserGroup - Edit", getDomainID());
        uMgr.updateUser(conn, context, getID(), getLoginID(), getEmail(),
                        description, null);
        try 
        {
            setRecord(uMgr.getUser(conn, getID()));
        } catch (DoesNotExist ignore) {} //Can't happen--we just used it.    
    }

    /**
     * Totally deletes a user group.
     */
    public void delete(AccessControlList acl)
        throws DataSetException, SQLException, JoistDatabaseException, 
               ACLException, DoesNotExist
    {
        acl.assertPermissionForDomain("UserGroup - Delete", getDomainID());

        UserRoleProjectManager urpMgr = (UserRoleProjectManager) 
            dMgr.getManager("org.tigris.helm.database.UserRoleProjectManager");

        List users = getUsers();
        //Remove all users from this group.
        for (Iterator i = users.iterator(); i.hasNext();)
        {
            removeUser(acl, (User)i.next());
        }

        //Revoke all the group's roles.
        urpMgr.deleteRolesForUser(conn, getID());
        
        //Remove the group proper.
        uMgr.deleteUser(conn, getID());
    }

    /**
     * Returns an IssueTrackingAccountDescriptor describing the
     * current state of the given user as regards the projects in
     * which this user group has a role.
     */
    public IssueTrackingAccountDescriptor getDescriptorForUser(User baseUser)
        throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
    {
        List projectList = new ArrayList();
        //All projects this usergroup has a role in are affected
        DataSet projects = urpMgr.getProjectsForUser(conn, getID(), false);
        for (int i = 0; i < projects.size(); i++)
        {
            Project project = new Project(conn, dMgr, projects.getRecord(i));
            projectList.add(project);
        }

        return new IssueTrackingAccountDescriptor(projectList, baseUser);
    }

    ////////////////////////////////////////////////////////////////////
    // Read-only methods.
    ////////////////////////////////////////////////////////////////////
    
    public List getUsers()
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        ArrayList users = new ArrayList();
        DataSet userSet = usrGrpMgr.getUsersForGroup(conn, getID());
        
        for (int i = 0; i < userSet.size(); i++)
        {
            String userID = userSet.getRecord(i).getValue(UserUserGroupManager.USER_ID).asString();
            users.add(new User(conn, dMgr, userID));
        }
        Collections.sort(users);
        return users;
    }
    
    public List expand()
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
	return getUsers();
    }

    public int getNumberOfUsers(AccessControlList acl)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
    {
        return getUsers().size();
    }

    public String getName() throws DataSetException
    {
        return getLoginID();
    }

    public String getDescription() throws DataSetException
    {
        return super.getName();
    }
    
}



@


1.24
log
@Consider roles obtained in project groups when seeing which projects to check.
@
text
@@


1.23
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d267 1
a267 1
        DataSet projects = urpMgr.getProjectsForUser(conn, getID());
@


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


1.22
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
@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
d59 1
a59 2
import org.tigris.helm.database.UserManager;
import org.tigris.helm.database.RoleManager;
d78 1
a78 1
    public UserGroup(DataManager dMgr, Record r)
d81 1
a81 1
        super(dMgr, r);
d87 1
a87 1
        this(u.dMgr, u.rec);
d90 3
a92 2
    public UserGroup(DataManager dMgr, String uID)
        throws DoesNotExist, DBException
d94 1
a94 1
        super(dMgr, uID);
d97 4
a100 2
    public UserGroup(DataManager dMgr, String domainID, String name)
        throws DoesNotExist, DBException
d102 1
a102 1
        super(dMgr, domainID, name);
d105 6
a110 4
    public UserGroup(DataManager dMgr, AccessControlList acl,
                     WebContext context, String domainID, String name,
                     String description, ArrayList members)
        throws ACLException, DoesNotExist, AlreadyExists, DBException
d112 1
a112 1
        super(dMgr);
d114 2
a115 1
        Integer userID = uMgr.addUser(context, description, name, "");
d127 1
a127 1
        setRecord(uMgr.getUser(userID.toString()));
d130 1
a130 1
        usrGrpMgr.addUserToDomainGroup(getID(), domainID);
d148 2
a149 1
    public static UserGroup getDomainUserGroup(DataManager dMgr,
d151 2
a152 1
        throws DoesNotExist, DBException
d157 3
a159 2
        String domainUserID = usrGrpMgr.getUserIDForDomainUserGroup(domainID);
        return new UserGroup(dMgr, domainUserID);
d167 2
a168 1
        throws ACLException, DoesNotExist, DBException
d174 4
a177 3
    public static void addUserToDomainUserGroup(DataManager dMgr,
                                                String domainID, User user)
        throws DoesNotExist, DBException
d179 2
a180 1
        getDomainUserGroup(dMgr, domainID).addUserBypassingPermissions(user);
d184 2
a185 1
        throws DoesNotExist, DBException
d189 1
a189 1
        usrGrpMgr.addUserToGroup(user.getID(), getID());
d191 2
a192 2
        AccessControlList.buildUserGroups(dMgr);
        AccessControlList.rebuildACL(dMgr, user.getID());               
d194 1
a194 1
        before.syncTo(dMgr, after);
d198 2
a199 1
        throws ACLException, DoesNotExist, DBLException
d206 2
a207 2
        usrGrpMgr.removeUserFromGroup(user.getID(), getID());
        AccessControlList.buildUserGroups(dMgr);        
d210 1
a210 1
        AccessControlList.rebuildACL(dMgr, user.getID());
d212 1
a212 1
        before.syncTo(dMgr, after, acl.getUser());
d218 2
a219 1
        throws ACLException, DBException
d222 1
a222 1
        uMgr.updateUser(context, getID(), getLoginID(), getEmail(),
d226 1
a226 1
            setRecord(uMgr.getUser(getID()));
d234 2
a235 1
        throws ACLException, DoesNotExist, DBException
d250 1
a250 1
        urpMgr.deleteRolesForUser(getID());
d253 1
a253 1
        uMgr.deleteUser(getID());
d262 2
a263 1
        throws DoesNotExist, DBException
d267 1
a267 1
        DataSet projects = urpMgr.getProjectsForUser(getID());
d270 1
a270 1
            Project project = new Project(dMgr, projects.getRecord(i));
d282 2
a283 1
        throws DoesNotExist, DBException
d286 1
a286 1
        DataSet userSet = usrGrpMgr.getUsersForGroup(getID());
d290 2
a291 3
            String userID = userSet.getRecord(i)
                .getValue(UserUserGroupManager.USER_ID).asString();
            users.add(new User(dMgr, userID));
d298 2
a299 1
        throws DoesNotExist, DBException
d305 2
a306 1
        throws DoesNotExist, DBException
d311 1
a311 1
    public String getName() throws DBException
d316 1
a316 1
    public String getDescription() throws DBException
d320 1
d322 3
@


1.21
log
@* Removed references to JDBC connections.  Connections are now pulled
  directly from the connection pool.
* Made use of DBException.
- dlr@@collab.net
@
text
@@


1.20
log
@Ported UserManager and RoleManager to Helm. Started moving other TableManagers toward a grab-connection-on-demand model. Massive breakage ensues. dlr and I are working on it.
@
text
@d79 1
a79 1
    public UserGroup(Connection c, DataManager dMgr, Record r)
d82 1
a82 1
        super(c, dMgr, r);
d88 1
a88 1
        super(u.conn, u.dMgr, u.rec);
d91 2
a92 3
    public UserGroup(Connection c, DataManager dMgr, String uID)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
d94 1
a94 1
        super(c, dMgr, uID);
d97 2
a98 4
    public UserGroup(Connection c, DataManager dMgr, String domainID,
                     String name)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
d100 1
a100 1
        super(c, dMgr, domainID, name);
d103 4
a106 6
    public UserGroup(Connection c, DataManager dMgr, 
                     AccessControlList acl, WebContext context,
                     String domainID, String name, String description, 
                     ArrayList members)
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist, AlreadyExists, ACLException
d108 1
a108 1
        super(c, dMgr);
d110 1
a110 2
        Integer userID = uMgr.addUser(conn, context, description, name, 
                                      "");
d122 1
a122 1
        setRecord(uMgr.getUser(conn, userID.toString()));
d125 1
a125 1
        usrGrpMgr.addUserToDomainGroup(conn, getID(), domainID);
d143 1
a143 2
    public static UserGroup getDomainUserGroup(Connection conn,
                                               DataManager dMgr,
d145 1
a145 2
        throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
d150 2
a151 3
        String domainUserID = usrGrpMgr
            .getUserIDForDomainUserGroup(conn, domainID);
        return new UserGroup(conn, dMgr, domainUserID);
d159 1
a159 2
        throws SQLException, DataSetException, JoistDatabaseException,
               ACLException, DoesNotExist
d165 3
a167 4
    public static void addUserToDomainUserGroup
        (Connection conn, DataManager dMgr, String domainID, User user)
        throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
d169 1
a169 2
        getDomainUserGroup(conn, dMgr, domainID)
            .addUserBypassingPermissions(user);
d173 1
a173 2
        throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
d177 1
a177 1
        usrGrpMgr.addUserToGroup(conn, user.getID(), getID());
d179 2
a180 2
        AccessControlList.buildUserGroups(conn, dMgr);
        AccessControlList.rebuildACL(conn, dMgr, user.getID());               
d182 1
a182 1
        before.syncTo(conn, dMgr, after);
d186 1
a186 2
        throws SQLException, DataSetException, JoistDatabaseException,
               ACLException, DoesNotExist
d193 2
a194 2
        usrGrpMgr.removeUserFromGroup(conn, user.getID(), getID());
        AccessControlList.buildUserGroups(conn, dMgr);        
d197 1
a197 1
        AccessControlList.rebuildACL(conn, dMgr, user.getID());
d199 1
a199 1
        before.syncTo(conn, dMgr, after, acl.getUser(connection));
d205 1
a205 2
        throws ACLException, DataSetException, SQLException,
               JoistDatabaseException
d208 1
a208 1
        uMgr.updateUser(conn, context, getID(), getLoginID(), getEmail(),
d212 1
a212 1
            setRecord(uMgr.getUser(conn, getID()));
d220 1
a220 2
        throws DataSetException, SQLException, JoistDatabaseException, 
               ACLException, DoesNotExist
d235 1
a235 1
        urpMgr.deleteRolesForUser(conn, getID());
d238 1
a238 1
        uMgr.deleteUser(conn, getID());
d247 1
a247 2
        throws SQLException, DataSetException, JoistDatabaseException,
               DoesNotExist
d251 1
a251 1
        DataSet projects = urpMgr.getProjectsForUser(conn, getID());
d254 1
a254 1
            Project project = new Project(conn, dMgr, projects.getRecord(i));
d266 1
a266 2
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
d269 1
a269 1
        DataSet userSet = usrGrpMgr.getUsersForGroup(conn, getID());
d273 3
a275 2
            String userID = userSet.getRecord(i).getValue(UserUserGroupManager.USER_ID).asString();
            users.add(new User(conn, dMgr, userID));
d282 1
a282 2
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
d288 1
a288 2
        throws DataSetException, SQLException, JoistDatabaseException,
               DoesNotExist
d293 1
a293 1
    public String getName() throws DataSetException
d298 1
a298 1
    public String getDescription() throws DataSetException
a301 1
    
a302 3



@


1.19
log
@Big patch bringing the smart script runner online.
@
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
d59 2
a60 1
import org.joist.database.UserManager;
d213 1
a213 1
        before.syncTo(conn, dMgr, after, acl.getUser());
@


1.19.2.1
log
@Ported in changes that cause new users to be properly added to Issuezilla when user groups have IZ roles in project groups.
@
text
@d267 1
a267 1
        DataSet projects = urpMgr.getProjectsForUser(conn, getID(), false);
@


1.18
log
@Big patch implementing a pilot test of the smart 'determine which scripts to run' system.
@
text
@d67 1
a67 1
import org.tigris.helm.tool.TigrisUpdate;
d187 2
d192 3
a194 24
        AccessControlList.rebuildACL(conn, dMgr, user.getID());
        
        ArrayList affectedUsers = new ArrayList();
        ArrayList affectedProjects = new ArrayList();
        
        UserManager uMgr = (UserManager)
            dMgr.getManager("org.joist.database.UserManager");
        UserRoleProjectManager urpMgr = (UserRoleProjectManager)
            dMgr.getManager("org.tigris.helm.database.UserRoleProjectManager");
        
        //All projects this usergroup has a role in are affected
        DataSet projects = urpMgr.getProjectsForUser(conn, getID());
        String domainName = null;
        for (int i = 0; i < projects.size(); i++)
        {
            Project project = new Project 
                (conn, dMgr, projects.getRecord(i));
            affectedProjects.add(project);
        }
        
        //Only one user -- the new one -- is affected by this change.
        affectedUsers.add(user);
        TigrisUpdate.findNewMembers
            (conn, dMgr, null, affectedUsers, affectedProjects);
d202 4
a205 1
        acl.assertPermissionForDomain("UserGroup Member - Delete", getDomainID());
d208 2
a209 1
        //Invalidate the removed user's ACL.
d211 3
a213 1
        runScriptsForUserUserGroup(user, "Delete");
d257 3
a259 2
     * Runs scripts to reflect a user's group membership after a
     * change. This method name does not very well describe what goes on.
d261 1
a261 1
    public void runScriptsForUserUserGroup(User baseUser, String mode)
d265 1
a265 3
        ArrayList affectedUsers = new ArrayList();
        ArrayList affectedProjects = new ArrayList();

d271 1
a271 13
            affectedProjects.add(project);
        }
        
        //Only one user -- the base user -- is affected by this change.
        affectedUsers.add(baseUser);
        if (affectedUsers.size() > 0 && affectedProjects.size() > 0)
        {
            if (mode.equals("Add"))
            {
                TigrisUpdate.findNewMembers(conn, dMgr, null, affectedUsers, affectedProjects);
            } else {
                TigrisUpdate.findExMembers(conn, dMgr, null, affectedUsers, affectedProjects);
            }
d273 2
@


1.17
log
@Removed unnecessary getCache() implementations in BusinessObject subclasses and migrated to a factory method for User's primary database key ctor.
@
text
@d321 7
@


1.16
log
@Propogated object cache interface.
@
text
@a142 5
    protected Dictionary getCache ()
    {
        return null;
    }

@


1.15
log
@Added a check so that business objects cannot be created with records from the wrong table. Also added some new business objects.
@
text
@d143 6
@


1.14
log
@Invalidate users' ACLs when they are added to or removed from a project.
@
text
@d79 1
a79 1
        throws DoesNotExist
d85 1
a85 1
        throws DoesNotExist
@


1.13
log
@Mega patch which makes script data persistent and which provides a general framework for tasks to be run (which will be used by anzu eventually)
@
text
@d189 1
d223 2
@


1.13.2.1
log
@merged in changes from HEAD
@
text
@a188 1
        AccessControlList.rebuildACL(conn, dMgr, user.getID());
a221 2
        //Invalidate the removed user's ACL.
        AccessControlList.rebuildACL(conn, dMgr, user.getID());
@


1.12
log
@All addition of users to user groups should go through the business objects.
@
text
@d210 2
a211 1
        TigrisUpdate.findNewMembers(affectedUsers, affectedProjects);
d290 1
a290 1
                TigrisUpdate.findNewMembers(affectedUsers, affectedProjects);
d292 1
a292 1
                TigrisUpdate.findExMembers(affectedUsers, affectedProjects);
@


1.11
log
@Mega patch providing more user group admin functionality.
@
text
@d170 16
@


1.10
log
@Fixed user group member removal.
@
text
@d67 2
d133 1
a133 1
        for (Iterator i = members.iterator(); i.hasNext();)
d135 6
a140 3
            User u = (User)i.next();
            usrGrpMgr.addUserToGroup(conn, u.getID(), getID());
        }        
d147 1
a147 1
    public static UserGroup getDomainUserGroup(Connection connection,
d157 2
a158 2
            .getUserIDForDomainUserGroup(connection, domainID);
        return new UserGroup(connection, dMgr, domainUserID);
d171 24
d204 2
d234 1
d236 1
a236 2
        DataSet users = usrGrpMgr.getBasesForComposite(conn, getID());
        for (int i = 0; i < users.size(); i++)
d238 1
a238 3
            String userID = users.getRecord(i)
                .getValue(UserUserGroupManager.USER_ID).toString();
            usrGrpMgr.removeUserFromGroup(conn, userID, getID());
d248 31
@


1.9
log
@More functionality for UserGroupEdit
@
text
@d164 1
a164 1
        acl.assertPermissionForProject("User Group Member - Add", getID());
d173 1
a173 1
        acl.assertPermissionForProject("User Group Member - Delete", getID());
@


1.8
log
@User group descriptions can now be changed.
@
text
@d172 1
@


1.7
log
@Bugfixes and template changes related to UserGroupEdit.
@
text
@d176 2
a177 1
    public void updateInfo(AccessControlList acl, String description)
d182 1
a182 1
        uMgr.updateUser(conn, null, getID(), getName(), getEmail(),
d184 4
@


1.6
log
@Fixed up display of user groups.
@
text
@a70 2
    private UserManager uMgr;
    private UserUserGroupManager usrGrpMgr;
d224 1
d227 2
a228 1
            users.add(userSet.getRecord(i));
d230 1
a238 13
    }

    /**
     * Creates all the various database managers for this instance.
     *
     * @@param dMgr The associated data manager.
     */
    protected void createManagers ()
    {
        uMgr = (UserManager) dMgr.getManager 
            ("org.joist.database.UserManager");        
        usrGrpMgr = (UserUserGroupManager) dMgr.getManager 
            ("org.tigris.helm.database.UserUserGroupManager");        
@


1.5
log
@Groups can now be added.
@
text
@d253 10
@


1.4
log
@Give registered users the project member list permission in public projects.
@
text
@d53 1
d106 3
a108 2
                     AccessControlList acl, String domainID,
                     String name, String description, ArrayList members)
d114 15
a128 4
        String userID = uMgr.addUser(conn, null, domainID, description,
                                     name, "").toString();
        this.rec = uMgr.getUser(c, userID);

d131 1
a131 1

@


1.3
log
@First stab at UserGroups.
@
text
@d106 1
a106 1
                     String name, String description)
d116 1
a116 1
        //Add the user to the appropriate group.
d118 7
@


1.2
log
@Changed permissions for groups.
@
text
@d82 6
d157 38
@


1.1
log
@Added user group business object.
@
text
@d69 1
a69 1
    private static Log log = new Log("prjGrp", "ProjectGroup");
d105 1
a105 1
        acl.assertPermissionForDomain("Group - Add", domainID);
@

