com.atlassian.jira.user
Class UserUtils

java.lang.Object
  extended by com.atlassian.jira.user.UserUtils

public class UserUtils
extends Object

A static helper class for User operations. Normally you should use dependency injection to get hold of a UserManager or a UserUtil instance.

Since:
v4.4

Constructor Summary
UserUtils()
           
 
Method Summary
static Collection<com.atlassian.crowd.embedded.api.User> getAllUsers()
          Returns all users.
static com.atlassian.crowd.embedded.api.User getUser(String username)
          Retrieves and returns the user by given username.
static com.atlassian.crowd.embedded.api.User getUserByEmail(String emailAddress)
          Return the first user found that matches the given email address (or null if not found).
static com.atlassian.crowd.embedded.api.User getUserEvenWhenUnknown(String username)
          Returns a User based on user name.
static UserManager getUserManager()
           
static boolean userExists(String username)
          Checks if a user with given username exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserUtils

public UserUtils()
Method Detail

userExists

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

getUser

public static com.atlassian.crowd.embedded.api.User getUser(String username)
Retrieves and returns the user by given username.

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

getUserEvenWhenUnknown

public static com.atlassian.crowd.embedded.api.User 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).
Since:
v4.4

getUserByEmail

public static com.atlassian.crowd.embedded.api.User 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.

getAllUsers

public static Collection<com.atlassian.crowd.embedded.api.User> getAllUsers()
Returns all users.

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

Returns:
all users.

getUserManager

public static UserManager getUserManager()


Copyright © 2002-2011 Atlassian. All Rights Reserved.