com.netscape.pm.model
Interface IRoleCache


public interface IRoleCache

Cache for application roles and users. The cache is meant to act as the Corporate directory interface for all IRole objects.
ICorporateDirectory
IRoleCache
IRoleIRole
When each role in the application registers itself with the cache, all the users are mapped to the role they belong to.

The primary purpose for the role cache is to provide a simple reverse mapping between a user and the groups that user belongs to. This is function is necessary to correctly display the workitems that belong to a given user since workitems that are assigned to a group have as their assignee id, a qualified role name (see the getQualifiedRoleName(java.lang.String, java.lang.String) getQualifiedRoleName} method).

The cache is bound off the cluster bean (since it needs to be available for access from the IFinder). To prevent role name collisions, it will be necessary to qualify each role name with the application it comes from.

See Also:
ICorporateDirectory, IRole

Method Summary
 boolean contains(java.lang.String qRoleName, java.lang.String userId)
          Check if the specified user id is a member of the role specified by roleName.
 java.lang.String getQualifiedRoleName(java.lang.String appName, java.lang.String roleName)
          Returns the role name qualified with the name of the application it is defined in.
 java.lang.String[] getRoleUsers(java.lang.String qRoleName)
          Returns the list of users that the role currently contains.
 java.lang.String getUnqualifiedRoleName(java.lang.String qRoleName)
          Returns the unqualified role name from a qualified role name.
 java.lang.String[] getUserRoles(java.lang.String userId)
          Returns a list of roles that the user belongs to.
 void refresh()
          Refresh all the user/role information in the cache.
 void registerRole(IRole role, java.util.Vector membership)
          Register the role with the cache - that is, create an internal representation of the role within the cache.
 void setCorporateDirectory(ICorporateDirectory cd)
          Binds the cluster corporate directory to the role cache.
 

Method Detail

getQualifiedRoleName

public java.lang.String getQualifiedRoleName(java.lang.String appName,
                                             java.lang.String roleName)
Returns the role name qualified with the name of the application it is defined in. Any method parameter in this class that requires a role name must be passed a qualified role name, since this cache object is shared across all application installed on the cluster.

Users should not rely on the format of the qualified role name to remain static and thus forgo the use of this method. The format may undergo changes in future versions.

Parameters:
appName - the current application name
roleName - the name of the role to qualify
Returns:
the role name qualified with the name of the application it is defined in.
Since:
PM 6.0

getUnqualifiedRoleName

public java.lang.String getUnqualifiedRoleName(java.lang.String qRoleName)
Returns the unqualified role name from a qualified role name.

Users should not rely on the format of the qualified role name to remain static and thus forgot the use of this method. The format may undergo changes in future versions.

Parameters:
qRoleName - the qualified role name to unqualify
Returns:
the role name unqualified from the name of the application it is defined in.
Since:
PM 6.0

setCorporateDirectory

public void setCorporateDirectory(ICorporateDirectory cd)
Binds the cluster corporate directory to the role cache.
Parameters:
cd - the cluster corporate directory
Since:
PM 6.0
See Also:
ICorporateDirectory

registerRole

public void registerRole(IRole role,
                         java.util.Vector membership)
                  throws PMException
Register the role with the cache - that is, create an internal representation of the role within the cache. This internal role will contain any specific LDAP information necessary to resolve the role with the corporate directory.

Users should not concern themselves with this method, since all the roles associated with the applications are automatically registered as part of the application initialization phase.

Parameters:
role - the role to register with the cache
membership - the user membership list to associate with the role; the value of this parameter will differ according to the type of role being registered
Throws:
PMException - if there is a problem with registering the role with the cache.
Since:
PM 6.0
See Also:
IRole

contains

public boolean contains(java.lang.String qRoleName,
                        java.lang.String userId)
Check if the specified user id is a member of the role specified by roleName. Returns true if user id is a member; otherwise returns false.
Parameters:
roleName - a qualified role name
userId - the id of the user to check for role membership
Returns:
true if the user id is a member of the role; false otherwise.
Since:
PM 6.0
See Also:
getQualifiedRoleName(java.lang.String, java.lang.String)

getUserRoles

public java.lang.String[] getUserRoles(java.lang.String userId)
Returns a list of roles that the user belongs to. If the user id is not contained in the cache (that is, does not belong to a role), null is returned. Note: the names of the roles returned are in their qualified format.
Parameters:
userId -  
Returns:
java.util.String array of qualified role names that correspond to the roles that the user is a member of.
Since:
PM 6.0

getRoleUsers

public java.lang.String[] getRoleUsers(java.lang.String qRoleName)
Returns the list of users that the role currently contains. If the role has not been registered with the cache (ie. role does not exist), null is returned.
Parameters:
roleName - qualified role name
Returns:
java.util.String array of user ids that the role contains.
Since:
PM 6.0

refresh

public void refresh()
             throws PMException
Refresh all the user/role information in the cache. Certain dynamic groups (for instance, dynamic LDAP roles), have membership lists that frequently change. This method can be called when the intention is to manually synchronize these dynamic groups with the role cache.
Throws:
PMException - if there is a problem with resolving one of the roles currently registered with the cache.
Since:
PM 6.0