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_KEYstatic Property<java.lang.Integer>AUTH_SOURCE_IDstatic Property<java.util.Date>CREATED_ONstatic Property<java.util.Set<CustomField>>CUSTOM_FIELDSstatic Property<java.lang.String>FIRST_NAMEstatic Property<java.lang.Boolean>GENERATE_PASSWORDstatic Property<java.util.Set<Group>>GROUPSstatic Property<java.lang.Integer>IDstatic Property<java.util.Date>LAST_LOGIN_ONstatic Property<java.lang.String>LAST_NAMEstatic Property<java.lang.String>LOGINstatic Property<java.lang.String>MAILstatic Property<java.lang.String>MAIL_NOTIFICATIONstatic Property<java.util.Set<Membership>>MEMBERSHIPstatic Property<java.lang.Boolean>MUST_CHANGE_PASSWDstatic Property<java.lang.String>PASSWORDstatic Property<java.lang.Integer>STATUSstatic java.lang.IntegerSTATUS_ACTIVEstatic java.lang.IntegerSTATUS_ANONYMOUSstatic java.lang.IntegerSTATUS_LOCKEDstatic java.lang.IntegerSTATUS_REGISTERED
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description UseraddCustomField(CustomField customField)If there is a custom field with the same ID already present, the new field replaces the old one.UseraddCustomFields(java.util.Collection<CustomField> customFields)NOTE: The custom field(s) must have correct database ID set to be saved to Redmine.UseraddGroups(java.util.Collection<Group> groups)UseraddMemberships(java.util.Collection<Membership> memberships)voidaddToGroup(int groupId)Adds this user (ID must be set!) to the given group.voidclearCustomFields()Usercreate()voiddelete()The user object must have ID set.booleanequals(java.lang.Object o)java.lang.StringgetApiKey()java.lang.IntegergetAuthSourceId()Deprecated.java.util.DategetCreatedOn()java.lang.StringgetCustomField(java.lang.String fieldName)java.util.Collection<CustomField>getCustomFields()java.lang.StringgetFirstName()java.lang.StringgetFullName()java.util.Collection<Group>getGroups()java.lang.IntegergetId()java.util.DategetLastLoginOn()java.lang.StringgetLastName()java.lang.StringgetLogin()java.lang.StringgetMail()This field is empty when using issues.get(i).getAssignee().getMail()java.util.Collection<Membership>getMemberships()java.lang.StringgetPassword()java.lang.IntegergetStatus()This field is visible to Admin only.PropertyStoragegetStorage()inthashCode()UsersetApiKey(java.lang.String apiKey)Deprecated.UsersetAuthSourceId(java.lang.Integer authSource)UsersetCreatedOn(java.util.Date createdOn)UsersetFirstName(java.lang.String firstName)UsersetFullName(java.lang.String fullName)This is a BIG HACK just to workaround Redmine REST API limitation.UsersetGeneratePassword(java.lang.Boolean generatePassword)UsersetId(int id)UsersetLastLoginOn(java.util.Date lastLoginOn)UsersetLastName(java.lang.String lastName)UsersetLogin(java.lang.String login)UsersetMail(java.lang.String mail)UsersetMailNotification(java.lang.String mailNotification)UsersetMustChangePasswd(java.lang.Boolean mustChangePasswd)UsersetPassword(java.lang.String password)UsersetStatus(java.lang.Integer status)Sets the user status.voidsetTransport(Transport transport)java.lang.StringtoString()voidupdate()
-
-
-
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:
getIdin interfaceIdentifiable
-
toString
public java.lang.String toString()
- Overrides:
toStringin 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein 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:
setTransportin interfaceFluentStyle
-
create
public User create() throws RedmineException
- Throws:
RedmineException
-
update
public void update() throws RedmineException- Throws:
RedmineException
-
addToGroup
public void addToGroup(int groupId) throws RedmineExceptionAdds 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 RedmineExceptionThe user object must have ID set.- Throws:
RedmineException
-
-