use of com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class DestroyUser method simulate.
@Override
public ActionResult simulate(Context context) throws ActionExecutionException {
ActionResult actionResult;
try {
User user = AuthorizablesUtils.getUser(context, userId);
context.setCurrentAuthorizable(user);
Action removeFromGroups = new RemoveFromGroup(getGroups(user));
ActionResult purgeResult = purge.simulate(context);
ActionResult removeFromGroupsResult = removeFromGroups.execute(context);
ActionResult removeResult = remove.simulate(context);
actionResult = new CompositeActionResult(purgeResult, removeFromGroupsResult, removeResult);
} catch (RepositoryException | ActionExecutionException e) {
actionResult = new ActionResult();
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
use of com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException 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.exceptions.ActionExecutionException 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.exceptions.ActionExecutionException 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.exceptions.ActionExecutionException 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