use of com.cognifide.cq.cqsm.api.actions.ActionResult in project APM by Cognifide.
the class ClearFromGroupDetacher method detachMembersFromGroup.
public ActionResult detachMembersFromGroup() {
ActionResult actionResult = new ActionResult();
try {
Authorizable authorizable = context.getCurrentAuthorizable();
if (authorizable.isGroup()) {
final Group group = context.getCurrentGroup();
LOGGER.info(String.format("Removing all members of group with id = %s", group.getID()));
Iterator<Authorizable> groupMembers = getGroupMembers(actionResult, group);
detachAllMembers(actionResult, group, groupMembers);
} else {
actionResult.logError("Child members can only be removed from groups");
}
} 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 ClearFromGroupDetacher method detachAuthorizableFromParents.
public ActionResult detachAuthorizableFromParents() {
ActionResult actionResult = new ActionResult();
try {
Authorizable currentAuthorizable = context.getCurrentAuthorizable();
Iterator<Group> groups = getGroupParents(actionResult, currentAuthorizable);
LOGGER.info(String.format("Removing all memberships of authorizable with id = %s", currentAuthorizable.getID()));
detachFromParents(actionResult, currentAuthorizable, groups);
} 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 CreateAuthorizable method process.
public ActionResult process(final Context context, boolean simulate) {
ActionResult actionResult = new ActionResult();
try {
Authorizable authorizable = AuthorizablesUtils.getAuthorizableIfExists(context, id);
LOGGER.info("Creating authorizable with id = " + id);
if (authorizable != null) {
logMessage(actionResult, authorizable);
} else {
createStrategy.create(id, password, path, context, actionResult, simulate);
}
} catch (RepositoryException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
use of com.cognifide.cq.cqsm.api.actions.ActionResult in project APM by Cognifide.
the class Define method execute.
@Override
public ActionResult execute(Context context) {
ActionResult actionResult = new ActionResult();
actionResult.logMessage("Definition saved");
return actionResult;
}
use of com.cognifide.cq.cqsm.api.actions.ActionResult 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;
}
Aggregations