use of net.jforum.exceptions.TemplateNotFoundException in project jforum2 by rafaelsteil.
the class Command method process.
/**
* Process and manipulate a requisition.
* @return <code>Template</code> reference
* @param request WebContextRequest
* @param response WebContextResponse
*/
public Template process(RequestContext request, ResponseContext response, SimpleHash context) {
this.request = request;
this.response = response;
this.context = context;
String action = this.request.getAction();
if (!this.ignoreAction) {
try {
this.getClass().getMethod(action, NO_ARGS_CLASS).invoke(this, NO_ARGS_OBJECT);
} catch (NoSuchMethodException e) {
this.list();
} catch (Exception e) {
throw new ForumException(e);
}
}
if (JForumExecutionContext.getRedirectTo() != null) {
this.setTemplateName(TemplateKeys.EMPTY);
} else if (request.getAttribute("template") != null) {
this.setTemplateName((String) request.getAttribute("template"));
}
if (JForumExecutionContext.isCustomContent()) {
return null;
}
if (this.templateName == null) {
throw new TemplateNotFoundException("Template for action " + action + " is not defined");
}
try {
return JForumExecutionContext.templateConfig().getTemplate(new StringBuffer(SystemGlobals.getValue(ConfigKeys.TEMPLATE_DIR)).append('/').append(this.templateName).toString());
} catch (IOException e) {
throw new ForumException(e);
}
}
Aggregations