java.lang.Object
ch.tocco.nice2.templating.api.freemarker.templatemodel.PrivilegedEntity

public class PrivilegedEntity extends Object
Call ObjectWrapper.wrap(Object) with an Entity wrapped in a PrivilegedEntity instance and it will be wrapped in a EntityHashModel where all fields and relations will be resolved in privileged mode.

This can be useful if you don't want to allow read rights by ACL, but someone should still be able to read field or relation values in a freemarker template.

 Example:

  PrivilegedEntity privilegedEntity = new PrivilegedEntity(userEntity); // User entity without ACL
  TemplateModel templateModel = environment.getObjectWrapper().wrap(privilegedEntity);

  environment.setVariable("user", templateModel);
 
Freemarker:


  <#-- firstname of user entity is resolved in privileged mode
       (couldn't be read otherwise if there's no ACL that allows it) -->
  ${user.firstname}
  
  • Constructor Details

    • PrivilegedEntity

      public PrivilegedEntity(Entity entity)
  • Method Details

    • getEntity

      public Entity getEntity()