Package com.atlassian.crowd.dao.group
Class GroupDAOHibernate
- All Implemented Interfaces:
InternalGroupDao
,GroupDao
public class GroupDAOHibernate
extends InternalDirectoryEntityHibernateDao<InternalGroup,InternalGroupAttribute>
implements InternalGroupDao, GroupDao
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
batchFinder, batchProcessor, logger, statelessSessionBatchProcessor, timeSource
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.StatelessDao
sessionFactory
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionAdds a new group.addAll
(Collection<InternalGroupWithAttributes> groups) Bulk add of groups and their attributes.Bulk add of groups.void
addAttribute
(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.long
getExternalGroupCount
(long directoryId) Gets the count of external groups for a directorylong
getGroupCount
(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.void
Removes group.void
removeAll
(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.void
removeAttribute
(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.void
setAuditProcessor
(GroupAuditProcessor auditProcessor) void
setDirectoryDao
(DirectoryDao directoryDao) void
setHqlQueryTranslater
(HQLQueryTranslater hqlQueryTranslater) void
setMembershipDao
(InternalMembershipDao membershipDao) void
Stores attributes into group.Updates group.Methods inherited from class com.atlassian.crowd.util.persistence.hibernate.InternalDirectoryEntityHibernateDao
executeBatchedQueriesIfNecessary, removeAttribute, removeAttribute, storeAttributes, updateTimestamps
Methods 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, update
Methods 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:GroupDao
Adds a new group.- Specified by:
add
in 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:GroupDao
Bulk 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:
addAll
in 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:InternalGroupDao
Bulk add of groups and their attributes.- Specified by:
addAll
in interfaceInternalGroupDao
- Parameters:
groups
- Groups with attributes.- Returns:
- Batch result.
-
addLocal
Description copied from interface:GroupDao
Add 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:
addLocal
in 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:InternalGroupDao
Finds internal group by directory id and group name.- Specified by:
findByName
in interfaceGroupDao
- Specified by:
findByName
in interfaceInternalGroupDao
- Specified by:
findByName
in 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:GroupDao
Finds 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:
findByNameWithAttributes
in 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:InternalGroupDao
Bulk find of groups using SQL disjunction.- Specified by:
findByNames
in 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:InternalGroupDao
Bulk 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:
findByIds
in interfaceInternalGroupDao
- Parameters:
groupIds
- identifiers of groups that will be found- Returns:
- the matching groups
-
findGroupAttributes
Description copied from interface:InternalGroupDao
Finds group attributes of the given group identified by group id.- Specified by:
findGroupAttributes
in interfaceInternalGroupDao
- Parameters:
groupId
- Group id.- Returns:
- Set of group attributes.
-
getPersistentClass
Description copied from class:HibernateDao
All subclasses of HibernateDao must implement this method forHibernateDao.load(Serializable)
to work correctly.- Specified by:
getPersistentClass
in classHibernateDao<InternalGroup>
- Returns:
- the entity class for this DAO
-
remove
Description copied from interface:GroupDao
Removes group.- Specified by:
remove
in interfaceGroupDao
- Parameters:
group
- group- Throws:
GroupNotFoundException
- if the group does not exist
-
removeAll
public void removeAll(long directoryId) Description copied from interface:InternalGroupDao
Removes all groups from a directory, but does not audit group removal operation- Specified by:
removeAll
in interfaceInternalGroupDao
- Parameters:
directoryId
- Directory Id.
-
removeAllGroups
Description copied from interface:GroupDao
Bulk 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:
removeAllGroups
in 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:GroupDao
Return all group externalId in the given directory. If a group's externalId isnull
or an empty String it won't be included.- Specified by:
getAllExternalIds
in 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:GroupDao
Return names of all local groups in given directory.- Specified by:
getLocalGroupNames
in 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:GroupDao
Return number of groups in given directory.- Specified by:
getGroupCount
in 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:GroupDao
Gets the count of external groups for a directory- Specified by:
getExternalGroupCount
in interfaceGroupDao
- Parameters:
directoryId
- the directory to count groups for- Returns:
- count of external groups
- Throws:
DirectoryNotFoundException
-
removeAttribute
Description copied from interface:GroupDao
Remove the attribute from the group. Does nothing if the attribute doesn't exist.- Specified by:
removeAttribute
in 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:GroupDao
Renames group.- Specified by:
rename
in 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:GroupDao
Searches for group based on the given criteria. -
findByExternalIds
Description copied from interface:GroupDao
Searches the specified directory for group names of groups with the specified external ids- Specified by:
findByExternalIds
in 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:GroupDao
Searches the specified directory for externalIds of groups with the specified names- Specified by:
findExternalIdsByNames
in 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:GroupDao
Stores attributes into group. Any existing attributes matching the supplied attribute keys will be replaced.- Specified by:
storeAttributes
in interfaceGroupDao
- Parameters:
group
- groupattributes
- attributes- Throws:
GroupNotFoundException
- if the group does not exist
-
update
Description copied from interface:GroupDao
Updates group.- Specified by:
update
in interfaceGroupDao
- Parameters:
group
- group- Returns:
- the updated group
- Throws:
GroupNotFoundException
- if the group does not exist
-
addAttribute
- Specified by:
addAttribute
in classInternalDirectoryEntityHibernateDao<InternalGroup,
InternalGroupAttribute>
-
setDirectoryDao
-
setHqlQueryTranslater
-
setMembershipDao
-
setAuditProcessor
@Autowired public void setAuditProcessor(@Qualifier("groupAuditProcessor") GroupAuditProcessor auditProcessor)
-