com.arsdigita.acs
Class GeneralPermissions

java.lang.Object
  |
  +--com.arsdigita.acs.GeneralPermissions

public class GeneralPermissions
extends Object


Constructor Summary
GeneralPermissions()
           
 
Method Summary
static Integer getPermissionId(Database db, String scope, Integer userId, Integer groupId, String role, String permissionType, Integer onWhatId, String onWhichTable)
          Returns the id in the general_permissions table for a database object, given the specified scope, user, group, etc.
static void grantPermission(Database db, String scope, Integer userId, Integer groupId, String role, String permissionType, Integer onWhatId, String onWhichTable)
          Grants a permission for a database object to the specified user or group/role, depending on what "scope" is.
static int permissionCount(Database db, Integer onWhatId, String onWhichTable, String permissionType)
          Returns the number of permissions records there are on a certain object, of a certain permission type.
 void revokePermission(Database db, Integer permissionId)
          Revokes the given permission row (the desired id can be obtained by calling getPermissionId)
static boolean userHasPermission(Integer userId, String permission_type, String onWhatId, String onWhichTable)
           
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GeneralPermissions

public GeneralPermissions()
Method Detail

userHasPermission

public static boolean userHasPermission(Integer userId,
                                        String permission_type,
                                        String onWhatId,
                                        String onWhichTable)
                                 throws ACSException

permissionCount

public static int permissionCount(Database db,
                                  Integer onWhatId,
                                  String onWhichTable,
                                  String permissionType)
                           throws ACSException,
                                  SQLException
Returns the number of permissions records there are on a certain object, of a certain permission type. Useful for knowing if you're about to revoke the last admin permission for a record.

grantPermission

public static void grantPermission(Database db,
                                   String scope,
                                   Integer userId,
                                   Integer groupId,
                                   String role,
                                   String permissionType,
                                   Integer onWhatId,
                                   String onWhichTable)
                            throws ACSException,
                                   SQLException
Grants a permission for a database object to the specified user or group/role, depending on what "scope" is. Calls the appropriate pl/sql functions in the general_permissions package.
Parameters:
scope - The scope of the permission (user, group, registered_users, all_users, group_role)

getPermissionId

public static Integer getPermissionId(Database db,
                                      String scope,
                                      Integer userId,
                                      Integer groupId,
                                      String role,
                                      String permissionType,
                                      Integer onWhatId,
                                      String onWhichTable)
                               throws ACSException,
                                      SQLException
Returns the id in the general_permissions table for a database object, given the specified scope, user, group, etc. Uses the pl/sql functions in the general_permissions package.
Parameters:
scope - The scope of the permission (user, group, registered_users, all_users, group_role)

revokePermission

public void revokePermission(Database db,
                             Integer permissionId)
                      throws SQLException
Revokes the given permission row (the desired id can be obtained by calling getPermissionId)