public class UserManager
extends java.lang.Object
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();
RedmineManager.getUserManager()
Modifier and Type | Method and Description |
---|---|
void |
addUserToGroup(User user,
Group group)
Adds the given user to the given group.
|
Group |
createGroup(Group base)
Creates a new group.
|
User |
createUser(User user) |
void |
deleteGroup(Group base)
Deletes a group.
|
void |
deleteUser(java.lang.Integer userId) |
User |
getCurrentUser() |
Group |
getGroupById(int id)
Returns the group based on its id.
|
Group |
getGroupByName(java.lang.String name)
Returns the group based on its name.
|
java.util.List<Group> |
getGroups()
Load list of groups on the server.
|
Role |
getRoleById(int id) |
java.util.List<Role> |
getRoles() |
User |
getUserById(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.
|
void |
update(Group group) |
void |
update(User obj) |
public User getCurrentUser() throws RedmineException
RedmineException
public User createUser(User user) throws RedmineException
RedmineException
public void deleteUser(java.lang.Integer userId) throws RedmineException
userId
- user identifier (numeric ID)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
public void addUserToGroup(User user, Group group) throws RedmineException
Note: "add to group" operation used to be safe (idempotent) for Redmine 2.6.x, but FAILS for Redmine 3.0.0 when executed twice on the same user. I submitted a bug: http://www.redmine.org/issues/19363
user
- - The user being added.group
- - The new group of the user.RedmineException
public java.util.List<User> getUsers() throws RedmineException
This operation requires "Redmine Administrator" permission.
RedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.NotFoundException
RedmineException
public User getUserById(java.lang.Integer userId) throws RedmineException
RedmineException
public java.util.List<Group> getGroups() throws RedmineException
This operation requires "Redmine Administrator" permission.
RedmineAuthenticationException
- invalid or no API access key is used with the server, which
requires authorization. Check the constructor arguments.NotFoundException
RedmineException
public Group getGroupById(int id) throws RedmineException
This operation requires "Redmine Administrators" permission.
id
- id of the groupRedmineException
public Group getGroupByName(java.lang.String name) throws RedmineException
This operation requires "Redmine Administrators" permission.
name
- the name of the groupRedmineException
public Group createGroup(Group base) throws RedmineException
This operation requires "Redmine Administrator" permission.
RedmineException
public void deleteGroup(Group base) throws RedmineException
This operation requires "Redmine Administrator" permission.
RedmineException
public java.util.List<Role> getRoles() throws RedmineException
RedmineException
public Role getRoleById(int id) throws RedmineException
RedmineException
public void update(User obj) throws RedmineException
RedmineException
public void update(Group group) throws RedmineException
RedmineException