}
}
private static void changeReadPermission(Principal principal, Node n, boolean allowRead) throws RepositoryException, NotExecutableException {
SessionImpl s = (SessionImpl) n.getSession();
JackrabbitAccessControlList acl = null;
AccessControlManager acMgr = s.getAccessControlManager();
AccessControlPolicyIterator it = acMgr.getApplicablePolicies(n.getPath());
while (it.hasNext()) {
AccessControlPolicy acp = it.nextAccessControlPolicy();
if (acp instanceof JackrabbitAccessControlList) {
acl = (JackrabbitAccessControlList) acp;
break;
}
}
if (acl == null) {
AccessControlPolicy[] acps = acMgr.getPolicies(n.getPath());
for (int i = 0; i < acps.length; i++) {
if (acps[i] instanceof JackrabbitAccessControlList) {
acl = (JackrabbitAccessControlList) acps[i];
break;
}
}
}
if (acl != null) {
acl.addEntry(principal, new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_READ)}, allowRead);
acMgr.setPolicy(n.getPath(), acl);
s.save();
} else {
// no JackrabbitAccessControlList found.
throw new NotExecutableException();