* @throws RepositoryException
*/
private JcrAccessControlList findAccessList( String absPath,
boolean searchParents ) throws PathNotFoundException, RepositoryException {
// this will not load any nodes in the JCR session, but might load the entire hierarchy in the node cache
CachedNode startingNode = session.cachedNode(session.pathFactory().create(absPath), false);
SessionCache sessionCache = session.cache();
Map<String, Set<String>> permissions = startingNode.getPermissions(sessionCache);
CachedNode node = startingNode;
if (permissions == null && searchParents) {
// walk up the hierarchy until we get a set of permissions or we reach the root or a missing parent
while (permissions == null) {
NodeKey parentKey = node.getParentKey(sessionCache);
if (parentKey == null) {
break;
}
node = sessionCache.getNode(parentKey);
if (node == null) {
break;
}
permissions = node.getPermissions(sessionCache);
}
}
if (permissions == null || node == null) {
return null;
}
// create a new access list object
String aclPath = startingNode.getKey().equals(node.getKey()) ? absPath : node.getPath(sessionCache).getString();
JcrAccessControlList acl = new JcrAccessControlList(this, aclPath);
for (String principalName : permissions.keySet()) {
Set<String> privileges = permissions.get(principalName);
acl.addAccessControlEntry(principal(principalName), privileges(privileges));
}