com.atlassian.crowd.integration.directory.cache
Class DefaultDirectoryCache

java.lang.Object
  extended by com.atlassian.crowd.integration.directory.cache.DefaultDirectoryCache
All Implemented Interfaces:
DirectoryCache, com.atlassian.event.EventListener
Direct Known Subclasses:
LDAPDirectoryCache

public class DefaultDirectoryCache
extends java.lang.Object
implements DirectoryCache

Default DirectoryCache implementation, backed by multiple eternal EhCache Cache implementations.

Caches include Entity caches (UNITARY): - userName -> User - groupName -> Group

Aggregated name caches (COLLECTION): - static -> [userNames] - static -> [groupNames]

Relationship caches (COLLECTION): - userName -> [groupNames] - groupName -> [userNames] (direct members) - groupName -> [child groupNames] (direct members) - groupName -> [parent groupNames] (direct parents)

Membership caches (UNITARY): - userName, groupName -> Boolean (direct membership) - userName, roleName -> Boolean - child groupName, parent groupName -> Boolean (direct membership)

All unitary caches support values of: - Entity value : when the entity is present - Boolean.FALSE : when the entity is KNOWN to be NOT present - null : when it is not known whether the entity exists or not

All collection based caches have values that are PartialSets that can be: - complete PartialSet : when the set is known to be an accurate representation of the remote directory - incomplete PartialSet : when the set contains SOME of the values - null : when the value of the collection is completely unknown

NOTE: implementation is case-insensitive for matching. Internal state stores keys (entity names) in lower-case. Queries always return values in the case in which they were stored.

IMPORTANT: this cache may turn into a concurrency bottleneck as one read-write lock is used to ensure the threadsafety of the entire cache. All store/update/remove methods are guarded by a write lock and all retrieve methods are guarded by the corresponding read lock. If we experience a massive degredation in performance, we should investigate lock-striping or moving to a database (read: transactional) based cache implementation.

Some words of warning regarding cache consistency (ie. caller must ensure): - If a group has it's members/memberships cached then the group itself MUST be cached, so don't call storeUserMembersOfGroup before storeGroup, etc. - If a user has it's memberships cached then the user itself MUST be cached. - If a user/group has any boolean membership information cached the user/group MUST be cached. These requirements are so that membership information is only cached when entity information is cached (eg. for DN mapping).


Field Summary
protected  net.sf.ehcache.CacheManager cacheManager
           
protected  long directoryId
           
protected  net.sf.ehcache.Cache groupCache
           
protected  net.sf.ehcache.Cache groupChildGroupsCache
           
protected  net.sf.ehcache.Cache groupGroupMembershipExistsCache
           
protected  net.sf.ehcache.Cache groupNamesCache
           
protected  net.sf.ehcache.Cache groupParentGroupsCache
           
protected  net.sf.ehcache.Cache groupUsersCache
           
protected  org.apache.log4j.Logger logger
           
protected  int maxElementsInMemoryPerSubCache
           
protected  net.sf.ehcache.Cache userCache
           
protected  net.sf.ehcache.Cache userGroupMembershipExistsCache
           
protected  net.sf.ehcache.Cache userGroupsCache
           
protected  net.sf.ehcache.Cache userNamesCache
           
 
Constructor Summary
DefaultDirectoryCache(long directoryId, net.sf.ehcache.CacheManager ehcacheManager, int maxElementsInMemoryPerSubCache)
           
 
Method Summary
protected  void addMembership(java.lang.String memberName, java.lang.String containerName, net.sf.ehcache.Cache membershipsCache, net.sf.ehcache.Cache membersCache, net.sf.ehcache.Cache booleanMembershipCache)
           
protected  void addRelationship(java.lang.String entityName, java.lang.String relationName, net.sf.ehcache.Cache relationshipCache)
           
 void clear()
          Clear the contents of the entire cache.
 void close()
          Close the cache and render it unuseable.
protected  net.sf.ehcache.Cache createAndConfigureCache(java.lang.String cacheName)
           
protected  void doClear()
           
protected  void doClose()
           
protected  boolean doHandleEvent(com.atlassian.event.Event evt)
           
protected  PartialSet<java.lang.String> getAllEntityNames(net.sf.ehcache.Cache entityNamesCache)
           
protected  java.util.List<java.lang.String> getAllEntityNamesAsList(net.sf.ehcache.Cache entityNamesCache)
           
 java.util.List<java.lang.String> getAllGroupNames()
          Retrieves the complete collection of all group names for the cached directory or null if the complete list is not cached.
 java.util.List<java.lang.String> getAllUserNames()
          Retrieves the complete collection of all user names for the cached directory or null if the complete list is not cached.
protected  java.util.List<java.lang.String> getCompleteRelationshipsAsList(java.lang.String entityName, net.sf.ehcache.Cache relationshipCache, net.sf.ehcache.Cache entityCache)
           
protected  java.lang.Object getEntity(java.lang.String name, net.sf.ehcache.Cache entityCache)
           
protected  java.lang.Object getFromCache(java.io.Serializable name, net.sf.ehcache.Cache cache)
           
 Group getGroup(java.lang.String groupName)
          Returns the cached Group matching the directoryID and groupName.
 java.util.List<java.lang.String> getGroupMembershipsOfGroup(java.lang.String groupName)
          Returns a list of group membership names for a particular group.
 java.util.List<java.lang.String> getGroupMembershipsOfUser(java.lang.String userName)
          Returns a list of group membership names for a particular user.
 java.util.List<java.lang.String> getGroupMembersOfGroup(java.lang.String groupName)
          Returns a list of child group member names for a particular group.
 java.lang.Class[] getHandledEventClasses()
           
protected  java.lang.String getKey(java.lang.String name)
          Return a version of the name appropriate for use as a cache key.
protected  java.util.Collection<java.lang.String> getKeys(java.util.Collection<java.lang.String> names)
          Applies getKey over a collection.
protected  PartialSet<java.lang.String> getRelationships(java.lang.String entityName, net.sf.ehcache.Cache relationshipCache)
           
protected  java.util.List<java.lang.String> getRelationshipsAsList(java.lang.String entityName, net.sf.ehcache.Cache relationshipCache)
           
 DirectoryCacheStatistics getStatistics()
          Allows abstraction away from the underlying implementation.
 User getUser(java.lang.String userName)
          Returns the cached User matching the directoryID and username.
 java.util.List<java.lang.String> getUserMembersOfGroup(java.lang.String groupName)
          Returns a list of user member names for a particular group.
 void handleEvent(com.atlassian.event.Event evt)
           
protected  boolean isEventForThisCache(com.atlassian.event.Event evt)
           
 java.lang.Boolean isGroupGroupMember(java.lang.String childGroup, java.lang.String parentGroup)
          Determines if a childGroup is a direct member of a parentGroup.
protected  java.lang.Boolean isMember(java.lang.String memberName, java.lang.String containerName, net.sf.ehcache.Cache membershipsCache, net.sf.ehcache.Cache membersCache, net.sf.ehcache.Cache booleanMembershipCache)
           
 java.lang.Boolean isUserGroupMember(java.lang.String userName, java.lang.String groupName)
          Determines if a user is a direct member of a group.
protected  void lockRead()
           
protected  void lockWrite()
           
protected  void removeAllRelations(java.lang.String entityName, net.sf.ehcache.Cache relationsCache, net.sf.ehcache.Cache inverseRelationsCache, net.sf.ehcache.Cache booleanMembershipCache, boolean isContainer)
           
protected  void removeCache(java.lang.String cacheName)
           
protected  void removeEntity(java.lang.String entityName, net.sf.ehcache.Cache entityCache, net.sf.ehcache.Cache entityNamesCache)
           
 void removeGroup(java.lang.String groupName)
          Removes a group (if it exists in the cache), along with any existing relationships of the group to users or groups.
 void removeGroupAsGroupMember(java.lang.String childGroup, java.lang.String parentGroup)
          Stores the fact that the childGroup is not a direct member of a parentGroup.
protected  void removeMembership(java.lang.String memberName, java.lang.String containerName, net.sf.ehcache.Cache membershipsCache, net.sf.ehcache.Cache membersCache, net.sf.ehcache.Cache booleanMembershipCache)
           
protected  void removeRelationship(java.lang.String entityName, java.lang.String relationName, net.sf.ehcache.Cache relationshipCache)
           
 void removeUser(java.lang.String userName)
          Removes a user (if it exists in the cache), along with any existing relationships of the user to groups or roles.
 void removeUserAsGroupMember(java.lang.String userName, java.lang.String groupName)
          Stores the fact that the user is not a direct member of a group.
 void setGroupAsGroupMember(java.lang.String childGroup, java.lang.String parentGroup)
          Stores the fact that the childGroup is a direct member of a parentGroup.
protected  void setMembershipFlag(java.lang.String memberName, java.lang.String containerName, boolean membershipFlag, net.sf.ehcache.Cache booleanMembershipCache)
           
 void setUserAsGroupMember(java.lang.String userName, java.lang.String groupName)
          Stores the fact that the user is a direct member of a group.
protected  void storeAllEntityNames(java.util.List<java.lang.String> entityNames, net.sf.ehcache.Cache entityNamesCache)
           
 void storeAllGroupNames(java.util.List<java.lang.String> groupNames)
          Store a complete list of all group names for the cached directory.
 void storeAllUserNames(java.util.List<java.lang.String> userNames)
          Store a complete list of all user names for the cached directory.
protected  void storeEntity(DirectoryEntity entity, net.sf.ehcache.Cache entityCache, net.sf.ehcache.Cache entityNamesCache)
           
 void storeGroup(Group group)
          Stores a clone of the supplied group object in the cache.
 void storeGroupMembershipsOfGroup(java.lang.String groupName, java.util.Collection<java.lang.String> parentGroupNames)
          Stores a list of direct group membership names for a particular group.
 void storeGroupMembershipsOfUser(java.lang.String userName, java.util.Collection<java.lang.String> groupNames)
          Stores a list of direct group membership names for a particular user.
 void storeGroupMembersOfGroup(java.lang.String groupName, java.util.Collection<java.lang.String> childGroupNames, boolean complete)
          Stores a list of group member names for a particular group.
protected  void storeMembers(java.lang.String containerName, java.util.Collection<java.lang.String> memberNames, net.sf.ehcache.Cache membersCache, net.sf.ehcache.Cache membershipsCache, net.sf.ehcache.Cache booleanMembershipCache, boolean complete)
          This first removes any existing relationships with the group (members, memberships, boolean membership) and then replaces them with the supplied member information.
protected  void storeMemberships(java.lang.String memberName, java.util.Collection<java.lang.String> membershipNames, net.sf.ehcache.Cache membershipsCache, net.sf.ehcache.Cache membersCache, net.sf.ehcache.Cache booleanMembershipCache)
           
 void storeUser(User user)
          Stores a clone of the supplied user object in the cache.
 void storeUserMembersOfGroup(java.lang.String groupName, java.util.Collection<java.lang.String> userNames, boolean complete)
          Stores a list of user member names for a particular group.
protected  void unlockRead()
           
protected  void unlockWrite()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.log4j.Logger logger

directoryId

protected final long directoryId

maxElementsInMemoryPerSubCache

protected final int maxElementsInMemoryPerSubCache

cacheManager

protected final net.sf.ehcache.CacheManager cacheManager

userCache

protected final net.sf.ehcache.Cache userCache

groupCache

protected final net.sf.ehcache.Cache groupCache

userNamesCache

protected final net.sf.ehcache.Cache userNamesCache

groupNamesCache

protected final net.sf.ehcache.Cache groupNamesCache

userGroupsCache

protected final net.sf.ehcache.Cache userGroupsCache

groupUsersCache

protected final net.sf.ehcache.Cache groupUsersCache

groupChildGroupsCache

protected final net.sf.ehcache.Cache groupChildGroupsCache

groupParentGroupsCache

protected final net.sf.ehcache.Cache groupParentGroupsCache

userGroupMembershipExistsCache

protected final net.sf.ehcache.Cache userGroupMembershipExistsCache

groupGroupMembershipExistsCache

protected final net.sf.ehcache.Cache groupGroupMembershipExistsCache
Constructor Detail

DefaultDirectoryCache

public DefaultDirectoryCache(long directoryId,
                             net.sf.ehcache.CacheManager ehcacheManager,
                             int maxElementsInMemoryPerSubCache)
Method Detail

createAndConfigureCache

protected net.sf.ehcache.Cache createAndConfigureCache(java.lang.String cacheName)

removeCache

protected void removeCache(java.lang.String cacheName)

lockRead

protected void lockRead()

unlockRead

protected void unlockRead()

lockWrite

protected void lockWrite()

unlockWrite

protected void unlockWrite()

clear

public void clear()
Description copied from interface: DirectoryCache
Clear the contents of the entire cache. All entities and relationships will be removed.

Specified by:
clear in interface DirectoryCache

doClear

protected void doClear()

close

public void close()
Description copied from interface: DirectoryCache
Close the cache and render it unuseable.

Specified by:
close in interface DirectoryCache

doClose

protected void doClose()

getKey

protected java.lang.String getKey(java.lang.String name)
Return a version of the name appropriate for use as a cache key.

The default implementation toLowers the name to produce a case-insensitive cache.

Parameters:
name - key.
Returns:
standardised key.

getKeys

protected java.util.Collection<java.lang.String> getKeys(java.util.Collection<java.lang.String> names)
Applies getKey over a collection.

Parameters:
names - set of names.
Returns:
collection of keys.

getEntity

protected java.lang.Object getEntity(java.lang.String name,
                                     net.sf.ehcache.Cache entityCache)
                              throws ObjectNotFoundException
Throws:
ObjectNotFoundException

getFromCache

protected java.lang.Object getFromCache(java.io.Serializable name,
                                        net.sf.ehcache.Cache cache)

getAllEntityNames

protected PartialSet<java.lang.String> getAllEntityNames(net.sf.ehcache.Cache entityNamesCache)

getAllEntityNamesAsList

protected java.util.List<java.lang.String> getAllEntityNamesAsList(net.sf.ehcache.Cache entityNamesCache)

storeAllEntityNames

protected void storeAllEntityNames(java.util.List<java.lang.String> entityNames,
                                   net.sf.ehcache.Cache entityNamesCache)

storeEntity

protected void storeEntity(DirectoryEntity entity,
                           net.sf.ehcache.Cache entityCache,
                           net.sf.ehcache.Cache entityNamesCache)

removeEntity

protected void removeEntity(java.lang.String entityName,
                            net.sf.ehcache.Cache entityCache,
                            net.sf.ehcache.Cache entityNamesCache)

removeAllRelations

protected void removeAllRelations(java.lang.String entityName,
                                  net.sf.ehcache.Cache relationsCache,
                                  net.sf.ehcache.Cache inverseRelationsCache,
                                  net.sf.ehcache.Cache booleanMembershipCache,
                                  boolean isContainer)

getRelationships

protected PartialSet<java.lang.String> getRelationships(java.lang.String entityName,
                                                        net.sf.ehcache.Cache relationshipCache)

getRelationshipsAsList

protected java.util.List<java.lang.String> getRelationshipsAsList(java.lang.String entityName,
                                                                  net.sf.ehcache.Cache relationshipCache)

getCompleteRelationshipsAsList

protected java.util.List<java.lang.String> getCompleteRelationshipsAsList(java.lang.String entityName,
                                                                          net.sf.ehcache.Cache relationshipCache,
                                                                          net.sf.ehcache.Cache entityCache)

removeRelationship

protected void removeRelationship(java.lang.String entityName,
                                  java.lang.String relationName,
                                  net.sf.ehcache.Cache relationshipCache)

addRelationship

protected void addRelationship(java.lang.String entityName,
                               java.lang.String relationName,
                               net.sf.ehcache.Cache relationshipCache)

setMembershipFlag

protected void setMembershipFlag(java.lang.String memberName,
                                 java.lang.String containerName,
                                 boolean membershipFlag,
                                 net.sf.ehcache.Cache booleanMembershipCache)

removeMembership

protected void removeMembership(java.lang.String memberName,
                                java.lang.String containerName,
                                net.sf.ehcache.Cache membershipsCache,
                                net.sf.ehcache.Cache membersCache,
                                net.sf.ehcache.Cache booleanMembershipCache)

addMembership

protected void addMembership(java.lang.String memberName,
                             java.lang.String containerName,
                             net.sf.ehcache.Cache membershipsCache,
                             net.sf.ehcache.Cache membersCache,
                             net.sf.ehcache.Cache booleanMembershipCache)

storeMembers

protected void storeMembers(java.lang.String containerName,
                            java.util.Collection<java.lang.String> memberNames,
                            net.sf.ehcache.Cache membersCache,
                            net.sf.ehcache.Cache membershipsCache,
                            net.sf.ehcache.Cache booleanMembershipCache,
                            boolean complete)
This first removes any existing relationships with the group (members, memberships, boolean membership) and then replaces them with the supplied member information.

The memberNames is allowed to be incomplete ONLY IF the missing memberNames are not stored in the cache at all (ie. the entities are not stored / the entities membership information is not stored). Therefore the memberNames ALWAYS represents the COMPLETE list of members the cache knows about (regardless of the "complete" flag).

The "complete" flag denotes that the collection is the complete list of memberNames in the entire directory for the container.

Parameters:
containerName - name of group.
memberNames - names of members.
membersCache - cache to put members, ie. groupName -> [memberNames]
membershipsCache - cache to put memberships, ie. memberName -> [groupNames]
booleanMembershipCache - cache to put boolean membership, ie. memberName, groupName -> TRUE
complete - if the collection of memberNames represents the complete/entire collection of direct members of the group.

storeMemberships

protected void storeMemberships(java.lang.String memberName,
                                java.util.Collection<java.lang.String> membershipNames,
                                net.sf.ehcache.Cache membershipsCache,
                                net.sf.ehcache.Cache membersCache,
                                net.sf.ehcache.Cache booleanMembershipCache)

isMember

protected java.lang.Boolean isMember(java.lang.String memberName,
                                     java.lang.String containerName,
                                     net.sf.ehcache.Cache membershipsCache,
                                     net.sf.ehcache.Cache membersCache,
                                     net.sf.ehcache.Cache booleanMembershipCache)

getUser

public User getUser(java.lang.String userName)
             throws ObjectNotFoundException
Description copied from interface: DirectoryCache
Returns the cached User matching the directoryID and username. If no user has been cached, null is returned. This signifies we do not know whether the user exists or not. If it is known that the user does not exist, an ObjectNotFoundException is thrown. For example, if a user is removed, a subsequent getUser call attempting to find the removed user will throw this exception. The returning user is a clone of user object in the cache. Callers are free to mutate the clone however they want.

Specified by:
getUser in interface DirectoryCache
Parameters:
userName - name of user to find.
Returns:
a clone of the cached user, if one exists, otherwise null.
Throws:
ObjectNotFoundException - if the object does not exist.

getAllUserNames

public java.util.List<java.lang.String> getAllUserNames()
Description copied from interface: DirectoryCache
Retrieves the complete collection of all user names for the cached directory or null if the complete list is not cached.

Specified by:
getAllUserNames in interface DirectoryCache
Returns:
complete list of all user names or null if the complete list is not cached.

storeAllUserNames

public void storeAllUserNames(java.util.List<java.lang.String> userNames)
Description copied from interface: DirectoryCache
Store a complete list of all user names for the cached directory.

Specified by:
storeAllUserNames in interface DirectoryCache
Parameters:
userNames - complete list of all user names.

storeUser

public void storeUser(User user)
Description copied from interface: DirectoryCache
Stores a clone of the supplied user object in the cache. If a user with the same name already exists in the cache, then it is silently replaced.

Specified by:
storeUser in interface DirectoryCache
Parameters:
user - user to cache.

removeUser

public void removeUser(java.lang.String userName)
Description copied from interface: DirectoryCache
Removes a user (if it exists in the cache), along with any existing relationships of the user to groups or roles. The cache entry will be marked so that subsequent calls to getUser(username) will throw an ObjectNotFoundException.

Specified by:
removeUser in interface DirectoryCache
Parameters:
userName - name of user to remove from cache.

getGroup

public Group getGroup(java.lang.String groupName)
               throws ObjectNotFoundException
Description copied from interface: DirectoryCache
Returns the cached Group matching the directoryID and groupName. If no group has been cached, null is returned. This signifies we do not know whether the group exists or not. If it is known that the group does not exist, an ObjectNotFoundException is thrown. For example, if a group is removed, a subsequent getGroup call attempting to find the removed group will throw this exception. The returning group is a clone of group object in the cache. Callers are free to mutate the clone however they want.

Specified by:
getGroup in interface DirectoryCache
Parameters:
groupName - name of group to find.
Returns:
a clone of the cached group, if one exists, otherwise null.
Throws:
ObjectNotFoundException - if the object does not exist.

getAllGroupNames

public java.util.List<java.lang.String> getAllGroupNames()
Description copied from interface: DirectoryCache
Retrieves the complete collection of all group names for the cached directory or null if the complete list is not cached.

Specified by:
getAllGroupNames in interface DirectoryCache
Returns:
complete list of all group names or null if the complete list is not cached.

storeAllGroupNames

public void storeAllGroupNames(java.util.List<java.lang.String> groupNames)
Description copied from interface: DirectoryCache
Store a complete list of all group names for the cached directory.

Specified by:
storeAllGroupNames in interface DirectoryCache
Parameters:
groupNames - complete list of all group names.

storeGroup

public void storeGroup(Group group)
Description copied from interface: DirectoryCache
Stores a clone of the supplied group object in the cache. If a group with the same name already exists in the cache, then it is silently replaced.

Specified by:
storeGroup in interface DirectoryCache
Parameters:
group - group to cache.

removeGroup

public void removeGroup(java.lang.String groupName)
Description copied from interface: DirectoryCache
Removes a group (if it exists in the cache), along with any existing relationships of the group to users or groups. The cache entry will be marked so that subsequent calls to getGroup(groupName) will throw an ObjectNotFoundException.

Specified by:
removeGroup in interface DirectoryCache
Parameters:
groupName - name of group to remove from cache.

getUserMembersOfGroup

public java.util.List<java.lang.String> getUserMembersOfGroup(java.lang.String groupName)
Description copied from interface: DirectoryCache
Returns a list of user member names for a particular group. The list reflects the complete, direct user members set for the group. If the cache does not have a complete set in memory (eg. it has a partial set), null is returned.

Specified by:
getUserMembersOfGroup in interface DirectoryCache
Parameters:
groupName - name of group to lookup.
Returns:
complete list of direct user member names OR null.

storeUserMembersOfGroup

public void storeUserMembersOfGroup(java.lang.String groupName,
                                    java.util.Collection<java.lang.String> userNames,
                                    boolean complete)
Description copied from interface: DirectoryCache
Stores a list of user member names for a particular group. If and only if the complete parameter is set to true, the collection of user names is assumed to be the complete collection of direct user members of the group. The usernames is allowed to be incomplete ONLY IF the missing usernames are not stored in the cache at all (ie. the entities are not stored / the entities membership information is not stored). Therefore the usernames ALWAYS represents the COMPLETE list of members the cache knows about (regardless of the "complete" flag). The "complete" flag denotes that the collection is the complete list of usernames in the entire directory for the group.

Specified by:
storeUserMembersOfGroup in interface DirectoryCache
Parameters:
groupName - name of the group.
userNames - collection of direct user members of the group.
complete - true if and only if the collection of direct user member names reflects the complete set of direct user members.

getGroupMembershipsOfUser

public java.util.List<java.lang.String> getGroupMembershipsOfUser(java.lang.String userName)
Description copied from interface: DirectoryCache
Returns a list of group membership names for a particular user. The list reflects the complete, direct group membership set for the user. If the cache does not have a complete set in memory (eg. it has a partial set), null is returned.

Specified by:
getGroupMembershipsOfUser in interface DirectoryCache
Parameters:
userName - name of user to lookup.
Returns:
complete list of direct group membership names OR null.

storeGroupMembershipsOfUser

public void storeGroupMembershipsOfUser(java.lang.String userName,
                                        java.util.Collection<java.lang.String> groupNames)
Description copied from interface: DirectoryCache
Stores a list of direct group membership names for a particular user. The collection of group names is assumed to be the complete collection of direct group memberships of the user.

Specified by:
storeGroupMembershipsOfUser in interface DirectoryCache
Parameters:
userName - name of the user.
groupNames - collection of direct group memberships of the user. group membership names reflects the complete set of direct group memberships.

isUserGroupMember

public java.lang.Boolean isUserGroupMember(java.lang.String userName,
                                           java.lang.String groupName)
Description copied from interface: DirectoryCache
Determines if a user is a direct member of a group.

Specified by:
isUserGroupMember in interface DirectoryCache
Parameters:
userName - name of user.
groupName - name of group.
Returns:
true iff the user is a direct member of the group, false iff the user is not a direct member of the group, null iff there is insufficient information in the cache to determine whether the user is a direct member of the group or not.

setUserAsGroupMember

public void setUserAsGroupMember(java.lang.String userName,
                                 java.lang.String groupName)
Description copied from interface: DirectoryCache
Stores the fact that the user is a direct member of a group.

Specified by:
setUserAsGroupMember in interface DirectoryCache
Parameters:
userName - name of user.
groupName - name of group.

removeUserAsGroupMember

public void removeUserAsGroupMember(java.lang.String userName,
                                    java.lang.String groupName)
Description copied from interface: DirectoryCache
Stores the fact that the user is not a direct member of a group.

Specified by:
removeUserAsGroupMember in interface DirectoryCache
Parameters:
userName - name of user.
groupName - name of group.

getGroupMembersOfGroup

public java.util.List<java.lang.String> getGroupMembersOfGroup(java.lang.String groupName)
Description copied from interface: DirectoryCache
Returns a list of child group member names for a particular group. The list reflects the complete, direct child group members set for the group. If the cache does not have a complete set in memory (eg. it has a partial set), null is returned.

Specified by:
getGroupMembersOfGroup in interface DirectoryCache
Parameters:
groupName - name of parent group to lookup.
Returns:
complete list of direct child group member names OR null.

storeGroupMembersOfGroup

public void storeGroupMembersOfGroup(java.lang.String groupName,
                                     java.util.Collection<java.lang.String> childGroupNames,
                                     boolean complete)
Description copied from interface: DirectoryCache
Stores a list of group member names for a particular group. If and only if the complete parameter is set to true, the collection of group names is assumed to be the complete collection of direct group members of the group. The childGroupNames is allowed to be incomplete ONLY IF the missing childGroupNames are not stored in the cache at all (ie. the entities are not stored / the entities membership information is not stored). Therefore the childGroupNames ALWAYS represents the COMPLETE list of members the cache knows about (regardless of the "complete" flag). The "complete" flag denotes that the collection is the complete list of childGroupNames in the entire directory for the group.

Specified by:
storeGroupMembersOfGroup in interface DirectoryCache
Parameters:
groupName - name of the group.
childGroupNames - collection of direct group members of the group.
complete - true if and only if the collection of direct group member names reflects the complete set of direct group members.

getGroupMembershipsOfGroup

public java.util.List<java.lang.String> getGroupMembershipsOfGroup(java.lang.String groupName)
Description copied from interface: DirectoryCache
Returns a list of group membership names for a particular group. The list reflects the complete, direct group membership set for the group. If the cache does not have a complete set in memory (eg. it has a partial set), null is returned.

Specified by:
getGroupMembershipsOfGroup in interface DirectoryCache
Parameters:
groupName - name of group to lookup.
Returns:
complete list of direct group membership names OR null.

storeGroupMembershipsOfGroup

public void storeGroupMembershipsOfGroup(java.lang.String groupName,
                                         java.util.Collection<java.lang.String> parentGroupNames)
Description copied from interface: DirectoryCache
Stores a list of direct group membership names for a particular group. The collection of group names is assumed to be the complete collection of direct parent group memberships of the child group.

Specified by:
storeGroupMembershipsOfGroup in interface DirectoryCache
Parameters:
groupName - name of the child group.
parentGroupNames - collection of direct group memberships of the child group. group membership names reflects the complete set of direct group memberships.

isGroupGroupMember

public java.lang.Boolean isGroupGroupMember(java.lang.String childGroup,
                                            java.lang.String parentGroup)
Description copied from interface: DirectoryCache
Determines if a childGroup is a direct member of a parentGroup.

Specified by:
isGroupGroupMember in interface DirectoryCache
Parameters:
childGroup - name of child group.
parentGroup - name of parent group.
Returns:
true iff the childGroup is a direct member of the parentGroup, false iff the childGroup is not a direct member of the parentGroup, null iff there is insufficient information in the cache to determine whether the childGroup is a direct member of the parentGroup or not.

setGroupAsGroupMember

public void setGroupAsGroupMember(java.lang.String childGroup,
                                  java.lang.String parentGroup)
Description copied from interface: DirectoryCache
Stores the fact that the childGroup is a direct member of a parentGroup.

Specified by:
setGroupAsGroupMember in interface DirectoryCache
Parameters:
childGroup - name of child group.
parentGroup - name of parent group.

removeGroupAsGroupMember

public void removeGroupAsGroupMember(java.lang.String childGroup,
                                     java.lang.String parentGroup)
Description copied from interface: DirectoryCache
Stores the fact that the childGroup is not a direct member of a parentGroup.

Specified by:
removeGroupAsGroupMember in interface DirectoryCache
Parameters:
childGroup - name of child group.
parentGroup - name of parent group.

isEventForThisCache

protected boolean isEventForThisCache(com.atlassian.event.Event evt)

doHandleEvent

protected boolean doHandleEvent(com.atlassian.event.Event evt)

handleEvent

public void handleEvent(com.atlassian.event.Event evt)
Specified by:
handleEvent in interface com.atlassian.event.EventListener

getHandledEventClasses

public java.lang.Class[] getHandledEventClasses()
Specified by:
getHandledEventClasses in interface com.atlassian.event.EventListener

getStatistics

public DirectoryCacheStatistics getStatistics()
Allows abstraction away from the underlying implementation.

Specified by:
getStatistics in interface DirectoryCache
Returns:


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.