com.atlassian.crowd.embedded.spi
Interface GroupDao


public interface GroupDao


Method Summary
 Group add(Group group)
          Adds a new group.
 BatchResult<Group> addAll(Set<? extends Group> groups)
          Bulk add of groups.
 Group addLocal(Group group)
          Add a new local group.
 InternalDirectoryGroup findByName(long directoryId, String name)
          Finds group by name.
 GroupWithAttributes findByNameWithAttributes(long directoryId, String name)
          Finds group by name.
 void remove(Group group)
          Removes group.
 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.
 Group 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 storeAttributes(Group group, Map<String,Set<String>> attributes)
          Stores attributes into group.
 Group update(Group group)
          Updates group.
 

Method Detail

findByName

InternalDirectoryGroup findByName(long directoryId,
                                  String name)
                                  throws com.atlassian.crowd.exception.GroupNotFoundException
Finds group by name.

Parameters:
directoryId - the ID of the directory to look for group
name - group name
Returns:
group
Throws:
com.atlassian.crowd.exception.GroupNotFoundException - if the group does not exist

findByNameWithAttributes

GroupWithAttributes findByNameWithAttributes(long directoryId,
                                             String name)
                                             throws com.atlassian.crowd.exception.GroupNotFoundException
Finds group by name. This is different from findByName(long, String) in that it also returns the group attributes associated with the retrieved group.

Parameters:
directoryId - the ID of the directory to look for group
name - group name
Returns:
group with attributes
Throws:
com.atlassian.crowd.exception.GroupNotFoundException - if the group does not exist

add

Group add(Group group)
          throws com.atlassian.crowd.exception.DirectoryNotFoundException,
                 com.atlassian.crowd.exception.InvalidGroupException
Adds a new group.

Parameters:
group - group
Returns:
the added group
Throws:
com.atlassian.crowd.exception.DirectoryNotFoundException - if the directory specified in group object does not exist
com.atlassian.crowd.exception.InvalidGroupException - if a group with the same directory and name (case-insensitive) already exists

addLocal

Group addLocal(Group group)
               throws com.atlassian.crowd.exception.DirectoryNotFoundException,
                      com.atlassian.crowd.exception.InvalidGroupException
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.

Parameters:
group - group
Returns:
the added group
Throws:
com.atlassian.crowd.exception.DirectoryNotFoundException - if the directory specified in group object does not exist
com.atlassian.crowd.exception.InvalidGroupException - if a group with the same directory and name (case-insensitive) already exists

update

Group update(Group group)
             throws com.atlassian.crowd.exception.GroupNotFoundException
Updates group.

Parameters:
group - group
Returns:
the updated group
Throws:
com.atlassian.crowd.exception.GroupNotFoundException - if the group does not exist

rename

Group rename(Group group,
             String newName)
             throws com.atlassian.crowd.exception.GroupNotFoundException,
                    com.atlassian.crowd.exception.InvalidGroupException
Renames group.

Parameters:
group - group
newName - the new name
Returns:
group with new name
Throws:
com.atlassian.crowd.exception.GroupNotFoundException - if the group does not exist
com.atlassian.crowd.exception.InvalidGroupException - if a group with the same directory and name (case-insensitive) already exists

storeAttributes

void storeAttributes(Group group,
                     Map<String,Set<String>> attributes)
                     throws com.atlassian.crowd.exception.GroupNotFoundException
Stores attributes into group. Any existing attributes matching the supplied attribute keys will be replaced.

Parameters:
group - group
attributes - attributes
Throws:
com.atlassian.crowd.exception.GroupNotFoundException - if the group does not exist

removeAttribute

void removeAttribute(Group group,
                     String attributeName)
                     throws com.atlassian.crowd.exception.GroupNotFoundException
Remove the attribute from the group. Does nothing if the attribute doesn't exist.

Parameters:
group - group
attributeName - attribute to be removed
Throws:
com.atlassian.crowd.exception.GroupNotFoundException - if the group does not exist

remove

void remove(Group group)
            throws com.atlassian.crowd.exception.GroupNotFoundException
Removes group.

Parameters:
group - group
Throws:
com.atlassian.crowd.exception.GroupNotFoundException - if the group does not exist

search

<T> List<T> search(long directoryId,
                   EntityQuery<T> query)
Searches for group based on the given criteria.

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

addAll

BatchResult<Group> addAll(Set<? extends Group> groups)
                          throws com.atlassian.crowd.exception.DirectoryNotFoundException
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.

Parameters:
groups - to be added
Returns:
a list of Groups that failed to be added
Throws:
com.atlassian.crowd.exception.DirectoryNotFoundException - if the directory cannot be found

removeAllGroups

BatchResult<String> removeAllGroups(long directoryId,
                                    Set<String> groupNames)
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.

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)


Copyright © 2014 Atlassian. All Rights Reserved.