Search in sources :

Example 1 with TemplateNotFoundException

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);
    }
}
Also used : ForumException(net.jforum.exceptions.ForumException) TemplateNotFoundException(net.jforum.exceptions.TemplateNotFoundException) IOException(java.io.IOException) TemplateNotFoundException(net.jforum.exceptions.TemplateNotFoundException) IOException(java.io.IOException) ForumException(net.jforum.exceptions.ForumException)

Aggregations

IOException (java.io.IOException)1 ForumException (net.jforum.exceptions.ForumException)1 TemplateNotFoundException (net.jforum.exceptions.TemplateNotFoundException)1