com.atlassian.crowd.dao.group
Class GroupDAOHibernate

java.lang.Object
  extended by com.atlassian.crowd.util.persistence.hibernate.HibernateDao
      extended by com.atlassian.crowd.dao.group.GroupDAOHibernate
All Implemented Interfaces:
InternalGroupDao, GroupDao

public class GroupDAOHibernate
extends HibernateDao
implements InternalGroupDao, GroupDao


Field Summary
 
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
batchFinder, batchProcessor, logger, sessionFactory
 
Constructor Summary
GroupDAOHibernate()
           
 
Method Summary
 InternalGroup add(Group group)
          Adds a new group.
 BatchResultWithIdReferences<Group> addAll(Collection<InternalGroupWithAttributes> groups)
          Bulk add of groups and their attributes.
 BatchResult<Group> addAll(Set<? extends Group> groups)
          Bulk add of groups.
 InternalGroup addLocal(Group group)
          Add a new local group.
 InternalGroup findByName(long directoryId, String groupName)
          Finds internal group by directory id and group name.
 Collection<InternalGroup> findByNames(long directoryID, Collection<String> groupnames)
          Bulk find of groups using SQL disjunction.
 InternalGroupWithAttributes findByNameWithAttributes(long directoryId, String groupName)
          Finds group by name.
 Set<InternalGroupAttribute> findGroupAttributes(long groupId)
          Finds group attributes of the given group identified by group id.
 Class getPersistentClass()
          All subclasses of HibernateDao must implement this method for HibernateDao.load(long) to work correctly.
 void remove(Group group)
          Removes group.
 void removeAll(long directoryId)
          Removes all groups from a directory.
 BatchResult<String> removeAllGroups(long directoryId, Set<String> groupNames)
          Bulk remove all the given groups.
 void removeAttribute(Group group, String attributeName)
          Remove the attribute from the group.
 InternalGroup rename(Group group, String newName)
          Renames group.
<T> List<T>
search(long directoryId, EntityQuery<T> query)
          Searches for group based on the given criteria.
 void setAttributesHelper(InternalAttributesHelper attributesHelper)
           
 void setDirectoryDao(DirectoryDao directoryDao)
           
 void setHqlQueryTranslater(HQLQueryTranslater hqlQueryTranslater)
           
 void setMembershipDao(InternalMembershipDao membershipDao)
           
 void storeAttributes(Group group, Map<String,Set<String>> attributes)
          Stores attributes into group.
 InternalGroup update(Group group)
          Updates group.
 
Methods inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
createHibernateQuery, load, load, loadReference, loadReference, remove, save, saveOrUpdate, session, setBatchFinder, setBatchProcessor, setSessionFactory, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupDAOHibernate

public GroupDAOHibernate()
Method Detail

add

public InternalGroup add(Group group)
                  throws DirectoryNotFoundException,
                         InvalidGroupException
Description copied from interface: GroupDao
Adds a new group.

Specified by:
add in interface GroupDao
Parameters:
group - group
Returns:
the added group
Throws:
DirectoryNotFoundException - if the directory specified in group object does not exist
InvalidGroupException - if a group with the same directory and name (case-insensitive) already exists

addAll

public BatchResult<Group> addAll(Set<? extends Group> groups)
                          throws DirectoryNotFoundException
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 interface GroupDao
Parameters:
groups - to be added
Returns:
a list of Groups that failed to be added
Throws:
DirectoryNotFoundException - if the directory cannot be found

addAll

public BatchResultWithIdReferences<Group> addAll(Collection<InternalGroupWithAttributes> groups)
Description copied from interface: InternalGroupDao
Bulk add of groups and their attributes.

Specified by:
addAll in interface InternalGroupDao
Parameters:
groups - Groups with attributes.
Returns:
Batch result.

addLocal

public InternalGroup addLocal(Group group)
                       throws DirectoryNotFoundException,
                              InvalidGroupException
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 interface GroupDao
Parameters:
group - group
Returns:
the added group
Throws:
DirectoryNotFoundException - if the directory specified in group object does not exist
InvalidGroupException - if a group with the same directory and name (case-insensitive) already exists

findByName

public InternalGroup findByName(long directoryId,
                                String groupName)
                         throws GroupNotFoundException
Description copied from interface: InternalGroupDao
Finds internal group by directory id and group name.

Specified by:
findByName in interface InternalGroupDao
Specified by:
findByName in interface GroupDao
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 from GroupDao.findByName(long, String) in that it also returns the group attributes associated with the retrieved group.

Specified by:
findByNameWithAttributes in interface GroupDao
Parameters:
directoryId - the ID of the directory to look for group
groupName - group name
Returns:
group with attributes
Throws:
GroupNotFoundException - if the group does not exist

findByNames

public Collection<InternalGroup> findByNames(long directoryID,
                                             Collection<String> groupnames)
Description copied from interface: InternalGroupDao
Bulk find of groups using SQL disjunction.

Specified by:
findByNames in interface InternalGroupDao
Parameters:
directoryID - the directory to search for the groups.
groupnames - names of groups to find
Returns:
collection of found groups.

findGroupAttributes

public Set<InternalGroupAttribute> findGroupAttributes(long groupId)
Description copied from interface: InternalGroupDao
Finds group attributes of the given group identified by group id.

Specified by:
findGroupAttributes in interface InternalGroupDao
Parameters:
groupId - Group id.
Returns:
Set of group attributes.

getPersistentClass

public Class getPersistentClass()
Description copied from class: HibernateDao
All subclasses of HibernateDao must implement this method for HibernateDao.load(long) to work correctly.

Specified by:
getPersistentClass in class HibernateDao
Returns:
the entity class for this DAO

remove

public void remove(Group group)
            throws GroupNotFoundException
Description copied from interface: GroupDao
Removes group.

Specified by:
remove in interface GroupDao
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.

Specified by:
removeAll in interface InternalGroupDao
Parameters:
directoryId - Directory Id.

removeAllGroups

public BatchResult<String> removeAllGroups(long directoryId,
                                           Set<String> groupNames)
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 interface GroupDao
Parameters:
directoryId - directory to perform the operation
groupNames - groups to be removed
Returns:
batch result containing successes (removed groups) and failures (groups which were not removed)

removeAttribute

public void removeAttribute(Group group,
                            String attributeName)
                     throws GroupNotFoundException
Description copied from interface: GroupDao
Remove the attribute from the group. Does nothing if the attribute doesn't exist.

Specified by:
removeAttribute in interface GroupDao
Parameters:
group - group
attributeName - 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 interface GroupDao
Parameters:
group - group
newName - the new name
Returns:
group with new name
Throws:
GroupNotFoundException - if the group does not exist
InvalidGroupException - if a group with the same directory and name (case-insensitive) already exists

search

public <T> List<T> search(long directoryId,
                          EntityQuery<T> query)
Description copied from interface: GroupDao
Searches for group based on the given criteria.

Specified by:
search in interface GroupDao
Parameters:
directoryId - directory to perform the search operation on
query - criteria
Returns:
list (could be empty) of groups which match the criteria

storeAttributes

public void storeAttributes(Group group,
                            Map<String,Set<String>> attributes)
                     throws GroupNotFoundException
Description copied from interface: GroupDao
Stores attributes into group. Any existing attributes matching the supplied attribute keys will be replaced.

Specified by:
storeAttributes in interface GroupDao
Parameters:
group - group
attributes - attributes
Throws:
GroupNotFoundException - if the group does not exist

update

public InternalGroup update(Group group)
                     throws GroupNotFoundException
Description copied from interface: GroupDao
Updates group.

Specified by:
update in interface GroupDao
Parameters:
group - group
Returns:
the updated group
Throws:
GroupNotFoundException - if the group does not exist

setAttributesHelper

@Autowired
public void setAttributesHelper(InternalAttributesHelper attributesHelper)

setDirectoryDao

@Autowired
public void setDirectoryDao(DirectoryDao directoryDao)

setHqlQueryTranslater

@Autowired
public void setHqlQueryTranslater(HQLQueryTranslater hqlQueryTranslater)

setMembershipDao

@Autowired
public void setMembershipDao(InternalMembershipDao membershipDao)


Copyright © 2013 Atlassian. All Rights Reserved.