com.atlassian.crowd.dao.membership
Class MembershipDAOHibernate

java.lang.Object
  extended by com.atlassian.crowd.util.persistence.hibernate.HibernateDao
      extended by com.atlassian.crowd.dao.membership.MembershipDAOHibernate
All Implemented Interfaces:
InternalMembershipDao, MembershipDao

public class MembershipDAOHibernate
extends HibernateDao
implements MembershipDao, InternalMembershipDao


Field Summary
 
Fields inherited from class com.atlassian.crowd.util.persistence.hibernate.HibernateDao
batchFinder, batchProcessor, logger, sessionFactory
 
Constructor Summary
MembershipDAOHibernate()
           
 
Method Summary
 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.
protected  org.hibernate.Query createHibernateSearchQuery(long directoryId, MembershipQuery<?> query)
          Builds a Hibernate query from a MembershipQuery.
 List<InternalMembership> findAll(Collection<Directory> directories)
           
 List<InternalMembership> findAllLocal(Collection<Directory> directories)
           
 Class getPersistentClass()
          All subclasses of HibernateDao must implement this method for HibernateDao.load(long) 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.
 void setGroupDao(InternalGroupDao groupDao)
           
 void setHqlQueryTranslater(HQLQueryTranslater hqlQueryTranslater)
           
 void setUserDao(InternalUserDao userDao)
           
 
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

MembershipDAOHibernate

public MembershipDAOHibernate()
Method Detail

addAll

public BatchResult<InternalMembership> addAll(Set<InternalMembership> memberships)
Description copied from interface: InternalMembershipDao
Bulk add of memberships.

Specified by:
addAll in interface InternalMembershipDao
Parameters:
memberships - Set of memberships.
Returns:
Batch result.

addAllUsersToGroup

public BatchResult<String> addAllUsersToGroup(long directoryId,
                                              Collection<String> userNames,
                                              String groupName)
                                       throws GroupNotFoundException
Description copied from interface: MembershipDao
Bulk adds all the given users into the given group. Users that are already direct members of the group are reported as failures. Usernames that cannot be found in the database are also reported as failures. 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:
addAllUsersToGroup in interface MembershipDao
Parameters:
directoryId - the directory to perform the operation
userNames - the collection of users
groupName - name of the group
Returns:
result containing both successful (membership successfully added) and failed users (unknown username, or already existing membership)
Throws:
GroupNotFoundException - if the group does not exist

addGroupToGroup

public void addGroupToGroup(long directoryId,
                            String childGroup,
                            String parentGroup)
                     throws GroupNotFoundException,
                            MembershipAlreadyExistsException
Description copied from interface: MembershipDao
Adds group as a child of the (supposedly) parent group.

Specified by:
addGroupToGroup in interface MembershipDao
Parameters:
directoryId - the directory to perform the operation
childGroup - the (supposedly) child group
parentGroup - parent group
Throws:
GroupNotFoundException - if either child or parent group is not found
MembershipAlreadyExistsException - if the child group is already a child of the parent group

addUserToGroup

public void addUserToGroup(long directoryId,
                           String username,
                           String groupName)
                    throws UserNotFoundException,
                           GroupNotFoundException,
                           MembershipAlreadyExistsException
Description copied from interface: MembershipDao
Adds user as a member of group.

Specified by:
addUserToGroup in interface MembershipDao
Parameters:
directoryId - the directory to perform the operation
username - user
groupName - group
Throws:
UserNotFoundException - if the user does not exist
GroupNotFoundException - if the group does not exist
MembershipAlreadyExistsException - if the user is already a direct member of the group

findAll

public List<InternalMembership> findAll(Collection<Directory> directories)
Parameters:
directories - directories to search for memberships
Returns:
all memberships across all directories (used for export).

findAllLocal

public List<InternalMembership> findAllLocal(Collection<Directory> directories)
Parameters:
directories - directories to search for memberships
Returns:
all memberships across all directories (used for export).

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

isGroupDirectMember

public boolean isGroupDirectMember(long directoryId,
                                   String childGroup,
                                   String parentGroup)
Description copied from interface: MembershipDao
Determines whether the group is a direct member of the (supposedly) parent group.

Specified by:
isGroupDirectMember in interface MembershipDao
Parameters:
directoryId - the directory to perform the operation
childGroup - child group
parentGroup - parent group
Returns:
true if the group is a direct member of the (supposedly) parent group

isUserDirectMember

public boolean isUserDirectMember(long directoryId,
                                  String username,
                                  String groupName)
Description copied from interface: MembershipDao
Determines whether the user is a direct member of the group.

Specified by:
isUserDirectMember in interface MembershipDao
Parameters:
directoryId - the directory to perform the operation
username - user
groupName - group
Returns:
true if the user is a direct member of the group

removeAllRelationships

public void removeAllRelationships(long directoryId)
Description copied from interface: InternalMembershipDao
Removes all relationships the the given directory identified by directory id.

Specified by:
removeAllRelationships in interface InternalMembershipDao
Parameters:
directoryId - Directory id.

removeAllUserRelationships

public void removeAllUserRelationships(long directoryId)
Description copied from interface: InternalMembershipDao
Removes all user relationships the the given directory identified by directory id.

Specified by:
removeAllUserRelationships in interface InternalMembershipDao
Parameters:
directoryId - Directory id.

removeGroupFromGroup

public void removeGroupFromGroup(long directoryId,
                                 String childGroup,
                                 String parentGroup)
                          throws MembershipNotFoundException
Description copied from interface: MembershipDao
Removes group from the parent group.

Specified by:
removeGroupFromGroup in interface MembershipDao
Parameters:
directoryId - the directory to perform the operation
childGroup - child group
parentGroup - parent group
Throws:
MembershipNotFoundException - if the membership relationship between the child and parent group does not exist

removeGroupMembers

public void removeGroupMembers(long directoryId,
                               String groupName)
Description copied from interface: InternalMembershipDao
Removes all members of the given group name.

Specified by:
removeGroupMembers in interface InternalMembershipDao
Parameters:
directoryId - Directory id.
groupName - Group name.

removeGroupMemberships

public void removeGroupMemberships(long directoryId,
                                   String groupName)
Description copied from interface: InternalMembershipDao
Removes all relationships from parent groups to the given group name.

Specified by:
removeGroupMemberships in interface InternalMembershipDao
Parameters:
directoryId - Directory id.
groupName - Group name.

removeUserFromGroup

public void removeUserFromGroup(long directoryId,
                                String username,
                                String groupName)
                         throws UserNotFoundException,
                                GroupNotFoundException,
                                MembershipNotFoundException
Description copied from interface: MembershipDao
Removes user as a member of the given group.

Specified by:
removeUserFromGroup in interface MembershipDao
Parameters:
directoryId - the directory to perform the operation
username - user
groupName - group
Throws:
UserNotFoundException - if the user does not exist
GroupNotFoundException - if the group does not exist
MembershipNotFoundException - if the user is not a member of the said group

removeUserMemberships

public void removeUserMemberships(long directoryId,
                                  String username)
Description copied from interface: InternalMembershipDao
Removes all MembershipType.GROUP_USER relationships from parent groups to the given username.

Specified by:
removeUserMemberships in interface InternalMembershipDao
Parameters:
directoryId - Directory id.
username - Username.

renameGroupRelationships

public void renameGroupRelationships(long directoryId,
                                     String oldName,
                                     String newName)
Description copied from interface: InternalMembershipDao
Renames group name in all relationships.

Specified by:
renameGroupRelationships in interface InternalMembershipDao
Parameters:
directoryId - Directory id.
oldName - Old group name.
newName - New group name.

renameUserRelationships

public void renameUserRelationships(long directoryId,
                                    String oldName,
                                    String newName)
Description copied from interface: InternalMembershipDao
Renames username in all relationships.

Specified by:
renameUserRelationships in interface InternalMembershipDao
Parameters:
directoryId - Directory id.
oldName - Old username.
newName - New username.

search

public <T> List<T> search(long directoryId,
                          MembershipQuery<T> query)
Description copied from interface: MembershipDao
Search for memberships by the given criteria.

Specified by:
search in interface MembershipDao
Parameters:
directoryId - the directory to perform the operation
query - criteria
Returns:
list (can be empty but never null) of memberships which match the given criteria

setGroupDao

@Autowired
public void setGroupDao(InternalGroupDao groupDao)

setHqlQueryTranslater

@Autowired
public void setHqlQueryTranslater(HQLQueryTranslater hqlQueryTranslater)

setUserDao

@Autowired
public void setUserDao(InternalUserDao userDao)

createHibernateSearchQuery

protected org.hibernate.Query createHibernateSearchQuery(long directoryId,
                                                         MembershipQuery<?> query)
Builds a Hibernate query from a MembershipQuery. This method is protected to allow subclasses to override it, for instance to configure query caching.

Parameters:
directoryId - the directory being queried
query - the query
Returns:
the translated Hibernate query


Copyright © 2013 Atlassian. All Rights Reserved.