Search in sources :

Example 1 with NotHasPermissionDirective

use of org.molgenis.security.freemarker.NotHasPermissionDirective 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;
}
Also used : HasPermissionDirective(org.molgenis.security.freemarker.HasPermissionDirective) NotHasPermissionDirective(org.molgenis.security.freemarker.NotHasPermissionDirective) Configuration(freemarker.template.Configuration) NotHasPermissionDirective(org.molgenis.security.freemarker.NotHasPermissionDirective) Properties(java.util.Properties) LimitMethod(org.molgenis.core.ui.freemarker.LimitMethod) FreeMarkerConfigurer(org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer) MolgenisFreemarkerObjectWrapper(org.molgenis.core.ui.freemarker.MolgenisFreemarkerObjectWrapper) Bean(org.springframework.context.annotation.Bean)

Aggregations

Configuration (freemarker.template.Configuration)1 Properties (java.util.Properties)1 LimitMethod (org.molgenis.core.ui.freemarker.LimitMethod)1 MolgenisFreemarkerObjectWrapper (org.molgenis.core.ui.freemarker.MolgenisFreemarkerObjectWrapper)1 HasPermissionDirective (org.molgenis.security.freemarker.HasPermissionDirective)1 NotHasPermissionDirective (org.molgenis.security.freemarker.NotHasPermissionDirective)1 Bean (org.springframework.context.annotation.Bean)1 FreeMarkerConfigurer (org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer)1