org.sakaiproject.component.legacy.authzGroup
Class DbAuthzGroupService.DbStorage

java.lang.Object
  extended byorg.sakaiproject.util.storage.BaseDbFlatStorage
      extended byorg.sakaiproject.component.legacy.authzGroup.DbAuthzGroupService.DbStorage
All Implemented Interfaces:
BaseAuthzGroupService.Storage, SqlReader
Enclosing class:
DbAuthzGroupService

protected class DbAuthzGroupService.DbStorage
extends BaseDbFlatStorage
implements BaseAuthzGroupService.Storage, SqlReader

Covers for the BaseXmlFileStorage, providing AuthzGroup and RealmEdit parameters


Nested Class Summary
 class DbAuthzGroupService.DbStorage.RealmAndProvider
           
 class DbAuthzGroupService.DbStorage.RealmAndRole
           
 class DbAuthzGroupService.DbStorage.UserAndRole
           
 
Field Summary
 
Fields inherited from class org.sakaiproject.util.storage.BaseDbFlatStorage
m_caseInsensitive, m_locking, m_locks, m_locksAreInTable, m_reader, m_resourcePropertyTableName, m_resourceTableDbidField, m_resourceTableIdField, m_resourceTableInsertFields, m_resourceTableInsertValues, m_resourceTableName, m_resourceTableReadFields, m_resourceTableSortField1, m_resourceTableSortField2, m_resourceTableUpdateFields, m_sql
 
Constructor Summary
DbAuthzGroupService.DbStorage()
          Construct.
 
Method Summary
 void cancel(AuthzGroup edit)
           
 boolean check(String id)
          Check if an AuthzGroup by this id exists.
 void completeGet(BaseAuthzGroup realm)
          Complete the read process once the basic realm info has been read
protected  void completeGet(Connection conn, BaseAuthzGroup realm, boolean updateProvider)
          Complete the read process once the basic realm info has been read
 int countAuthzGroups(String criteria)
          Count the AuthzGroup objets that meet specified criteria.
 AuthzGroup edit(String id)
           
protected  Object[] fields(String id, BaseAuthzGroup edit, boolean idAgain)
          Get the fields for the database from the edit for this id, and the id again at the end if needed
protected  AuthzGroup get(Connection conn, String id)
           
 AuthzGroup get(String id)
          Get the AuthzGroup with this id, or null if not found.
 Set getAllowedFunctions(String role, Collection realms)
          Get the set of functions that users with this role in these AuthzGroups are allowed to perform.
 List getAuthzGroups(String criteria, PagingPosition page)
          Access a list of AuthzGroups that meet specified criteria, naturally sorted.
 Set getAuthzGroupsIsAllowed(String userId, String lock, Collection azGroups)
          Get the set of AuthzGroup ids in which this user is allowed to perform this function.
 String getUserRole(String userId, String azGroupId)
          Get the role name for this user in this AuthzGroup.
 Set getUsersIsAllowed(String lock, Collection realms)
          Get the set of user ids of users who are allowed to perform the function in the named AuthzGroups.
 Map getUsersRole(Collection userIds, String azGroupId)
          Get the role name for each user in the userIds Collection in this AuthzGroup.
 boolean isAllowed(String userId, String lock, Collection realms)
          Test if this user is allowed to perform the function in the named AuthzGroups.
 boolean isAllowed(String userId, String lock, String realmId)
          Test if this user is allowed to perform the function in the named AuthzGroup.
 AuthzGroup put(String id)
          Add a new AuthzGroup with this id.
 Object readSqlResultRecord(ResultSet result)
          Read from the result one set of fields to create a Resource.
 void refreshAuthzGroup(BaseAuthzGroup realm)
          Refresh the external user - role membership for this AuthzGroup
 void refreshUser(String userId, Map providerGrants)
          Refresh this user's roles in any AuthzGroup that has an entry in the map; the user's new role is in the map.
 void remove(AuthzGroup edit)
          Remove this AuthzGroup.
 void save(AuthzGroup edit)
          Save the changes to the AuthzGroup
 
Methods inherited from class org.sakaiproject.util.storage.BaseDbFlatStorage
cancelResource, caseId, checkResource, close, commitResource, commitResource, countAllResources, countSelectedResources, countSelectedResources, deleteProperties, editResource, editResource, fieldList, getAllResources, getAllResources, getResource, getResource, getSelectedResources, getSelectedResources, getSelectedResources, getSelectedResources, getSelectedResources, getSelectedResources, insertResource, open, putResource, putResource, qualifyField, readProperties, readProperties, readProperties, readProperties, readProperties, readProperties, removeResource, removeResource, setCaseInsensitivity, setDbidField, setLocking, setSortField, setWriteFields, updateFields, updateSet, valuesParams, writeProperties, writeProperties, writeProperties, writeProperties, writeProperties, writeProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.sakaiproject.component.legacy.authzGroup.BaseAuthzGroupService.Storage
close, open
 

Constructor Detail

DbAuthzGroupService.DbStorage

public DbAuthzGroupService.DbStorage()
Construct.

Method Detail

check

public boolean check(String id)
Description copied from interface: BaseAuthzGroupService.Storage
Check if an AuthzGroup by this id exists.

Specified by:
check in interface BaseAuthzGroupService.Storage
Parameters:
id - The AuthzGroup id.
Returns:
true if an AuthzGroup by this id exists, false if not.

get

public AuthzGroup get(String id)
Description copied from interface: BaseAuthzGroupService.Storage
Get the AuthzGroup with this id, or null if not found.

Specified by:
get in interface BaseAuthzGroupService.Storage
Parameters:
id - The AuthzGroup id.
Returns:
The AuthzGroup with this id, or null if not found.

get

protected AuthzGroup get(Connection conn,
                         String id)

completeGet

public void completeGet(BaseAuthzGroup realm)
Complete the read process once the basic realm info has been read

Specified by:
completeGet in interface BaseAuthzGroupService.Storage
Parameters:
realm - The real to complete

completeGet

protected void completeGet(Connection conn,
                           BaseAuthzGroup realm,
                           boolean updateProvider)
Complete the read process once the basic realm info has been read

Parameters:
conn - optional SQL connection to use.
realm - The real to complete.
updateProvider - if true, update and store the provider info.

getAuthzGroups

public List getAuthzGroups(String criteria,
                           PagingPosition page)
Access a list of AuthzGroups that meet specified criteria, naturally sorted.

Specified by:
getAuthzGroups in interface BaseAuthzGroupService.Storage
Parameters:
criteria - Selection criteria: AuthzGroups returned will match this string somewhere in their id, or provider group id.
page - The PagePosition subset of items to return.
Returns:
The List (AuthzGroup) of AuthzGroups that meet specified criteria.

countAuthzGroups

public int countAuthzGroups(String criteria)
Count the AuthzGroup objets that meet specified criteria.

Specified by:
countAuthzGroups in interface BaseAuthzGroupService.Storage
Parameters:
criteria - Selection criteria: realms returned will match this string somewhere in their id, or provider group id.
Returns:
The count of AuthzGroups that meet specified criteria.

getAuthzGroupsIsAllowed

public Set getAuthzGroupsIsAllowed(String userId,
                                   String lock,
                                   Collection azGroups)
Get the set of AuthzGroup ids in which this user is allowed to perform this function.

Specified by:
getAuthzGroupsIsAllowed in interface BaseAuthzGroupService.Storage
Parameters:
userId - The user id.
lock - The function to check.
azGroups - The Collection of AuthzGroup ids to search; if null, search them all.
Returns:
the Set (String) of AuthzGroup ids in which this user is allowed to perform this function.

put

public AuthzGroup put(String id)
Description copied from interface: BaseAuthzGroupService.Storage
Add a new AuthzGroup with this id.

Specified by:
put in interface BaseAuthzGroupService.Storage
Parameters:
id - The AuthzGroup id.
Returns:
The new AuthzGroup, or null if the id is in use.

edit

public AuthzGroup edit(String id)

save

public void save(AuthzGroup edit)
Description copied from interface: BaseAuthzGroupService.Storage
Save the changes to the AuthzGroup

Specified by:
save in interface BaseAuthzGroupService.Storage
Parameters:
edit - The AuthzGroup to save.

cancel

public void cancel(AuthzGroup edit)

remove

public void remove(AuthzGroup edit)
Description copied from interface: BaseAuthzGroupService.Storage
Remove this AuthzGroup.

Specified by:
remove in interface BaseAuthzGroupService.Storage
Parameters:
edit - The azGroup to remove.

fields

protected Object[] fields(String id,
                          BaseAuthzGroup edit,
                          boolean idAgain)
Get the fields for the database from the edit for this id, and the id again at the end if needed

Parameters:
id - The resource id
edit - The edit (may be null in a new)
idAgain - If true, include the id field again at the end, else don't.
Returns:
The fields for the database.

readSqlResultRecord

public Object readSqlResultRecord(ResultSet result)
Read from the result one set of fields to create a Resource.

Specified by:
readSqlResultRecord in interface SqlReader
Parameters:
result - The Sql query result.
Returns:
The Resource object.

isAllowed

public boolean isAllowed(String userId,
                         String lock,
                         String realmId)
Test if this user is allowed to perform the function in the named AuthzGroup.

Specified by:
isAllowed in interface BaseAuthzGroupService.Storage
Parameters:
userId - The user id.
lock - The function to open.
realmId - The AuthzGroup id to consult, if it exists.
Returns:
true if this user is allowed to perform the function in the named AuthzGroup, false if not.

isAllowed

public boolean isAllowed(String userId,
                         String lock,
                         Collection realms)
Test if this user is allowed to perform the function in the named AuthzGroups.

Specified by:
isAllowed in interface BaseAuthzGroupService.Storage
Parameters:
userId - The user id.
lock - The function to open.
Returns:
true if this user is allowed to perform the function in the named AuthzGroups, false if not.

getUsersIsAllowed

public Set getUsersIsAllowed(String lock,
                             Collection realms)
Get the set of user ids of users who are allowed to perform the function in the named AuthzGroups.

Specified by:
getUsersIsAllowed in interface BaseAuthzGroupService.Storage
Parameters:
lock - The function to check.
realms - A collection of the ids of AuthzGroups to consult.
Returns:
the Set (String) of user ids of users who are allowed to perform the function in the named AuthzGroups.

getAllowedFunctions

public Set getAllowedFunctions(String role,
                               Collection realms)
Get the set of functions that users with this role in these AuthzGroups are allowed to perform.

Specified by:
getAllowedFunctions in interface BaseAuthzGroupService.Storage
Parameters:
role - The role name.
realms - A collection of AuthzGroup ids to consult.
Returns:
the Set (String) of functions that users with this role in these AuthzGroups are allowed to perform

refreshUser

public void refreshUser(String userId,
                        Map providerGrants)
Refresh this user's roles in any AuthzGroup that has an entry in the map; the user's new role is in the map.

Specified by:
refreshUser in interface BaseAuthzGroupService.Storage
Parameters:
userId - The user id
providerGrants - The Map of external group id -> role id.

refreshAuthzGroup

public void refreshAuthzGroup(BaseAuthzGroup realm)
Refresh the external user - role membership for this AuthzGroup

Specified by:
refreshAuthzGroup in interface BaseAuthzGroupService.Storage
Parameters:
realm - The azGroup to refresh.

getUserRole

public String getUserRole(String userId,
                          String azGroupId)
Get the role name for this user in this AuthzGroup.

Specified by:
getUserRole in interface BaseAuthzGroupService.Storage
Parameters:
userId - The user id.
azGroupId - The AuthzGroup id to consult, if it exists.
Returns:
the role name for this user in this AuthzGroup, if the user has active membership, or null if not.

getUsersRole

public Map getUsersRole(Collection userIds,
                        String azGroupId)
Get the role name for each user in the userIds Collection in this AuthzGroup.

Specified by:
getUsersRole in interface BaseAuthzGroupService.Storage
Parameters:
azGroupId - The AuthzGroup id to consult, if it exists.
Returns:
A Map (userId -> role name) of role names for each user who have active membership; if the user does not, it will not be in the Map.