String language,
Path storedAtPath ) throws InvalidQueryException, RepositoryException {
session.checkLive();
// Look for a parser for the specified language ...
QueryParsers queryParsers = session.repository().runningState().queryParsers();
QueryParser parser = queryParsers.getParserFor(language);
if (parser == null) {
Set<String> languages = queryParsers.getLanguages();
throw new InvalidQueryException(JcrI18n.invalidQueryLanguage.text(language, languages));
}
try {
// Parsing must be done now ...
QueryCommand command = parser.parseQuery(expression, typeSystem);
if (command == null) {
// The query is not well-formed and cannot be parsed ...
throw new InvalidQueryException(JcrI18n.queryCannotBeParsedUsingLanguage.text(language, expression));
}
// Set up the hints ...
PlanHints hints = new PlanHints();
hints.showPlan = true;
hints.hasFullTextSearch = true; // always include the score
hints.validateColumnExistance = false; // see MODE-1055
if (parser.getLanguage().equals(QueryLanguage.JCR_SQL2)) {
hints.qualifyExpandedColumnNames = true;
}
return resultWith(expression, parser.getLanguage(), command, hints, storedAtPath);
} catch (ParsingException e) {
// The query is not well-formed and cannot be parsed ...
String reason = e.getMessage();
throw new InvalidQueryException(JcrI18n.queryCannotBeParsedUsingLanguage.text(language, expression, reason));
} catch (org.modeshape.jcr.query.parse.InvalidQueryException e) {