public boolean invoke(Environment env,
InvokeContext context) throws Exception {
List params = null;
// Resolve parameters
if (parameters != null) {
params = resolveList(parameters, manager, context, env.getObjectModel());
}
// Need redirector in any case
Redirector redirector = context.getRedirector();
// If the continuation id is not null, it takes precedence over
// the function call, so we invoke it here.
String continuation = continuationId.resolve(context, env.getObjectModel());
if (continuation != null && continuation.length() > 0) {
try {
interpreter.handleContinuation(continuation, params, redirector);
} catch(Exception e) {
throw ProcessingException.throwLocated("Sitemap: error calling continuation", e, getLocation());
}
if (!redirector.hasRedirected()) {
throw new ProcessingException("Sitemap: < map:call continuation > did not send a response", getLocation());
}
return true;
}
// We don't have a continuation id passed in < map:call >, so invoke
// the specified function
String name = functionName.resolve(context, env.getObjectModel());
if (name != null && name.length() > 0) {
try {
interpreter.callFunction(name, params, redirector);
} catch(Exception e) {
throw ProcessingException.throwLocated("Sitemap: error calling function '" + name + "'", e, getLocation());
}
if (!redirector.hasRedirected()) {
throw new ProcessingException("Sitemap: < map:call function > did not send a response", getLocation());
}
return true;
}
// Found neither continuation nor function to call
throw new ProcessingException("Sitemap: no function nor continuation given in < map:call function >", getLocation());
}
|