Package com.taskadapter.redmineapi.bean
Class User
- java.lang.Object
-
- com.taskadapter.redmineapi.bean.User
-
- All Implemented Interfaces:
FluentStyle
,Identifiable
public class User extends java.lang.Object implements Identifiable, FluentStyle
Redmine User.
-
-
Field Summary
Fields Modifier and Type Field Description static Property<java.lang.String>
API_KEY
static Property<java.lang.Integer>
AUTH_SOURCE_ID
static Property<java.util.Date>
CREATED_ON
static Property<java.util.Set<CustomField>>
CUSTOM_FIELDS
static Property<java.lang.String>
FIRST_NAME
static Property<java.lang.Boolean>
GENERATE_PASSWORD
static Property<java.util.Set<Group>>
GROUPS
static Property<java.lang.Integer>
ID
static Property<java.util.Date>
LAST_LOGIN_ON
static Property<java.lang.String>
LAST_NAME
static Property<java.lang.String>
LOGIN
static Property<java.lang.String>
MAIL
static Property<java.lang.String>
MAIL_NOTIFICATION
static Property<java.util.Set<Membership>>
MEMBERSHIP
static Property<java.lang.Boolean>
MUST_CHANGE_PASSWD
static Property<java.lang.String>
PASSWORD
static Property<java.lang.Integer>
STATUS
static java.lang.Integer
STATUS_ACTIVE
static java.lang.Integer
STATUS_ANONYMOUS
static java.lang.Integer
STATUS_LOCKED
static java.lang.Integer
STATUS_REGISTERED
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description User
addCustomField(CustomField customField)
If there is a custom field with the same ID already present, the new field replaces the old one.User
addCustomFields(java.util.Collection<CustomField> customFields)
NOTE: The custom field(s) must have correct database ID set to be saved to Redmine.User
addGroups(java.util.Collection<Group> groups)
User
addMemberships(java.util.Collection<Membership> memberships)
void
addToGroup(int groupId)
Adds this user (ID must be set!) to the given group.void
clearCustomFields()
User
create()
void
delete()
The user object must have ID set.boolean
equals(java.lang.Object o)
java.lang.String
getApiKey()
java.lang.Integer
getAuthSourceId()
Deprecated.java.util.Date
getCreatedOn()
java.lang.String
getCustomField(java.lang.String fieldName)
java.util.Collection<CustomField>
getCustomFields()
java.lang.String
getFirstName()
java.lang.String
getFullName()
java.util.Collection<Group>
getGroups()
java.lang.Integer
getId()
java.util.Date
getLastLoginOn()
java.lang.String
getLastName()
java.lang.String
getLogin()
java.lang.String
getMail()
This field is empty when using issues.get(i).getAssignee().getMail()java.util.Collection<Membership>
getMemberships()
java.lang.String
getPassword()
java.lang.Integer
getStatus()
This field is visible to Admin only.PropertyStorage
getStorage()
int
hashCode()
User
setApiKey(java.lang.String apiKey)
Deprecated.User
setAuthSourceId(java.lang.Integer authSource)
User
setCreatedOn(java.util.Date createdOn)
User
setFirstName(java.lang.String firstName)
User
setFullName(java.lang.String fullName)
This is a BIG HACK just to workaround Redmine REST API limitation.User
setGeneratePassword(java.lang.Boolean generatePassword)
User
setId(int id)
User
setLastLoginOn(java.util.Date lastLoginOn)
User
setLastName(java.lang.String lastName)
User
setLogin(java.lang.String login)
User
setMail(java.lang.String mail)
User
setMailNotification(java.lang.String mailNotification)
User
setMustChangePasswd(java.lang.Boolean mustChangePasswd)
User
setPassword(java.lang.String password)
User
setStatus(java.lang.Integer status)
Sets the user status.void
setTransport(Transport transport)
java.lang.String
toString()
void
update()
-
-
-
Field Detail
-
STATUS_ANONYMOUS
public static final java.lang.Integer STATUS_ANONYMOUS
-
STATUS_ACTIVE
public static final java.lang.Integer STATUS_ACTIVE
-
STATUS_REGISTERED
public static final java.lang.Integer STATUS_REGISTERED
-
STATUS_LOCKED
public static final java.lang.Integer STATUS_LOCKED
-
ID
public static final Property<java.lang.Integer> ID
-
LOGIN
public static final Property<java.lang.String> LOGIN
-
PASSWORD
public static final Property<java.lang.String> PASSWORD
-
FIRST_NAME
public static final Property<java.lang.String> FIRST_NAME
-
LAST_NAME
public static final Property<java.lang.String> LAST_NAME
-
MAIL
public static final Property<java.lang.String> MAIL
-
API_KEY
public static final Property<java.lang.String> API_KEY
-
CREATED_ON
public static final Property<java.util.Date> CREATED_ON
-
LAST_LOGIN_ON
public static final Property<java.util.Date> LAST_LOGIN_ON
-
AUTH_SOURCE_ID
public static final Property<java.lang.Integer> AUTH_SOURCE_ID
-
STATUS
public static final Property<java.lang.Integer> STATUS
-
MAIL_NOTIFICATION
public static final Property<java.lang.String> MAIL_NOTIFICATION
-
MUST_CHANGE_PASSWD
public static final Property<java.lang.Boolean> MUST_CHANGE_PASSWD
-
GENERATE_PASSWORD
public static final Property<java.lang.Boolean> GENERATE_PASSWORD
-
CUSTOM_FIELDS
public static final Property<java.util.Set<CustomField>> CUSTOM_FIELDS
-
MEMBERSHIP
public static final Property<java.util.Set<Membership>> MEMBERSHIP
-
-
Constructor Detail
-
User
public User(Transport transport)
-
-
Method Detail
-
setId
public User setId(int id)
-
getId
public java.lang.Integer getId()
- Specified by:
getId
in interfaceIdentifiable
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getLogin
public java.lang.String getLogin()
-
setLogin
public User setLogin(java.lang.String login)
-
getFirstName
public java.lang.String getFirstName()
-
setFirstName
public User setFirstName(java.lang.String firstName)
-
getLastName
public java.lang.String getLastName()
-
setLastName
public User setLastName(java.lang.String lastName)
-
getMail
public java.lang.String getMail()
This field is empty when using issues.get(i).getAssignee().getMail()
-
setMail
public User setMail(java.lang.String mail)
-
getCreatedOn
public java.util.Date getCreatedOn()
-
setCreatedOn
public User setCreatedOn(java.util.Date createdOn)
-
getLastLoginOn
public java.util.Date getLastLoginOn()
-
setLastLoginOn
public User setLastLoginOn(java.util.Date lastLoginOn)
-
getApiKey
public java.lang.String getApiKey()
-
setApiKey
@Deprecated public User setApiKey(java.lang.String apiKey)
Deprecated.APIKey property is read-only. This setter is only for serialization JSon. The value you set using this method will be ignored by the server.
-
getAuthSourceId
@Deprecated public java.lang.Integer getAuthSourceId()
Deprecated.This value is not returned by redmine on existing users.- Returns:
- - The Authentication Source ID, if you set it on your own.
-
setAuthSourceId
public User setAuthSourceId(java.lang.Integer authSource)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
getFullName
public java.lang.String getFullName()
- Returns:
- `firstName` + space + `lastName` if `lastName` is not null. otherwise returns value of `firstName`
-
setFullName
public User setFullName(java.lang.String fullName)
This is a BIG HACK just to workaround Redmine REST API limitation. see http://www.redmine.org/issues/7487
-
getPassword
public java.lang.String getPassword()
-
setPassword
public User setPassword(java.lang.String password)
-
getCustomField
public java.lang.String getCustomField(java.lang.String fieldName)
- Returns:
- the value or NULL if the field is not found
-
getCustomFields
public java.util.Collection<CustomField> getCustomFields()
- Returns:
- Custom Fields, NEVER NULL.
-
clearCustomFields
public void clearCustomFields()
-
addCustomFields
public User addCustomFields(java.util.Collection<CustomField> customFields)
NOTE: The custom field(s) must have correct database ID set to be saved to Redmine. This is Redmine REST API's limitation. ID can be seen in database or in Redmine administration when editing the custom field (number is part of the URL!).
-
addCustomField
public User addCustomField(CustomField customField)
If there is a custom field with the same ID already present, the new field replaces the old one.- Parameters:
customField
- the field to add.
-
getMemberships
public java.util.Collection<Membership> getMemberships()
-
addMemberships
public User addMemberships(java.util.Collection<Membership> memberships)
-
getGroups
public java.util.Collection<Group> getGroups()
-
getStatus
public java.lang.Integer getStatus()
This field is visible to Admin only.Returns the user status. This number can theoretically be different for different Redmine versions, But the **current Redmine version in 2018** defines these numbers as:
- 0: status anonymous
- 1: status active
- 2: status registered
- 3: status locked
see http://www.redmine.org/projects/redmine/repository/entry/trunk/app/models/principal.rb#L22-25
- Returns:
- possibly Redmine-version-specific number that represents user status (active/locked/etc)
- Since:
- Redmine REST API 2.4.0
-
setStatus
public User setStatus(java.lang.Integer status)
Sets the user status.- Parameters:
status
-STATUS_ACTIVE
,STATUS_LOCKED
, etc...
-
setMailNotification
public User setMailNotification(java.lang.String mailNotification)
-
setMustChangePasswd
public User setMustChangePasswd(java.lang.Boolean mustChangePasswd)
-
setGeneratePassword
public User setGeneratePassword(java.lang.Boolean generatePassword)
-
getStorage
public PropertyStorage getStorage()
-
setTransport
public void setTransport(Transport transport)
- Specified by:
setTransport
in interfaceFluentStyle
-
create
public User create() throws RedmineException
- Throws:
RedmineException
-
update
public void update() throws RedmineException
- Throws:
RedmineException
-
addToGroup
public void addToGroup(int groupId) throws RedmineException
Adds this user (ID must be set!) to the given group.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 which was closed as "invalid"...
- Parameters:
groupId
- - id of the group to add to.- Throws:
RedmineException
- Since:
- Redmine 2.1
-
delete
public void delete() throws RedmineException
The user object must have ID set.- Throws:
RedmineException
-
-