Search in sources :

Example 1 with RemoveAll

use of com.cognifide.cq.cqsm.foundation.actions.removeall.RemoveAll in project APM by Cognifide.

the class Purge method purge.

private void purge(final Context context, final ActionResult actionResult) throws RepositoryException, ActionExecutionException {
    NodeIterator iterator = getPermissions(context);
    String normalizedPath = normalizePath(path);
    while (iterator != null && iterator.hasNext()) {
        Node node = iterator.nextNode();
        if (node.hasProperty(PermissionConstants.REP_ACCESS_CONTROLLED_PATH)) {
            String parentPath = node.getProperty(PermissionConstants.REP_ACCESS_CONTROLLED_PATH).getString();
            String normalizedParentPath = normalizePath(parentPath);
            boolean isUsersPermission = parentPath.startsWith(context.getCurrentAuthorizable().getPath());
            if (StringUtils.startsWith(normalizedParentPath, normalizedPath) && !isUsersPermission) {
                RemoveAll removeAll = new RemoveAll(parentPath);
                ActionResult removeAllResult = removeAll.execute(context);
                if (Status.ERROR.equals(removeAllResult.getStatus())) {
                    actionResult.logError(removeAllResult);
                }
            }
        }
    }
}
Also used : NodeIterator(javax.jcr.NodeIterator) ActionResult(com.cognifide.cq.cqsm.api.actions.ActionResult) Node(javax.jcr.Node) RemoveAll(com.cognifide.cq.cqsm.foundation.actions.removeall.RemoveAll)

Aggregations

ActionResult (com.cognifide.cq.cqsm.api.actions.ActionResult)1 RemoveAll (com.cognifide.cq.cqsm.foundation.actions.removeall.RemoveAll)1 Node (javax.jcr.Node)1 NodeIterator (javax.jcr.NodeIterator)1