public class DefaultSearchService extends Object implements SearchService
SearchService.SearchService.IssueSearchParameters, SearchService.ParseResult| Constructor and Description |
|---|
DefaultSearchService(SearchHandlerManager searchHandlerManager,
JqlQueryParser jqlQueryParser,
ValidatorVisitor.ValidatorVisitorFactory validatorVisitorFactory,
QueryContextVisitor.QueryContextVisitorFactory queryContextVisitorFactory,
JqlStringSupport jqlStringSupport,
QueryContextConverter queryContextConverter,
QueryCache queryCache,
JqlOperandResolver jqlOperandResolver,
OrderByValidator orderByValidator,
SearchProvider searchProvider,
IssueFactory issueFactory,
I18nHelper.BeanFactory factory) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
doesQueryFitFilterForm(ApplicationUser user,
Query query)
Checks if a
Query is capable of being shown on the simple (GUI-based) issue navigator edit screen. |
String |
getGeneratedJqlString(Query query)
Generates a JQL string representation for the passed query.
|
String |
getIssueSearchPath(ApplicationUser user,
SearchService.IssueSearchParameters params)
Returns the URL relative to the app context to represent the specified issue search.
|
String |
getJqlString(Query query)
Gets the JQL string representation for the passed query.
|
QueryContext |
getQueryContext(ApplicationUser searcher,
Query query)
Generates a full QueryContext for the specified
Query for the searching user. |
String |
getQueryString(ApplicationUser user,
Query query)
Returns the query string to represent the specified SearchQuery.
|
SearchContext |
getSearchContext(ApplicationUser searcher,
Query query)
This produces an old-style
SearchContext based on the passed in
search query and the user that is performing the search. |
QueryContext |
getSimpleQueryContext(ApplicationUser searcher,
Query query)
Generates a simple QueryContext for the specified
Query for the searching user. |
SearchService.ParseResult |
parseQuery(ApplicationUser searcher,
String query)
Parses the query string into a JQL
Query. |
Query |
sanitiseSearchQuery(ApplicationUser searcher,
Query query)
Returns an equivalent
Query with all the potential "information leaks" removed,
with regards to the specified user. |
SearchResults<Issue> |
search(ApplicationUser searcher,
Query query,
PagerFilter pager)
Search the index, and only return issues that are in the pager's range.
|
long |
searchCount(ApplicationUser searcher,
Query query)
Search the index, and return the count of the issues matching the query.
|
long |
searchCount(ApplicationUser searcher,
Query query,
Long timeout)
Search the index, and return the count of the issues matching the query.
|
long |
searchCountOverrideSecurity(ApplicationUser searcher,
Query query)
Return the number of issues matching the provided search criteria, overridding any security constraints.
|
SearchResults<Issue> |
searchOverrideSecurity(ApplicationUser searcher,
Query query,
PagerFilter pager)
Search the index, and only return issues that are in the pager's range while AND'ing the raw lucene query
to the generated query from the provided searchQuery, not taking into account any security
constraints.
|
MessageSet |
validateQuery(ApplicationUser searcher,
Query query)
Validates the specified
Query for passed user. |
MessageSet |
validateQuery(ApplicationUser searcher,
Query query,
Long searchRequestId)
Validates the specified
Query for passed user and search request. |
public DefaultSearchService(SearchHandlerManager searchHandlerManager, JqlQueryParser jqlQueryParser, ValidatorVisitor.ValidatorVisitorFactory validatorVisitorFactory, QueryContextVisitor.QueryContextVisitorFactory queryContextVisitorFactory, JqlStringSupport jqlStringSupport, QueryContextConverter queryContextConverter, QueryCache queryCache, JqlOperandResolver jqlOperandResolver, OrderByValidator orderByValidator, SearchProvider searchProvider, IssueFactory issueFactory, I18nHelper.BeanFactory factory)
public boolean doesQueryFitFilterForm(ApplicationUser user, Query query)
SearchServiceQuery is capable of being shown on the simple (GUI-based) issue navigator edit screen.doesQueryFitFilterForm in interface SearchServiceuser - the user who is executing the query.query - the Query which to check that is displayable on the simple (GUI-based) issue navigator edit screen.
Does not accept null.public SearchResults<Issue> search(ApplicationUser searcher, Query query, PagerFilter pager) throws SearchException
SearchService
Note: that this method returns read only Issue objects, and should not be
used where you need the issue for update.
search in interface SearchServicesearcher - the user performing the search, which will be used to create a permission filter that filters out
any of the results the user is not able to see and will be used to provide context for the search.query - contains the information required to perform the search.pager - Pager filter (use PagerFilter.getUnlimitedFilter() to get all issues).SearchResults containing the resulting issues.SearchException - thrown if there is a severe problem encountered with lucene when searching (wraps an
IOException).public SearchResults<Issue> searchOverrideSecurity(ApplicationUser searcher, Query query, PagerFilter pager) throws SearchException
SearchServiceAs the method name implies, it bypasses the security restrictions that would normally be applied when performing a search. As such, it should only be used for administrative tasks where you really need to know about ALL affected issues.
Note that this method returns read only Issue objects, and should not be
used where you need the issue for update. Also note that if you are only after the number of search
results use SearchService.searchCount(ApplicationUser, Query) as it provides better performance.
searchOverrideSecurity in interface SearchServicesearcher - the user performing the search which will be used to provide context for the search.query - contains the information required to perform the search.pager - Pager filter (use PagerFilter.getUnlimitedFilter() to get all issues).SearchResults containing the resulting issues.SearchException - thrown if there is a severe problem encountered with lucene when searching (wraps an
IOException).ClauseTooComplexSearchException - if the query or part of the query produces
lucene that is too complex to be processed.public long searchCount(ApplicationUser searcher, Query query) throws SearchException
SearchServicesearchCount in interface SearchServicesearcher - the user performing the search, which will be used to create a permission filter that filters out
any of the results the user is not able to see and will be used to provide context for the search.query - contains the information required to perform the search.SearchException - thrown if there is a severe problem encountered with lucene when searching (wraps an
IOException).public long searchCount(ApplicationUser searcher, Query query, Long timeout) throws SearchException
SearchServicesearchCount in interface SearchServicesearcher - the user performing the search, which will be used to create a permission filter that filters out
any of the results the user is not able to see and will be used to provide context for the searchquery - contains the information required to perform the search.timeout - timeout in millisecondsSearchException - thrown if there is a severe problem encountered with lucene when searching (wraps an
IOException).public long searchCountOverrideSecurity(ApplicationUser searcher, Query query) throws SearchException
SearchServiceAs the method name implies, it bypasses the security restrictions that would normally be applied when performing a search. As such, it should only be used for administrative tasks where you really need to know about ALL affected issues.
Note: Searching for the count avoids loading the issue data into memory, so this should be preferred when the count is all you need to know.
searchCountOverrideSecurity in interface SearchServicesearcher - the user performing the search which will be used to provide context for the search.query - contains the information required to perform the search.SearchException - thrown if there is a severe problem encountered with lucene when searching (wraps an
IOException).ClauseTooComplexSearchException - if the query or part of the query produces
lucene that is too complex to be processed.public SearchContext getSearchContext(ApplicationUser searcher, Query query)
SearchServiceSearchContext based on the passed in
search query and the user that is performing the search.
This will only make sense if the query returns true for SearchService.doesQueryFitFilterForm(ApplicationUser, Query)
since SearchContext is only relevant for simple queries.
The more acurate context can be gotten by calling SearchService.getQueryContext(ApplicationUser, Query).
If the query will not fit in the simple issue navigator then the generated SearchContext will be empty. This method never returns a null SearchContext, even when passed a null SearchQuery.
getSearchContext in interface SearchServicesearcher - the user performing the search, not always the SearchRequest's ownerquery - the query for which you want a contextpublic String getQueryString(ApplicationUser user, Query query)
SearchService
The query string is prepended with "&jqlQuery=" so that it is ready for use in building a URL.
getQueryString in interface SearchServiceuser - the user performing the searchquery - the SearchQuery to generate the query string of. Does not accept null.public String getIssueSearchPath(ApplicationUser user, SearchService.IssueSearchParameters params)
SearchService
The URL is composed by the issue search path and provided parameters (e.g. "&/issues/?jql=...&filter=..."), but does NOT include the context path.
getIssueSearchPath in interface SearchServiceuser - the user performing the searchparams - the parameters to generate the URL. Possible parameters are filter Id and query (JQL), both are optional but you cannot use both at the same time. Does not accept null.public SearchService.ParseResult parseQuery(ApplicationUser searcher, String query)
SearchServiceQuery.parseQuery in interface SearchServicesearcher - the user in contextquery - the query to parse into a Query.public QueryContext getQueryContext(ApplicationUser searcher, Query query)
SearchServiceQuery for the searching user. The full
QueryContext contains all explicit and implicitly specified projects and issue types from the Query.
For a better explanation of the differences between the full and simple QueryContexts, see
QueryContextVisitor in jira-core.
getQueryContext in interface SearchServicesearcher - the user performing the searchquery - the search query to generate the context forpublic QueryContext getSimpleQueryContext(ApplicationUser searcher, Query query)
SearchServiceQuery for the searching user.
The simple QueryContext contains only the explicit projects and issue types specified in the Query. If none were
specified, it will be the Global context.
For a better explanation of the differences between the full and simple QueryContexts, see
QueryContextVisitor in jira-core.
getSimpleQueryContext in interface SearchServicesearcher - the user performing the searchquery - the search query to generate the context for@Nonnull public MessageSet validateQuery(ApplicationUser searcher, @Nonnull Query query)
SearchServiceQuery for passed user. The same as calling
validateQuery(searcher, query, null);.validateQuery in interface SearchServicesearcher - the user performing the searchquery - the search query to validate@Nonnull public MessageSet validateQuery(ApplicationUser searcher, @Nonnull Query query, Long searchRequestId)
SearchServiceQuery for passed user and search request. This validates the
the passed query as if it was run as the passed search request.validateQuery in interface SearchServicesearcher - the user performing the search.query - the search query to validate.searchRequestId - validate in the context of this search request. Can be null to indicate the passed
query is not currently a search request.public String getJqlString(Query query)
SearchServiceQuery.getQueryString()
if it exists or generates one if it does not. Equilavent to:
if (query.getQueryString() != null)
return query.getQueryString();
else
return getGeneratedJqlString(query);
getJqlString in interface SearchServicequery - the query. Cannot be null.public String getGeneratedJqlString(Query query)
SearchServiceQuery.getQueryString()
is completely ignored if it exists. The returned JQL is automatically escaped as necessary.getGeneratedJqlString in interface SearchServicequery - the query. Cannot be null.public Query sanitiseSearchQuery(ApplicationUser searcher, Query query)
SearchServiceQuery with all the potential "information leaks" removed,
with regards to the specified user. For example, if the query contains the clause "project = Invisible", and the
specified user does not have browse permission for project "Invisible", the sanitised query will replace this
clause with "project = 12345" (where 12345 is the id of the project).sanitiseSearchQuery in interface SearchServicesearcher - the user performing the searchquery - the query to sanitise; must not be null.Copyright © 2002-2021 Atlassian. All Rights Reserved.