public final class

ApplicationUsers

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

Class Overview

Contains utility methods for getting an ApplicationUser from a directory User.

Summary

Public Constructors
ApplicationUsers()
Public Methods
@Nullable static ApplicationUser byKey(String key)
Gets the ApplicationUser in a null-safe manner.
@Nullable static List<ApplicationUser> from(Collection<User> users)
Performs null-safe conversion of a collection of directory users to corresponding ApplicationUser objects.
@Nullable static ApplicationUser from(User user)
Obtains an ApplicationUser for the given directory User.
@Nullable static List<ApplicationUser> from(Iterable<User> users)
Performs null-safe conversion of a collection of directory users to corresponding ApplicationUser objects.
@Nullable static String getKeyFor(User user)
Gets the user key for the given directory User.
@Nullable static String getKeyFor(ApplicationUser user)
Get the key from the given user in a null-safe manner
@Nullable static User toDirectoryUser(ApplicationUser user)
Does a null-safe conversion from an application user to a directory user.
@Nullable static List<User> toDirectoryUsers(Collection<ApplicationUser> applicationUsers)
Performs null-safe conversion of a collection of application users to corresponding directory User objects.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ApplicationUsers ()

Public Methods

@Nullable public static ApplicationUser byKey (String key)

Gets the ApplicationUser in a null-safe manner. This is a convenient shorthand for ComponentAccessor.getUserManager().getUserByKey(key)). Prefer getUserByKey(String) when the UserManager is already available.

Parameters
key the user's key
Returns
  • the corresponding user, or null if no user exists with that key.

@Nullable public static List<ApplicationUser> from (Collection<User> users)

Performs null-safe conversion of a collection of directory users to corresponding ApplicationUser objects.

Parameters
users the users to transform (may be null and may contain null
Returns
  • a list of application users
Throws
IllegalStateException if any of the users exists in the crowd directory but has no mapping in the UserKeyService (see comments for from(User)).

@Nullable public static ApplicationUser from (User user)

Obtains an ApplicationUser for the given directory User.

Parameters
user the directory User
Returns
  • the Application User, or null if the incoming user is null.
Throws
IllegalStateException if user is not null, but the UserKeyService has no mapping for its username. This should not occur during normal operation, as all users are assigned keys during the upgrade to v6.0 or when the user is created.

@Nullable public static List<ApplicationUser> from (Iterable<User> users)

Performs null-safe conversion of a collection of directory users to corresponding ApplicationUser objects.

Parameters
users the users to transform (may be null and may contain null
Returns
  • a list of application users
Throws
IllegalStateException if any of the users exists in the crowd directory but has no mapping in the UserKeyService (see comments for from(User)).

@Nullable public static String getKeyFor (User user)

Gets the user key for the given directory User.

This is a null-safe shorthand for

     ApplicationUsers.from(user).getKey()
 

Parameters
user the directory User
Returns
  • the application user Key for the given directory User, or null if the incoming user is null or has no mapping in the UserKeyService

@Nullable public static String getKeyFor (ApplicationUser user)

Get the key from the given user in a null-safe manner

Parameters
user the user (possibly null)
Returns
  • the key of the given user, or null if the user is null

@Nullable public static User toDirectoryUser (ApplicationUser user)

Does a null-safe conversion from an application user to a directory user.

Parameters
user the ApplicationUser
Returns
  • the corresponding Directory user

@Nullable public static List<User> toDirectoryUsers (Collection<ApplicationUser> applicationUsers)

Performs null-safe conversion of a collection of application users to corresponding directory User objects.

Parameters
applicationUsers the users to transform (may be null and may contain null
Returns
  • a list of directory users