Search in sources :

Example 16 with ActionResult

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;
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) ActionResult(com.cognifide.cq.cqsm.api.actions.ActionResult) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) RepositoryException(javax.jcr.RepositoryException) ActionExecutionException(com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException)

Example 17 with 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;
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) ActionResult(com.cognifide.cq.cqsm.api.actions.ActionResult) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) RepositoryException(javax.jcr.RepositoryException) ActionExecutionException(com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException)

Example 18 with 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;
}
Also used : ActionResult(com.cognifide.cq.cqsm.api.actions.ActionResult) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) RepositoryException(javax.jcr.RepositoryException)

Example 19 with 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;
}
Also used : ActionResult(com.cognifide.cq.cqsm.api.actions.ActionResult)

Example 20 with 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;
}
Also used : Action(com.cognifide.cq.cqsm.api.actions.Action) User(org.apache.jackrabbit.api.security.user.User) RemoveUser(com.cognifide.cq.cqsm.foundation.actions.removeuser.RemoveUser) CompositeActionResult(com.cognifide.cq.cqsm.foundation.actions.CompositeActionResult) ActionResult(com.cognifide.cq.cqsm.api.actions.ActionResult) RemoveFromGroup(com.cognifide.cq.cqsm.foundation.actions.removefromgroup.RemoveFromGroup) RepositoryException(javax.jcr.RepositoryException) ActionExecutionException(com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException) CompositeActionResult(com.cognifide.cq.cqsm.foundation.actions.CompositeActionResult)

Aggregations

ActionResult (com.cognifide.cq.cqsm.api.actions.ActionResult)30 RepositoryException (javax.jcr.RepositoryException)22 ActionExecutionException (com.cognifide.cq.cqsm.api.exceptions.ActionExecutionException)21 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)16 ArrayList (java.util.ArrayList)10 Group (org.apache.jackrabbit.api.security.user.Group)10 User (org.apache.jackrabbit.api.security.user.User)5 PathNotFoundException (javax.jcr.PathNotFoundException)3 Action (com.cognifide.cq.cqsm.api.actions.Action)2 SessionSavingPolicy (com.cognifide.cq.cqsm.core.sessions.SessionSavingPolicy)2 CompositeActionResult (com.cognifide.cq.cqsm.foundation.actions.CompositeActionResult)2 RemoveFromGroup (com.cognifide.cq.cqsm.foundation.actions.removefromgroup.RemoveFromGroup)2 RemoveUser (com.cognifide.cq.cqsm.foundation.actions.removeuser.RemoveUser)2 PermissionActionHelper (com.cognifide.cq.cqsm.foundation.permissions.PermissionActionHelper)2 PermissionException (com.cognifide.cq.cqsm.foundation.permissions.exceptions.PermissionException)2 ActionDescriptor (com.cognifide.cq.cqsm.api.actions.ActionDescriptor)1 ExecutionException (com.cognifide.cq.cqsm.api.exceptions.ExecutionException)1 Context (com.cognifide.cq.cqsm.api.executors.Context)1 Progress (com.cognifide.cq.cqsm.api.logger.Progress)1 ActionExecutor (com.cognifide.cq.cqsm.core.actions.executor.ActionExecutor)1