head	1.26;
access;
symbols
	TIGRIS_0_9_2_4:1.19
	TIGRIS_0_9_2_3:1.19
	HELM_PEER_PORT_BRANCH:1.24.0.2
	TURBINE_PEER:1.24
	TIGRIS_0_9_2_1:1.24
	TIGRIS_0_9_2:1.19.0.2
	TIGRIS_0_9_0:1.14.0.2
	TIGRIS_0_8_4:1.5.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.26
date	2001.02.21.03.23.57;	author edk;	state dead;
branches;
next	1.25;

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

1.24
date	2001.01.26.18.29.02;	author edk;	state Exp;
branches
	1.24.2.1;
next	1.23;

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

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

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

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

1.19
date	2001.01.15.19.14.40;	author leonardr;	state Exp;
branches;
next	1.18;

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

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

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

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

1.14
date	2000.12.14.03.04.17;	author edk;	state Exp;
branches;
next	1.13;

1.13
date	2000.12.14.00.35.43;	author elicia;	state Exp;
branches;
next	1.12;

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

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

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

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

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

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

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

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

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

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

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

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

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

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


desc
@@


1.26
log
@delete stuff from the head which is obsolete in the branch (more changes
are still needed for a clean compile)
@
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.domain;

import java.sql.*;
import java.util.*;

import org.webmacro.util.*;
import com.workingdogs.village.*;

import org.joist.database.*;
import org.tigris.helm.database.*;
import org.tigris.helm.DoesNotExist;
import org.tigris.helm.domain.*;
import org.tigris.helm.security.*;
import org.tigris.helm.tool.DBFlag;

/**
 * Business object representing a role.
 *
 * @@author <a href="mailto:leonardr@@collab.net">Leonard Richardson</a>
 */
public class Role extends BusinessObject
{
    /**
     * Open the log file.
     */
    private static Log log = new Log("Role", "Role Business Object");

    /**
     * Whether to log debugging information.
     */
    private static boolean debug = true;

    public static final String PROJECT_ROLE = "Project";
    public static final String DOMAIN_ROLE = "Domain";
    public static final String HOST_ROLE = "Host";

    public static final String DESCRIPTION = "description";
    public static final String REQUESTABLE = "requestable";
    public static final String OWNERSHIP = "ownership";

    protected final String getTableName() { return RoleManager.TABLE_NAME; }

    private RoleManager rMgr;
    private RoleActionResourceManager rarMgr;

    public Role (Connection conn, DataManager dMgr, Record rec)
        throws DoesNotExist, DataSetException
    {
        super(conn, dMgr, rec);
    }

    public Role(Connection conn, DataManager dMgr, String roleID)
        throws SQLException, DataSetException, DoesNotExist
    {
        super(conn, dMgr);
        setRecord(rMgr.getRole(conn, roleID));
    }

    public Role(Connection c, DataManager dMgr, String roleName, boolean ignore)
        throws SQLException, DataSetException, DoesNotExist, JoistDatabaseException
    {
        super(c, dMgr);
        setRecord(rMgr.getRole(conn, rMgr.getRoleID(c,roleName)));
    }

    public Role(Connection c, DataManager dMgr, AccessControlList acl,
                Domain domain, String roleName, String description,
                String type, boolean requestable, boolean isOwnership,
                ArrayList permissions)
        throws ACLException, SQLException, DataSetException,
               JoistDatabaseException, DoesNotExist
    {
        super(c, dMgr);

        //Make sure they have permission.
        if (type.equals(RoleManager.PROJECT_ROLE_TYPE))
        {
            acl.assertPermissionForDomain("Project Role - Add", 
                                          domain.getSpecialProject().getID());
        } else if (type.equals(RoleManager.DOMAIN_ROLE_TYPE)) {
            acl.assertPermissionForDomain("Domain Role - Add", 
                                          domain.getSpecialProject().getID());
        } else {
            acl.assertPermissionForHost("Host Role - Add");
        }

        //Create the role in the database.
        Record r = addRole(conn, roleName, description, type, requestable, isOwnership);
        try {
            setRecord(r);
        } catch (DoesNotExist ignore) {} //Can't happen for Records.
        
        //Now add the permissions to the role.
        for (Iterator i = permissions.iterator(); i.hasNext();)
        {
            Permission perm = (Permission)i.next();
            addPermissionBypassingChecks(perm);
        }
        AccessControlList.buildActionsByRole(conn, dMgr);
    }

    protected void createManagers ()
    {
        rMgr = (RoleManager)dMgr.getManager ("org.joist.database.RoleManager");
        rarMgr = (RoleActionResourceManager)dMgr.getManager 
            ("org.tigris.helm.database.RoleActionResourceManager");
    }

    public List getPermissions()
        throws SQLException, DataSetException, DoesNotExist, JoistDatabaseException
    {
        ArrayList perms = new ArrayList();
        DataSet rarSet = rarMgr.getActionsResourcesForRole(conn, getID());
        for (int i = 0; i < rarSet.size(); i++)
        {            
            Record r = rarSet.getRecord(i);
            String actionID = r.getValue
                (RoleActionResourceManager.ACTION_ID).asString();
            String resourceID = r.getValue
                (RoleActionResourceManager.RESOURCE_ID).asString();
            Action action = new Action(conn, dMgr, actionID);
            Resource resource = new Resource(conn, dMgr, resourceID);
            perms.add(new Permission(conn, dMgr, action, resource));
        }
        return perms;
    }

    public void update(AccessControlList acl, Domain domain,
                       String name, String description, String type,
                       boolean requestable, boolean ownership)
        throws ACLException, SQLException, DataSetException, DoesNotExist
    {
        //Make sure they have permission.
        assertEditPermission(acl, domain);
        setRecord(updateRole(conn, getID(), name, description, type, requestable, ownership));
    }
    
    /**
     * Add a permission to a role. Note that this does not recalculate
     * issue tracking accounts--that is done in RoleMemberAdd because it
     * takes a *long* time, and we might be adding more than one issue
     * tracking permission here.  
     */
    public void addPermission(AccessControlList acl, Domain domain,
                              Permission permission)
        throws ACLException, SQLException, DataSetException, DoesNotExist,
               JoistDatabaseException
    {
        //Make sure they have permission.
        assertEditPermission(acl, domain);
        addPermissionBypassingChecks(permission);
    }

    /**
     * Add a permission to a role, without checking any ACL.
     */
    private void addPermissionBypassingChecks(Permission permission)
        throws SQLException, DataSetException, JoistDatabaseException
    {
        Action action = permission.getAction();
        Resource resource = permission.getResource();
        rarMgr.grant(conn, getID(), action.getID(), resource.getID());

        AccessControlList.buildActionsByRole(conn, dMgr);
    }

    /**
     * Remove a permission from a role. Note that this does not
     * recalculate issue tracking accounts--that is done in RoleEdit
     * because it takes a *long* time, and we might be removing more
     * than one issue tracking permission here.  
     */
    public void removePermission(AccessControlList acl, Domain domain,
                                 Permission permission)
        throws ACLException, SQLException, DataSetException, DoesNotExist,
               JoistDatabaseException
    {
        //Make sure they have permission.
        assertEditPermission(acl, domain);
        removePermissionBypassingChecks(permission);
    }

    /**
     * Remove a permission from a role, without checking any ACL.
     */
    private void removePermissionBypassingChecks(Permission permission)
        throws SQLException, DataSetException, JoistDatabaseException
    {
        Action action = permission.getAction();
        Resource resource = permission.getResource();
        rarMgr.revoke(conn, getID(), action.getID(), resource.getID());

        AccessControlList.buildActionsByRole(conn, dMgr);
    }

    /**
     * Asserts permission to edit this role in the given domain.
     */
    private void assertEditPermission(AccessControlList acl, Domain domain)
        throws ACLException, DataSetException, SQLException, DoesNotExist
    {
        String type = getType();
        if (type.equals(RoleManager.PROJECT_ROLE_TYPE))
        {
            acl.assertPermissionForDomain("Project Role - Edit", 
                                          domain.getSpecialProject().getID());
        } else if (type.equals(RoleManager.DOMAIN_ROLE_TYPE)) {
            acl.assertPermissionForDomain("Domain Role - Edit", 
                                          domain.getSpecialProject().getID());
        } else {
            acl.assertPermissionForHost("Host Role - Edit");
        }
    }

/////////////////////////////////////////////////
// Stuff that should go into RoleManager but can't
/////////////////////////////////////////////////

    public Record addRole(Connection connection, String name, 
                          String description, String type, boolean requestable,
                          boolean isOwnership)
        throws DataSetException, SQLException
    {       
        return updateRole(conn, null, name, description, type, requestable, 
                          isOwnership);
    }

    /**
     * Updates an existing role or adds a new role to the database 
     * (depending on whether given a <code>roleID</code> or not).
     *
     * @@param connection The JDBC database connection to use.
     * @@param roleID     The database key of the role to update, or 
     *                   <code>null</code> if the role is new.
     * @@param name       The name of the role.
     * @@param type
     * @@return	         The system-assigned role ID for the role updated.
     *
     * @@exception	SQLException
     * @@exception	DataSetException
     */
    public Record updateRole (Connection connection, String roleID, 
                              String name, String description,
                              String type, boolean requestable,
                              boolean isOwnership)
	throws SQLException, DataSetException
    {

        String newRoleID = rMgr.updateRole(connection, roleID, name);
        log.info("That worked, going forward.");
        Record role = rMgr.getRole(connection, newRoleID);
        role.setValue(rMgr.ROLE_TYPE, type);
        role.setValue(DESCRIPTION, description);
        role.setValue(REQUESTABLE, DBFlag.flagValueOf(requestable));
        role.setValue(OWNERSHIP, DBFlag.flagValueOf(isOwnership));
        role.save();
	return role;
    }

    public String getID()
        throws DataSetException
    {
        return rec.getValue(RoleManager.ROLE_ID).asString();
    }

    public String getName()
        throws DataSetException
    {
        return rec.getValue(RoleManager.ROLE_NAME).asString();
    }

    public String getType()
        throws DataSetException
    {
        return rec.getValue("type").asString();
    }

    public boolean isRequestable()
        throws DataSetException
    {
        return rec.getValue("requestable").asString().equals("Y");
    }

    public boolean isOwnership()
        throws DataSetException
    {
        return rec.getValue(OWNERSHIP).asString().equals("Y");
    }

    public String getDescription()
        throws DataSetException
    {
        return rec.getValue("description").asString();
    }
}

@


1.25
log
@Added a new field to the Role table: ownership. This designates whether someone who has the role in the project/domain/host is the sort of person who gets emails when something happens that affects the project/domain/host.
@
text
@@


1.24
log
@readding all the files as part of the process of returning to the way
things were as of tuesday
@
text
@d85 1
d114 2
a115 1
                String type, boolean requestable, ArrayList permissions)
d134 1
a134 1
        Record r = addRole(conn, roleName, description, type, requestable);
d176 1
a176 1
                       boolean requestable)
d181 1
a181 1
        setRecord(updateRole(conn, getID(), name, description, type, requestable));
d266 2
a267 1
                          String description, String type, boolean requestable)
d270 2
a271 1
        return updateRole(conn, null, name, description, type, requestable);
d290 2
a291 1
                              String type, boolean requestable)
d301 1
d328 6
@


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


1.23
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
@d55 1
a55 2
import org.joist.database.TableManager;
import org.joist.database.DataManager;
d86 2
d91 2
a92 2
    public Role (DataManager dMgr, Record rec)
        throws DoesNotExist, DBException
d94 1
a94 1
        super(dMgr, rec);
d97 2
a98 2
    public Role(DataManager dMgr, String roleID)
        throws DoesNotExist, DBException
d100 2
a101 2
        super(dMgr);
        setRecord(rMgr.getRole(roleID));
d104 2
a105 2
    public Role(DataManager dMgr, String roleName, boolean ignore)
        throws DoesNotExist, DBException
d107 2
a108 2
        super(dMgr);
        setRecord(rMgr.getRole(rMgr.getRoleID(roleName)));
d111 5
a115 4
    public Role(DataManager dMgr, AccessControlList acl, Domain domain,
                String roleName, String description, String type,
                boolean requestable, ArrayList permissions)
        throws ACLException, DoesNotExist, DBException
d117 1
a117 1
        super(dMgr);
d122 2
a123 2
            acl.assertPermissionForDomain
                ("Project Role - Add", domain.getSpecialProject().getID());
d125 2
a126 2
            acl.assertPermissionForDomain
                ("Domain Role - Add", domain.getSpecialProject().getID());
d132 1
a132 1
        Record r = addRole(roleName, description, type, requestable);
d135 1
a135 3
        } catch (DoesNotExist ignored) {
            // Can't happen when we already have a Record object.
        }
d143 1
a143 1
        AccessControlList.buildActionsByRole(dMgr);
a152 5
    protected final String getTableName()
    {
        return RoleManager.TABLE_NAME;
    }

d154 1
a154 1
        throws DoesNotExist, DBException
d157 1
a157 1
        DataSet rarSet = rarMgr.getActionsResourcesForRole(getID());
d165 3
a167 3
            Action action = new Action(dMgr, actionID);
            Resource resource = new Resource(dMgr, resourceID);
            perms.add(new Permission(dMgr, action, resource));
d175 1
a175 1
        throws ACLException, DoesNotExist, DBException
d179 1
a179 1
        setRecord(updateRole(getID(), name, description, type, requestable));
d190 2
a191 1
        throws ACLException, DoesNotExist, DBException
d202 1
a202 1
        throws DBException
d206 1
a206 1
        rarMgr.grant(getID(), action.getID(), resource.getID());
d208 1
a208 1
        AccessControlList.buildActionsByRole(dMgr);
d219 2
a220 1
        throws ACLException, DoesNotExist, DBException
d231 1
a231 1
        throws DBException
d235 1
a235 1
        rarMgr.revoke(getID(), action.getID(), resource.getID());
d237 1
a237 1
        AccessControlList.buildActionsByRole(dMgr);
d244 1
a244 1
        throws ACLException, DoesNotExist, DBException
d247 1
a247 1
        try
d249 7
a255 22
            if (type.equals(RoleManager.PROJECT_ROLE_TYPE))
            {
                acl.assertPermissionForDomain
                    ("Project Role - Edit", domain.getSpecialProject().getID());
            } else if (type.equals(RoleManager.DOMAIN_ROLE_TYPE)) {
                acl.assertPermissionForDomain
                    ("Domain Role - Edit", domain.getSpecialProject().getID());
            } else {
                acl.assertPermissionForHost("Host Role - Edit");
            }
        }
        catch (JoistDatabaseException e)
        {
            throw new DBException(e);
        }
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        catch (SQLException e)
        {
            throw new DBException(e);
d259 7
a265 8
    /////////////////////////////////////////////////
    // Stuff that should go into RoleManager but can't
    // TODO: We now have a RoleManager in Helm to move this into.
    /////////////////////////////////////////////////

    public Record addRole(String name, String description, String type,
                          boolean requestable)
        throws DBException
d267 1
a267 1
        return updateRole(null, name, description, type, requestable);
d274 1
d281 2
a282 1
     * @@exception DBException
d284 2
a285 1
    public Record updateRole (String roleID, String name, String description,
d287 1
a287 1
	throws DBException
d290 7
a296 14
        String newRoleID = rMgr.updateRole(roleID, name);
        if (debug) log.info("That worked, going forward.");
        Record role = rMgr.getRole(newRoleID);
        try
        {
            role.setValue(rMgr.ROLE_TYPE, type);
            role.setValue(DESCRIPTION, description);
            role.setValue(REQUESTABLE, DBFlag.flagValueOf(requestable));
            role.save();
        }
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
d301 1
a301 1
        throws DBException
d307 1
a307 1
        throws DBException
d313 1
a313 1
        throws DBException
d319 1
a319 1
        throws DBException
d325 1
a325 1
        throws DBException
d330 1
@


1.22
log
@Less compile errors.
@
text
@@


1.21
log
@Removed all references to JDBC connections.  Connections are now pulled
directly from the connection pool.
- dlr@@collab.net
@
text
@d55 2
a56 1
import org.joist.database.*;
a86 2
    protected final String getTableName() { return RoleManager.TABLE_NAME; }

d99 2
a100 1
        super(dMgr, rMgr.getRole(roleID));
d106 2
a107 1
        super(dMgr, rMgr.getRole(rMgr.getRoleID(c,roleName)));
d118 1
a118 1
        try
d120 7
a126 26
            if (type.equals(RoleManager.PROJECT_ROLE_TYPE))
            {
                acl.assertPermissionForDomain
                    ("Project Role - Add", domain.getSpecialProject().getID());
            } else if (type.equals(RoleManager.DOMAIN_ROLE_TYPE)) {
                acl.assertPermissionForDomain
                    ("Domain Role - Add", domain.getSpecialProject().getID());
            } else {
                acl.assertPermissionForHost("Host Role - Add");
            }

            //Create the role in the database.
            Record r = addRole(roleName, description, type, requestable);
            try {
                setRecord(r);
            } catch (DoesNotExist ignored) {
                // Can't happen when we already have a Record object.
            }
        
            //Now add the permissions to the role.
            for (Iterator i = permissions.iterator(); i.hasNext();)
            {
                Permission perm = (Permission)i.next();
                addPermissionBypassingChecks(perm);
            }
            AccessControlList.buildActionsByRole(dMgr);
d128 7
a134 3
        catch (JoistDatabaseException e)
        {
            throw new DBException(e);
d136 3
a138 5
        catch (DataSetException e)
        {
            throw new DBException(e);
        }
        catch (SQLException e)
d140 2
a141 1
            throw new DBException(e);
d143 1
d151 5
@


1.20
log
@Making use of DBException.
@
text
@d91 1
a91 1
    public Role (Connection conn, DataManager dMgr, Record rec)
d94 1
a94 1
        super(conn, dMgr, rec);
d97 2
a98 2
    public Role(Connection conn, DataManager dMgr, String roleID)
        throws SQLException, DataSetException, DoesNotExist
d100 1
a100 2
        super(conn, dMgr);
        setRecord(rMgr.getRole(conn, roleID));
d103 2
a104 2
    public Role(Connection c, DataManager dMgr, String roleName, boolean ignore)
        throws SQLException, DataSetException, DoesNotExist, JoistDatabaseException
d106 1
a106 2
        super(c, dMgr);
        setRecord(rMgr.getRole(conn, rMgr.getRoleID(c,roleName)));
d109 4
a112 4
    public Role(Connection c, DataManager dMgr, AccessControlList acl,
                Domain domain, String roleName, String description,
                String type, boolean requestable, ArrayList permissions)
        throws ACLException, DBException, DoesNotExist
d114 1
a114 1
        super(c, dMgr);
d131 1
a131 1
            Record r = addRole(conn, roleName, description, type, requestable);
d144 1
a144 1
            AccessControlList.buildActionsByRole(conn, dMgr);
d168 1
a168 1
        throws SQLException, DataSetException, DoesNotExist, JoistDatabaseException
d171 1
a171 1
        DataSet rarSet = rarMgr.getActionsResourcesForRole(conn, getID());
d179 3
a181 3
            Action action = new Action(conn, dMgr, actionID);
            Resource resource = new Resource(conn, dMgr, resourceID);
            perms.add(new Permission(conn, dMgr, action, resource));
d193 1
a193 2
        setRecord(updateRole(conn, getID(), name, description, type,
                             requestable));
d219 1
a219 1
        rarMgr.grant(conn, getID(), action.getID(), resource.getID());
d221 1
a221 1
        AccessControlList.buildActionsByRole(conn, dMgr);
d243 1
a243 1
        throws SQLException, DataSetException, JoistDatabaseException
d247 1
a247 1
        rarMgr.revoke(conn, getID(), action.getID(), resource.getID());
d249 1
a249 1
        AccessControlList.buildActionsByRole(conn, dMgr);
d286 4
a289 3
/////////////////////////////////////////////////
// Stuff that should go into RoleManager but can't
/////////////////////////////////////////////////
d291 2
a292 2
    public Record addRole(Connection connection, String name, 
                          String description, String type, boolean requestable)
d295 1
a295 1
        return updateRole(conn, null, name, description, type, requestable);
a301 1
     * @@param connection The JDBC database connection to use.
d308 1
a308 2
     * @@exception	SQLException
     * @@exception	DataSetException
d310 1
a310 2
    public Record updateRole (Connection connection, String roleID, 
                              String name, String description,
d315 1
a315 1
        String newRoleID = rMgr.updateRole(connection, roleID, name);
d317 1
a317 1
        Record role = rMgr.getRole(connection, newRoleID);
d333 1
a333 1
        throws DataSetException
d339 1
a339 1
        throws DataSetException
d345 1
a345 1
        throws DataSetException
d351 1
a351 1
        throws DataSetException
d357 1
a357 1
        throws DataSetException
a361 1

@


1.19
log
@TODO taken care of.
@
text
@d92 1
a92 1
        throws DoesNotExist, DataSetException
d114 1
a114 2
        throws ACLException, SQLException, DataSetException,
               JoistDatabaseException, DoesNotExist
d119 1
a119 1
        if (type.equals(RoleManager.PROJECT_ROLE_TYPE))
d121 18
a138 14
            acl.assertPermissionForDomain("Project Role - Add", 
                                          domain.getSpecialProject().getID());
        } else if (type.equals(RoleManager.DOMAIN_ROLE_TYPE)) {
            acl.assertPermissionForDomain("Domain Role - Add", 
                                          domain.getSpecialProject().getID());
        } else {
            acl.assertPermissionForHost("Host Role - Add");
        }

        //Create the role in the database.
        Record r = addRole(conn, roleName, description, type, requestable);
        try {
            setRecord(r);
        } catch (DoesNotExist ignore) {} //Can't happen for Records.
d140 17
a156 2
        //Now add the permissions to the role.
        for (Iterator i = permissions.iterator(); i.hasNext();)
d158 1
a158 2
            Permission perm = (Permission)i.next();
            addPermissionBypassingChecks(perm);
a159 1
        AccessControlList.buildActionsByRole(conn, dMgr);
d191 1
a191 1
        throws ACLException, SQLException, DataSetException, DoesNotExist
d195 2
a196 1
        setRecord(updateRole(conn, getID(), name, description, type, requestable));
d207 1
a207 2
        throws ACLException, SQLException, DataSetException, DoesNotExist,
               JoistDatabaseException
d218 1
a218 1
        throws SQLException, DataSetException, JoistDatabaseException
d235 1
a235 2
        throws ACLException, SQLException, DataSetException, DoesNotExist,
               JoistDatabaseException
d259 1
a259 1
        throws ACLException, DataSetException, SQLException, DoesNotExist
d262 14
a275 1
        if (type.equals(RoleManager.PROJECT_ROLE_TYPE))
d277 9
a285 7
            acl.assertPermissionForDomain("Project Role - Edit", 
                                          domain.getSpecialProject().getID());
        } else if (type.equals(RoleManager.DOMAIN_ROLE_TYPE)) {
            acl.assertPermissionForDomain("Domain Role - Edit", 
                                          domain.getSpecialProject().getID());
        } else {
            acl.assertPermissionForHost("Host Role - Edit");
d295 1
a295 1
        throws DataSetException, SQLException
d317 1
a317 1
	throws SQLException, DataSetException
d321 1
a321 1
        log.info("That worked, going forward.");
d323 11
a333 4
        role.setValue(rMgr.ROLE_TYPE, type);
        role.setValue(DESCRIPTION, description);
        role.setValue(REQUESTABLE, DBFlag.flagValueOf(requestable));
        role.save();
@


1.18
log
@Recalculate issue tracking accounts after adding or removing issue tracking permissions to or from a role.
@
text
@a207 1
        //TODO: Run the neccessary scripts.
a236 1
        //TODO: Run the neccessary scripts.
@


1.17
log
@Made use of new DBFlag class.
@
text
@d172 16
d198 3
a200 10
    public void update(AccessControlList acl, Domain domain,
                       String name, String description, String type,
                       boolean requestable)
        throws ACLException, SQLException, DataSetException, DoesNotExist
    {
        //Make sure they have permission.
        assertEditPermission(acl, domain);
        setRecord(updateRole(conn, getID(), name, description, type, requestable));
    }
    
d212 6
d228 3
d242 3
@


1.16
log
@Removed unnecessary getCache() implementations in BusinessObject subclasses and migrated to a factory method for User's primary database key ctor.
@
text
@d60 1
d276 1
a276 1
        role.setValue(REQUESTABLE, requestable?"Y":"N");
@


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

@


1.14
log
@* adjust for corrections to Role constructor
* correct another Role constructor which listed the DataManager before
  the Connection
@
text
@d152 5
@


1.13
log
@the getRequestedRoles() method was throwing exceptions. I changed it to invoke the ctor with roleID instead of record.
@
text
@d103 1
a103 1
    public Role(DataManager dMgr, Connection c, String roleName, boolean ignore)
@


1.12
log
@Update ACL cached info after adding or changing a role.
@
text
@d96 1
a96 1
    public Role(DataManager dMgr, Connection c, String roleID)
d99 1
a99 1
        super(c, dMgr);
@


1.11
log
@New servlet: RoleEdit
@
text
@d142 1
d173 2
a174 1
        throws ACLException, SQLException, DataSetException, DoesNotExist
d192 1
a192 1
        throws SQLException, DataSetException
d199 1
d204 2
a205 1
        throws ACLException, SQLException, DataSetException, DoesNotExist
d213 1
a213 1
        throws SQLException, DataSetException
d220 1
@


1.10
log
@RoleAdd can now set all the fields in Helm's role table.
@
text
@a173 1
        String type = getType();
d175 1
a175 11
        if (type.equals(RoleManager.PROJECT_ROLE_TYPE))
        {
            acl.assertPermissionForDomain("Project Role - Edit", 
                                          domain.getSpecialProject().getID());
        } else if (type.equals(RoleManager.DOMAIN_ROLE_TYPE)) {
            acl.assertPermissionForDomain("Domain Role - Edit", 
                                          domain.getSpecialProject().getID());
        } else {
            acl.assertPermissionForHost("Host Role - Edit");
        }

d179 10
d203 18
a221 1
        //Make sure they have permission.
a231 12
        
        removePermissionBypassingChecks(permission);
    }

    private void removePermissionBypassingChecks(Permission permission)
        throws SQLException, DataSetException
    {
        Action action = permission.getAction();
        Resource resource = permission.getResource();
        rarMgr.revoke(conn, action.getID(), resource.getID());

        //TODO: Run the neccessary scripts.
d264 1
d266 1
@


1.9
log
@First stab at dynamic role creation.
@
text
@d82 3
d111 2
a112 2
                Domain domain, String roleName, String type, 
                ArrayList permissions)
d131 1
a131 1
        Record r = addRole(conn, roleName, type);
d234 2
a235 1
    public Record addRole(Connection connection, String name, String type)
d238 1
a238 1
        return updateRole(conn, null, name, type);
d256 2
a257 1
                              String name, String type)
d262 3
a264 1
        role.setValue(rMgr.ROLE_TYPE, name);
@


1.8
log
@Roles can now find out about their Permissions.
@
text
@d58 2
d107 34
d165 95
@


1.7
log
@Enabled security check of records passed into business objects.
@
text
@d50 1
d56 1
a56 1

d83 1
d108 21
@


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


1.5
log
@Implemented requestable roles and requesting roles in proprietary projects.
@
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
d51 1
d58 5
d65 10
d82 1
a82 1
        throws DoesNotExist
@


1.4
log
@Added role description.
@
text
@d93 1
a93 1
        return rec.getValue(RoleManager.ROLE_ID).toString();
d99 1
a99 1
        return rec.getValue(RoleManager.ROLE_NAME).toString();
d105 7
a111 1
        return rec.getValue("type").toString();
d117 1
a117 1
        return rec.getValue("description").toString();
@


1.3
log
@Split up ProjectMembershipRequest to show requested/approved/other roles.
@
text
@d107 6
@


1.2
log
@Email host admins on failure of a script.
@
text
@d108 1
@


1.1
log
@Initial revision
@
text
@d78 7
@


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