com.atlassian.crowd.manager.directory
Class DirectoryManagerGeneric

java.lang.Object
  extended by com.atlassian.crowd.manager.directory.DirectoryManagerGeneric
All Implemented Interfaces:
DirectoryManager
Direct Known Subclasses:
MockDirectoryManager

public class DirectoryManagerGeneric
extends java.lang.Object
implements DirectoryManager


Constructor Summary
DirectoryManagerGeneric()
           
 
Method Summary
 BulkAddResult<Group> addAllGroups(long directoryId, java.util.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, java.util.Collection<UserTemplateWithCredentialAndAttributes> users, boolean overwrite)
          Will add a collection of users to the directory specified by the passed in directoryId param.
 BulkAddResult<java.lang.String> addAllUsersToGroup(long directoryId, java.util.Collection<java.lang.String> userNames, java.lang.String groupName)
          A bulk version of DirectoryManager.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, java.lang.String childGroup, java.lang.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, java.lang.String username, java.lang.String groupName)
          Adds an existing user as a direct member of an existing group in the directory specified by the passed in directoryId.
 java.util.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(java.lang.String name)
          Finds a directory given the supplied name.
 Group findGroupByName(long directoryId, java.lang.String groupName)
          Returns the group matching the supplied groupName in the directory specified by the passed in directoryId..
 GroupWithAttributes findGroupWithAttributesByName(long directoryId, java.lang.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, java.lang.String username)
          Returns the user matching the supplied username in the directory specified by the passed in directoryId..
 User findUserByToken(java.lang.String key)
          Will find a user via the passed in token key.
 UserWithAttributes findUserWithAttributesByName(long directoryId, java.lang.String username)
          Returns the user with all attributes matching the supplied username in the directory specified by the passed in directoryId..
 void invalidateToken(java.lang.String tokenKey)
          Attempts to invalidate a Token based on the passed in Token key (random hash).
 boolean isGroupDirectGroupMember(long directoryId, java.lang.String childGroup, java.lang.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, java.lang.String childGroup, java.lang.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 isUserDirectGroupMember(long directoryId, java.lang.String username, java.lang.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, java.lang.String username, java.lang.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 removeExpiredTokens()
          Removes all tokens that have exceeded their expiry time.
 void removeGroup(long directoryId, java.lang.String groupName)
          Removes a group matching the supplied groupName in the directory specified by the passed in directoryId.
 void removeGroupAttributes(long directoryId, java.lang.String groupName, java.lang.String attributeName)
          Removes a group's attribute values in the directory specified by the passed in directoryId.
 void removeGroupFromGroup(long directoryId, java.lang.String childGroup, java.lang.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, java.lang.String username)
          Removes a user matching the supplied username in the directory specified by the passed in directoryId.
 void removeUserAttributes(long directoryId, java.lang.String username, java.lang.String attributeName)
          Removes a user's attribute values in the directory specified by the passed in directoryId.
 void removeUserFromGroup(long directoryId, java.lang.String username, java.lang.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, java.lang.String oldGroupname, java.lang.String newGroupname)
          Renames a group in the directory specified by the passed in directoryId.
 User renameUser(long directoryId, java.lang.String oldUsername, java.lang.String newUsername)
          Renames a user in the directory specified by the passed in directoryId.
 void resetPassword(long directoryId, java.lang.String username)
          Resets the password of user in the directory specified by the passed in directoryId.
 java.util.List searchDirectGroupRelationships(long directoryId, MembershipQuery query)
          Searches for direct group relationships in the directory specified by the passed in directoryId.
 java.util.List<Directory> searchDirectories(EntityQuery query)
          Returns a List of Directories matching the search query.
 java.util.List searchGroups(long directoryId, EntityQuery query)
          Returns a list of groups matching the given query in the directory specified by the passed in directoryId..
 java.util.List searchNestedGroupRelationships(long directoryId, MembershipQuery query)
          Searches for direct and indirect (nested) group relationships in the directory specified by the passed in directoryId.
 java.util.List<Token> searchTokens(EntityQuery query)
          Returns a list of users matching the given query.
 java.util.List searchUsers(long directoryId, EntityQuery query)
          Returns a list of users matching the given query in the directory specified by the passed in directoryId..
 void setApplicationDAO(ApplicationDAO applicationDAO)
           
 void setDirectoryDAO(DirectoryDAO directoryDAO)
           
 void setEventManager(com.atlassian.event.EventManager eventManager)
           
 void setI18nHelper(I18nHelper i18nHelper)
           
 void setPasswordHelper(PasswordHelper passwordHelper)
           
 void setPermissionManager(PermissionManager permissionManager)
           
 void setPropertyManager(PropertyManager propertyManager)
           
 void setTokenDAO(TokenDAO tokenDAO)
           
 void storeGroupAttributes(long directoryId, java.lang.String groupName, java.util.Map<java.lang.String,java.util.List<java.lang.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, java.lang.String username, java.util.Map<java.lang.String,java.util.List<java.lang.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.
 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, java.lang.String username, PasswordCredential credential)
          This will update the user's credential in the given directory specified by the passed in directoryId.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectoryManagerGeneric

public DirectoryManagerGeneric()
Method Detail

addDirectory

public Directory addDirectory(Directory directory)
                       throws DirectoryInstantiationException
Description copied from interface: DirectoryManager
Adds the given directory.

Specified by:
addDirectory in interface DirectoryManager
Parameters:
directory - the Directory to add
Returns:
the added Directory
Throws:
DirectoryInstantiationException - if there was an error instantiating the directory

findDirectoryById

public Directory findDirectoryById(long directoryId)
                            throws ObjectNotFoundException
Description copied from interface: DirectoryManager
Returns a Directory based on the passed in directoryId.

Specified by:
findDirectoryById in interface DirectoryManager
Parameters:
directoryId - the id of the directory to find
Returns:
the directory
Throws:
ObjectNotFoundException - is thrown if the Directory cannot be found.

findAllDirectories

public java.util.List<Directory> findAllDirectories()
Description copied from interface: DirectoryManager
Returns a List of all directories in the system.

Specified by:
findAllDirectories in interface DirectoryManager
Returns:
List of all Directories.

searchDirectories

public java.util.List<Directory> searchDirectories(EntityQuery query)
Description copied from interface: DirectoryManager
Returns a List of Directories matching the search query.

Specified by:
searchDirectories in interface DirectoryManager
Parameters:
query - the context to search on
Returns:
a List of directories, or an Empty List of none are found

findDirectoryByName

public Directory findDirectoryByName(java.lang.String name)
                              throws ObjectNotFoundException
Description copied from interface: DirectoryManager
Finds a directory given the supplied name.

Specified by:
findDirectoryByName in interface DirectoryManager
Parameters:
name - the name of the directory
Returns:
the directory with the given name
Throws:
ObjectNotFoundException - if no Directory is found

updateDirectory

public Directory updateDirectory(Directory directory)
                          throws ObjectNotFoundException
Description copied from interface: DirectoryManager
Updates the passed in directory.

Specified by:
updateDirectory in interface DirectoryManager
Parameters:
directory - the directory with updated attrbutes
Returns:
the updated directory
Throws:
ObjectNotFoundException - if no Directory is found

removeDirectory

public void removeDirectory(Directory directory)
                     throws ObjectNotFoundException
Description copied from interface: DirectoryManager
Removes a given directory and all its associated entities and mappings.

Specified by:
removeDirectory in interface DirectoryManager
Parameters:
directory - the directory to remove
Throws:
ObjectNotFoundException - if the directory cannot be found

invalidateToken

public void invalidateToken(java.lang.String tokenKey)
Description copied from interface: DirectoryManager
Attempts to invalidate a Token based on the passed in Token key (random hash).

If the token does not exist (ie. already invalidated) this method silently returns. If an existing token is successfully invalidated, a TokenInvalidatedEvent is fired.

Specified by:
invalidateToken in interface DirectoryManager
Parameters:
tokenKey - the token key (random hash) to invalidate.

searchTokens

public java.util.List<Token> searchTokens(EntityQuery query)
Description copied from interface: DirectoryManager
Returns a list of users matching the given query.

Specified by:
searchTokens in interface DirectoryManager
Parameters:
query - entity query for Entity.TOKEN.
Returns:
list of Token matching the search criteria.

removeExpiredTokens

public void removeExpiredTokens()
Description copied from interface: DirectoryManager
Removes all tokens that have exceeded their expiry time.

NOTE: Do not call this method from the web layer, as this is wrapped in a Spring managed transaction.

Specified by:
removeExpiredTokens in interface DirectoryManager

findUserByToken

public User findUserByToken(java.lang.String key)
                     throws InvalidTokenException,
                            DirectoryAccessException
Description copied from interface: DirectoryManager
Will find a user via the passed in token key.

Specified by:
findUserByToken in interface DirectoryManager
Parameters:
key - the token key
Returns:
the User associated to the given token key
Throws:
InvalidTokenException - if the User or Directory cannot be found that relates to the given token, or the token is associated to an Application and not a User
DirectoryAccessException - if there was an issue accessing the user from the underlying directory

findUserByName

public User findUserByName(long directoryId,
                           java.lang.String username)
                    throws ObjectNotFoundException,
                           DirectoryAccessException
Description copied from interface: DirectoryManager
Returns the user matching the supplied username in the directory specified by the passed in directoryId..

Specified by:
findUserByName in interface DirectoryManager
Parameters:
directoryId - ID of the directory to search.
username - username of the user to retrieve.
Returns:
user matching the supplied username.
Throws:
ObjectNotFoundException - if no user with the supplied username exists in the directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error looking up the user or instantiating the RemoteDirectory.
See Also:
DirectoryManager.findUserWithAttributesByName(long, String)

findUserWithAttributesByName

public UserWithAttributes findUserWithAttributesByName(long directoryId,
                                                       java.lang.String username)
                                                throws ObjectNotFoundException,
                                                       DirectoryAccessException
Description copied from interface: DirectoryManager
Returns the user with all attributes matching the supplied username in the directory specified by the passed in directoryId..

Specified by:
findUserWithAttributesByName in interface DirectoryManager
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:
ObjectNotFoundException - if no user with the supplied username exists in the directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error looking up the user or instantiating the RemoteDirectory.
See Also:
DirectoryManager.findUserByName(long, String)

searchUsers

public java.util.List searchUsers(long directoryId,
                                  EntityQuery query)
                           throws DirectoryAccessException,
                                  ObjectNotFoundException
Description copied from interface: DirectoryManager
Returns a list of users matching the given query in the directory specified by the passed in directoryId..

Specified by:
searchUsers in interface DirectoryManager
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:
DirectoryAccessException - if there was an error executing the search or instantiating the RemoteDirectory.
ObjectNotFoundException - if the directory with the given directoryId cannot be found.

addUser

public User addUser(long directoryId,
                    UserTemplate user,
                    PasswordCredential credential)
             throws InvalidCredentialException,
                    InvalidUserException,
                    DirectoryAccessException,
                    DirectoryPermissionException,
                    ObjectNotFoundException
Description copied from interface: DirectoryManager
Adds a User to the directory specified by the passed in directoryId.

Specified by:
addUser in interface DirectoryManager
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 already exists in the given directory or the user template does not have the required properties populated.
DirectoryAccessException - if there was an error performing the add operation or instantiating the RemoteDirectory.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.CREATE_USER.
ObjectNotFoundException - if the directory with the given directoryId cannot be found OR the user cannot be retrieved from the directory after the add operation.

updateUser

public User updateUser(long directoryId,
                       UserTemplate user)
                throws ObjectNotFoundException,
                       DirectoryAccessException,
                       DirectoryPermissionException,
                       InvalidUserException
Description copied from interface: DirectoryManager
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.

Specified by:
updateUser in interface DirectoryManager
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:
ObjectNotFoundException - if the user with the template's username does not exist in this directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error updating the user or instantiating the RemoteDirectory.
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:
DirectoryManager.renameUser(long, String, String), DirectoryManager.updateUserCredential(long, String, com.atlassian.crowd.integration.authentication.PasswordCredential), DirectoryManager.storeUserAttributes(long, String, java.util.Map), DirectoryManager.removeUserAttributes(long, String, String)

renameUser

public User renameUser(long directoryId,
                       java.lang.String oldUsername,
                       java.lang.String newUsername)
                throws ObjectNotFoundException,
                       DirectoryAccessException,
                       DirectoryPermissionException,
                       InvalidUserException
Description copied from interface: DirectoryManager
Renames a user in the directory specified by the passed in directoryId.

Specified by:
renameUser in interface DirectoryManager
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:
ObjectNotFoundException - if the user with the oldUsername does not exist in the directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error renaming the user or instantiating the RemoteDirectory.
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 or if a user already exists with the new username.

storeUserAttributes

public void storeUserAttributes(long directoryId,
                                java.lang.String username,
                                java.util.Map<java.lang.String,java.util.List<java.lang.String>> attributes)
                         throws DirectoryAccessException,
                                DirectoryPermissionException,
                                ObjectNotFoundException
Description copied from interface: DirectoryManager
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.

Specified by:
storeUserAttributes in interface DirectoryManager
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:
DirectoryAccessException - if there was an error updating the user's attributes or instantiating the RemoteDirectory.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_USER.
ObjectNotFoundException - if the user with the supplied username does not exist in this directory or if the directory with the given directoryId cannot be found.
See Also:
DirectoryManager.updateUser(long, com.atlassian.crowd.integration.model.user.UserTemplate)

removeUserAttributes

public void removeUserAttributes(long directoryId,
                                 java.lang.String username,
                                 java.lang.String attributeName)
                          throws DirectoryAccessException,
                                 DirectoryPermissionException,
                                 ObjectNotFoundException
Description copied from interface: DirectoryManager
Removes a user's attribute values in the directory specified by the passed in directoryId.

Specified by:
removeUserAttributes in interface DirectoryManager
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:
DirectoryAccessException - if there was an error updating the user's attributes or instantiating the RemoteDirectory.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_USER.
ObjectNotFoundException - if the user with the supplied username does not exist in this directory or if the directory with the given directoryId cannot be found.
See Also:
DirectoryManager.updateUser(long, com.atlassian.crowd.integration.model.user.UserTemplate)

updateUserCredential

public void updateUserCredential(long directoryId,
                                 java.lang.String username,
                                 PasswordCredential credential)
                          throws DirectoryAccessException,
                                 DirectoryPermissionException,
                                 InvalidCredentialException,
                                 ObjectNotFoundException
Description copied from interface: DirectoryManager
This will update the user's credential in the given directory specified by the passed in directoryId.

Specified by:
updateUserCredential in interface DirectoryManager
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:
DirectoryAccessException - if there was an error updating the user's credential or instantiating the RemoteDirectory.
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.
ObjectNotFoundException - if no user with the supplied username exists in the directory or if the directory with the given directoryId cannot be found.

resetPassword

public void resetPassword(long directoryId,
                          java.lang.String username)
                   throws ObjectNotFoundException,
                          DirectoryAccessException,
                          InvalidEmailAddressException,
                          DirectoryPermissionException,
                          InvalidCredentialException
Description copied from interface: DirectoryManager
Resets the password of user in the directory specified by the passed in directoryId.

Specified by:
resetPassword in interface DirectoryManager
Parameters:
directoryId - ID of the directory to find and update the user credential.
username - username of the user to update.
Throws:
ObjectNotFoundException - if the user with the supplied username does not exist in this directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error updating the user's credential or instantiating the RemoteDirectory.
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

public void removeUser(long directoryId,
                       java.lang.String username)
                throws ObjectNotFoundException,
                       DirectoryPermissionException,
                       DirectoryAccessException
Description copied from interface: DirectoryManager
Removes a user matching the supplied username in the directory specified by the passed in directoryId.

Specified by:
removeUser in interface DirectoryManager
Parameters:
directoryId - ID of the directory to remove the user from.
username - username of the user to remove.
Throws:
ObjectNotFoundException - if the user does not exist in the directory or if the directory with the given directoryId cannot be found.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.DELETE_USER.
DirectoryAccessException - if there was an error removing the user or instantiating the RemoteDirectory.

findGroupByName

public Group findGroupByName(long directoryId,
                             java.lang.String groupName)
                      throws ObjectNotFoundException,
                             DirectoryAccessException
Description copied from interface: DirectoryManager
Returns the group matching the supplied groupName in the directory specified by the passed in directoryId..

Specified by:
findGroupByName in interface DirectoryManager
Parameters:
directoryId - ID of the directory to search.
groupName - groupName of the group to retrieve.
Returns:
group matching the supplied groupName.
Throws:
ObjectNotFoundException - if no group with the supplied groupName exists in the directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error looking up the group or instantiating the RemoteDirectory.
See Also:
DirectoryManager.findGroupWithAttributesByName(long, String)

findGroupWithAttributesByName

public GroupWithAttributes findGroupWithAttributesByName(long directoryId,
                                                         java.lang.String groupName)
                                                  throws ObjectNotFoundException,
                                                         DirectoryAccessException
Description copied from interface: DirectoryManager
Returns the group with all attributes matching the supplied groupName in the directory specified by the passed in directoryId..

Specified by:
findGroupWithAttributesByName in interface DirectoryManager
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:
ObjectNotFoundException - if no group with the supplied groupName exists in the directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error looking up the group or instantiating the RemoteDirectory.
See Also:
DirectoryManager.findGroupByName(long, String)

searchGroups

public java.util.List searchGroups(long directoryId,
                                   EntityQuery query)
                            throws DirectoryAccessException,
                                   ObjectNotFoundException
Description copied from interface: DirectoryManager
Returns a list of groups matching the given query in the directory specified by the passed in directoryId..

Specified by:
searchGroups in interface DirectoryManager
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:
DirectoryAccessException - if there was an error executing the search or instantiating the RemoteDirectory.
ObjectNotFoundException - if the directory with the given directoryId cannot be found.

addGroup

public Group addGroup(long directoryId,
                      GroupTemplate group)
               throws InvalidGroupException,
                      DirectoryAccessException,
                      DirectoryPermissionException,
                      ObjectNotFoundException
Description copied from interface: DirectoryManager
Adds a Group to the directory specified by the passed in directoryId.

Specified by:
addGroup in interface DirectoryManager
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.
DirectoryAccessException - if there was an error performing the add operation or instantiating the RemoteDirectory.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.CREATE_GROUP.
ObjectNotFoundException - if the directory with the given directoryId cannot be found OR the group cannot be retrieved from the directory after the add operation.

updateGroup

public Group updateGroup(long directoryId,
                         GroupTemplate group)
                  throws ObjectNotFoundException,
                         DirectoryAccessException,
                         DirectoryPermissionException,
                         InvalidGroupException
Description copied from interface: DirectoryManager
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.

Specified by:
updateGroup in interface DirectoryManager
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:
ObjectNotFoundException - if the group with the template's groupName does not exist in this directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error updating the group or instantiating the RemoteDirectory.
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.
See Also:
DirectoryManager.renameGroup(long, String, String), DirectoryManager.storeGroupAttributes(long, String, java.util.Map), DirectoryManager.removeGroupAttributes(long, String, String)

renameGroup

public Group renameGroup(long directoryId,
                         java.lang.String oldGroupname,
                         java.lang.String newGroupname)
                  throws ObjectNotFoundException,
                         DirectoryAccessException,
                         DirectoryPermissionException,
                         InvalidGroupException
Description copied from interface: DirectoryManager
Renames a group in the directory specified by the passed in directoryId.

Specified by:
renameGroup in interface DirectoryManager
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:
ObjectNotFoundException - if the group with the oldGroupname does not exist in the directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error renaming the group or instantiating the RemoteDirectory.
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

public void storeGroupAttributes(long directoryId,
                                 java.lang.String groupName,
                                 java.util.Map<java.lang.String,java.util.List<java.lang.String>> attributes)
                          throws DirectoryAccessException,
                                 DirectoryPermissionException,
                                 ObjectNotFoundException
Description copied from interface: DirectoryManager
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.

Specified by:
storeGroupAttributes in interface DirectoryManager
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:
DirectoryAccessException - if there was an error updating the group's attributes or instantiating the RemoteDirectory.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
ObjectNotFoundException - if the group with the supplied groupName does not exist in this directory or if the directory with the given directoryId cannot be found.
See Also:
DirectoryManager.updateGroup(long, com.atlassian.crowd.integration.model.group.GroupTemplate)

removeGroupAttributes

public void removeGroupAttributes(long directoryId,
                                  java.lang.String groupName,
                                  java.lang.String attributeName)
                           throws DirectoryAccessException,
                                  DirectoryPermissionException,
                                  ObjectNotFoundException
Description copied from interface: DirectoryManager
Removes a group's attribute values in the directory specified by the passed in directoryId.

Specified by:
removeGroupAttributes in interface DirectoryManager
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:
DirectoryAccessException - if there was an error updating the group's attributes or instantiating the RemoteDirectory.
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
ObjectNotFoundException - if the group with the supplied groupName does not exist in this directory or if the directory with the given directoryId cannot be found.
See Also:
DirectoryManager.updateGroup(long, com.atlassian.crowd.integration.model.group.GroupTemplate)

removeGroup

public void removeGroup(long directoryId,
                        java.lang.String groupName)
                 throws ObjectNotFoundException,
                        DirectoryPermissionException,
                        DirectoryAccessException
Description copied from interface: DirectoryManager
Removes a group matching the supplied groupName in the directory specified by the passed in directoryId.

Specified by:
removeGroup in interface DirectoryManager
Parameters:
directoryId - ID of the directory to remove the group from.
groupName - groupName of the group to remove.
Throws:
ObjectNotFoundException - if the group does not exist in the directory or 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.
DirectoryAccessException - if there was an error removing the group or instantiating the RemoteDirectory.

isUserDirectGroupMember

public boolean isUserDirectGroupMember(long directoryId,
                                       java.lang.String username,
                                       java.lang.String groupName)
                                throws ObjectNotFoundException,
                                       DirectoryAccessException
Description copied from interface: DirectoryManager
Returns true if the user is a direct member of the group in the directory specified by the passed in directoryId.

Specified by:
isUserDirectGroupMember in interface DirectoryManager
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:
ObjectNotFoundException - if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error executing the search or instantiating the RemoteDirectory.

isGroupDirectGroupMember

public boolean isGroupDirectGroupMember(long directoryId,
                                        java.lang.String childGroup,
                                        java.lang.String parentGroup)
                                 throws ObjectNotFoundException,
                                        DirectoryAccessException
Description copied from interface: DirectoryManager
Returns true if the childGroup is a direct member of the parentGroup in the directory specified by the passed in directoryId.

Specified by:
isGroupDirectGroupMember in interface DirectoryManager
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:
ObjectNotFoundException - if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error executing the search or instantiating the RemoteDirectory.

addUserToGroup

public void addUserToGroup(long directoryId,
                           java.lang.String username,
                           java.lang.String groupName)
                    throws DirectoryPermissionException,
                           ObjectNotFoundException,
                           DirectoryAccessException
Description copied from interface: DirectoryManager
Adds an existing user as a direct member of an existing group in the directory specified by the passed in directoryId.

Specified by:
addUserToGroup in interface DirectoryManager
Parameters:
directoryId - ID of the directory to add membership information.
username - username of the user.
groupName - name of the group.
Throws:
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
ObjectNotFoundException - if the user or group does not exist in the directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error executing the update or instantiating the RemoteDirectory.

addGroupToGroup

public void addGroupToGroup(long directoryId,
                            java.lang.String childGroup,
                            java.lang.String parentGroup)
                     throws DirectoryPermissionException,
                            ObjectNotFoundException,
                            DirectoryAccessException,
                            InvalidMembershipException
Description copied from interface: DirectoryManager
Adds an existing child group as direct member of an existing parent group in the directory specified by the passed in directoryId.

Specified by:
addGroupToGroup in interface DirectoryManager
Parameters:
directoryId - ID of the directory to add membership information.
childGroup - name of child group.
parentGroup - name of the parent group.
Throws:
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
ObjectNotFoundException - if either group does not exist in the directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error executing the update or instantiating the RemoteDirectory.
InvalidMembershipException - GroupType of childGroup does not match parentGroup.

removeUserFromGroup

public void removeUserFromGroup(long directoryId,
                                java.lang.String username,
                                java.lang.String groupName)
                         throws DirectoryPermissionException,
                                ObjectNotFoundException,
                                DirectoryAccessException,
                                MembershipNotFoundException
Description copied from interface: DirectoryManager
Removes an existing user from being a direct member of an existing group in the directory specified by the passed in directoryId.

Specified by:
removeUserFromGroup in interface DirectoryManager
Parameters:
directoryId - ID of the directory to add membership information.
username - username of the user.
groupName - name of the group.
Throws:
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
ObjectNotFoundException - if the user or group does not exist in the directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error executing the update or instantiating the RemoteDirectory.
MembershipNotFoundException - user is not a direct member of group.

removeGroupFromGroup

public void removeGroupFromGroup(long directoryId,
                                 java.lang.String childGroup,
                                 java.lang.String parentGroup)
                          throws DirectoryPermissionException,
                                 ObjectNotFoundException,
                                 DirectoryAccessException,
                                 InvalidMembershipException,
                                 MembershipNotFoundException
Description copied from interface: DirectoryManager
Removes an existing child group from being a direct member of an existing parent group in the directory specified by the passed in directoryId.

Specified by:
removeGroupFromGroup in interface DirectoryManager
Parameters:
directoryId - ID of the directory to add membership information.
childGroup - name of child group.
parentGroup - name of the parent group.
Throws:
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
ObjectNotFoundException - if either group does not exist in the directory or if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error executing the update or instantiating the RemoteDirectory.
InvalidMembershipException - GroupType of childGroup does not match parentGroup.
MembershipNotFoundException - group is not a direct member of group.

searchDirectGroupRelationships

public java.util.List searchDirectGroupRelationships(long directoryId,
                                                     MembershipQuery query)
                                              throws ObjectNotFoundException,
                                                     DirectoryAccessException
Description copied from interface: DirectoryManager
Searches for direct group relationships in the directory specified by the passed in directoryId.

Specified by:
searchDirectGroupRelationships in interface DirectoryManager
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:
ObjectNotFoundException - if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error executing the search or instantiating the RemoteDirectory.

isUserNestedGroupMember

public boolean isUserNestedGroupMember(long directoryId,
                                       java.lang.String username,
                                       java.lang.String groupName)
                                throws ObjectNotFoundException,
                                       DirectoryAccessException
Description copied from interface: DirectoryManager
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 DirectoryManager.isUserDirectGroupMember(long, String, String).

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

Specified by:
isUserNestedGroupMember in interface DirectoryManager
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:
ObjectNotFoundException - if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error executing the search or instantiating the RemoteDirectory.

isGroupNestedGroupMember

public boolean isGroupNestedGroupMember(long directoryId,
                                        java.lang.String childGroup,
                                        java.lang.String parentGroup)
                                 throws ObjectNotFoundException,
                                        DirectoryAccessException
Description copied from interface: DirectoryManager
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 DirectoryManager.isGroupDirectGroupMember(long, String, String).

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

Specified by:
isGroupNestedGroupMember in interface DirectoryManager
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:
ObjectNotFoundException - if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error executing the search or instantiating the RemoteDirectory.

searchNestedGroupRelationships

public java.util.List searchNestedGroupRelationships(long directoryId,
                                                     MembershipQuery query)
                                              throws ObjectNotFoundException,
                                                     DirectoryAccessException
Description copied from interface: DirectoryManager
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 DirectoryManager.searchDirectGroupRelationships(long, com.atlassian.crowd.search.query.membership.MembershipQuery).

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

Specified by:
searchNestedGroupRelationships in interface DirectoryManager
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:
ObjectNotFoundException - if the directory with the given directoryId cannot be found.
DirectoryAccessException - if there was an error executing the search or instantiating the RemoteDirectory.

addAllUsers

public BulkAddResult<User> addAllUsers(long directoryId,
                                       java.util.Collection<UserTemplateWithCredentialAndAttributes> users,
                                       boolean overwrite)
                                throws DirectoryPermissionException,
                                       DirectoryAccessException,
                                       ObjectNotFoundException
Description copied from interface: DirectoryManager
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 BatchingRemoteDirectory), it may be faster than manual iteration of each entity.

Specified by:
addAllUsers in interface DirectoryManager
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:
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.CREATE_USER.
DirectoryAccessException - if there was an error adding the user or instantiating the RemoteDirectory.
ObjectNotFoundException - if the directory with the given directoryId cannot be found.

addAllGroups

public BulkAddResult<Group> addAllGroups(long directoryId,
                                         java.util.Collection<GroupTemplate> groups,
                                         boolean overwrite)
                                  throws DirectoryPermissionException,
                                         DirectoryAccessException,
                                         ObjectNotFoundException
Description copied from interface: DirectoryManager
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 BatchingRemoteDirectory), it may be faster than manual iteration of each entity.

Specified by:
addAllGroups in interface DirectoryManager
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:
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.CREATE_GROUP.
DirectoryAccessException - if there was an error adding the Group or instantiating the RemoteDirectory.
ObjectNotFoundException - if the directory with the given directoryId cannot be found.

addAllUsersToGroup

public BulkAddResult<java.lang.String> addAllUsersToGroup(long directoryId,
                                                          java.util.Collection<java.lang.String> userNames,
                                                          java.lang.String groupName)
                                                   throws DirectoryPermissionException,
                                                          DirectoryAccessException,
                                                          ObjectNotFoundException
Description copied from interface: DirectoryManager
A bulk version of DirectoryManager.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 BatchingRemoteDirectory), it may be faster than manual iteration of each entity.

Specified by:
addAllUsersToGroup in interface DirectoryManager
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:
DirectoryPermissionException - if the directory is not allowed to perform operations of type OperationType.UPDATE_GROUP.
DirectoryAccessException - if there was an error adding the Group or instantiating the RemoteDirectory.
ObjectNotFoundException - if the directory with the given directoryId cannot be found.

setTokenDAO

public void setTokenDAO(TokenDAO tokenDAO)

setPropertyManager

public void setPropertyManager(PropertyManager propertyManager)

setI18nHelper

public void setI18nHelper(I18nHelper i18nHelper)

setDirectoryDAO

public void setDirectoryDAO(DirectoryDAO directoryDAO)

setApplicationDAO

public void setApplicationDAO(ApplicationDAO applicationDAO)

setPermissionManager

public void setPermissionManager(PermissionManager permissionManager)

setEventManager

public void setEventManager(com.atlassian.event.EventManager eventManager)

setPasswordHelper

public void setPasswordHelper(PasswordHelper passwordHelper)


Copyright © 2009 Atlassian Pty Ltd. All Rights Reserved.