@PublicApi public interface

UserService

com.atlassian.jira.bc.user.UserService
Known Indirect Subclasses

@PublicApi

This interface is designed for plugins to consume (call its methods).

Clients of @PublicApi can expect that programs compiled against a given version will remain binary compatible with later versions of the @PublicApi as per each product's API policy as long as the client does not implement/extend @PublicApi interfaces or classes (refer to each product's API policy for the exact guarantee---usually binary compatibility is guaranteed at least across minor versions).

Note: since @PublicApi interfaces and classes are not designed to be implemented or extended by clients, we may perform certain types of binary-incompatible changes to these classes and interfaces, but these will not affect well-behaved clients that do not extend/implement these types (in general, only classes and interfaces annotated with @PublicSpi are safe to extend/implement).

Class Overview

UserService provides User manipulation methods exposed for remote API and actions.

Summary

Nested Classes
class UserService.CreateUserValidationResult  
class UserService.CreateUsernameValidationResult  
class UserService.DeleteUserValidationResult  
class UserService.FieldName  
class UserService.UpdateUserValidationResult  
Public Methods
User createUserFromSignup(UserService.CreateUserValidationResult result)
Given a valid validation result, this will create the user using the details provided in the validation result.
User createUserNoNotification(UserService.CreateUserValidationResult result)
Given a valid validation result, this will create the user using the details provided in the validation result.
User createUserWithNotification(UserService.CreateUserValidationResult result)
Given a valid validation result, this will create the user using the details provided in the validation result.
void removeUser(ApplicationUser loggedInUser, UserService.DeleteUserValidationResult result)
Given a valid validation result, this will remove the user and removes the user from all the groups.
void removeUser(User loggedInUser, UserService.DeleteUserValidationResult result)
This method is deprecated. Use removeUser(ApplicationUser, DeleteUserValidationResult) instead. Since v6.0.
void updateUser(UserService.UpdateUserValidationResult updateUserValidationResult)
Execute the update using the validation result from validateUpdateUser(User).
UserService.CreateUserValidationResult validateCreateUserForAdmin(User loggedInUser, String username, String password, String confirmPassword, String email, String fullname, Long directoryId)
Validates creating a user for the admin section.
UserService.CreateUserValidationResult validateCreateUserForAdmin(User loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
Validates creating a user for the admin section.
UserService.CreateUserValidationResult validateCreateUserForAdminPasswordRequired(User loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
Validates creating a user for RPC calls.
UserService.CreateUserValidationResult validateCreateUserForSetup(User loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
Validates creating a user during setup of JIRA.
UserService.CreateUserValidationResult validateCreateUserForSignup(User loggedInUser, String username, String password, String confirmPassword, String email, String fullname)
Validates creating a user during public signup.
UserService.CreateUserValidationResult validateCreateUserForSignupOrSetup(User user, String username, String password, String confirmPassword, String email, String fullname)
UserService.CreateUsernameValidationResult validateCreateUsername(User loggedInUser, String username)
Validates the username for a new user.
UserService.CreateUsernameValidationResult validateCreateUsername(User loggedInUser, String username, Long directoryId)
Validates the username for a new user.
UserService.DeleteUserValidationResult validateDeleteUser(User loggedInUser, String username)
UserService.DeleteUserValidationResult validateDeleteUser(ApplicationUser loggedInUser, String username)
Validates removing a user for the admin section.
UserService.DeleteUserValidationResult validateDeleteUser(ApplicationUser loggedInUser, ApplicationUser userForDelete)
Validates removing a user for the admin section.
UserService.UpdateUserValidationResult validateUpdateUser(ApplicationUser user)
Validates updating a user's details.
UserService.UpdateUserValidationResult validateUpdateUser(User user)
This method is deprecated. Use validateUpdateUser(com.atlassian.jira.user.ApplicationUser) instead. Since v6.0.

Public Methods

public User createUserFromSignup (UserService.CreateUserValidationResult result)

Given a valid validation result, this will create the user using the details provided in the validation result. Email notification will be send to created user - via UserEventType.USER_SIGNUP event.

Parameters
result The validation result
Returns
  • The new user object that was created
Throws
CreateException if the user could not be created, eg username already exists
PermissionException If you cannot create users in this directory (it is read-only).

public User createUserNoNotification (UserService.CreateUserValidationResult result)

Given a valid validation result, this will create the user using the details provided in the validation result. No email notification will be send to created user.

Parameters
result The validation result
Returns
  • The new user object that was created
Throws
CreateException if the user could not be created, eg username already exists
PermissionException If you cannot create users in this directory (it is read-only).

public User createUserWithNotification (UserService.CreateUserValidationResult result)

Given a valid validation result, this will create the user using the details provided in the validation result. Email notification will be send to created user - via UserEventType.USER_CREATED event.

Parameters
result The validation result
Returns
  • The new user object that was created
Throws
CreateException if the user could not be created, eg username already exists
PermissionException If you cannot create users in this directory (it is read-only).

public void removeUser (ApplicationUser loggedInUser, UserService.DeleteUserValidationResult result)

Given a valid validation result, this will remove the user and removes the user from all the groups. All components lead by user will have lead cleared.

Parameters
loggedInUser the user performing operation
result The validation result

public void removeUser (User loggedInUser, UserService.DeleteUserValidationResult result)

This method is deprecated.
Use removeUser(ApplicationUser, DeleteUserValidationResult) instead. Since v6.0.

Given a valid validation result, this will remove the user and removes the user from all the groups. All components lead by user will have lead cleared.

Parameters
loggedInUser the user performing operation
result The validation result

public void updateUser (UserService.UpdateUserValidationResult updateUserValidationResult)

Execute the update using the validation result from validateUpdateUser(User).

Parameters
updateUserValidationResult Result from the validation, which also contains all the user's details.
Throws
IllegalStateException if the validation result contains any errors.

public UserService.CreateUserValidationResult validateCreateUserForAdmin (User loggedInUser, String username, String password, String confirmPassword, String email, String fullname, Long directoryId)

Validates creating a user for the admin section. This method checks that external user management is disabled and that the user performing the operation has global admin rights. It also validates that all parameters (username, email, fullname) except for the password have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

This method allows the caller to name a directory to create the user in and the directoryId must be valid and represent a Directory with "create user" permission.

This validation differs from the 'ForSetup' and 'ForAdminPasswordRequired' validations as follows:

  • Does require global admin rights
  • The password is NOT required

Parameters
loggedInUser The remote user trying to add a new user
username The username of the new user. Needs to be lowercase and unique.
password The password for the new user.
confirmPassword The password confirmation. Needs to match password.
email The email for the new user. Needs to be a valid email address.
fullname The full name for the new user
directoryId The User Directory
Returns
  • a validation result containing appropriate errors or the new user's details

public UserService.CreateUserValidationResult validateCreateUserForAdmin (User loggedInUser, String username, String password, String confirmPassword, String email, String fullname)

Validates creating a user for the admin section. This method checks that external user management is disabled and that the user performing the operation has global admin rights. It also validates that all parameters (username, email, fullname) except for the password have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

This validation differs from the 'ForSetup' and 'ForAdminPasswordRequired' validations as follows:

  • Does require global admin rights
  • The password is NOT required

Parameters
loggedInUser The remote user trying to add a new user
username The username of the new user. Needs to be lowercase and unique.
password The password for the new user.
confirmPassword The password confirmation. Needs to match password.
email The email for the new user. Needs to be a valid email address.
fullname The full name for the new user
Returns
  • a validation result containing appropriate errors or the new user's details

public UserService.CreateUserValidationResult validateCreateUserForAdminPasswordRequired (User loggedInUser, String username, String password, String confirmPassword, String email, String fullname)

Validates creating a user for RPC calls. This method checks that external user management is disabled and that the user performing the operation has global admin rights. It also validates that all parameters (username, email, fullname, password) have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

This validation differs from the 'ForSetup' and 'ForAdmin' validations as follows:

  • Does require global admin rights
  • The password is required
Parameters
loggedInUser The remote user trying to add a new user
username The username of the new user. Needs to be lowercase and unique.
password The password for the new user.
confirmPassword The password confirmation. Needs to match password.
email The email for the new user. Needs to be a valid email address.
fullname The full name for the new user
Returns
  • a validation result containing appropriate errors or the new user's details

public UserService.CreateUserValidationResult validateCreateUserForSetup (User loggedInUser, String username, String password, String confirmPassword, String email, String fullname)

Validates creating a user during setup of JIRA. This method does not check for a writable User Directory because the embedded crowd subsystem will not be initialised, and we know we will just have an Internal Directory during Setup. It also validates that all parameters (username, email, fullname, password) have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

This validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:

  • Does not require global admin rights
  • The password is required
Parameters
loggedInUser The remote user trying to add a new user
username The username of the new user. Needs to be lowercase and unique.
password The password for the new user.
confirmPassword The password confirmation. Needs to match password.
email The email for the new user. Needs to be a valid email address.
fullname The full name for the new user
Returns
  • a validation result containing appropriate errors or the new user's details

public UserService.CreateUserValidationResult validateCreateUserForSignup (User loggedInUser, String username, String password, String confirmPassword, String email, String fullname)

Validates creating a user during public signup. This method checks that there is a writable User Directory available. It also validates that all parameters (username, email, fullname, password) have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

This validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:

  • Does not require global admin rights
  • The password is required
Parameters
loggedInUser The remote user trying to add a new user
username The username of the new user. Needs to be lowercase and unique.
password The password for the new user.
confirmPassword The password confirmation. Needs to match password.
email The email for the new user. Needs to be a valid email address.
fullname The full name for the new user
Returns
  • a validation result containing appropriate errors or the new user's details

public UserService.CreateUserValidationResult validateCreateUserForSignupOrSetup (User user, String username, String password, String confirmPassword, String email, String fullname)

This method is deprecated.
Use validateCreateUserForSignup(com.atlassian.crowd.embedded.api.User, String, String, String, String, String) or validateCreateUserForSetup(com.atlassian.crowd.embedded.api.User, String, String, String, String, String) instead. Since v5.0.

Validates creating a user during setup of JIRA or during public signup. This method checks that there is a writable User Directory available. It also validates that all parameters (username, email, fullname, password) have been provided. Email is also checked to ensure that it is a valid email address. The username is required to be lowercase characters only and unique. The confirmPassword has to match the password provided.

This validation differs from the 'ForAdminPasswordRequired' and 'ForAdmin' validations as follows:

  • Does not require global admin rights
  • The password is required
Parameters
user The remote user trying to add a new user
username The username of the new user. Needs to be lowercase and unique.
password The password for the new user.
confirmPassword The password confirmation. Needs to match password.
email The email for the new user. Needs to be a valid email address.
fullname The full name for the new user
Returns
  • a validation result containing appropriate errors or the new user's details

public UserService.CreateUsernameValidationResult validateCreateUsername (User loggedInUser, String username)

Validates the username for a new user. The username is required to be lowercase characters only and unique across all directories.

Parameters
loggedInUser The remote user trying to add a new user
username The username of the new user. Needs to be lowercase and unique.
Returns
  • a validation result containing appropriate errors

public UserService.CreateUsernameValidationResult validateCreateUsername (User loggedInUser, String username, Long directoryId)

Validates the username for a new user. The username is required to be lowercase characters only and unique in the given directory.

Parameters
loggedInUser The remote user trying to add a new user
username The username of the new user. Needs to be lowercase and unique.
directoryId The directory which the new user is intended to be created in.
Returns
  • a validation result containing appropriate errors

public UserService.DeleteUserValidationResult validateDeleteUser (User loggedInUser, String username)

This method is deprecated.
Use validateDeleteUser(ApplicationUser, String) or validateDeleteUser(ApplicationUser, ApplicationUser) instead. Since v6.0.

Validates removing a user for the admin section. This method checks that external user management is disabled and that the user performing the operation has global admin rights. It also validates that username have been provided.

See validateDeleteUser(ApplicationUser, ApplicationUser) for restrictions.

Parameters
loggedInUser The remote user trying to remove a user
username The username of the user to remove. Needs to be valid
Returns
  • a validation result containing appropriate errors or the user object for delete

public UserService.DeleteUserValidationResult validateDeleteUser (ApplicationUser loggedInUser, String username)

Validates removing a user for the admin section. This method checks that external user management is disabled and that the user performing the operation has global admin rights. It also validates that username have been provided.

See validateDeleteUser(ApplicationUser, ApplicationUser) for restrictions.

Parameters
loggedInUser The remote user trying to remove a user
username The username of the user to remove. Needs to be valid
Returns
  • a validation result containing appropriate errors or the user object for delete

public UserService.DeleteUserValidationResult validateDeleteUser (ApplicationUser loggedInUser, ApplicationUser userForDelete)

Validates removing a user for the admin section. This method checks that external user management is disabled and that the user performing the operation has global admin rights. It also validates that username have been provided.

Removing the user is not allowed if:

  • Logged in user lacks global admin permissions
  • Logged in user and target user are the same user
  • Logged in user is not a system administrator but the target user is
  • Target user is the assignee for any issue
  • Target user is the reporter for any issue
  • Target user is the project lead for any project
  • A plugin that implements PreDeleteUserErrors rejects the request

Parameters
loggedInUser The remote user trying to remove a user
userForDelete The user to remove. Needs to be valid
Returns
  • a validation result containing appropriate errors or the user object for delete

public UserService.UpdateUserValidationResult validateUpdateUser (ApplicationUser user)

Validates updating a user's details.

Parameters
user The user details to update
Returns
  • A validation result containing any errors and all user details

public UserService.UpdateUserValidationResult validateUpdateUser (User user)

This method is deprecated.
Use validateUpdateUser(com.atlassian.jira.user.ApplicationUser) instead. Since v6.0.

Validates updating a user's details.

Parameters
user The user details to update
Returns
  • A validation result containing any errors and all user details