com.atlassian.crowd.manager.directory
Interface DirectoryManager

All Known Implementing Classes:
DirectoryManagerGeneric, MockDirectoryManager

public interface DirectoryManager

A service interface providing:

  1. Directory CRUD Operations
  2. Token Operations
  3. RemoteDirectory User Operations
  4. RemoteDirectory Group Operations
  5. RemoteDirectory Membership Operations
  6. RemoteDirectory Bulk Operations

Methods on this interface operate on a single directory whereas methods on the ApplicationService interface amalgamate results from multiple directories.

In the future, it is likely that we will break up the DirectoryManager into a DirectoryManager (directory CRUD), RemoteDirectoryManager (remote directory delegater) and a TokenManager (token ops) for better functional decomposition.


Method Summary
 BulkAddResult<Group> addAllGroups(long directoryId, Collection<GroupTemplate> groups, boolean overwrite)
          Will add a collection of Group to the directory specified by the passed in directoryId param.
 BulkAddResult<User> addAllUsers(long directoryId, Collection<UserTemplateWithCredentialAndAttributes> users, boolean overwrite)
          Will add a collection of users to the directory specified by the passed in directoryId param.
 BulkAddResult<String> addAllUsersToGroup(long directoryID, Collection<String> userNames, String groupName)
          A bulk version of addUserToGroup(long, String, String).
 Directory addDirectory(Directory directory)
          Adds the given directory.
 Group addGroup(long directoryId, GroupTemplate group)
          Adds a Group to the directory specified by the passed in directoryId.
 void addGroupToGroup(long directoryId, String childGroup, String parentGroup)
          Adds an existing child group as direct member of an existing parent group in the directory specified by the passed in directoryId.
 User addUser(long directoryId, UserTemplate user, PasswordCredential credential)
          Adds a User to the directory specified by the passed in directoryId.
 void addUserToGroup(long directoryId, String username, String groupName)
          Adds an existing user as a direct member of an existing group in the directory specified by the passed in directoryId.
 User authenticateUser(long directoryId, String username, PasswordCredential passwordCredential)
           
 List<Directory> findAllDirectories()
          Returns a List of all directories in the system.
 Directory findDirectoryById(long directoryID)
          Returns a Directory based on the passed in directoryId.
 Directory findDirectoryByName(String name)
          Finds a directory given the supplied name.
 Group findGroupByName(long directoryId, String groupName)
          Returns the group matching the supplied groupName in the directory specified by the passed in directoryId..
 GroupWithAttributes findGroupWithAttributesByName(long directoryId, String groupName)
          Returns the group with all attributes matching the supplied groupName in the directory specified by the passed in directoryId..
 User findUserByName(long directoryId, String username)
          Returns the user matching the supplied username in the directory specified by the passed in directoryId..
 UserWithAttributes findUserWithAttributesByName(long directoryId, String username)
          Returns the user with all attributes matching the supplied username in the directory specified by the passed in directoryId..
 DirectorySynchronisationInformation getDirectorySynchronisationInformation(long directoryId)
          Retrieves the sync info for the directory - last sync start time & duration, current sync start time (if directory is currently synchronising)
 boolean isGroupDirectGroupMember(long directoryId, String childGroup, String parentGroup)
          Returns true if the childGroup is a direct member of the parentGroup in the directory specified by the passed in directoryId.
 boolean isGroupNestedGroupMember(long directoryId, String childGroup, String parentGroup)
          Returns true if the childGroup is a direct or indirect (nested) member of the parentGroup in the directory specified by the passed in directoryId.
 boolean isSynchronisable(long directoryId)
          Returns true if the underlying directory implementation supports manual synchronisation of the directory's local cache.
 boolean isSynchronising(long directoryId)
          Returns true if the given Directory is currently synchronising.
 boolean isUserDirectGroupMember(long directoryId, String username, String groupName)
          Returns true if the user is a direct member of the group in the directory specified by the passed in directoryId.
 boolean isUserNestedGroupMember(long directoryId, String username, String groupName)
          Returns true if the user is a direct or indirect (nested) member of the group in the directory specified by the passed in directoryId.
 void removeDirectory(Directory directory)
          Removes a given directory and all its associated entities and mappings.
 void removeGroup(long directoryId, String groupName)
          Removes a group matching the supplied groupName in the directory specified by the passed in directoryId.
 void removeGroupAttributes(long directoryId, String groupName, String attributeName)
          Removes a group's attribute values in the directory specified by the passed in directoryId.
 void removeGroupFromGroup(long directoryId, String childGroup, String parentGroup)
          Removes an existing child group from being a direct member of an existing parent group in the directory specified by the passed in directoryId.
 void removeUser(long directoryId, String username)
          Removes a user matching the supplied username in the directory specified by the passed in directoryId.
 void removeUserAttributes(long directoryId, String username, String attributeName)
          Removes a user's attribute values in the directory specified by the passed in directoryId.
 void removeUserFromGroup(long directoryId, String username, String groupName)
          Removes an existing user from being a direct member of an existing group in the directory specified by the passed in directoryId.
 Group renameGroup(long directoryId, String oldGroupname, String newGroupname)
          Renames a group in the directory specified by the passed in directoryId.
 User renameUser(long directoryId, String oldUsername, String newUsername)
          Renames a user in the directory specified by the passed in directoryId.
 void resetPassword(long directoryId, String username)
          Deprecated. since 2.1
<T> List<T>
searchDirectGroupRelationships(long directoryId, MembershipQuery<T> query)
          Searches for direct group relationships in the directory specified by the passed in directoryId.
 List<Directory> searchDirectories(EntityQuery<Directory> query)
          Returns a List of Directories matching the search query.
<T> List<T>
searchGroups(long directoryId, EntityQuery<T> query)
          Returns a list of groups matching the given query in the directory specified by the passed in directoryId..
<T> List<T>
searchNestedGroupRelationships(long directoryId, MembershipQuery<T> query)
          Searches for direct and indirect (nested) group relationships in the directory specified by the passed in directoryId.
<T> List<T>
searchUsers(long directoryId, EntityQuery<T> query)
          Returns a list of users matching the given query in the directory specified by the passed in directoryId..
 void storeGroupAttributes(long directoryId, String groupName, Map<String,Set<String>> attributes)
          Adds or updates a group's attributes with the new Map of attribute values in the directory specified by the passed in directoryId.
 void storeUserAttributes(long directoryId, String username, Map<String,Set<String>> attributes)
          Adds or updates a user's attributes with the new Map of attribute values in the directory specified by the passed in directoryId.
 boolean supportsNestedGroups(long directoryId)
          Returns true if the underlying directory implementation supports nested groups.
 void synchroniseCache(long directoryId, SynchronisationMode mode)
          Requests that this directory should update its cache by synchronising with the remote User data.
 void synchroniseCache(long directoryId, SynchronisationMode mode, boolean runInBackground)
          Requests that this directory should update its cache by synchronising with the remote User data.
 Directory updateDirectory(Directory directory)
          Updates the passed in directory.
 Group updateGroup(long directoryId, GroupTemplate group)
          Updates a group with the supplied template and returns the updated group retrieved from the directory specified by the passed in directoryId.
 User updateUser(long directoryId, UserTemplate user)
          Updates a user with the supplied template and returns the updated user retrieved from the directory specified by the passed in directoryId.
 void updateUserCredential(long directoryId, String username, PasswordCredential credential)
          This will update the user's credential in the given directory specified by the passed in directoryId.
 

Method Detail

addDirectory

Directory addDirectory(Directory directory)
                       throws DirectoryInstantiationException
Adds the given directory.

Parameters:
directory - the Directory to add
Returns:
the added Directory
Throws:
DirectoryInstantiationException - if there was an error instantiating the directory

findDirectoryById

Directory findDirectoryById(long directoryID)
                            throws DirectoryNotFoundException
Returns a Directory based on the passed in directoryId.

Parameters:
directoryID - the id of the directory to find
Returns:
the directory
Throws:
DirectoryNotFoundException - is thrown if the Directory cannot be found.

findAllDirectories

List<Directory> findAllDirectories()
Returns a List of all directories in the system.

Returns:
List of all Directories.

searchDirectories

List<Directory> searchDirectories(EntityQuery<Directory> query)
Returns a List of Directories matching the search query.

Parameters:
query - the context to search on
Returns:
a List of directories, or an Empty List of none are found

findDirectoryByName

Directory findDirectoryByName(String name)
                              throws DirectoryNotFoundException
Finds a directory given the supplied name.

Parameters:
name - the name of the directory
Returns:
the directory with the given name
Throws:
DirectoryNotFoundException - if no Directory is found

updateDirectory

Directory updateDirectory(Directory directory)
                          throws DirectoryNotFoundException
Updates the passed in directory.

Parameters:
directory - the directory with updated attributes
Returns:
the updated directory
Throws:
DirectoryNotFoundException - if no Directory is found

removeDirectory

void removeDirectory(Directory directory)
                     throws DirectoryNotFoundException,
                            DirectoryCurrentlySynchronisingException
Removes a given directory and all its associated entities and mappings.

Parameters:
directory - the directory to remove
Throws:
DirectoryNotFoundException - if the directory cannot be found
DirectoryCurrentlySynchronisingException - if the directory is currently synchronising

authenticateUser

User authenticateUser(long directoryId,
                      String username,
                      PasswordCredential passwordCredential)
                      throws OperationFailedException,
                             InactiveAccountException,
                             InvalidAuthenticationException,
                             ExpiredCredentialException,
                             DirectoryNotFoundException,
                             UserNotFoundException
Parameters:
directoryId - the id of the directory to authenticate against
username - the username to use for authentication
passwordCredential - the credential to use for authentication
Returns:
will return the user if authentication is successful
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
InactiveAccountException - if the user account is inactive
InvalidAuthenticationException - if authentication with the provided credentials failed
ExpiredCredentialException - if the credentials of the user have expired.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if no user with the supplied username exists in the directory

findUserByName

User findUserByName(long directoryId,
                    String username)
                    throws DirectoryNotFoundException,
                           UserNotFoundException,
                           OperationFailedException
Returns the user matching the supplied username in the directory specified by the passed in directoryId..

Parameters:
directoryId - ID of the directory to search.
username - username of the user to retrieve.
Returns:
user matching the supplied username.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if no user with the supplied username exists in the directory
OperationFailedException - underlying directory implementation failed to execute the operation.
See Also:
findUserWithAttributesByName(long, String)

findUserWithAttributesByName

UserWithAttributes findUserWithAttributesByName(long directoryId,
                                                String username)
                                                throws DirectoryNotFoundException,
                                                       UserNotFoundException,
                                                       OperationFailedException
Returns the user with all attributes matching the supplied username in the directory specified by the passed in directoryId..

Parameters:
directoryId - ID of the directory to search.
username - username of the user to retrieve.
Returns:
user (with all attributes) matching the supplied username.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if no user with the supplied username exists in the directory
OperationFailedException - underlying directory implementation failed to execute the operation.
See Also:
findUserByName(long, String)

searchUsers

<T> List<T> searchUsers(long directoryId,
                        EntityQuery<T> query)
                    throws DirectoryNotFoundException,
                           OperationFailedException
Returns a list of users matching the given query in the directory specified by the passed in directoryId..

Parameters:
directoryId - ID of the directory to search.
query - query to exectute.
Returns:
List of User entities or String usernames matching the query criteria.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.

addUser

User addUser(long directoryId,
             UserTemplate user,
             PasswordCredential credential)
             throws InvalidCredentialException,
                    InvalidUserException,
                    DirectoryPermissionException,
                    DirectoryNotFoundException,
                    OperationFailedException,
                    UserAlreadyExistsException
Adds a User to the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to add the user to.
user - a template of the user to be added.
credential - the password credential of the user (unencrypted).
Returns:
the added user returned from the directory.
Throws:
InvalidCredentialException - if the user's credential does not meet the validation requirements for the given directory.
InvalidUserException - if the user template does not have the required properties populated.
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.CREATE_USER.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserAlreadyExistsException - if the user already exists in the given directory

updateUser

User updateUser(long directoryId,
                UserTemplate user)
                throws DirectoryNotFoundException,
                       UserNotFoundException,
                       DirectoryPermissionException,
                       InvalidUserException,
                       OperationFailedException
Updates a user with the supplied template and returns the updated user retrieved from the directory specified by the passed in directoryId.

This method cannot be used to rename the user, update the user's credentials or update the user's custom attributes.

Parameters:
directoryId - ID of the directory to find and update the user.
user - template of the user to update.
Returns:
the updated user returned from the directory.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if no user with the supplied username exists in the directory
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_USER.
InvalidUserException - the user template does not have the required properties populated.
See Also:
renameUser(long, String, String), updateUserCredential(long, String, com.atlassian.crowd.embedded.api.PasswordCredential), storeUserAttributes(long, String, java.util.Map), removeUserAttributes(long, String, String)

renameUser

User renameUser(long directoryId,
                String oldUsername,
                String newUsername)
                throws DirectoryNotFoundException,
                       UserNotFoundException,
                       OperationFailedException,
                       DirectoryPermissionException,
                       InvalidUserException,
                       UserAlreadyExistsException
Renames a user in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to find and update the user.
oldUsername - current username of the user.
newUsername - desired username of the user.
Returns:
updated user returned from the directory.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if no user with the supplied username exists in the directory
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_USER.
InvalidUserException - if the new username does not meet the username requirements of the directory
UserAlreadyExistsException - if the newUsername user already exists in the given directory
UnsupportedOperationException - if the directory does not support user renaming

storeUserAttributes

void storeUserAttributes(long directoryId,
                         String username,
                         Map<String,Set<String>> attributes)
                         throws DirectoryPermissionException,
                                DirectoryNotFoundException,
                                UserNotFoundException,
                                OperationFailedException
Adds or updates a user's attributes with the new Map of attribute values in the directory specified by the passed in directoryId.

The attributes map represents new or updated attributes and does not replace existing attributes unless the key of an attribute matches the key of an existing attribute on the user.

This method does not update primary field attributes like firstName, lastName, etc.

Parameters:
directoryId - ID of the directory to find and update the user.
username - username of the user to update.
attributes - map of one-to-many attribute-values. All attribute keys are treated as new or updated attributes.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if no user with the supplied username exists in the directory
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_USER_ATTRIBUTE.
See Also:
updateUser(long, com.atlassian.crowd.model.user.UserTemplate)

removeUserAttributes

void removeUserAttributes(long directoryId,
                          String username,
                          String attributeName)
                          throws DirectoryPermissionException,
                                 DirectoryNotFoundException,
                                 UserNotFoundException,
                                 OperationFailedException
Removes a user's attribute values in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to find and update the user.
username - username of the user to update.
attributeName - all attribute values for this key will be removed from the user.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if no user with the supplied username exists in the directory
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_USER_ATTRIBUTE.
See Also:
updateUser(long, com.atlassian.crowd.model.user.UserTemplate)

updateUserCredential

void updateUserCredential(long directoryId,
                          String username,
                          PasswordCredential credential)
                          throws DirectoryPermissionException,
                                 InvalidCredentialException,
                                 DirectoryNotFoundException,
                                 UserNotFoundException,
                                 OperationFailedException
This will update the user's credential in the given directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to find and update the user.
username - username of the user to update.
credential - the new password credential for the user (unencrypted).
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_USER.
InvalidCredentialException - if the new credential does not meet the requirements for the given directory.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if no user with the supplied username exists in the directory

resetPassword

void resetPassword(long directoryId,
                   String username)
                   throws DirectoryNotFoundException,
                          UserNotFoundException,
                          InvalidEmailAddressException,
                          DirectoryPermissionException,
                          InvalidCredentialException,
                          OperationFailedException
Deprecated. since 2.1

Resets the password of user in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to find and update the user credential.
username - username of the user to update.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if no user with the supplied username exists in the directory
OperationFailedException - underlying directory implementation failed to execute the operation.
InvalidEmailAddressException - if the user does not have a valid email address to send the password reset email to.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_USER.
InvalidCredentialException - if the randomly generated credential does not meet the requirements for the given directory.

removeUser

void removeUser(long directoryId,
                String username)
                throws DirectoryNotFoundException,
                       UserNotFoundException,
                       DirectoryPermissionException,
                       OperationFailedException
Removes a user matching the supplied username in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to remove the user from.
username - username of the user to remove.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if no user with the supplied username exists in the directory
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.DELETE_USER.
OperationFailedException - underlying directory implementation failed to execute the operation.

findGroupByName

Group findGroupByName(long directoryId,
                      String groupName)
                      throws GroupNotFoundException,
                             DirectoryNotFoundException,
                             OperationFailedException
Returns the group matching the supplied groupName in the directory specified by the passed in directoryId..

Parameters:
directoryId - ID of the directory to search.
groupName - groupName of the group to retrieve.
Returns:
group matching the supplied groupName.
Throws:
GroupNotFoundException - if no group with the supplied groupName exists in the directory
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
OperationFailedException - underlying directory implementation failed to execute the operation.
See Also:
findGroupWithAttributesByName(long, String)

findGroupWithAttributesByName

GroupWithAttributes findGroupWithAttributesByName(long directoryId,
                                                  String groupName)
                                                  throws GroupNotFoundException,
                                                         DirectoryNotFoundException,
                                                         OperationFailedException
Returns the group with all attributes matching the supplied groupName in the directory specified by the passed in directoryId..

Parameters:
directoryId - ID of the directory to search.
groupName - groupName of the group to retrieve.
Returns:
group (with all attributes) matching the supplied groupName.
Throws:
GroupNotFoundException - if no group with the supplied groupName exists in the directory
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
OperationFailedException - underlying directory implementation failed to execute the operation.
See Also:
findGroupByName(long, String)

searchGroups

<T> List<T> searchGroups(long directoryId,
                         EntityQuery<T> query)
                     throws DirectoryNotFoundException,
                            OperationFailedException
Returns a list of groups matching the given query in the directory specified by the passed in directoryId..

Parameters:
directoryId - ID of the directory to search.
query - query to exectute.
Returns:
List of Group entities or String groupNames matching the query criteria.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.

addGroup

Group addGroup(long directoryId,
               GroupTemplate group)
               throws InvalidGroupException,
                      DirectoryPermissionException,
                      DirectoryNotFoundException,
                      OperationFailedException
Adds a Group to the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to add the group to.
group - a template of the group to be added.
Returns:
the added group returned from the directory.
Throws:
InvalidGroupException - if the group already exists in the given directory.
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.CREATE_GROUP.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found after the add operation.

updateGroup

Group updateGroup(long directoryId,
                  GroupTemplate group)
                  throws GroupNotFoundException,
                         DirectoryNotFoundException,
                         DirectoryPermissionException,
                         InvalidGroupException,
                         OperationFailedException,
                         ReadOnlyGroupException
Updates a group with the supplied template and returns the updated group retrieved from the directory specified by the passed in directoryId.

This method cannot be used to rename the group, update the group's credentials or update the group's custom attributes.

Parameters:
directoryId - ID of the directory to find and update the group.
group - template of the group to update.
Returns:
the updated group returned from the directory.
Throws:
GroupNotFoundException - if no group with the supplied groupName exists in the directory
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
InvalidGroupException - if the group template does not have the required properties populated.
ReadOnlyGroupException - if the group is read-only
See Also:
renameGroup(long, String, String), storeGroupAttributes(long, String, java.util.Map), removeGroupAttributes(long, String, String)

renameGroup

Group renameGroup(long directoryId,
                  String oldGroupname,
                  String newGroupname)
                  throws GroupNotFoundException,
                         DirectoryNotFoundException,
                         DirectoryPermissionException,
                         InvalidGroupException,
                         OperationFailedException
Renames a group in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to find and update the group.
oldGroupname - current groupName of the group.
newGroupname - desired groupName of the group.
Returns:
updated group returned from the directory.
Throws:
GroupNotFoundException - if the group with the oldGroupname does not exist in the directory or if the directory with the given directoryId cannot be found.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
InvalidGroupException - if the new groupName does not meet the groupName requirements of the directory or if a group already exists with the new groupName.

storeGroupAttributes

void storeGroupAttributes(long directoryId,
                          String groupName,
                          Map<String,Set<String>> attributes)
                          throws DirectoryPermissionException,
                                 GroupNotFoundException,
                                 DirectoryNotFoundException,
                                 OperationFailedException
Adds or updates a group's attributes with the new Map of attribute values in the directory specified by the passed in directoryId.

The attributes map represents new or updated attributes and does not replace existing attributes unless the key of an attribute matches the key of an existing attribute on the group.

This method does not update primary field attributes like firstName, lastName, etc.

Parameters:
directoryId - ID of the directory to find and update the group.
groupName - groupName of the group to update.
attributes - map of one-to-many attribute-values. All attribute keys are treated as new or updated attributes.
Throws:
GroupNotFoundException - if no group with the supplied groupName exists in the directory
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP_ATTRIBUTE.
See Also:
updateGroup(long, com.atlassian.crowd.model.group.GroupTemplate)

removeGroupAttributes

void removeGroupAttributes(long directoryId,
                           String groupName,
                           String attributeName)
                           throws DirectoryPermissionException,
                                  GroupNotFoundException,
                                  DirectoryNotFoundException,
                                  OperationFailedException
Removes a group's attribute values in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to find and update the group.
groupName - groupName of the group to update.
attributeName - all attribute values for this key will be removed from the group.
Throws:
GroupNotFoundException - if no group with the supplied groupName exists in the directory
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP_ATTRIBUTE.
See Also:
updateGroup(long, com.atlassian.crowd.model.group.GroupTemplate)

removeGroup

void removeGroup(long directoryId,
                 String groupName)
                 throws GroupNotFoundException,
                        DirectoryNotFoundException,
                        DirectoryPermissionException,
                        OperationFailedException,
                        ReadOnlyGroupException
Removes a group matching the supplied groupName in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to remove the group from.
groupName - groupName of the group to remove.
Throws:
GroupNotFoundException - if no group with the supplied groupName exists in the directory
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.DELETE_GROUP.
ReadOnlyGroupException - if the group is read-only
OperationFailedException - underlying directory implementation failed to execute the operation.

isUserDirectGroupMember

boolean isUserDirectGroupMember(long directoryId,
                                String username,
                                String groupName)
                                throws DirectoryNotFoundException,
                                       OperationFailedException
Returns true if the user is a direct member of the group in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to inspect membership information.
username - name of the user to inspect.
groupName - name of the group to inspect.
Returns:
true if and only if the user is a direct member of the group. If the group or user does not exist in the directory, false is returned.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.

isGroupDirectGroupMember

boolean isGroupDirectGroupMember(long directoryId,
                                 String childGroup,
                                 String parentGroup)
                                 throws DirectoryNotFoundException,
                                        OperationFailedException
Returns true if the childGroup is a direct member of the parentGroup in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to inspect membership information.
childGroup - name of the group to inspect.
parentGroup - name of the group to inspect.
Returns:
true if and only if the childGroup is a direct member of the parentGroup. If either group does not exist in the directory, false is returned.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.

addUserToGroup

void addUserToGroup(long directoryId,
                    String username,
                    String groupName)
                    throws DirectoryPermissionException,
                           DirectoryNotFoundException,
                           UserNotFoundException,
                           GroupNotFoundException,
                           OperationFailedException,
                           ReadOnlyGroupException
Adds an existing user as a direct member of an existing group in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to add membership information.
username - username of the user.
groupName - name of the group.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if the user does not exist in the directory
GroupNotFoundException - if the group does not exist in the directory
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
ReadOnlyGroupException - if the group is read-only

addGroupToGroup

void addGroupToGroup(long directoryId,
                     String childGroup,
                     String parentGroup)
                     throws DirectoryPermissionException,
                            DirectoryNotFoundException,
                            GroupNotFoundException,
                            InvalidMembershipException,
                            NestedGroupsNotSupportedException,
                            OperationFailedException,
                            ReadOnlyGroupException
Adds an existing child group as direct member of an existing parent group in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to add membership information.
childGroup - name of child group.
parentGroup - name of the parent group.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
GroupNotFoundException - if the group does not exist in the directory
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
InvalidMembershipException - GroupType of childGroup does not match parentGroup.
NestedGroupsNotSupportedException - If the directory does not support nested groups.
ReadOnlyGroupException - if the group is read-only

removeUserFromGroup

void removeUserFromGroup(long directoryId,
                         String username,
                         String groupName)
                         throws DirectoryPermissionException,
                                DirectoryNotFoundException,
                                UserNotFoundException,
                                GroupNotFoundException,
                                MembershipNotFoundException,
                                OperationFailedException,
                                ReadOnlyGroupException
Removes an existing user from being a direct member of an existing group in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to add membership information.
username - username of the user.
groupName - name of the group.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
UserNotFoundException - if the user does not exist in the directory
GroupNotFoundException - if the group does not exist in the directory
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
MembershipNotFoundException - user is not a direct member of group.
ReadOnlyGroupException - if the group is read-only

removeGroupFromGroup

void removeGroupFromGroup(long directoryId,
                          String childGroup,
                          String parentGroup)
                          throws DirectoryPermissionException,
                                 GroupNotFoundException,
                                 DirectoryNotFoundException,
                                 InvalidMembershipException,
                                 MembershipNotFoundException,
                                 OperationFailedException,
                                 ReadOnlyGroupException
Removes an existing child group from being a direct member of an existing parent group in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to add membership information.
childGroup - name of child group.
parentGroup - name of the parent group.
Throws:
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
GroupNotFoundException - if the group does not exist in the directory
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
MembershipNotFoundException - group is not a direct member of group.
InvalidMembershipException - GroupType of childGroup does not match parentGroup.
ReadOnlyGroupException - if the group is read-only

searchDirectGroupRelationships

<T> List<T> searchDirectGroupRelationships(long directoryId,
                                           MembershipQuery<T> query)
                                       throws DirectoryNotFoundException,
                                              OperationFailedException
Searches for direct group relationships in the directory specified by the passed in directoryId.

Parameters:
directoryId - ID of the directory to inspect membership information.
query - membership query.
Returns:
List of User entities, Group entites, String usernames or String group names matching the query criteria. If there are no results, returns an empty List.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.

isUserNestedGroupMember

boolean isUserNestedGroupMember(long directoryId,
                                String username,
                                String groupName)
                                throws DirectoryNotFoundException,
                                       OperationFailedException
Returns true if the user is a direct or indirect (nested) member of the group in the directory specified by the passed in directoryId.

If the directory does not support nested groups, this call will be equivalent to isUserDirectGroupMember(long, String, String).

WARNING: this method could be very slow if the underlying RemoteDirectory does not employ caching.

Parameters:
directoryId - ID of the directory to inspect membership information.
username - name of the user to inspect.
groupName - name of the group to inspect.
Returns:
true if and only if the user is a direct or indirect (nested) member of the group. If the group or user does not exist in the directory, false is returned.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.

isGroupNestedGroupMember

boolean isGroupNestedGroupMember(long directoryId,
                                 String childGroup,
                                 String parentGroup)
                                 throws DirectoryNotFoundException,
                                        OperationFailedException
Returns true if the childGroup is a direct or indirect (nested) member of the parentGroup in the directory specified by the passed in directoryId.

If the directory does not support nested groups, this call will be equivalent to isGroupDirectGroupMember(long, String, String).

WARNING: this method could be very slow if the underlying RemoteDirectory does not employ caching.

Parameters:
directoryId - ID of the directory to inspect membership information.
childGroup - name of the user to inspect.
parentGroup - name of the group to inspect.
Returns:
true if and only if the childGroup is a direct or indirect (nested) member of the parentGruop. If either group does not exist in the directory, false is returned.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.

searchNestedGroupRelationships

<T> List<T> searchNestedGroupRelationships(long directoryId,
                                           MembershipQuery<T> query)
                                       throws DirectoryNotFoundException,
                                              OperationFailedException
Searches for direct and indirect (nested) group relationships in the directory specified by the passed in directoryId.

If the directory does not support nested groups, this call will be equivalent to searchDirectGroupRelationships(long, com.atlassian.crowd.search.query.membership.MembershipQuery).

WARNING: this method could be very slow if the underlying RemoteDirectory does not employ caching.

Parameters:
directoryId - ID of the directory to inspect membership information.
query - membership query.
Returns:
List of User entities, Group entites, String usernames or String group names matching the query criteria.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.

addAllUsers

BulkAddResult<User> addAllUsers(long directoryId,
                                Collection<UserTemplateWithCredentialAndAttributes> users,
                                boolean overwrite)
                                throws DirectoryPermissionException,
                                       DirectoryNotFoundException,
                                       OperationFailedException
Will add a collection of users to the directory specified by the passed in directoryId param.

If adding a particular user fails then this user will be skipped and the error will be reported in the logs and the BulkAddResult object.

If the underlying directory supports bulk adding of entities (ie. implements InternalRemoteDirectory), it may be faster than manual iteration of each entity.

Parameters:
directoryId - the directory to add the User too.
users - the templates of the users to add.
overwrite - true if you want to remove any existing user matching a username in the users to add prior to adding the user. false if you want to skip over users that already exist (same username exists).
Returns:
results for bulk add process.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.CREATE_USER.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.

addAllGroups

BulkAddResult<Group> addAllGroups(long directoryId,
                                  Collection<GroupTemplate> groups,
                                  boolean overwrite)
                                  throws DirectoryPermissionException,
                                         DirectoryNotFoundException,
                                         OperationFailedException,
                                         InvalidGroupException
Will add a collection of Group to the directory specified by the passed in directoryId param.

If adding a group fails then this user will be skipped and the error will be reported in the logs and the BulkAddResult object.

If the underlying directory supports bulk adding of entities (ie. implements InternalRemoteDirectory), it may be faster than manual iteration of each entity.

Parameters:
directoryId - the directory to add the Group too.
groups - the Groups to add.
overwrite - true if you want to remove any existing group matching a username in the groups to add prior to adding the group. false if you want to skip over groups that already exist (same group name exists).
Returns:
results for bulk add process.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.CREATE_GROUP.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
InvalidGroupException - if any of the group is invalid

addAllUsersToGroup

BulkAddResult<String> addAllUsersToGroup(long directoryID,
                                         Collection<String> userNames,
                                         String groupName)
                                         throws DirectoryPermissionException,
                                                DirectoryNotFoundException,
                                                GroupNotFoundException,
                                                OperationFailedException,
                                                UserNotFoundException
A bulk version of addUserToGroup(long, String, String).

If creating a particular membership fails, it will be skipped and the error will be reported in the logs and the BulkAddResult object.

If the underlying directory supports bulk adding of entities (ie. implements InternalRemoteDirectory), it may be faster than manual iteration of each entity.

Parameters:
directoryID - the directory to add the membership to.
userNames - usernames of users to add membership to.
groupName - name of group to add users to.
Returns:
results for bulk add process consisting of the names of the users which could not be added to the group.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
DirectoryNotFoundException - if the directory with the given directoryId cannot be found.
GroupNotFoundException - if the groupName did not resolve to a group
UserNotFoundException - if any of the user does not exist

supportsNestedGroups

boolean supportsNestedGroups(long directoryId)
                             throws DirectoryInstantiationException,
                                    DirectoryNotFoundException
Returns true if the underlying directory implementation supports nested groups.

Parameters:
directoryId - ID of directory.
Returns:
true if the directory supports nested groups
Throws:
DirectoryInstantiationException - if there was an error instantiating the directory
DirectoryNotFoundException - if the directory could not be found.

isSynchronisable

boolean isSynchronisable(long directoryId)
                         throws DirectoryInstantiationException,
                                DirectoryNotFoundException
Returns true if the underlying directory implementation supports manual synchronisation of the directory's local cache.

That is if we keep a local cache that is periodically updated from the remote server.

Parameters:
directoryId - ID of directory.
Returns:
true if the directory supports synchronisation
Throws:
DirectoryInstantiationException - if there was an error instantiating the directory
DirectoryNotFoundException - if the directory could not be found.

synchroniseCache

void synchroniseCache(long directoryId,
                      SynchronisationMode mode)
                      throws OperationFailedException,
                             DirectoryNotFoundException
Requests that this directory should update its cache by synchronising with the remote User data. The synchronisation will occur asynchronously, i.e. this method returns immediately and the synchronization continues in the background.

If a synchronisation is currently in progress when this method is called, then this method does nothing.

Parameters:
directoryId - ID of directory.
mode - the mode of the synchronisation
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryNotFoundException - if the directory could not be found.

synchroniseCache

void synchroniseCache(long directoryId,
                      SynchronisationMode mode,
                      boolean runInBackground)
                      throws OperationFailedException,
                             DirectoryNotFoundException
Requests that this directory should update its cache by synchronising with the remote User data.

If a synchronisation is currently in progress when this method is called, then this method does nothing if runInBackGround is true, otherwise it will throw OperationFailedException.

Parameters:
directoryId - ID of directory.
mode - the mode of the synchronisation
runInBackground - If True the synchronise will happen asynchronously.
Throws:
OperationFailedException - underlying directory implementation failed to execute the operation.
DirectoryNotFoundException - if the directory could not be found.

isSynchronising

boolean isSynchronising(long directoryId)
                        throws DirectoryInstantiationException,
                               DirectoryNotFoundException
Returns true if the given Directory is currently synchronising. This method should only be used to give an indication regarding the synchronisation state in the UI and should not be used to control whether or not to start another synchronisation.

Parameters:
directoryId - ID of directory.
Returns:
true if the given Directory is currently synchronising, otherwise false.
Throws:
DirectoryInstantiationException - if there was an error instantiating the directory
DirectoryNotFoundException - if the directory could not be found

getDirectorySynchronisationInformation

DirectorySynchronisationInformation getDirectorySynchronisationInformation(long directoryId)
                                                                           throws DirectoryInstantiationException,
                                                                                  DirectoryNotFoundException
Retrieves the sync info for the directory - last sync start time & duration, current sync start time (if directory is currently synchronising)

Parameters:
directoryId - ID of directory
Returns:
a DirectorySynchronisationInformation object that contains the synchronisation information for the directory. null if the RemoteDirectory is not an instance of SynchronisableDirectory
Throws:
DirectoryInstantiationException - if there was an error instantiating the directory
DirectoryNotFoundException - if the directory could not be found.


Copyright © 2013 Atlassian. All Rights Reserved.