1   package com.atlassian.user.search.query;
2   
3   import com.atlassian.user.EntityException;
4   import com.atlassian.user.Group;
5   import com.atlassian.user.User;
6   import com.atlassian.user.search.SearchResult;
7   
8   /**
9    * Parses and executes queries for users and groups against one or more Atlassian-User repositories.
10   * Implementations generally support single-term and arbitrarily nested boolean queries for user and
11   * group properties.
12   * <p/>
13   * Membership queries are not supported and have been officially deprecated as of Atlassian-User 2.1.
14   *
15   * @see Query
16   * @see UserQuery
17   * @see GroupQuery
18   */
19  public interface EntityQueryParser
20  {
21      /**
22       * Returns the users matching the provided query.
23       *
24       * @throws EntityQueryException if the query is a boolean query constructed from different term types
25       * @throws IllegalArgumentException if the query is a membership query
26       * @throws EntityException is there is a problem performing the query (e.g. database connection failure)
27       */
28      SearchResult<? extends User> findUsers(Query query) throws EntityException;
29  
30      /**
31       * Returns the groups matching the provided query.
32       *
33       * @throws EntityQueryException if the query is a boolean query constructed from different term types
34       * @throws IllegalArgumentException if the query is a membership query
35       * @throws EntityException is there is a problem performing the query (e.g. database connection failure)
36       */
37      SearchResult<? extends Group> findGroups(Query query) throws EntityException;
38  
39      /**
40       * If the repository matches the query context, returns the users matching the query, otherwise returns {@code null}.
41       *
42       * @throws EntityQueryException if the query is a boolean query constructed from different term types
43       * @throws IllegalArgumentException if the query is a membership query
44       * @throws EntityException is there is a problem performing the query (e.g. database connection failure)
45       */
46      SearchResult<? extends User> findUsers(Query query, QueryContext context) throws EntityException;
47  
48      /**
49       * If the repository matches the query context, returns the groups matching the query, otherwise returns {@code null}.
50       *
51       * @throws EntityQueryException if the query is a boolean query constructed from different term types
52       * @throws IllegalArgumentException if the query is a membership query
53       * @throws EntityException is there is a problem performing the query (e.g. database connection failure)
54       */
55      SearchResult<? extends Group> findGroups(Query query, QueryContext context) throws EntityException;
56  }