use of com.cognifide.apm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class AddParents method process.
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = context.createActionResult();
List<String> errors = new ArrayList<>();
Authorizable authorizable = null;
try {
authorizable = context.getCurrentAuthorizable();
actionResult.setAuthorizable(authorizable.getID());
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
return actionResult;
}
for (String id : groupIds) {
try {
Group group = context.getAuthorizableManager().getGroup(id);
if (authorizable.isGroup()) {
ActionUtils.checkCyclicRelations(group, (Group) authorizable);
}
LOGGER.info(String.format("Adding Authorizable with id = %s to group with id = %s", authorizable.getID(), group.getID()));
if (execute) {
group.addMember(authorizable);
}
actionResult.logMessage(MessagingUtils.addedToGroup(authorizable.getID(), id));
} catch (RepositoryException | ActionExecutionException e) {
errors.add(MessagingUtils.createMessage(e));
}
}
if (!errors.isEmpty()) {
ActionUtils.logErrors(errors, actionResult);
actionResult.logError("Execution interrupted");
}
return actionResult;
}
use of com.cognifide.apm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class SetPassword method process.
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = context.createActionResult();
try {
User user = context.getCurrentUser();
actionResult.setAuthorizable(user.getID());
LOGGER.info(String.format("Setting password for user with id = %s", user.getID()));
if (execute) {
user.changePassword(password);
}
actionResult.logMessage(MessagingUtils.newPasswordSet(user.getID()));
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
use of com.cognifide.apm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class SetProperty method process.
private ActionResult process(final Context context, boolean simulate) {
ActionResult actionResult = context.createActionResult();
try {
Authorizable authorizable = context.getCurrentAuthorizable();
actionResult.setAuthorizable(authorizable.getID());
LOGGER.info(String.format("Setting property %s for authorizable with id = %s", nameProperty, authorizable.getID()));
final Value value = context.getValueFactory().createValue(valueProperty);
if (!simulate) {
authorizable.setProperty(nameProperty, value);
}
actionResult.logMessage("Property " + nameProperty + " for " + authorizable.getID() + " added vith value: " + valueProperty);
} catch (RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
use of com.cognifide.apm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class RemoveAll method process.
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = context.createActionResult();
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;
}
use of com.cognifide.apm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class DeleteGroup method process.
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = context.createActionResult();
List<String> errors = new ArrayList<>();
LOGGER.info(String.format("Removing groups with ids = %s", StringUtils.join(ids, ", ")));
for (String id : ids) {
try {
Group group = context.getAuthorizableManager().getGroupIfExists(id);
if (group != null) {
context.getAuthorizableManager().markAuthorizableAsRemoved(group);
if (execute) {
context.getAuthorizableManager().removeGroup(group);
}
actionResult.logMessage("Group with id: " + id + " removed");
}
} 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;
}
Aggregations