public synchronized void grant()

in torque/src/java/org/apache/fulcrum/security/torque/turbine/TorqueTurbineModelManagerImpl.java [63:114]


	public synchronized void grant(Role role, Permission permission)
        throws DataBackendException, UnknownEntityException
    {
        boolean roleExists = getRoleManager().checkExists(role);
        boolean permissionExists = getPermissionManager().checkExists(permission);

        if (roleExists && permissionExists)
        {
            if (role instanceof TurbineRole ) {
            	((TurbineRole)role).addPermission(permission);	
            }
            if (permission instanceof TurbinePermission) {
                ((TurbinePermission)permission).addRole(role);
            }
        
            Connection con = null;

            try
            {
                con = Transaction.begin();

                ((TorqueAbstractSecurityEntity)role).update(con);
                ((TorqueAbstractSecurityEntity)permission).update(con);// this updates all permission

                Transaction.commit(con);
                con = null;
            }
            catch (TorqueException e)
            {
                throw new DataBackendException("grant('" + role.getName() + "', '" + permission.getName() + "') failed", e);
            }
            finally
            {
                if (con != null)
                {
                    Transaction.safeRollback(con);
                }
            }

            return;
        }

        if (!roleExists)
        {
            throw new UnknownEntityException("Unknown role '" + role.getName() + "'");
        }

        if (!permissionExists)
        {
            throw new UnknownEntityException("Unknown permission '" + permission.getName() + "'");
        }
    }