@PublicApi public interface

UserSearchService

com.atlassian.jira.bc.user.search.UserSearchService
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

Service that retrieves a collection of ApplicationUser objects based on a partial query string

Summary

Public Methods
boolean canPerformAjaxSearch(JiraServiceContext jiraServiceContext)
Returns true only if UserPicker Ajax search is enabled AND the user in the context has com.atlassian.jira.user.ApplicationUser Browse permission.
boolean canPerformAjaxSearch(ApplicationUser user)
Determines whether the given user could perform AJAX search.
boolean canShowEmailAddresses(JiraServiceContext jiraServiceContext)
Whether or not the UserPicker Ajax should search or show email addresses
@Nonnull Iterable<String> findUserKeysByEmail(String email)
Searches for a user with the specified e-mail address.
@Nonnull Iterable<String> findUserKeysByFullName(String fullName)
Searches for a user with the specified full name.
List<String> findUserNames(String nameQuery, String emailQuery, UserSearchParams userSearchParams)
Get user names based on query strings.
List<String> findUserNames(String query, UserSearchParams userSearchParams)
Get user names based on a query string.
List<ApplicationUser> findUsers(JiraServiceContext jiraServiceContext, String query, UserSearchParams userSearchParams)
Get Users based on a query string.
List<ApplicationUser> findUsers(JiraServiceContext jiraServiceContext, String query)
Get Users based on a query string.
List<ApplicationUser> findUsers(String query, UserSearchParams userSearchParams)
Get Users based on a query string.
List<ApplicationUser> findUsers(String nameQuery, String emailQuery, UserSearchParams userSearchParams)
Get Users based on query strings.
List<ApplicationUser> findUsersAllowEmptyQuery(JiraServiceContext jiraServiceContext, String query)
Get Users based on a query string.
@Nonnull Iterable<ApplicationUser> findUsersByEmail(String email)
Searches for a user with the specified e-mail address.
@Nonnull Iterable<ApplicationUser> findUsersByFullName(String fullName)
Searches for a user with the specified full name.
ApplicationUser getUserByName(JiraServiceContext jiraServiceContext, String query)
Returns a user by exact username
boolean userMatches(ApplicationUser user, UserSearchParams userSearchParams)
Determine whether a user matches the search criteria specified in the userSearchParams parameter.

Public Methods

public boolean canPerformAjaxSearch (JiraServiceContext jiraServiceContext)

Returns true only if UserPicker Ajax search is enabled AND the user in the context has com.atlassian.jira.user.ApplicationUser Browse permission.

Parameters
jiraServiceContext Jira Service Context
Returns
  • True if enabled, otherwise false

public boolean canPerformAjaxSearch (ApplicationUser user)

Determines whether the given user could perform AJAX search.

public boolean canShowEmailAddresses (JiraServiceContext jiraServiceContext)

Whether or not the UserPicker Ajax should search or show email addresses

Parameters
jiraServiceContext Jira Service Context
Returns
  • True if email addresses can be shown, otherwise false

@Nonnull public Iterable<String> findUserKeysByEmail (String email)

Searches for a user with the specified e-mail address.

Parameters
email the e-mail address to search.
Returns
  • collection of found user keys, empty if none were found.

@Nonnull public Iterable<String> findUserKeysByFullName (String fullName)

Searches for a user with the specified full name.

Parameters
fullName the full name to search for.
Returns
  • a collection of user keys with the specified full name, empty if none were found.

public List<String> findUserNames (String nameQuery, String emailQuery, UserSearchParams userSearchParams)

Get user names based on query strings.

Matches nameQuery on start of username, full name and email as well as all the tokenised (on spaces, '.', '@' etc) words

Matches emailQuery on start of email, as well as the tokenised words. Email matching is performed only when userSearchParams.canMatchEmail() is true. If email matching is enabled, nameQuery AND emailQuery criteria must match returned users.

If the users in the database change during this call results might not be consistent if a post processing filter and a result limit is used.

Parameters
nameQuery the query to search username and display name.
emailQuery the query to search email address, subject to userSearchParams.canMatchEmail.
userSearchParams the search criteria
Returns
  • the list of matched users

public List<String> findUserNames (String query, UserSearchParams userSearchParams)

Get user names based on a query string.

Matches on start of username, full name and email as well as all the tokenised (on spaces, '.', '@' etc) words

Matches email only when userSearchParams.canMatchEmail() is true.

If the users in the database change during this call results might not be consistent if a post processing filter and a result limit is used.

Parameters
query the query to search username, display name and email address
userSearchParams the search criteria
Returns
  • the list of matched user names

public List<ApplicationUser> findUsers (JiraServiceContext jiraServiceContext, String query, UserSearchParams userSearchParams)

Get Users based on a query string.

Matches on start of username, full name and email as well as all the tokenised (on spaces, '.', '@' etc) words

Results are sorted according to the UserCachingComparator.

If the users in the database change during this call results might not be consistent if a post processing filter and a result limit is used.

Parameters
jiraServiceContext Jira Service Context
query String to search for.
userSearchParams Additional search parameters
Returns

public List<ApplicationUser> findUsers (JiraServiceContext jiraServiceContext, String query)

Get Users based on a query string.

Matches on start of username, full name and email as well as all the tokenised (on spaces, '.', '@' etc) words Only returns active users.

Results are sorted according to the UserCachingComparator.

Parameters
jiraServiceContext Jira Service Context
query String to search for.
Returns

public List<ApplicationUser> findUsers (String query, UserSearchParams userSearchParams)

Get Users based on a query string.

Matches on start of username, full name and email as well as all the tokenised (on spaces, '.', '@' etc) words

Matches email only when userSearchParams.canMatchEmail() is true.

If the users in the database change during this call results might not be consistent if a post processing filter and a result limit is used.

Parameters
query the query to search username, display name and email address
userSearchParams the search criteria
Returns
  • the list of matched users

public List<ApplicationUser> findUsers (String nameQuery, String emailQuery, UserSearchParams userSearchParams)

Get Users based on query strings.

Matches nameQuery on start of username, full name and email as well as all the tokenised (on spaces, '.', '@' etc) words

Matches emailQuery on start of email, as well as the tokenised words. Email matching is performed only when userSearchParams.canMatchEmail() is true. If email matching is enabled, nameQuery AND emailQuery criteria must match returned users.

If the users in the database change during this call results might not be consistent if a post processing filter and a result limit is used.

Parameters
nameQuery the query to search username and display name.
emailQuery the query to search email address, subject to userSearchParams.canMatchEmail.
userSearchParams the search criteria
Returns
  • the list of matched users

public List<ApplicationUser> findUsersAllowEmptyQuery (JiraServiceContext jiraServiceContext, String query)

Get Users based on a query string.

Matches on start of username, full name and email as well as all the tokenised (on spaces, '.', '@' etc) words This will search even if the query passed is null or empty. Only returns active users.

Results are sorted according to the UserCachingComparator.

Parameters
jiraServiceContext Jira Service Context
query String to search for.
Returns

@Nonnull public Iterable<ApplicationUser> findUsersByEmail (String email)

Searches for a user with the specified e-mail address.

Parameters
email the e-mail address to search.
Returns
  • collection of found users, empty if none were found.

@Nonnull public Iterable<ApplicationUser> findUsersByFullName (String fullName)

Searches for a user with the specified full name.

Parameters
fullName the full name to search for.
Returns
  • a collection of users with the specified full name, empty if none were found.

public ApplicationUser getUserByName (JiraServiceContext jiraServiceContext, String query)

Returns a user by exact username

Parameters
jiraServiceContext Jira Service Context
query String to search for.
Returns

public boolean userMatches (ApplicationUser user, UserSearchParams userSearchParams)

Determine whether a user matches the search criteria specified in the userSearchParams parameter.

allowEmptyQuery in userSearchParams is ignored.

Parameters
user the user to be matched
userSearchParams the search criteria
Returns
  • true if the user matches the search criteria