*
* @throws ServiceAccessException
*
*/
public SearchQueryResult execute () throws ServiceAccessException {
SearchQueryResult result = null;
try {
IBasicResultSet resultSet = getExpression().execute();
if (orderBy != null) {
if (isLimitDefined()) {
result = new SearchQueryResult (resultSet,
orderBy.getComparator(),
limit);
}
else {
result = new SearchQueryResult (resultSet,
orderBy.getComparator());
}
}
else {
result = new SearchQueryResult (resultSet);
}
if (resultSet.isPartialResultSet()) {
result.setStatus(SearchQueryResult.STATUS_PARTIAL_RESULT);
result.setDescription ("The server truncated the result set");
}
}
catch (InvalidScopeException e) {
result = new SearchQueryResult ();
result.setStatus (SearchQueryResult.STATUS_INVALID_SCOPE);
result.setHref (queryScope.getHref());
}
catch (BadQueryException e) { // is this only INVALID_SCOPE?
result = new SearchQueryResult ();
result.setStatus (SearchQueryResult.STATUS_BAD_QUERY);
result.setDescription (e.getMessage());
result.setHref (queryScope.getHref());
}
catch (SearchException e) { // is this only INVALID_SCOPE?
result = new SearchQueryResult ();
result.setStatus (SearchQueryResult.STATUS_BAD_QUERY);
result.setDescription (e.getMessage());
result.setHref (queryScope.getHref());
}
return result;
}