public class

UserUtils

extends Object
java.lang.Object
   ↳ com.atlassian.jira.user.UserUtils

Class Overview

A static helper class for User operations.

Normally you should use dependency injection to get hold of a UserManager or a UserUtil instance.

Summary

Public Constructors
UserUtils()
Public Methods
@Deprecated static Collection<ApplicationUser> getAllUsers()
This method is deprecated. Since v7.0. Only retrieve the users you really need. See UserSearchService
static ApplicationUser getUser(String username)
Retrieves and returns the user by given username.
static ApplicationUser getUserByEmail(String emailAddress)
Return the first user found that matches the given email address (or null if not found).
static ApplicationUser getUserEvenWhenUnknown(String username)
Returns a User based on user name.
static UserManager getUserManager()
static List getUsersByEmail(String email)
Finds the users by the given e-mail address.
static boolean userExists(String username)
Checks if a user with given username exists.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public UserUtils ()

Public Methods

@Deprecated public static Collection<ApplicationUser> getAllUsers ()

This method is deprecated.
Since v7.0. Only retrieve the users you really need. See UserSearchService

Returns all users.

WARNING: this could be very high in some JIRA installations, and may therefore pose a performance issue.

Returns
  • all users.

public static ApplicationUser getUser (String username)

Retrieves and returns the user by given username.

Parameters
username the username to get
Returns
  • user or null if not found

public static ApplicationUser getUserByEmail (String emailAddress)

Return the first user found that matches the given email address (or null if not found).

The email address is matched case insensitive.

Parameters
emailAddress user email address
Returns
  • The first user that matches the email address or null if not found or the given email address is null.

public static ApplicationUser getUserEvenWhenUnknown (String username)

Returns a User based on user name.

If a null username is passed, then a null User object is returned, but it is guaranteed to return a non-null User in all other cases.
If the username is not null, but the User is not found then a proxy unknown immutable User object is returned.

Parameters
username the user name of the user
Returns
  • the User object, or proxy unknown immutable User object (null iff the username is null).

public static UserManager getUserManager ()

public static List getUsersByEmail (String email)

Finds the users by the given e-mail address. E-mail address look-up is done case insensitively. Leading or trailing spaces in the given e-mail address are trimmed before look up.

Parameters
email e-mail address
Returns
  • always returns a list of users found (even if empty)

public static boolean userExists (String username)

Checks if a user with given username exists. Returns true if such user exists, false otherwise.

Parameters
username username to look up
Returns
  • true if user found, false otherwise