if (s == null || s.length() == 0)
s = request.getServletPath();
if (pathIgnored(s, _config.getExtensions()))
return false;
final ActionContext ac = new ActionContextImpl(request, response,
_config.getVariableResolver(), _config.getFunctionMapper());
final ActionDefinition[] defs = _config.getActionDefinitions();
for (int j = 0; j < defs.length; ++j) {
final ActionDefinition def = defs[j];
Object action = null;
try {
action = def.getAction(ac);
if (action != null) {
request.setAttribute("action", action);
if (!parameterIgnored(action))
coerceParameters(ac, action);
final String result = def.execute(ac, action);
request.setAttribute("result", result);
final ViewInfo viewInfo = def.getViewInfo(ac, result);
if (viewInfo == null)
throw new ZestException("No information specified for "+action+" under result is "+result+", when handling "+ac.getRequestPath());
switch (viewInfo.getViewType()) {
case REDIRECT:
Https.sendRedirect(_ctx, request, response, viewInfo.getURI(), null, 0);
break;
case ERROR:
final String msg = viewInfo.getErrorMessage();
if (msg != null)
response.sendError(viewInfo.getErrorCode(), msg);
else
response.sendError(viewInfo.getErrorCode());
case DONE:
break;
default:
Https.forward(_ctx, request, response, viewInfo.getURI());
break;
}
return true;
}
} catch (Throwable ex) {
try {
_config.getErrorHandler().onError(ac, action, ex);
} catch (ServletException t) {
throw (ServletException)t;
} catch (IOException t) {
throw (IOException)t;
} catch (Throwable t) {
throw ZestException.Aide.wrap(t, "Failed to handle "+ac.getRequestPath());
}
}
}
return false;
}