throw new RemoteException(parser.getErrorMessage());
}
final AST ast = parser.getAST();
final PathExpr expr = new PathExpr(context);
treeParser.xpath(ast, expr);
if (treeParser.foundErrors()) {
LOG.debug(treeParser.getErrorMessage());
throw new EXistException(treeParser.getErrorMessage());
}
LOG.info("query: " + ExpressionDumper.dump(expr));
final long start = System.currentTimeMillis();
expr.analyze(new AnalyzeContextInfo());
final Sequence seq= expr.eval(null, null);
QueryResponseCollection[] collections = null;
if (!seq.isEmpty() && Type.subTypeOf(seq.getItemType(), Type.NODE))
{collections = collectQueryInfo(scanResults(seq));}
session.addQueryResult(seq);
resp.setCollections(new QueryResponseCollections(collections));
resp.setHits(seq.getItemCount());
resp.setQueryTime(System.currentTimeMillis() - start);
expr.reset();
context.reset();
} catch (final Exception e) {
LOG.debug(e.getMessage(), e);
throw new RemoteException("query execution failed: " + e.getMessage());
} finally {