public class MembershipDAOHibernate extends HibernateDao<InternalMembership> implements MembershipDao, InternalMembershipDao
batchFinder, batchProcessor, logger, statelessSessionBatchProcessor, timeSource
sessionFactory
Constructor and Description |
---|
MembershipDAOHibernate() |
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.
|
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> |
findAll(Collection<Directory> directories) |
List<InternalMembership> |
findAllLocal(Collection<Directory> directories) |
List<InternalMembership> |
getMembershipsCreatedAfter(long directoryId,
Date timestamp,
int maxResults)
Retrieves memberships with the creation timestamp greater than the specified date
|
Class<InternalMembership> |
getPersistentClass()
All subclasses of HibernateDao must implement this method for
HibernateDao.load(Serializable) to work
correctly. |
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.
|
void |
setAuditProcessor(MembershipAuditProcessor auditProcessor) |
void |
setGroupDao(InternalGroupDao groupDao) |
void |
setHqlQueryTranslater(HQLQueryTranslater hqlQueryTranslater) |
void |
setUserDao(InternalUserDao userDao) |
createDeleteQuery, createDeleteQuery, createQuery, createQuery, executeHQLQuery, executeHQLQuery, findAllInternal, findByProperties, findByPropertiesOptional, findByProperty, findByProperty, findByPropertyOptional, findByPropertyOrThrow, getCountByProperties, load, load, loadOptional, loadReference, loadReference, remove, removeByIdIfPresent, save, saveOrUpdate, session, setBatchFinder, setBatchProcessor, setClock, setStatelessSessionBatchProcessor, toPredicates, update
setSessionFactory, withStatelessSession
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 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 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 List<InternalMembership> findAll(Collection<Directory> directories)
directories
- directories to search for membershipspublic List<InternalMembership> findAllLocal(Collection<Directory> directories)
directories
- directories to search for membershipspublic Class<InternalMembership> getPersistentClass()
HibernateDao
HibernateDao.load(Serializable)
to work
correctly.getPersistentClass
in class HibernateDao<InternalMembership>
public boolean isGroupDirectMember(long directoryId, String childGroup, String parentGroup)
MembershipDao
isGroupDirectMember
in interface MembershipDao
directoryId
- the directory to perform the operationchildGroup
- child groupparentGroup
- parent grouppublic boolean isUserDirectMember(long directoryId, String username, String groupName)
MembershipDao
isUserDirectMember
in interface MembershipDao
directoryId
- the directory to perform the operationusername
- usergroupName
- grouppublic 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 removeGroupFromGroup(long directoryId, String childGroup, String parentGroup) throws MembershipNotFoundException
MembershipDao
removeGroupFromGroup
in interface MembershipDao
directoryId
- the directory to perform the operationchildGroup
- child groupparentGroup
- parent groupMembershipNotFoundException
- if the membership relationship between the child and parent group does not existpublic 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 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 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 renameGroupRelationships(long directoryId, String oldName, String newName)
InternalMembershipDao
renameGroupRelationships
in interface InternalMembershipDao
directoryId
- Directory id.oldName
- Old group name.newName
- New group name.public void renameUserRelationships(long directoryId, String oldName, String newName)
InternalMembershipDao
renameUserRelationships
in interface InternalMembershipDao
directoryId
- Directory id.oldName
- Old username.newName
- New username.public 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 <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
- criteria@Autowired public void setGroupDao(InternalGroupDao groupDao)
@Autowired public void setHqlQueryTranslater(HQLQueryTranslater hqlQueryTranslater)
@Autowired public void setUserDao(InternalUserDao userDao)
@Autowired public void setAuditProcessor(@Qualifier(value="membershipAuditProcessor") MembershipAuditProcessor auditProcessor)
Copyright © 2020 Atlassian. All rights reserved.