aclNode = addNode(acNode, N_POLICY, NT_REP_ACL);
/* add all entries defined on the template */
AccessControlEntry[] aces = acl.getAccessControlEntries();
for (int i = 0; i < aces.length; i++) {
JackrabbitAccessControlEntry ace = (JackrabbitAccessControlEntry) aces[i];
// create the ACE node
Name nodeName = getUniqueNodeName(aclNode, "entry");
Name ntName = (ace.isAllow()) ? NT_REP_GRANT_ACE : NT_REP_DENY_ACE;
NodeImpl aceNode = addNode(aclNode, nodeName, ntName);
ValueFactory vf = session.getValueFactory();
// write the rep:principalName property
setProperty(aceNode, P_PRINCIPAL_NAME, vf.createValue(ace.getPrincipal().getName()));
// ... and the rep:privileges property
Privilege[] privs = ace.getPrivileges();
Value[] vs = new Value[privs.length];
for (int j = 0; j < privs.length; j++) {
vs[j] = vf.createValue(privs[j].getName(), PropertyType.NAME);
}
setProperty(aceNode, P_PRIVILEGES, vs);
// store the restrictions:
String[] restrNames = ace.getRestrictionNames();
for (int rnIndex = 0; rnIndex < restrNames.length; rnIndex++) {
Name pName = session.getQName(restrNames[rnIndex]);
Value value = ace.getRestriction(restrNames[rnIndex]);
setProperty(aceNode, pName, value);
}
}
}