use of org.molgenis.security.freemarker.HasPermissionDirective in project molgenis by molgenis.
the class MolgenisWebAppConfig method freeMarkerConfigurer.
/**
* Configure freemarker. All freemarker templates should be on the classpath in a package called 'freemarker'
*/
@Bean
public FreeMarkerConfigurer freeMarkerConfigurer() {
FreeMarkerConfigurer result = new FreeMarkerConfigurer() {
@Override
protected void postProcessConfiguration(Configuration config) throws IOException, TemplateException {
config.setObjectWrapper(new MolgenisFreemarkerObjectWrapper(VERSION_2_3_23));
}
};
result.setPreferFileSystemAccess(false);
result.setTemplateLoaderPath("classpath:/templates/");
result.setDefaultEncoding("UTF-8");
Properties freemarkerSettings = new Properties();
freemarkerSettings.setProperty(Configuration.LOCALIZED_LOOKUP_KEY, Boolean.FALSE.toString());
result.setFreemarkerSettings(freemarkerSettings);
Map<String, Object> freemarkerVariables = Maps.newHashMap();
freemarkerVariables.put("limit", new LimitMethod());
freemarkerVariables.put("hasPermission", new HasPermissionDirective(permissionService));
freemarkerVariables.put("notHasPermission", new NotHasPermissionDirective(permissionService));
addFreemarkerVariables(freemarkerVariables);
result.setFreemarkerVariables(freemarkerVariables);
return result;
}
Aggregations