use of com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class CheckAuthorizableExists method process.
public ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = new ActionResult();
try {
Authorizable authorizable = null;
if (shouldBeGroup) {
authorizable = AuthorizablesUtils.getGroupIfExists(context, id);
} else {
authorizable = AuthorizablesUtils.getUserIfExists(context, 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.cq.cqsm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class CheckPermissions method process.
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = new ActionResult();
try {
final Authorizable authorizable = AuthorizablesUtils.getAuthorizable(context, authorizableId);
final Set<Principal> authorizablesToCheck = getAuthorizablesToCheck(authorizable, context);
final CqActions actions = new CqActions(context.getSession());
final List<String> privilegesToCheck = preparePrivilegesToCheck();
if (StringUtils.isBlank(glob)) {
if (checkPermissionsForPath(authorizablesToCheck, actions, privilegesToCheck, path)) {
logFailure(execute, actionResult, authorizable, path);
} else {
actionResult.logMessage("All required privileges are set for " + authorizable.getID() + " on " + path);
}
} else {
checkPermissionsForGlob(context.getSession(), execute, actionResult, authorizable, authorizablesToCheck, actions, privilegesToCheck);
}
} catch (final PathNotFoundException e) {
actionResult.logError("Path " + path + " not found");
} catch (RepositoryException | ActionExecutionException | LoginException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
use of com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException in project APM by Cognifide.
the class CheckProperty method process.
private ActionResult process(final Context context, boolean execute) {
ActionResult actionResult = new ActionResult();
try {
Authorizable authorizable = AuthorizablesUtils.getAuthorizable(context, authorizableId);
if (!checkIfAuthHasProperty(execute, actionResult, authorizable)) {
return actionResult;
}
if (checkPropertyExists(authorizable)) {
return actionResult;
}
actionResult.logError("Authorizable " + authorizableId + ": unexpected value of property: " + propertyName);
if (execute) {
actionResult.logError(ActionUtils.ASSERTION_FAILED_MSG);
}
} catch (final RepositoryException | ActionExecutionException e) {
actionResult.logError(MessagingUtils.createMessage(e));
}
return actionResult;
}
use of com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException 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.exceptions.ActionExecutionException 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;
}
Aggregations