private void remove(Set<String> principalNames) {
String msg = "Unable to remove permission entry";
for (String principalName: entries.keySet()) {
if (permissionRoot.hasChildNode(principalName)) {
principalNames.add(principalName);
NodeBuilder principalRoot = permissionRoot.getChildNode(principalName);
// find the ACL node that for this path and principal
NodeBuilder parent = principalRoot.getChildNode(nodeName);
if (!parent.exists()) {
continue;
}
long numEntries = PermissionUtil.getNumPermissions(principalRoot);
// check if the node is the correct one
if (PermissionUtil.checkACLPath(parent, accessControlledPath)) {
// remove and reconnect child nodes
NodeBuilder newParent = null;
for (String childName : parent.getChildNodeNames()) {
if (childName.charAt(0) != 'c') {
numEntries--;
continue;
}
NodeBuilder child = parent.getChildNode(childName);
if (newParent == null) {
newParent = child;
} else {
newParent.setChildNode(childName, child.getNodeState());
child.remove();
}
}
parent.remove();
if (newParent != null) {
principalRoot.setChildNode(nodeName, newParent.getNodeState());
}
} else {
// check if any of the child nodes match
for (String childName : parent.getChildNodeNames()) {
if (childName.charAt(0) != 'c') {
continue;
}
NodeBuilder child = parent.getChildNode(childName);
if (PermissionUtil.checkACLPath(child, accessControlledPath)) {
// remove child
for (String n: child.getChildNodeNames()) {
numEntries--;
}
child.remove();
}
}
}
touch(principalRoot, numEntries);
} else {