com.atlassian.jira.bc.issue.search
Class DefaultSearchService

java.lang.Object
  extended by com.atlassian.jira.bc.issue.search.DefaultSearchService
All Implemented Interfaces:
SearchService

public class DefaultSearchService
extends Object
implements SearchService

The default implementation of the SearchService.

Since:
v4.0

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.atlassian.jira.bc.issue.search.SearchService
SearchService.ParseResult
 
Constructor Summary
DefaultSearchService(SearchHandlerManager searchHandlerManager, JqlQueryParser jqlQueryParser, ValidatorVisitor.ValidatorVisitorFactory validatorVisitorFactory, QueryContextVisitor.QueryContextVisitorFactory queryContextVisitorFactory, JqlStringSupport jqlStringSupport, QueryContextConverter queryContextConverter, QueryCache queryCache, JqlOperandResolver jqlOperandResolver, OrderByValidator orderByValidator, SearchProvider searchProvider, I18nHelper.BeanFactory factory)
           
 
Method Summary
 boolean doesQueryFitFilterForm(com.atlassian.crowd.embedded.api.User 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 getJqlString(Query query)
          Gets the JQL string representation for the passed query.
 QueryContext getQueryContext(com.atlassian.crowd.embedded.api.User searcher, Query query)
          Generates a full QueryContext for the specified Query for the searching user.
 String getQueryString(com.atlassian.crowd.embedded.api.User user, Query query)
          Returns the query string to represent the specified SearchQuery.
 SearchContext getSearchContext(com.atlassian.crowd.embedded.api.User 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(com.atlassian.crowd.embedded.api.User searcher, Query query)
          Generates a simple QueryContext for the specified Query for the searching user.
 SearchService.ParseResult parseQuery(com.atlassian.crowd.embedded.api.User searcher, String query)
          Parses the query string into a JQL Query.
 Query sanitiseSearchQuery(com.atlassian.crowd.embedded.api.User searcher, Query query)
          Returns an equivalent Query with all the potential "information leaks" removed, with regards to the specified user.
 SearchResults search(com.atlassian.crowd.embedded.api.User searcher, Query query, PagerFilter pager)
          Search the index, and only return issues that are in the pager's range.
 long searchCount(com.atlassian.crowd.embedded.api.User searcher, Query query)
          Search the index, and return the count of the issues matching the query.
 MessageSet validateQuery(com.atlassian.crowd.embedded.api.User searcher, Query query)
          Validates the specified Query for the searching user.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSearchService

public DefaultSearchService(SearchHandlerManager searchHandlerManager,
                            JqlQueryParser jqlQueryParser,
                            ValidatorVisitor.ValidatorVisitorFactory validatorVisitorFactory,
                            QueryContextVisitor.QueryContextVisitorFactory queryContextVisitorFactory,
                            JqlStringSupport jqlStringSupport,
                            QueryContextConverter queryContextConverter,
                            QueryCache queryCache,
                            JqlOperandResolver jqlOperandResolver,
                            OrderByValidator orderByValidator,
                            SearchProvider searchProvider,
                            I18nHelper.BeanFactory factory)
Method Detail

doesQueryFitFilterForm

public boolean doesQueryFitFilterForm(com.atlassian.crowd.embedded.api.User user,
                                      Query query)
Description copied from interface: SearchService
Checks if a Query is capable of being shown on the simple (GUI-based) issue navigator edit screen.

Specified by:
doesQueryFitFilterForm in interface SearchService
Parameters:
user - 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.
Returns:
true if the query is displayable on the simple (GUI-based) issue navigator edit screen, false otherwise.

search

public SearchResults search(com.atlassian.crowd.embedded.api.User searcher,
                            Query query,
                            PagerFilter pager)
                     throws SearchException
Description copied from interface: SearchService
Search the index, and only return issues that are in the pager's range. 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 after running a more complicated query see SearchProvider.

Specified by:
search in interface SearchService
Parameters:
searcher - 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).
Returns:
A SearchResults containing the resulting issues.
Throws:
SearchException - thrown if there is a severe problem encountered with lucene when searching (wraps an IOException).

searchCount

public long searchCount(com.atlassian.crowd.embedded.api.User searcher,
                        Query query)
                 throws SearchException
Description copied from interface: SearchService
Search the index, and return the count of the issues matching the query.

Specified by:
searchCount in interface SearchService
Parameters:
searcher - 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.
Returns:
the number of issues matching the query
Throws:
SearchException - thrown if there is a severe problem encountered with lucene when searching (wraps an IOException).

getSearchContext

public SearchContext getSearchContext(com.atlassian.crowd.embedded.api.User searcher,
                                      Query query)
Description copied from interface: SearchService
This produces an old-style SearchContext 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(com.atlassian.crowd.embedded.api.User, com.atlassian.query.Query) since SearchContext is only relevant for simple queries. The more acurate context can be gotten by calling SearchService.getQueryContext(com.atlassian.crowd.embedded.api.User, com.atlassian.query.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.

Specified by:
getSearchContext in interface SearchService
Parameters:
searcher - the user performing the search, not always the SearchRequest's owner
query - the query for which you want a context
Returns:
a SearchContext with the correct project/issue types if the query fits in the issue navigator, otherwise an empty SearchContext. Never null.

getQueryString

public String getQueryString(com.atlassian.crowd.embedded.api.User user,
                             Query query)
Description copied from interface: SearchService
Returns the query string to represent the specified SearchQuery.

The query string is prepended with "&jqlQuery=" so that it is ready for use in building a URL.

Specified by:
getQueryString in interface SearchService
Parameters:
user - the user performing the search
query - the SearchQuery to generate the query string of. Does not accept null.
Returns:
a String which represents the query string of a SearchQuery (ie no context/base applied). Never null.

parseQuery

public SearchService.ParseResult parseQuery(com.atlassian.crowd.embedded.api.User searcher,
                                            String query)
Description copied from interface: SearchService
Parses the query string into a JQL Query.

Specified by:
parseQuery in interface SearchService
Parameters:
searcher - the user in context
query - the query to parse into a Query.
Returns:
a result set that contains the query and a message set of any errors or warnings that occured during the parse.

getQueryContext

public QueryContext getQueryContext(com.atlassian.crowd.embedded.api.User searcher,
                                    Query query)
Description copied from interface: SearchService
Generates a full QueryContext for the specified Query 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.

Specified by:
getQueryContext in interface SearchService
Parameters:
searcher - the user performing the search
query - the search query to generate the context for
Returns:
a QueryContext that contains the implicit and explicit project / issue types implied by the included clauses in the query.
See Also:
QueryContextVisitor

getSimpleQueryContext

public QueryContext getSimpleQueryContext(com.atlassian.crowd.embedded.api.User searcher,
                                          Query query)
Description copied from interface: SearchService
Generates a simple QueryContext for the specified Query 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.

Specified by:
getSimpleQueryContext in interface SearchService
Parameters:
searcher - the user performing the search
query - the search query to generate the context for
Returns:
a QueryContext that contains only the explicit project / issue types from the included clauses in the query.
See Also:
QueryContextVisitor

validateQuery

public MessageSet validateQuery(com.atlassian.crowd.embedded.api.User searcher,
                                Query query)
Description copied from interface: SearchService
Validates the specified Query for the searching user.

Specified by:
validateQuery in interface SearchService
Parameters:
searcher - the user performing the search
query - the search query to validate
Returns:
a message set containing any errors encountered; never null.

getJqlString

public String getJqlString(Query query)
Description copied from interface: SearchService
Gets the JQL string representation for the passed query. Returns the string from Query.getQueryString() if it exists or generates one if it does not. Equilavent to:
  if (query.getQueryString() != null)
    return query.getQueryString();
  else
    return getGeneratedJqlString(query);

 

Specified by:
getJqlString in interface SearchService
Parameters:
query - the query. Cannot be null.
Returns:
the JQL string represenation of the passed query.

getGeneratedJqlString

public String getGeneratedJqlString(Query query)
Description copied from interface: SearchService
Generates a JQL string representation for the passed query. The JQL string is always generated, that is, Query.getQueryString() is completely ignored if it exists. The returned JQL is automatically escaped as necessary.

Specified by:
getGeneratedJqlString in interface SearchService
Parameters:
query - the query. Cannot be null.
Returns:
the generated JQL string representation of the passed query.

sanitiseSearchQuery

public Query sanitiseSearchQuery(com.atlassian.crowd.embedded.api.User searcher,
                                 Query query)
Description copied from interface: SearchService
Returns an equivalent Query 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).

Specified by:
sanitiseSearchQuery in interface SearchService
Parameters:
searcher - the user performing the search
query - the query to sanitise; must not be null.
Returns:
the sanitised query; never null.


Copyright © 2002-2013 Atlassian. All Rights Reserved.