com.atlassian.crowd.integration.service.cache
Class CacheImpl

java.lang.Object
  extended by com.atlassian.crowd.integration.service.cache.CacheImpl
All Implemented Interfaces:
BasicCache

public class CacheImpl
extends java.lang.Object
implements BasicCache


Constructor Summary
CacheImpl(net.sf.ehcache.CacheManager ehCacheManager)
           
CacheImpl(java.net.URL configLocation)
           
 
Method Summary
 void addGroupToUser(java.lang.String userName, java.lang.String groupName)
           
 void addIsUserOrGroup(java.lang.String name, java.lang.Boolean isValidUserOrGroup)
           
 void addOrReplaceAllGroupNames(java.util.List groupNames)
          Adds, or if it already exists, replaces the list of all group names.
 void addOrReplaceAllMembers(java.lang.String groupName, java.util.List userNames)
          Cache a list of all users in this group.
 void addOrReplaceAllMemberships(java.lang.String userName, java.util.List groupNames)
          Cache a list of all groups this user belongs to.
 void addOrReplaceAllUserNames(java.util.List userNames)
          Adds a list of all users, or if one already exists, replaces it.
 void addOrReplaceGroup(SOAPGroup group)
          Adds a group, or if it exists, replaces the old SOAPGroup instance.
 void addOrReplaceUser(SOAPPrincipal user)
          Adds, or if they exist, replaces an existing user.
 void addParentForGroup(java.lang.String childGroup, java.lang.String parentGroup)
          Makes the underlying cache aware of the fact that childGroup is a member of parentGroup
 void addToAllGroupNamesCache(java.lang.String groupName)
          If we have a list of all groups, when we add one we should update the list.
 void addToAllUsers(java.lang.String userName)
          Adds userName to the list of all users in the system.
 void addUserToGroup(java.lang.String userName, java.lang.String groupName)
           
 boolean containsGroupRelationships()
          Returns true if the cache contains enough information to reliably compute parent group relationships.
 void flush()
          Clears the caches
 java.util.List getAllGroupNames()
          Returns a List of Strings containing all group names, or null if the list is not cached.
 java.util.List getAllMembers(java.lang.String groupName)
          Returns a list of users that belong to groupName belongs to, or null if there aren't any.
 java.util.List getAllMemberships(java.lang.String userName)
          Returns a list of groups that userName belongs to, or null if they don't belong to any.
 java.util.List getAllUserNames()
          Returns a List with all user names, or null if none are cached.
 SOAPGroup getGroup(java.lang.String groupName)
          Returns the group, or null if it's not in the cache.
 java.util.List getParentGroups(java.lang.String childGroup)
          Returns the list of groups that are registered as parents for this group.
 SOAPPrincipal getUser(java.lang.String userName)
          Returns the SOAPPrincipal representing userName, or null if it's not in the cache.
 java.lang.Boolean isMember(java.lang.String userName, java.lang.String groupName)
          Maintains a list of true/false for "is this user a member of this group".
 java.lang.Boolean isMemberInGroupCache(java.lang.String userName, java.lang.String groupName)
          Checks the group->user cache to see if the user is a member.
 java.lang.Boolean isUserOrGroup(java.lang.String name)
          Will return true is the string represents a user or group
 void removeAllMembers(java.lang.String groupName)
          Removes the list of users in the group.
 void removeAllMemberships(java.lang.String userName)
          Called by CachingUserManager.removeUser(String) to ensure the users details are removed from any and all user->groups and (user+group)->[yes,no] caches.
 void removeAllMembershipsFromUserMembershipsCache(java.lang.String userName)
          Removes the list of groups the user belongs to.
 void removeCachedGroupMembership(java.lang.String userName, java.lang.String groupName)
          Removes all the membership details for this specific userName, groupName pair, when a group is being removed.
 void removeCachedGroupMemberships(java.lang.String groupName)
          Called by CachingGroupManager.removeGroup(String) to ensure the group details are removed from any and all user->groups and (user+group)->[yes,no] caches.
 void removeCachedUser(java.lang.String userName, java.lang.String groupName)
           
 void removeFromAllGroupNamesCache(java.lang.String groupName)
          When we remove a group, if we have already cached the list of all available groups, we need to remove this group.
 void removeFromAllUsers(java.lang.String userName)
           
 void removeGroup(java.lang.String groupName)
          Removes the group, if it exists
 void removeGroupFromUser(java.lang.String userName, java.lang.String groupName)
           
 void removeMembership(java.lang.String userName, java.lang.String groupName)
          Remove any stored [yes,no] membership relationship for a userName & groupName combination.
 boolean removeUser(java.lang.String userName)
          Removes the user from the cache.
 void removeUserFromGroup(java.lang.String userName, java.lang.String groupName)
           
 java.util.List setMembers(java.lang.String groupName, java.lang.String[] userNameArray)
          Caches the member list for a group called groupName.
 void setMembership(java.lang.String userName, java.lang.String groupName, java.lang.Boolean isMember)
          Adds or replaces a membership relationship between the user and the group.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheImpl

public CacheImpl(java.net.URL configLocation)

CacheImpl

public CacheImpl(net.sf.ehcache.CacheManager ehCacheManager)
Method Detail

flush

public void flush()
Clears the caches

Specified by:
flush in interface BasicCache

addOrReplaceUser

public void addOrReplaceUser(SOAPPrincipal user)
Description copied from interface: BasicCache
Adds, or if they exist, replaces an existing user.

Specified by:
addOrReplaceUser in interface BasicCache

removeUser

public boolean removeUser(java.lang.String userName)
Description copied from interface: BasicCache
Removes the user from the cache.

Specified by:
removeUser in interface BasicCache
Returns:
true if the user was cached, false otherwise.

getUser

public SOAPPrincipal getUser(java.lang.String userName)
Description copied from interface: BasicCache
Returns the SOAPPrincipal representing userName, or null if it's not in the cache.

Specified by:
getUser in interface BasicCache
Returns:

getAllUserNames

public java.util.List getAllUserNames()
Description copied from interface: BasicCache
Returns a List with all user names, or null if none are cached.

Specified by:
getAllUserNames in interface BasicCache
Returns:

addOrReplaceAllUserNames

public void addOrReplaceAllUserNames(java.util.List userNames)
Description copied from interface: BasicCache
Adds a list of all users, or if one already exists, replaces it.

Specified by:
addOrReplaceAllUserNames in interface BasicCache

getGroup

public SOAPGroup getGroup(java.lang.String groupName)
Description copied from interface: BasicCache
Returns the group, or null if it's not in the cache.

Specified by:
getGroup in interface BasicCache
Returns:

addOrReplaceGroup

public void addOrReplaceGroup(SOAPGroup group)
Description copied from interface: BasicCache
Adds a group, or if it exists, replaces the old SOAPGroup instance.

Specified by:
addOrReplaceGroup in interface BasicCache

removeGroup

public void removeGroup(java.lang.String groupName)
Description copied from interface: BasicCache
Removes the group, if it exists

Specified by:
removeGroup in interface BasicCache

getAllGroupNames

public java.util.List getAllGroupNames()
Description copied from interface: BasicCache
Returns a List of Strings containing all group names, or null if the list is not cached.

Specified by:
getAllGroupNames in interface BasicCache
Returns:

addOrReplaceAllGroupNames

public void addOrReplaceAllGroupNames(java.util.List groupNames)
Description copied from interface: BasicCache
Adds, or if it already exists, replaces the list of all group names.

Specified by:
addOrReplaceAllGroupNames in interface BasicCache

addParentForGroup

public void addParentForGroup(java.lang.String childGroup,
                              java.lang.String parentGroup)
Description copied from interface: BasicCache
Makes the underlying cache aware of the fact that childGroup is a member of parentGroup

Specified by:
addParentForGroup in interface BasicCache

getParentGroups

public java.util.List getParentGroups(java.lang.String childGroup)
Description copied from interface: BasicCache
Returns the list of groups that are registered as parents for this group.

Specified by:
getParentGroups in interface BasicCache
Returns:

containsGroupRelationships

public boolean containsGroupRelationships()
Returns true if the cache contains enough information to reliably compute parent group relationships. If not, returns false.

Specified by:
containsGroupRelationships in interface BasicCache
Returns:

isMemberInGroupCache

public java.lang.Boolean isMemberInGroupCache(java.lang.String userName,
                                              java.lang.String groupName)
Checks the group->user cache to see if the user is a member.

Specified by:
isMemberInGroupCache in interface BasicCache
Parameters:
userName -
groupName -
Returns:
Boolean.TRUE if the user is a member. Boolean.FALSE if not. null if we don't have enough information to tell.

addGroupToUser

public void addGroupToUser(java.lang.String userName,
                           java.lang.String groupName)
Specified by:
addGroupToUser in interface BasicCache

addUserToGroup

public void addUserToGroup(java.lang.String userName,
                           java.lang.String groupName)
Specified by:
addUserToGroup in interface BasicCache

removeGroupFromUser

public void removeGroupFromUser(java.lang.String userName,
                                java.lang.String groupName)
Specified by:
removeGroupFromUser in interface BasicCache

removeUserFromGroup

public void removeUserFromGroup(java.lang.String userName,
                                java.lang.String groupName)
Specified by:
removeUserFromGroup in interface BasicCache

setMembers

public java.util.List setMembers(java.lang.String groupName,
                                 java.lang.String[] userNameArray)
Caches the member list for a group called groupName. Since group member information arrives when the group is fetched from the Crowd server, this is also called from CachingGroupManager.getGroup(String).

Specified by:
setMembers in interface BasicCache
Parameters:
groupName -
userNameArray -

removeCachedGroupMembership

public void removeCachedGroupMembership(java.lang.String userName,
                                        java.lang.String groupName)
Removes all the membership details for this specific userName, groupName pair, when a group is being removed.

Specified by:
removeCachedGroupMembership in interface BasicCache
Parameters:
userName -
groupName -

removeCachedGroupMemberships

public void removeCachedGroupMemberships(java.lang.String groupName)
Called by CachingGroupManager.removeGroup(String) to ensure the group details are removed from any and all user->groups and (user+group)->[yes,no] caches.

Specified by:
removeCachedGroupMemberships in interface BasicCache
Parameters:
groupName -

removeFromAllGroupNamesCache

public void removeFromAllGroupNamesCache(java.lang.String groupName)
When we remove a group, if we have already cached the list of all available groups, we need to remove this group.

Specified by:
removeFromAllGroupNamesCache in interface BasicCache
Parameters:
groupName -

addToAllGroupNamesCache

public void addToAllGroupNamesCache(java.lang.String groupName)
If we have a list of all groups, when we add one we should update the list.

Specified by:
addToAllGroupNamesCache in interface BasicCache
Parameters:
groupName -

removeCachedUser

public void removeCachedUser(java.lang.String userName,
                             java.lang.String groupName)
Specified by:
removeCachedUser in interface BasicCache

removeAllMemberships

public void removeAllMemberships(java.lang.String userName)
Called by CachingUserManager.removeUser(String) to ensure the users details are removed from any and all user->groups and (user+group)->[yes,no] caches.

Specified by:
removeAllMemberships in interface BasicCache
Parameters:
userName -

setMembership

public void setMembership(java.lang.String userName,
                          java.lang.String groupName,
                          java.lang.Boolean isMember)
Description copied from interface: BasicCache
Adds or replaces a membership relationship between the user and the group. Updates the list of memberships returned by getAllMemberships() to keep them in sync.

Specified by:
setMembership in interface BasicCache
isMember - true if the user is a member, false if not.

removeMembership

public void removeMembership(java.lang.String userName,
                             java.lang.String groupName)
Description copied from interface: BasicCache
Remove any stored [yes,no] membership relationship for a userName & groupName combination.

Specified by:
removeMembership in interface BasicCache

isMember

public java.lang.Boolean isMember(java.lang.String userName,
                                  java.lang.String groupName)
Description copied from interface: BasicCache
Maintains a list of true/false for "is this user a member of this group". Returns null if no information is cached.

Specified by:
isMember in interface BasicCache
Returns:

getAllMemberships

public java.util.List getAllMemberships(java.lang.String userName)
Description copied from interface: BasicCache
Returns a list of groups that userName belongs to, or null if they don't belong to any.

Specified by:
getAllMemberships in interface BasicCache
Returns:

addOrReplaceAllMemberships

public void addOrReplaceAllMemberships(java.lang.String userName,
                                       java.util.List groupNames)
Description copied from interface: BasicCache
Cache a list of all groups this user belongs to.

Specified by:
addOrReplaceAllMemberships in interface BasicCache

removeAllMembershipsFromUserMembershipsCache

public void removeAllMembershipsFromUserMembershipsCache(java.lang.String userName)
Description copied from interface: BasicCache
Removes the list of groups the user belongs to. Used when the user is being deleted.

Specified by:
removeAllMembershipsFromUserMembershipsCache in interface BasicCache

getAllMembers

public java.util.List getAllMembers(java.lang.String groupName)
Description copied from interface: BasicCache
Returns a list of users that belong to groupName belongs to, or null if there aren't any.

Specified by:
getAllMembers in interface BasicCache
Returns:

addOrReplaceAllMembers

public void addOrReplaceAllMembers(java.lang.String groupName,
                                   java.util.List userNames)
Description copied from interface: BasicCache
Cache a list of all users in this group.

Specified by:
addOrReplaceAllMembers in interface BasicCache

removeAllMembers

public void removeAllMembers(java.lang.String groupName)
Description copied from interface: BasicCache
Removes the list of users in the group. Used when the group is being deleted.

Specified by:
removeAllMembers in interface BasicCache

isUserOrGroup

public java.lang.Boolean isUserOrGroup(java.lang.String name)
Description copied from interface: BasicCache
Will return true is the string represents a user or group

Specified by:
isUserOrGroup in interface BasicCache

addIsUserOrGroup

public void addIsUserOrGroup(java.lang.String name,
                             java.lang.Boolean isValidUserOrGroup)
Specified by:
addIsUserOrGroup in interface BasicCache

addToAllUsers

public void addToAllUsers(java.lang.String userName)
Adds userName to the list of all users in the system.

Specified by:
addToAllUsers in interface BasicCache
Parameters:
userName -

removeFromAllUsers

public void removeFromAllUsers(java.lang.String userName)
Specified by:
removeFromAllUsers in interface BasicCache


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.