use of com.cognifide.apm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class RemoveProperty 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("Removing property %s from authorizable with id = %s", nameProperty, authorizable.getID()));
if (!simulate) {
authorizable.removeProperty(nameProperty);
}
actionResult.logMessage("Property " + nameProperty + " for " + authorizable.getID() + " removed");
} 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 ForAuthorizable method process.
public ActionResult process(final Context context) {
ActionResult actionResult = context.createActionResult();
try {
if (shouldBeGroup) {
Group group = context.getAuthorizableManager().getGroup(id);
context.setCurrentAuthorizable(group);
actionResult.logMessage("Group with id: " + group.getID() + " set as current authorizable");
} else {
User user = context.getAuthorizableManager().getUser(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.apm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class CheckAuthorizableExists method process.
public ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = context.createActionResult();
try {
Authorizable authorizable = null;
if (shouldBeGroup) {
authorizable = context.getAuthorizableManager().getGroupIfExists(id);
} else {
authorizable = context.getAuthorizableManager().getUserIfExists(id);
}
if (checkIfAuthIsNull(execute, actionResult, authorizable)) {
return actionResult;
}
checkPath(actionResult, authorizable, execute);
} 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 AuthorizableManagerImpl method getAuthorizable.
private <T extends Authorizable> T getAuthorizable(Class<T> authorizableClass, String id) throws ActionExecutionException, RepositoryException {
if (checkIfRemoved(id)) {
throw new ActionExecutionException(format("%s with id %s not found", authorizableClass.getSimpleName(), id));
}
Authorizable authorizable = existingAuthorizables.get(id);
if (authorizable == null) {
authorizable = userManager.getAuthorizable(id);
}
if (authorizable == null) {
throw new ActionExecutionException(format("%s with id %s not found", authorizableClass.getSimpleName(), id));
}
if (!authorizableClass.isInstance(authorizable)) {
throw new ActionExecutionException(format("Authorizable with id %s exists but is a ", authorizableClass.getSimpleName()));
}
existingAuthorizables.put(id, authorizable);
return authorizableClass.cast(authorizable);
}
use of com.cognifide.apm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class CheckIncludes method checkMembers.
private boolean checkMembers(final Context context, final ActionResult actionResult, final Group authorizable, final List<String> errors) {
boolean checkFailed = false;
for (String id : groupIds) {
try {
Authorizable group = context.getAuthorizableManager().getAuthorizable(id);
if (!authorizable.isMember(group)) {
actionResult.logError(id + " is excluded from group " + authorizableId);
checkFailed = true;
}
actionResult.logMessage(id + " is a member of group " + authorizableId);
} catch (RepositoryException | ActionExecutionException e) {
errors.add(MessagingUtils.createMessage(e));
}
}
return checkFailed;
}
Aggregations