Package com.atlassian.crowd.dao.group
Class GroupDAOHibernate
java.lang.Object
com.atlassian.crowd.util.persistence.hibernate.StatelessDao
com.atlassian.crowd.util.persistence.hibernate.HibernateDao<InternalGroup>
com.atlassian.crowd.util.persistence.hibernate.InternalDirectoryEntityHibernateDao<InternalGroup,InternalGroupAttribute>
com.atlassian.crowd.dao.group.GroupDAOHibernate
- All Implemented Interfaces:
InternalGroupDao,GroupDao
public class GroupDAOHibernate
extends InternalDirectoryEntityHibernateDao<InternalGroup,InternalGroupAttribute>
implements InternalGroupDao, GroupDao
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
batchFinder, batchProcessor, logger, statelessSessionBatchProcessor, timeSourceFields inherited from class com.atlassian.crowd.util.persistence.hibernate.StatelessDao
sessionFactory -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a new group.addAll(Collection<InternalGroupWithAttributes> groups) Bulk add of groups and their attributes.Bulk add of groups.voidaddAttribute(InternalGroup group, String attributeName, String attributeValue) Add a new local group.findByExternalIds(long directoryId, Set<String> externalIds) Searches the specified directory for group names of groups with the specified external idsfindByIds(Collection<Long> groupIds) Bulk find of groups with the specified database identifiers.findByName(long directoryId, String groupName) Finds internal group by directory id and group name.findByNames(long directoryID, Collection<String> groupnames) Bulk find of groups using SQL disjunction.findByNameWithAttributes(long directoryId, String groupName) Finds group by name.findExternalIdsByNames(long directoryId, Set<String> groupNames) Searches the specified directory for externalIds of groups with the specified namesfindGroupAttributes(long groupId) Finds group attributes of the given group identified by group id.getAllExternalIds(long directoryId) Return all group externalId in the given directory.longgetExternalGroupCount(long directoryId) Gets the count of external groups for a directorylonggetGroupCount(long directoryId) Return number of groups in given directory.getLocalGroupNames(long directoryId) Return names of all local groups in given directory.All subclasses of HibernateDao must implement this method forHibernateDao.load(Serializable)to work correctly.voidRemoves group.voidremoveAll(long directoryId) Removes all groups from a directory, but does not audit group removal operationremoveAllGroups(long directoryId, Set<String> groupNames) Bulk remove all the given groups.voidremoveAttribute(Group group, String attributeName) Remove the attribute from the group.Renames group.<T> List<T> search(long directoryId, EntityQuery<T> query) Searches for group based on the given criteria.voidsetAuditProcessor(GroupAuditProcessor auditProcessor) voidsetDirectoryDao(DirectoryDao directoryDao) voidsetHqlQueryTranslater(HQLQueryTranslater hqlQueryTranslater) voidsetMembershipDao(InternalMembershipDao membershipDao) voidStores attributes into group.Updates group.Methods inherited from class com.atlassian.crowd.util.persistence.hibernate.InternalDirectoryEntityHibernateDao
executeBatchedQueriesIfNecessary, removeAttribute, removeAttribute, storeAttributes, updateTimestampsMethods inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
createDeleteQuery, createDeleteQuery, createQuery, createQuery, executeHQLQuery, findAllInternal, findByProperties, findByPropertiesOptional, findByProperty, findByProperty, findByPropertyOptional, findByPropertyOrThrow, getCountByProperties, load, load, loadOptional, loadReference, loadReference, remove, removeByIdIfPresent, save, saveOrUpdate, session, setBatchFinder, setBatchProcessor, setClock, setStatelessSessionBatchProcessor, toPredicates, updateMethods inherited from class com.atlassian.crowd.util.persistence.hibernate.StatelessDao
setSessionFactory, withStatelessSession
-
Field Details
-
EXTERNAL_ID
- See Also:
-
DIRECTORY_ID
- See Also:
-
IS_LOCAL
- See Also:
-
NAME
- See Also:
-
-
Constructor Details
-
GroupDAOHibernate
public GroupDAOHibernate()
-
-
Method Details
-
add
Description copied from interface:GroupDaoAdds a new group.- Specified by:
addin interfaceGroupDao- Parameters:
group- group- Returns:
- the added group
- Throws:
DirectoryNotFoundException- if the directory specified in group object does not existInvalidGroupException- if a group with the same directory and name (case-insensitive) already exists
-
addAll
Description copied from interface:GroupDaoBulk add of groups. Will only add remote groups (ie. isLocal=false) Implementations must make sure that changes in bulk methods such as this are immediately visible to other bulk methods. For example, if this is run in a transaction, either that transaction must be committed when this method returns, or all other bulk method implementations must guarantee to reuse the same transaction.- Specified by:
addAllin interfaceGroupDao- Parameters:
groups- to be added- Returns:
- a list of Groups that failed to be added
- Throws:
DirectoryNotFoundException- if the directory cannot be found
-
addAll
Description copied from interface:InternalGroupDaoBulk add of groups and their attributes.- Specified by:
addAllin interfaceInternalGroupDao- Parameters:
groups- Groups with attributes.- Returns:
- Batch result.
-
addLocal
Description copied from interface:GroupDaoAdd a new local group. A local group is a group that does not exist in the remote directory. The implementation must take into account and also persist the fact that the group is only local.- Specified by:
addLocalin interfaceGroupDao- Parameters:
group- group- Returns:
- the added group
- Throws:
DirectoryNotFoundException- if the directory specified in group object does not existInvalidGroupException- if a group with the same directory and name (case-insensitive) already exists
-
findByName
Description copied from interface:InternalGroupDaoFinds internal group by directory id and group name.- Specified by:
findByNamein interfaceGroupDao- Specified by:
findByNamein interfaceInternalGroupDao- Specified by:
findByNamein classInternalDirectoryEntityHibernateDao<InternalGroup,InternalGroupAttribute> - Parameters:
directoryId- Directory id.groupName- Group name.- Returns:
- An internal group.
- Throws:
GroupNotFoundException- If the group cannot be found.
-
findByNameWithAttributes
public InternalGroupWithAttributes findByNameWithAttributes(long directoryId, String groupName) throws GroupNotFoundException Description copied from interface:GroupDaoFinds group by name. This is different fromGroupDao.findByName(long, String)in that it also returns the group attributes associated with the retrieved group.- Specified by:
findByNameWithAttributesin interfaceGroupDao- Parameters:
directoryId- the ID of the directory to look for groupgroupName- group name- Returns:
- group with attributes
- Throws:
GroupNotFoundException- if the group does not exist
-
findByNames
Description copied from interface:InternalGroupDaoBulk find of groups using SQL disjunction.- Specified by:
findByNamesin interfaceInternalGroupDao- Parameters:
directoryID- the directory to search for the groups.groupnames- names of groups to find- Returns:
- collection of found groups.
-
findByIds
Description copied from interface:InternalGroupDaoBulk find of groups with the specified database identifiers. The result collection may be smaller than the input if ids that did not match with any groups were supplied- Specified by:
findByIdsin interfaceInternalGroupDao- Parameters:
groupIds- identifiers of groups that will be found- Returns:
- the matching groups
-
findGroupAttributes
Description copied from interface:InternalGroupDaoFinds group attributes of the given group identified by group id.- Specified by:
findGroupAttributesin interfaceInternalGroupDao- Parameters:
groupId- Group id.- Returns:
- Set of group attributes.
-
getPersistentClass
Description copied from class:HibernateDaoAll subclasses of HibernateDao must implement this method forHibernateDao.load(Serializable)to work correctly.- Specified by:
getPersistentClassin classHibernateDao<InternalGroup>- Returns:
- the entity class for this DAO
-
remove
Description copied from interface:GroupDaoRemoves group.- Specified by:
removein interfaceGroupDao- Parameters:
group- group- Throws:
GroupNotFoundException- if the group does not exist
-
removeAll
public void removeAll(long directoryId) Description copied from interface:InternalGroupDaoRemoves all groups from a directory, but does not audit group removal operation- Specified by:
removeAllin interfaceInternalGroupDao- Parameters:
directoryId- Directory Id.
-
removeAllGroups
Description copied from interface:GroupDaoBulk remove all the given groups. Implementations must make sure that changes in bulk methods such as this are immediately visible to other bulk methods. For example, if this is run in a transaction, either that transaction must be committed when this method returns, or all other bulk method implementations must guarantee to reuse the same transaction.- Specified by:
removeAllGroupsin interfaceGroupDao- Parameters:
directoryId- directory to perform the operationgroupNames- groups to be removed- Returns:
- batch result containing successes (removed groups) and failures (groups which were not removed)
-
getAllExternalIds
Description copied from interface:GroupDaoReturn all group externalId in the given directory. If a group's externalId isnullor an empty String it won't be included.- Specified by:
getAllExternalIdsin interfaceGroupDao- Parameters:
directoryId- the ID of the directory- Returns:
- set containing all externalIds with nulls filtered out
- Throws:
DirectoryNotFoundException- when directory with given id does not exist
-
getLocalGroupNames
Description copied from interface:GroupDaoReturn names of all local groups in given directory.- Specified by:
getLocalGroupNamesin interfaceGroupDao- Parameters:
directoryId- the ID of the directory- Returns:
- names of all local groups in given directory
- Throws:
DirectoryNotFoundException- when directory with given id does not exist
-
getGroupCount
Description copied from interface:GroupDaoReturn number of groups in given directory.- Specified by:
getGroupCountin interfaceGroupDao- Parameters:
directoryId- the ID of the directory- Returns:
- group count
- Throws:
DirectoryNotFoundException- when directory with given id does not exist
-
getExternalGroupCount
Description copied from interface:GroupDaoGets the count of external groups for a directory- Specified by:
getExternalGroupCountin interfaceGroupDao- Parameters:
directoryId- the directory to count groups for- Returns:
- count of external groups
- Throws:
DirectoryNotFoundException
-
removeAttribute
Description copied from interface:GroupDaoRemove the attribute from the group. Does nothing if the attribute doesn't exist.- Specified by:
removeAttributein interfaceGroupDao- Parameters:
group- groupattributeName- attribute to be removed- Throws:
GroupNotFoundException- if the group does not exist
-
rename
public InternalGroup rename(Group group, String newName) throws GroupNotFoundException, InvalidGroupException Description copied from interface:GroupDaoRenames group.- Specified by:
renamein interfaceGroupDao- Parameters:
group- groupnewName- the new name- Returns:
- group with new name
- Throws:
GroupNotFoundException- if the group does not existInvalidGroupException- if a group with the same directory and name (case-insensitive) already exists
-
search
Description copied from interface:GroupDaoSearches for group based on the given criteria. -
findByExternalIds
Description copied from interface:GroupDaoSearches the specified directory for group names of groups with the specified external ids- Specified by:
findByExternalIdsin interfaceGroupDao- Parameters:
directoryId- the id of the directory to searchexternalIds- external ids of the groups to find- Returns:
- a map from external ids to group names
-
findExternalIdsByNames
Description copied from interface:GroupDaoSearches the specified directory for externalIds of groups with the specified names- Specified by:
findExternalIdsByNamesin interfaceGroupDao- Parameters:
directoryId- the id of the directory to searchgroupNames- names of the groups to find- Returns:
- a map from group names to external ids
-
storeAttributes
public void storeAttributes(Group group, Map<String, Set<String>> attributes) throws GroupNotFoundExceptionDescription copied from interface:GroupDaoStores attributes into group. Any existing attributes matching the supplied attribute keys will be replaced.- Specified by:
storeAttributesin interfaceGroupDao- Parameters:
group- groupattributes- attributes- Throws:
GroupNotFoundException- if the group does not exist
-
update
Description copied from interface:GroupDaoUpdates group.- Specified by:
updatein interfaceGroupDao- Parameters:
group- group- Returns:
- the updated group
- Throws:
GroupNotFoundException- if the group does not exist
-
addAttribute
- Specified by:
addAttributein classInternalDirectoryEntityHibernateDao<InternalGroup,InternalGroupAttribute>
-
setDirectoryDao
-
setHqlQueryTranslater
-
setMembershipDao
-
setAuditProcessor
@Autowired public void setAuditProcessor(@Qualifier("groupAuditProcessor") GroupAuditProcessor auditProcessor)
-