*/
private NodeData initACL(NodeData parent, NodeData node, ACLSearch search) throws RepositoryException
{
if (node != null)
{
AccessControlList acl = node.getACL();
if (acl == null)
{
if (parent != null)
{
// use parent ACL
node =
new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
node.getParentIdentifier(), parent.getACL());
}
else
{
if (search == null)
{
search = new ACLSearch(null, null);
}
// use nearest ancestor ACL... case of get by id
node =
new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
node.getParentIdentifier(), getNearestACAncestorAcl(node, search));
}
}
else if (!acl.hasPermissions())
{
// use nearest ancestor permissions
if (search == null)
{
search = new ACLSearch(acl.getOwner(), null);
}
else
{
search.setOwner(acl.getOwner());
if (search.found())
{
return new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
node.getParentIdentifier(), new AccessControlList(acl.getOwner(), null));
}
}
AccessControlList ancestorAcl =
parent != null && parent.getACL() != null && parent.getACL().hasPermissions() ? parent.getACL()
: getNearestACAncestorAcl(node, search);
node =
new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(), node.getParentIdentifier(),
new AccessControlList(acl.getOwner(), ancestorAcl.getPermissionEntries()));
}
else if (!acl.hasOwner())
{
if (search == null)
{
search = new ACLSearch(null, acl.getPermissionEntries());
}
else
{
search.setPermissions(acl.getPermissionEntries());
if (search.found())
{
return new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(),
node.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(),
node.getParentIdentifier(), new AccessControlList(null, acl.getPermissionEntries()));
}
}
// use nearest ancestor owner
AccessControlList ancestorAcl =
parent != null && parent.getACL() != null && parent.getACL().hasOwner() ? parent.getACL()
: getNearestACAncestorAcl(node, search);
node =
new TransientNodeData(node.getQPath(), node.getIdentifier(), node.getPersistedVersion(), node
.getPrimaryTypeName(), node.getMixinTypeNames(), node.getOrderNumber(), node.getParentIdentifier(),
new AccessControlList(ancestorAcl.getOwner(), acl.getPermissionEntries()));
}
}
return node;