use of freemarker.template.TemplateModelException in project wombat by PLOS.
the class ThemeConfigDirective method getValue.
@Override
protected Object getValue(Environment env, Map params) throws TemplateException, IOException {
Object mapNameObj = params.get("map");
if (mapNameObj == null)
throw new TemplateModelException("map param required");
Object valueNameObj = params.get("value");
if (valueNameObj == null)
throw new TemplateModelException("value param required");
Object journalKeyObj = params.get("journal");
Theme theme = new SitePageContext(siteResolver, env).getSite().getTheme();
if (journalKeyObj != null) {
theme = theme.resolveForeignJournalKey(siteSet, journalKeyObj.toString()).getTheme();
}
Map<String, Object> configMap = theme.getConfigMap(mapNameObj.toString());
if (configMap == null) {
throw new TemplateModelException("No config map exists for: " + mapNameObj);
}
return configMap.get(valueNameObj.toString());
}
use of freemarker.template.TemplateModelException in project openj9 by eclipse.
the class UMA method get.
public TemplateModel get(String arg0) throws TemplateModelException {
if (arg0.equals("spec")) {
return new Spec();
}
if (arg0.equals("year")) {
GregorianCalendar calendar = new GregorianCalendar();
return new SimpleScalar(Integer.toString(calendar.get(Calendar.YEAR)));
}
try {
TemplateModel platformExtension = com.ibm.uma.UMA.getUma().getPlatform().getDataModelExtension(com.ibm.uma.UMA.FREEMARKER_UMA, arg0);
if (platformExtension != null)
return platformExtension;
TemplateModel configurationExtension = com.ibm.uma.UMA.getUma().getConfiguration().getDataModelExtension(com.ibm.uma.UMA.FREEMARKER_UMA, arg0);
if (configurationExtension != null)
return configurationExtension;
} catch (UMAException e) {
throw new TemplateModelException(e);
}
return null;
}
Aggregations