use of com.cognifide.apm.main.actions.removeparents.RemoveParents in project APM by Cognifide.
the class DestroyUser method execute.
@Override
public ActionResult execute(Context context) throws ActionExecutionException {
ActionResult actionResult;
try {
User user = context.getAuthorizableManager().getUser(userId);
// local context is used here to not override current authorizable in given context
Context localContext = context.newContext();
localContext.setCurrentAuthorizable(user);
Action removeFromGroups = new RemoveParents(getGroups(user));
ActionResult purgeResult = purge.execute(localContext);
ActionResult removeFromGroupsResult = removeFromGroups.execute(localContext);
ActionResult removeResult = remove.execute(localContext);
actionResult = purgeResult.merge(removeFromGroupsResult, removeResult);
actionResult.setAuthorizable(context.getCurrentAuthorizable().getID() + " (ignored)");
} catch (RepositoryException | ActionExecutionException e) {
actionResult = context.createActionResult();
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
use of com.cognifide.apm.main.actions.removeparents.RemoveParents in project APM by Cognifide.
the class DestroyUser method simulate.
@Override
public ActionResult simulate(Context context) throws ActionExecutionException {
ActionResult actionResult;
try {
User user = context.getAuthorizableManager().getUser(userId);
context.setCurrentAuthorizable(user);
Action removeFromGroups = new RemoveParents(getGroups(user));
ActionResult purgeResult = purge.simulate(context);
ActionResult removeFromGroupsResult = removeFromGroups.execute(context);
ActionResult removeResult = remove.simulate(context);
actionResult = purgeResult.merge(removeFromGroupsResult, removeResult);
} catch (RepositoryException | ActionExecutionException e) {
actionResult = context.createActionResult();
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
Aggregations