Interface UserSearchService

All Known Implementing Classes:
DefaultUserPickerSearchService

@PublicApi public interface UserSearchService
Service that retrieves a collection of ApplicationUser objects based on a partial query string
Since:
7.0
  • Method Details

    • findUsers

      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:
      List of ApplicationUser objects that match criteria.
      See Also:
    • getUserByName

      ApplicationUser getUserByName(JiraServiceContext jiraServiceContext, String query)
      Returns a user by exact username
      Parameters:
      jiraServiceContext - Jira Service Context
      query - String to search for.
      Returns:
      The ApplicationUser object with supplied username.
    • findUsersAllowEmptyQuery

      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:
      List of ApplicationUser objects that match criteria.
      See Also:
    • findUsers

      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:
      List of ApplicationUser objects that match criteria.
      Since:
      5.1.5
    • findUsers

      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
      Since:
      6.2
    • findUsers

      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
      Since:
      6.2
    • findUserNames

      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
      Since:
      7.0
    • findUserNames

      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
      Since:
      7.0
    • findTopMentionableUsers

      @Internal List<ApplicationUser> findTopMentionableUsers(String searchName, UserSearchIssueContext userSearchIssueContext, int topN)
      Finds topN mentionable users in a given issue.
      Returns:
      list of ApplicationUser matching requirements ordered ascending by user display name
    • findTopAssignableUsers

      @Internal List<ApplicationUser> findTopAssignableUsers(String searchName, UserSearchIssueContext userSearchIssueContext, int topN)
      Finds topN users that can be assigned in a given issue.
      Returns:
      list of ApplicationUser matching requirements ordered ascending by user display name
    • findTopWatcherUsers

      @Internal List<ApplicationUser> findTopWatcherUsers(String searchName, UserSearchIssueContext userSearchIssueContext, int topN)
      Finds topN users that can watch a given issue.
      Returns:
      list of ApplicationUser matching requirements ordered ascending by user display name
    • userMatches

      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
      Since:
      v6.2
    • canPerformAjaxSearch

      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
    • canPerformAjaxSearch

      boolean canPerformAjaxSearch(ApplicationUser user)
      Determines whether the given user could perform AJAX search.
      Since:
      v6.2
    • canShowEmailAddresses

      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
    • findUserKeysByFullName

      @Nonnull Iterable<String> findUserKeysByFullName(@Nullable 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.
      Since:
      7.0
    • findUsersByFullName

      @Nonnull Iterable<ApplicationUser> findUsersByFullName(@Nullable 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.
      Since:
      7.0
    • findUserKeysByEmail

      @Nonnull Iterable<String> findUserKeysByEmail(@Nullable 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.
      Since:
      7.0
    • findUsersByEmail

      @Nonnull Iterable<ApplicationUser> findUsersByEmail(@Nullable 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.
      Since:
      7.0
    • filterUsers

      @Nonnull @ExperimentalApi List<ApplicationUser> filterUsers(List<ApplicationUser> applicationUsers, String nameQuery, UserSearchParams userSearchParams)
      Filter a list of ApplicationUser based on provided criteria and return only those users that match.

      NB: The resultant list will be sorted and duplicates removed, if the UserSearchParams.isSorted() value is true. If this is set to false, then the resultant list will not be sorted and no duplicate checks performed, which may provide some better performance in specific scenarios, as the source list will be filtered as-is and all valid results returned in the order they were initially. If a max results value is provided (>= 0) in the UserSearchParams then it will be limited in size to that value.

      Parameters:
      applicationUsers - the user to be filtered
      nameQuery - the query to search username and display name.
      userSearchParams - the search criteria
      Returns:
      a new list of users from provided list that match the filter criteria
      Since:
      v7.3
    • filterUsers

      @Nonnull @ExperimentalApi List<ApplicationUser> filterUsers(List<ApplicationUser> applicationUsers, String nameQuery, String emailQuery, UserSearchParams userSearchParams)
      Filter a list of ApplicationUser based on provided criteria and return only those users that match.

      NB: The resultant list will be sorted and duplicates removed, if the UserSearchParams.isSorted() value is true. If this is set to false, then the resultant list will not be sorted and no duplicate checks performed, which may provide some better performance in specific scenarios, as the source list will be filtered as-is and all valid results returned in the order they were initially. If a max results value is provided (>= 0) in the UserSearchParams then it will be limited in size to that value.

      Parameters:
      applicationUsers - the user to be filtered
      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:
      a new list of users from provided list that match the filter criteria
      Since:
      v7.3
    • findTopUsers

      @ExperimentalApi List<ApplicationUser> findTopUsers(String searchName, UserSearchIssueContext userSearchIssueContext, int topN, ProjectPermissionKey projectPermission)
    • findTopUsers

      @ExperimentalApi List<ApplicationUser> findTopUsers(String searchName, UserSearchIssueContext userSearchIssueContext, int topN, ProjectPermissionKey projectPermission, boolean forceReporterAndAssignee)