public final boolean invoke(Environment env,
InvokeContext context) throws Exception {
boolean passThrough;
Object passThroughRaw = env.getAttribute(MountNode.COCOON_PASS_THROUGH);
if (passThroughRaw == null) {
// Use default value
passThrough = false;
} else {
passThrough = ((Boolean) passThroughRaw).booleanValue();
}
// Always fail on external request if pipeline is internal only.
if (this.internalOnly && env.isExternal()) {
if (!this.isLast || passThrough) {
return false;
}
// Do not use internal-only pipeline error handler for external requests.
throw new ResourceNotFoundException("No pipeline matched request: " +
env.getURIPrefix() + env.getURI());
}
context.inform(this.processingPipeline, this.parameters, env.getObjectModel());
try {
if (this.errorHandlerHelper.isInternal()) {
// Set internal error handler in the pipeline
context.setErrorHandler(
new SitemapErrorHandler(this.errorHandlerHelper, env, context));
} else {
// Reset internal error handler (previous pipeline might had set it)
context.setErrorHandler(null);
}
if (invokeNodes(children, env, context)) {
return true;
} else if (!this.isLast || passThrough) {
return false;
}
throw new ResourceNotFoundException("No pipeline matched request: " +
env.getURIPrefix() + env.getURI());
} catch (ConnectionResetException e) {
// Will be reported by CocoonServlet, rethrowing
throw e;
} catch (Exception e) {
// Invoke error handler
return this.errorHandlerHelper.invokeErrorHandler(e, env, context);
}
}
|