if (collection == null)
{throw new BadRequestException("Collection " + request.getPath() + " does not exist.");}
final XQuery xquery = broker.getXQueryService();
CompiledXQuery feedQuery = xquery.getXQueryPool().borrowCompiledXQuery(broker, config.querySource);
XQueryContext context;
if (feedQuery == null) {
context = xquery.newContext(AccessContext.REST);
context.setModuleLoadPath(getContext().getModuleLoadPath());
try {
feedQuery = xquery.compile(context, config.querySource);
} catch (final XPathException ex) {
throw new EXistException("Cannot compile xquery "
+ config.querySource.getURL(), ex);
} catch (final IOException ex) {
throw new EXistException(
"I/O exception while compiling xquery "
+ config.querySource.getURL(), ex);
}
} else {
context = feedQuery.getContext();
context.setModuleLoadPath(getContext().getModuleLoadPath());
}
context.setStaticallyKnownDocuments(new XmldbURI[] { XmldbURI.create(
request.getPath()).append(AtomProtocol.FEED_DOCUMENT_NAME) });