use of com.cognifide.apm.api.actions.ActionResult in project APM by Cognifide.
the class CompositeAction method simulate.
@Override
public ActionResult simulate(Context context) throws ActionExecutionException {
ActionResult result = context.createActionResult();
List<ActionResult> actionResults = Lists.newArrayListWithCapacity(actions.size());
for (Action action : actions) {
actionResults.add(action.simulate(context));
}
return result.merge(actionResults);
}
use of com.cognifide.apm.api.actions.ActionResult in project APM by Cognifide.
the class AddChildren method process.
private ActionResult process(Context context, boolean execute) {
ActionResult actionResult = context.createActionResult();
Group group = null;
try {
group = context.getCurrentGroup();
actionResult.setAuthorizable(group.getID());
LOGGER.info(String.format("Adding authorizables %s to 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 = context.getAuthorizableManager().getAuthorizable(authorizableId);
if (authorizable.isGroup()) {
ActionUtils.checkCyclicRelations(group, (Group) authorizable);
}
if (execute) {
group.addMember(authorizable);
}
actionResult.logMessage(MessagingUtils.addedToGroup(authorizableId, group.getID()));
} catch (RepositoryException | ActionExecutionException 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.apm.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())) {
copyErrorMessages(removeAllResult, actionResult);
}
}
}
}
}
use of com.cognifide.apm.api.actions.ActionResult in project APM by Cognifide.
the class CheckExcludes method process.
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = context.createActionResult();
Group group = tryGetGroup(context, actionResult);
if (group == null) {
return actionResult;
}
List<String> errors = new ArrayList<>();
boolean checkFailed = checkMembers(context, actionResult, group, errors);
if (execute && checkFailed) {
actionResult.logError(ActionUtils.ASSERTION_FAILED_MSG);
return actionResult;
}
ActionUtils.logErrors(errors, actionResult);
return actionResult;
}
use of com.cognifide.apm.api.actions.ActionResult in project APM by Cognifide.
the class CheckIncludes method process.
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = context.createActionResult();
Group authorizable = tryGetGroup(context, actionResult);
if (authorizable == null) {
return actionResult;
}
List<String> errors = new ArrayList<>();
boolean checkFailed = checkMembers(context, actionResult, authorizable, errors);
if (execute && checkFailed) {
actionResult.logError(ActionUtils.ASSERTION_FAILED_MSG);
return actionResult;
}
ActionUtils.logErrors(errors, actionResult);
return actionResult;
}
Aggregations