com.atlassian.crowd.plugin.rest.service.controller
Class UsersController

java.lang.Object
  extended by com.atlassian.crowd.plugin.rest.service.controller.AbstractResourceController
      extended by com.atlassian.crowd.plugin.rest.service.controller.UsersController

public class UsersController
extends AbstractResourceController

Controller responsible for user management.


Field Summary
 
Fields inherited from class com.atlassian.crowd.plugin.rest.service.controller.AbstractResourceController
applicationManager, applicationService
 
Constructor Summary
UsersController(ApplicationService applicationService, ApplicationManager applicationManager, ForgottenLoginManager forgottenLoginManager)
           
 
Method Summary
 String addUser(String applicationName, UserEntity userEntity)
          Adds a new user.
 void addUserToGroup(String applicationName, String userName, String groupName)
          Adds a user to a group.
 UserEntity findUserByName(String applicationName, String name, com.atlassian.plugins.rest.common.Link userLink, boolean expandAttributes)
          Returns a UserEntity specified by the name.
 GroupEntity getDirectGroup(String applicationName, String userName, String groupName, URI baseUri)
          Returns the specified group that the user is a direct member of.
 GroupEntityList getDirectGroups(String applicationName, String userName, boolean expandGroups, int maxResults, int startIndex, URI baseUri)
          Returns the groups that the user is a direct member of.
 GroupEntity getNestedGroup(String applicationName, String userName, String groupName, URI baseUri)
          Returns the specified group that the user is a nested member of.
 GroupEntityList getNestedGroups(String applicationName, String userName, boolean expandGroups, int maxResults, int startIndex, URI baseUri)
          Returns the groups that the user is a nested member of.
 void removeUser(String applicationName, String username)
          Removes the user.
 void removeUserAttribute(String applicationName, String username, String attributeName)
          Removes the user attribute.
 void removeUserFromGroup(String applicationName, String userName, String groupName)
          Removes a user from a group.
 void requestPasswordReset(String applicationName, String username)
          Requests a password reset.
 boolean requestUsernames(String applicationName, String email)
          Requests an email to be sent containing usernames associated with the given email address.
 void storeUserAttributes(String applicationName, String username, MultiValuedAttributeEntityList attributes)
          Stores (add/replace) the user attributes.
 String updateUser(String applicationName, UserEntity userEntity)
          Updates a user.
 void updateUserPassword(String applicationName, String username, String password)
          Updates a user's password.
 
Methods inherited from class com.atlassian.crowd.plugin.rest.service.controller.AbstractResourceController
getApplication
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UsersController

public UsersController(ApplicationService applicationService,
                       ApplicationManager applicationManager,
                       ForgottenLoginManager forgottenLoginManager)
Method Detail

findUserByName

public UserEntity findUserByName(String applicationName,
                                 String name,
                                 com.atlassian.plugins.rest.common.Link userLink,
                                 boolean expandAttributes)
                          throws UserNotFoundException
Returns a UserEntity specified by the name.

Parameters:
applicationName - name of the application
name - name of the user to retrieve
userLink - link to the user resource
expandAttributes - set to true if the attributes field should be expanded
Returns:
UserEntity
Throws:
UserNotFoundException - if the user could not be found

addUser

public String addUser(String applicationName,
                      UserEntity userEntity)
               throws ApplicationPermissionException,
                      InvalidUserException,
                      InvalidCredentialException,
                      OperationFailedException
Adds a new user.

Parameters:
applicationName - name of the application
userEntity - new user to add
Returns:
canonical username
Throws:
ApplicationPermissionException - if none of the application's underlying directories are allowed to perform this operation
OperationFailedException - if the operation failed for any other reason
InvalidCredentialException - if the password is not valid
InvalidUserException - if the user is not valid

updateUser

public String updateUser(String applicationName,
                         UserEntity userEntity)
                  throws ApplicationPermissionException,
                         InvalidUserException,
                         UserNotFoundException,
                         OperationFailedException
Updates a user.

Parameters:
applicationName - name of the application
userEntity - updated user information
Returns:
canonical username
Throws:
ApplicationPermissionException - if none of the application's underlying directories are allowed to perform this operation
InvalidUserException - if the user template does not have the required properties populated.
UserNotFoundException - if the user was not found
OperationFailedException - if the operation failed for any other reason

storeUserAttributes

public void storeUserAttributes(String applicationName,
                                String username,
                                MultiValuedAttributeEntityList attributes)
                         throws ApplicationPermissionException,
                                UserNotFoundException,
                                OperationFailedException
Stores (add/replace) the user attributes. Attribute values will not be overwritten if not specified in attributes.

Parameters:
applicationName - name of the application
username - name of the user
attributes - attributes of the user
Throws:
ApplicationPermissionException - if none of the application's underlying directories are allowed to perform this operation
OperationFailedException - if the operation failed for any other reason
UserNotFoundException - if the user could not be found

removeUserAttribute

public void removeUserAttribute(String applicationName,
                                String username,
                                String attributeName)
                         throws ApplicationPermissionException,
                                UserNotFoundException,
                                OperationFailedException
Removes the user attribute.

Parameters:
applicationName - name of the application
username - name of the user
attributeName - name of attribute to remove
Throws:
ApplicationPermissionException - if none of the application's underlying directories have permission to perform the operation
OperationFailedException - if the operation failed for any other reason
UserNotFoundException - if the user could not be found

requestPasswordReset

public void requestPasswordReset(String applicationName,
                                 String username)
                          throws InvalidEmailAddressException,
                                 ApplicationPermissionException,
                                 ApplicationNotFoundException,
                                 UserNotFoundException
Requests a password reset.

Parameters:
applicationName - name of the application
username - name of the user
Throws:
UserNotFoundException - if the user could not be found
InvalidEmailAddressException - if the user does not have a valid email to send the reset password link to
ApplicationPermissionException - if none of the application's underlying directories can update the user's password
ApplicationNotFoundException - if the application could not be found

requestUsernames

public boolean requestUsernames(String applicationName,
                                String email)
                         throws InvalidEmailAddressException,
                                ApplicationNotFoundException
Requests an email to be sent containing usernames associated with the given email address.

Parameters:
applicationName - name of the application
email - email address of the user
Throws:
InvalidEmailAddressException - if the email is not valid
ApplicationNotFoundException - if the application could not be found

removeUser

public void removeUser(String applicationName,
                       String username)
                throws ApplicationPermissionException,
                       UserNotFoundException,
                       OperationFailedException
Removes the user.

Parameters:
applicationName - name of the application
username - name of the user
Throws:
ApplicationPermissionException - if none of the application's underlying directories can update the user's password
OperationFailedException - if the operation failed for any other reason
UserNotFoundException - if the user could not be found

updateUserPassword

public void updateUserPassword(String applicationName,
                               String username,
                               String password)
                        throws ApplicationPermissionException,
                               UserNotFoundException,
                               InvalidCredentialException,
                               OperationFailedException
Updates a user's password.

Parameters:
applicationName - name of the application
username - name of the user
password - new password
Throws:
ApplicationPermissionException - if none of the application's underlying directories are allowed to perform this operation
UserNotFoundException - if the user was not found
OperationFailedException - if the operation failed for any other reason
InvalidCredentialException - if the new password is not valid

getDirectGroups

public GroupEntityList getDirectGroups(String applicationName,
                                       String userName,
                                       boolean expandGroups,
                                       int maxResults,
                                       int startIndex,
                                       URI baseUri)
Returns the groups that the user is a direct member of.

Parameters:
applicationName - name of the application
userName - name of the user
expandGroups - should groups be expanded
maxResults - maximum number of results returned. If -1, then all the results are returned.
startIndex - starting index of the results
baseUri - base URI of the REST service
Returns:
groups that the user is a direct member of

getDirectGroup

public GroupEntity getDirectGroup(String applicationName,
                                  String userName,
                                  String groupName,
                                  URI baseUri)
                           throws MembershipNotFoundException
Returns the specified group that the user is a direct member of.

Parameters:
applicationName - name of the application
userName - name of the user
groupName - name of the group the user is a member of
baseUri - base URI of the REST service
Returns:
group that the user is a direct member of
Throws:
MembershipNotFoundException - if the membership was not found

addUserToGroup

public void addUserToGroup(String applicationName,
                           String userName,
                           String groupName)
                    throws ApplicationPermissionException,
                           UserNotFoundException,
                           GroupNotFoundException,
                           OperationFailedException
Adds a user to a group.

Parameters:
applicationName - name of the application
userName - name of the user
groupName - name of the group
Throws:
ApplicationPermissionException - if none of the application's associated directories are allowed to perform operations of type OperationType.UPDATE_GROUP.
UserNotFoundException - if the user could not be found
GroupNotFoundException - if the group could not be found
OperationFailedException - if the operation failed for any other reason

removeUserFromGroup

public void removeUserFromGroup(String applicationName,
                                String userName,
                                String groupName)
                         throws ApplicationPermissionException,
                                MembershipNotFoundException,
                                UserNotFoundException,
                                GroupNotFoundException,
                                OperationFailedException
Removes a user from a group.

Parameters:
applicationName - name of the application
userName - name of the user
groupName - name of the group
Throws:
ApplicationPermissionException - if none of the application's associated directories are allowed to perform operations of type OperationType.UPDATE_GROUP.
GroupNotFoundException - if the group could not be found
MembershipNotFoundException - if the membership does not exist
UserNotFoundException - if the user could not be found
OperationFailedException - if the operation failed for any other reason

getNestedGroups

public GroupEntityList getNestedGroups(String applicationName,
                                       String userName,
                                       boolean expandGroups,
                                       int maxResults,
                                       int startIndex,
                                       URI baseUri)
Returns the groups that the user is a nested member of.

Parameters:
applicationName - name of the application
userName - name of the user
expandGroups - should groups be expanded
maxResults - maximum number of results returned. If -1, then all the results are returned.
startIndex - starting index of the results
baseUri - base URI of the REST service
Returns:
groups that the user is a nested member of

getNestedGroup

public GroupEntity getNestedGroup(String applicationName,
                                  String userName,
                                  String groupName,
                                  URI baseUri)
                           throws MembershipNotFoundException
Returns the specified group that the user is a nested member of.

Parameters:
applicationName - name of the application
userName - name of the user
groupName - name of the group the user is a member of
baseUri - base URI of the REST service
Returns:
group that the user is a nested member of
Throws:
MembershipNotFoundException - if the membership was not found


Copyright © 2013 Atlassian. All Rights Reserved.