public class CachingMembershipDao extends Object implements InternalMembershipDao
InternalMembershipDao
.Constructor and Description |
---|
CachingMembershipDao(InternalMembershipDao delegate,
MembershipCache membershipCache) |
Modifier and Type | Method and Description |
---|---|
BatchResult<InternalMembership> |
addAll(Set<InternalMembership> memberships)
Bulk add of memberships.
|
BatchResult<String> |
addAllUsersToGroup(long directoryId,
Collection<String> userNames,
String groupName)
Bulk adds all the given users into the given group.
|
void |
addGroupToGroup(long directoryId,
String childGroup,
String parentGroup)
Adds group as a child of the (supposedly) parent group.
|
void |
addUserToGroup(long directoryId,
String userName,
String groupName)
Adds user as a member of group.
|
BatchResult<String> |
addUserToGroups(long directoryId,
String username,
Set<String> groupNames)
Add many groups to a user
|
void |
clearCache() |
BoundedCount |
countDirectMembersOfGroup(long directoryId,
String groupName,
int potentialMaxCount)
Count the direct members of a group with a recommended upper bound on the count.
|
List<InternalMembership> |
getMembershipsCreatedAfter(long directoryId,
Date timestamp,
int maxResults)
Retrieves memberships with the creation timestamp greater than the specified date
|
boolean |
isGroupDirectMember(long directoryId,
String childGroup,
String parentGroup)
Determines whether the group is a direct member of the (supposedly) parent group.
|
boolean |
isUserDirectMember(long directoryId,
String userName,
String groupName)
Determines whether the user is a direct member of the group.
|
void |
removeAllRelationships(long directoryId)
Removes all relationships the the given directory identified by directory id.
|
void |
removeAllUserRelationships(long directoryId)
Removes all user relationships the the given directory identified by directory id.
|
void |
removeGroupFromGroup(long directoryId,
String childGroup,
String parentGroup)
Removes group from the parent group.
|
void |
removeGroupMembers(long directoryId,
String groupName)
Removes all members of the given group name.
|
void |
removeGroupMemberships(long directoryId,
String groupName)
Removes all relationships from parent groups to the given group name.
|
void |
removeUserFromGroup(long directoryId,
String userName,
String groupName)
Removes user as a member of the given group.
|
void |
removeUserMemberships(long directoryId,
String username)
Removes all
MembershipType.GROUP_USER relationships
from parent groups to the given username. |
void |
renameGroupRelationships(long directoryId,
String oldName,
String newName)
Renames group name in all relationships.
|
void |
renameUserRelationships(long directoryId,
String oldName,
String newName)
Renames username in all relationships.
|
<T> List<T> |
search(long directoryId,
MembershipQuery<T> query)
Search for memberships by the given criteria.
|
<T> com.google.common.collect.ListMultimap<String,T> |
searchGroupedByName(long directoryId,
MembershipQuery<T> query)
Search for memberships by the given criteria.
|
protected <T> boolean |
shouldCache(MembershipQuery<T> query) |
public CachingMembershipDao(InternalMembershipDao delegate, MembershipCache membershipCache)
public void removeGroupMembers(long directoryId, String groupName)
InternalMembershipDao
removeGroupMembers
in interface InternalMembershipDao
directoryId
- Directory id.groupName
- Group name.public void removeGroupMemberships(long directoryId, String groupName)
InternalMembershipDao
removeGroupMemberships
in interface InternalMembershipDao
directoryId
- Directory id.groupName
- Group name.public void removeUserMemberships(long directoryId, String username)
InternalMembershipDao
MembershipType.GROUP_USER
relationships
from parent groups to the given username.removeUserMemberships
in interface InternalMembershipDao
directoryId
- Directory id.username
- Username.public void removeAllRelationships(long directoryId)
InternalMembershipDao
removeAllRelationships
in interface InternalMembershipDao
directoryId
- Directory id.public void removeAllUserRelationships(long directoryId)
InternalMembershipDao
removeAllUserRelationships
in interface InternalMembershipDao
directoryId
- Directory id.public void renameUserRelationships(long directoryId, String oldName, String newName)
InternalMembershipDao
renameUserRelationships
in interface InternalMembershipDao
directoryId
- Directory id.oldName
- Old username.newName
- New username.public void renameGroupRelationships(long directoryId, String oldName, String newName)
InternalMembershipDao
renameGroupRelationships
in interface InternalMembershipDao
directoryId
- Directory id.oldName
- Old group name.newName
- New group name.public BatchResult<InternalMembership> addAll(Set<InternalMembership> memberships)
InternalMembershipDao
addAll
in interface InternalMembershipDao
memberships
- Set of memberships.public List<InternalMembership> getMembershipsCreatedAfter(long directoryId, Date timestamp, int maxResults)
InternalMembershipDao
getMembershipsCreatedAfter
in interface InternalMembershipDao
directoryId
- the id of the directory to searchtimestamp
- the date to limit the search bymaxResults
- the maximum number of results to returnpublic boolean isUserDirectMember(long directoryId, String userName, String groupName)
MembershipDao
isUserDirectMember
in interface MembershipDao
directoryId
- the directory to perform the operationuserName
- usergroupName
- grouppublic boolean isGroupDirectMember(long directoryId, String childGroup, String parentGroup)
MembershipDao
isGroupDirectMember
in interface MembershipDao
directoryId
- the directory to perform the operationchildGroup
- child groupparentGroup
- parent grouppublic void addUserToGroup(long directoryId, String userName, String groupName) throws UserNotFoundException, GroupNotFoundException, MembershipAlreadyExistsException
MembershipDao
addUserToGroup
in interface MembershipDao
directoryId
- the directory to perform the operationuserName
- usergroupName
- groupUserNotFoundException
- if the user does not existGroupNotFoundException
- if the group does not existMembershipAlreadyExistsException
- if the user is already a direct member of the grouppublic BatchResult<String> addAllUsersToGroup(long directoryId, Collection<String> userNames, String groupName) throws GroupNotFoundException
MembershipDao
addAllUsersToGroup
in interface MembershipDao
directoryId
- the directory to perform the operationuserNames
- the collection of usersgroupName
- name of the groupGroupNotFoundException
- if the group does not existpublic void addGroupToGroup(long directoryId, String childGroup, String parentGroup) throws GroupNotFoundException, MembershipAlreadyExistsException
MembershipDao
addGroupToGroup
in interface MembershipDao
directoryId
- the directory to perform the operationchildGroup
- the (supposedly) child groupparentGroup
- parent groupGroupNotFoundException
- if either child or parent group is not foundMembershipAlreadyExistsException
- if the child group is already a child of the parent grouppublic void removeUserFromGroup(long directoryId, String userName, String groupName) throws UserNotFoundException, GroupNotFoundException, MembershipNotFoundException
MembershipDao
removeUserFromGroup
in interface MembershipDao
directoryId
- the directory to perform the operationuserName
- usergroupName
- groupUserNotFoundException
- if the user does not existGroupNotFoundException
- if the group does not existMembershipNotFoundException
- if the user is not a member of the said grouppublic void removeGroupFromGroup(long directoryId, String childGroup, String parentGroup) throws GroupNotFoundException, MembershipNotFoundException
MembershipDao
removeGroupFromGroup
in interface MembershipDao
directoryId
- the directory to perform the operationchildGroup
- child groupparentGroup
- parent groupGroupNotFoundException
- if either child or parent group does not existMembershipNotFoundException
- if the membership relationship between the child and parent group does not existpublic <T> List<T> search(long directoryId, MembershipQuery<T> query)
MembershipDao
search
in interface MembershipDao
directoryId
- the directory to perform the operationquery
- criteriapublic <T> com.google.common.collect.ListMultimap<String,T> searchGroupedByName(long directoryId, MembershipQuery<T> query)
MembershipDao
MembershipQuery.getEntityNamesToMatch()
.searchGroupedByName
in interface MembershipDao
directoryId
- the directory to perform the operationquery
- criteriapublic BoundedCount countDirectMembersOfGroup(long directoryId, String groupName, int potentialMaxCount)
MembershipDao
Count the direct members of a group with a recommended upper bound on the count.
The upper bound is there so that, in directories that do not support efficient counting of memberships, less work may be performed.
Important: Please note that any directory wishing to implement this method should make it as efficient as possible. Such that an administrator could land on a page that showed ~20 groups, run this method once per group, and it would still return results as efficiently as possible.
countDirectMembersOfGroup
in interface MembershipDao
directoryId
- the directory to perform the operationgroupName
- the name of the group to search forpotentialMaxCount
- a suggested minimum number of elements for the implementation to count. The implementation
will only use this number if it can get efficiency benefits; otherwise this number may be ignored.BoundedCount.exactly(long)
0 will be returned.public BatchResult<String> addUserToGroups(long directoryId, String username, Set<String> groupNames) throws UserNotFoundException
InternalMembershipDao
This method assumes that groups and user already exist.
Default implementation is not-optimal in respect of number of DB queries. Reference optimal implementation for Hibernate5 is located in crowd-persistance-hibernate5.
addUserToGroups
in interface InternalMembershipDao
directoryId
- the id of the directory to which user and groups belongusername
- username of the user to whom we add groupsgroupNames
- names of the group to add to a user. The groups need to exist in the directoryUserNotFoundException
- when user with a given username
does not exist in the directory with
directoryId
idprotected <T> boolean shouldCache(MembershipQuery<T> query)
public void clearCache()
Copyright © 2021 Atlassian. All rights reserved.