Search in sources :

Example 1 with TemplateProcessor

use of org.alfresco.service.cmr.repository.TemplateProcessor in project alfresco-repository by Alfresco.

the class TemplateServiceImpl method processTemplate.

/**
 * @see org.alfresco.service.cmr.repository.TemplateService#processTemplate(java.lang.String, java.lang.String, java.lang.Object, java.util.Locale)
 */
private void processTemplate(String engine, String template, Object model, Writer out, Locale locale) throws TemplateException {
    Locale currentLocale = I18NUtil.getLocaleOrNull();
    Locale currentContentLocale = I18NUtil.getContentLocaleOrNull();
    try {
        // set locale for cases where message method is used inside of template
        I18NUtil.setLocale(locale);
        // execute template processor
        TemplateProcessor processor = getTemplateProcessor(engine);
        processor.process(template, model, out, locale);
    } catch (TemplateException terr) {
        throw terr;
    } catch (Throwable err) {
        throw new TemplateException(err.getMessage(), err);
    } finally {
        I18NUtil.setLocale(currentLocale);
        I18NUtil.setContentLocale(currentContentLocale);
    }
}
Also used : Locale(java.util.Locale) TemplateException(org.alfresco.service.cmr.repository.TemplateException) TemplateProcessor(org.alfresco.service.cmr.repository.TemplateProcessor)

Example 2 with TemplateProcessor

use of org.alfresco.service.cmr.repository.TemplateProcessor in project alfresco-repository by Alfresco.

the class TemplateServiceImpl method processTemplate.

/**
 * @see org.alfresco.service.cmr.repository.TemplateService#processTemplate(java.lang.String, java.lang.String, java.lang.Object, java.io.Writer)
 */
public void processTemplate(String engine, String template, Object model, Writer out) throws TemplateException {
    try {
        // execute template processor
        TemplateProcessor processor = getTemplateProcessor(engine);
        processor.process(template, model, out);
    } catch (TemplateException terr) {
        throw terr;
    } catch (Throwable err) {
        throw new TemplateException(err.getMessage(), err);
    }
}
Also used : TemplateException(org.alfresco.service.cmr.repository.TemplateException) TemplateProcessor(org.alfresco.service.cmr.repository.TemplateProcessor)

Example 3 with TemplateProcessor

use of org.alfresco.service.cmr.repository.TemplateProcessor in project alfresco-repository by Alfresco.

the class TemplateServiceImpl method processTemplateString.

/**
 * @see org.alfresco.service.cmr.repository.TemplateService#processTemplateString(java.lang.String, java.lang.String, java.lang.Object, java.io.Writer)
 */
public void processTemplateString(String engine, String template, Object model, Writer out) throws TemplateException {
    try {
        // execute template processor
        TemplateProcessor processor = getTemplateProcessor(engine);
        processor.processString(template, model, out);
    } catch (TemplateException terr) {
        throw terr;
    } catch (Throwable err) {
        throw new TemplateException(err.getMessage(), err);
    }
}
Also used : TemplateException(org.alfresco.service.cmr.repository.TemplateException) TemplateProcessor(org.alfresco.service.cmr.repository.TemplateProcessor)

Aggregations

TemplateException (org.alfresco.service.cmr.repository.TemplateException)3 TemplateProcessor (org.alfresco.service.cmr.repository.TemplateProcessor)3 Locale (java.util.Locale)1