use of com.cognifide.cq.cqsm.api.actions.ActionResult in project APM by Cognifide.
the class Exclude method process.
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = new ActionResult();
Group group = null;
try {
group = context.getCurrentGroup();
actionResult.setAuthorizable(group.getID());
LOGGER.info(String.format("Removing authorizables %s from group with id = %s", StringUtils.join(authorizableIds, ", "), group.getID()));
} catch (ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
return actionResult;
} catch (RepositoryException e) {
actionResult.logError(MessagingUtils.createMessage(e));
return actionResult;
}
List<String> errors = new ArrayList<>();
for (String authorizableId : authorizableIds) {
try {
Authorizable authorizable = AuthorizablesUtils.getAuthorizableIfExists(context, authorizableId);
if (authorizable == null) {
actionResult.logWarning(MessagingUtils.authorizableNotExists(authorizableId));
continue;
}
if (execute) {
group.removeMember(authorizable);
}
actionResult.logMessage(MessagingUtils.removedFromGroup(authorizableId, group.getID()));
} catch (RepositoryException e) {
errors.add(MessagingUtils.createMessage(e));
}
}
if (!errors.isEmpty()) {
for (String error : errors) {
actionResult.logError(error);
}
actionResult.logError("Execution interrupted");
}
return actionResult;
}
use of com.cognifide.cq.cqsm.api.actions.ActionResult in project APM by Cognifide.
the class ForAuthorizable method process.
public ActionResult process(final Context context) {
ActionResult actionResult = new ActionResult();
try {
if (shouldBeGroup) {
Group group = AuthorizablesUtils.getGroup(context, id);
context.setCurrentAuthorizable(group);
actionResult.logMessage("Group with id: " + group.getID() + " set as current authorizable");
} else {
User user = AuthorizablesUtils.getUser(context, id);
context.setCurrentAuthorizable(user);
actionResult.logMessage("User with id: " + user.getID() + " set as current authorizable");
}
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
use of com.cognifide.cq.cqsm.api.actions.ActionResult 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);
}
}
}
}
}
use of com.cognifide.cq.cqsm.api.actions.ActionResult in project APM by Cognifide.
the class Purge method process.
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = new ActionResult();
try {
Authorizable authorizable = context.getCurrentAuthorizable();
actionResult.setAuthorizable(authorizable.getID());
LOGGER.info(String.format("Purging privileges for authorizable with id = %s under path = %s", authorizable.getID(), path));
if (execute) {
purge(context, actionResult);
}
actionResult.logMessage("Purged privileges for " + authorizable.getID() + " on " + path);
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
use of com.cognifide.cq.cqsm.api.actions.ActionResult in project APM by Cognifide.
the class RemoveAll method process.
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = new ActionResult();
try {
Authorizable authorizable = context.getCurrentAuthorizable();
actionResult.setAuthorizable(authorizable.getID());
LOGGER.info(String.format("Removing all priveleges for authorizable with id = %s on path = %s", authorizable.getID(), path));
if (execute) {
removeAll(context, authorizable);
}
actionResult.logMessage("Removed all privileges for " + authorizable.getID() + " on " + path);
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
Aggregations