use of freemarker.template.TemplateScalarModel in project alfresco-repository by Alfresco.
the class HasPermissionMethod method exec.
/**
* @see freemarker.template.TemplateMethodModel#exec(java.util.List)
*/
public Object exec(List args) throws TemplateModelException {
int result = 0;
if (args.size() == 2) {
// arg 0 must be a wrapped TemplateNode object
BeanModel arg0 = (BeanModel) args.get(0);
// arg 1 must be a String permission name
String permission;
Object arg1 = args.get(1);
if (arg1 instanceof TemplateScalarModel) {
permission = ((TemplateScalarModel) arg1).getAsString();
if (arg0.getWrappedObject() instanceof TemplateNode) {
// test to see if this node has the permission
if (((TemplateNode) arg0.getWrappedObject()).hasPermission(permission)) {
result = 1;
}
}
}
}
return Integer.valueOf(result);
}
Aggregations