Package com.taskadapter.redmineapi
Class UserManager
- java.lang.Object
-
- com.taskadapter.redmineapi.UserManager
-
public class UserManager extends java.lang.ObjectWorks with Users and Groups.Obtain it via RedmineManager:
RedmineManager redmineManager = RedmineManagerFactory.createWithUserAuth(redmineURI, login, password); UserManager userManager = redmineManager.getUserManager();
Note that some operations with users require Redmine Admin privileges.Sample usage:
users = mgr.getUserManager().getUsers();- See Also:
RedmineManager.getUserManager()
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddUserToGroup(User user, Group group)Deprecated.GroupcreateGroup(Group base)Deprecated.UsercreateUser(User user)Deprecated.voiddeleteGroup(Group base)Deprecated.voiddeleteUser(java.lang.Integer userId)Deprecated.UsergetCurrentUser()GroupgetGroupById(int id)Returns the group based on its id.GroupgetGroupByName(java.lang.String name)Returns the group based on its name.java.util.List<Group>getGroups()Load list of groups on the server.RolegetRoleById(int id)java.util.List<Role>getRoles()UsergetUserById(java.lang.Integer userId)This does NOT require Admin privileges by default Redmine installation (tested with Redmine 2.0.3).java.util.List<User>getUsers()Load list of users from the server.ResultsWrapper<User>getUsers(java.util.Map<java.lang.String,java.lang.String> parameters)This method does NOT handle paging for you.voidupdate(Group group)Deprecated.voidupdate(User obj)Deprecated.
-
-
-
Method Detail
-
getCurrentUser
public User getCurrentUser() throws RedmineException
- Returns:
- the current user logged into Redmine
- Throws:
RedmineException
-
createUser
@Deprecated public User createUser(User user) throws RedmineException
Deprecated.DEPRECATED. use user.create() instead.- Throws:
RedmineException
-
deleteUser
@Deprecated public void deleteUser(java.lang.Integer userId) throws RedmineExceptionDeprecated.DEPRECATED. use user.delete() instead- Parameters:
userId- user identifier (numeric ID)- Throws:
RedmineAuthenticationException- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.NotFoundException- if the user with the given id is not foundRedmineException
-
addUserToGroup
@Deprecated public void addUserToGroup(User user, Group group) throws RedmineException
Deprecated.DEPRECATED. use user.addToGroup()- Throws:
RedmineException
-
getUsers
public java.util.List<User> getUsers() throws RedmineException
Load list of users from the server.This operation requires "Redmine Administrator" permission.
This method calls Redmine with "include = memberships,groups" parameter.
- Returns:
- list of User objects
- Throws:
RedmineAuthenticationException- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.NotFoundExceptionRedmineException
-
getUsers
public ResultsWrapper<User> getUsers(java.util.Map<java.lang.String,java.lang.String> parameters) throws RedmineException
This method does NOT handle paging for you. You need to provide "offset" and "limit" parameters if you want to control paging.
Sample usage:
final Mapparams = new HashMap (); params.put("name", name); final List users = userManager.getUsers(params); - Parameters:
parameters- http parameters: key/value pairs to append to the rest api request- Returns:
- resultsWrapper with raw response from Redmine REST API
- Throws:
RedmineAuthenticationException- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.RedmineException
-
getUserById
public User getUserById(java.lang.Integer userId) throws RedmineException
This does NOT require Admin privileges by default Redmine installation (tested with Redmine 2.0.3).- Throws:
RedmineException
-
getGroups
public java.util.List<Group> getGroups() throws RedmineException
Load list of groups on the server.This operation requires "Redmine Administrator" permission.
- Returns:
- list of User objects
- Throws:
RedmineAuthenticationException- invalid or no API access key is used with the server, which requires authorization. Check the constructor arguments.NotFoundExceptionRedmineException
-
getGroupById
public Group getGroupById(int id) throws RedmineException
Returns the group based on its id.This operation requires "Redmine Administrators" permission.
- Parameters:
id- id of the group- Returns:
- the group
- Throws:
RedmineException
-
getGroupByName
public Group getGroupByName(java.lang.String name) throws RedmineException
Returns the group based on its name.This operation requires "Redmine Administrators" permission.
- Parameters:
name- the name of the group- Returns:
- the group
- Throws:
RedmineException
-
createGroup
@Deprecated public Group createGroup(Group base) throws RedmineException
Deprecated.DEPRECATED. use group.create() Creates a new group.This operation requires "Redmine Administrator" permission.
- Returns:
- created group.
- Throws:
RedmineException
-
deleteGroup
@Deprecated public void deleteGroup(Group base) throws RedmineException
Deprecated.Deletes a group.This operation requires "Redmine Administrator" permission.
- Throws:
RedmineException
-
getRoles
public java.util.List<Role> getRoles() throws RedmineException
- Throws:
RedmineException
-
getRoleById
public Role getRoleById(int id) throws RedmineException
- Throws:
RedmineException
-
update
@Deprecated public void update(User obj) throws RedmineException
Deprecated.- Throws:
RedmineException
-
update
@Deprecated public void update(Group group) throws RedmineException
Deprecated.- Throws:
RedmineException
-
-