Search in sources :

Example 56 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class ProgressPanel method executeChanges.

public void executeChanges(Collection<ObjectDelta<? extends ObjectType>> deltas, boolean previewOnly, ExecuteChangeOptionsDto executeOptions, Task task, OperationResult result, AjaxRequestTarget target) {
    ModelExecuteOptions options = createOptions(executeOptions, previewOnly);
    LOGGER.debug("Using execute options {}.", options);
    if (executeOptions.isSaveInBackground() && !previewOnly) {
        executeChangesInBackground(deltas, previewOnly, options, task, result, target);
        return;
    }
    executeChanges(deltas, previewOnly, options, task, result, target);
}
Also used : ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions)

Example 57 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class PageUsers method updateActivationPerformed.

/**
 * This method updates user activation. If userOid parameter is not null,
 * than it updates only that user, otherwise it checks table for selected
 * users.
 */
private void updateActivationPerformed(AjaxRequestTarget target, boolean enabling, UserType selectedUser) {
    List<UserType> users = getTable().isAnythingSelected(target, selectedUser);
    if (users.isEmpty()) {
        return;
    }
    String operation = enabling ? OPERATION_ENABLE_USERS : OPERATION_DISABLE_USERS;
    OperationResult result = new OperationResult(operation);
    for (UserType user : users) {
        operation = enabling ? OPERATION_ENABLE_USER : OPERATION_DISABLE_USER;
        OperationResult subResult = result.createSubresult(operation);
        try {
            Task task = createSimpleTask(operation);
            ObjectDelta objectDelta = WebModelServiceUtils.createActivationAdminStatusDelta(UserType.class, user.getOid(), enabling, getPrismContext());
            ExecuteChangeOptionsDto executeOptions = getTable().getExecuteOptions();
            ModelExecuteOptions options = executeOptions.createOptions(getPrismContext());
            LOGGER.debug("Using options {}.", executeOptions);
            getModelService().executeChanges(MiscUtil.createCollection(objectDelta), options, task, subResult);
            subResult.recordSuccess();
        } catch (Exception ex) {
            subResult.recomputeStatus();
            if (enabling) {
                subResult.recordFatalError(getString("PageUsers.message.enable.fatalError"), ex);
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't enable user", ex);
            } else {
                subResult.recordFatalError(getString("PageUsers.message.disable.fatalError"), ex);
                LoggingUtils.logUnexpectedException(LOGGER, "Couldn't disable user", ex);
            }
        }
    }
    result.recomputeStatus();
    showResult(result);
    target.add(getFeedbackPanel());
    getTable().clearCache();
    getTable().refreshTable(target);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ExecuteChangeOptionsDto(com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException)

Example 58 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestPolicyDrivenRoleLifecycle method test040AssignOwnerAndApproverToCorrectRole.

/**
 * Now assigning owner and approver to `role-correct`, making it eligible for activation.
 */
@Test
public void test040AssignOwnerAndApproverToCorrectRole() throws Exception {
    given();
    Task task = getTestTask();
    task.setOwner(userAdministrator.asPrismObject());
    OperationResult result = task.getResult();
    when();
    // We don't want to activate approval policy rules for these operations.
    ModelExecuteOptions noApprovals = executeOptions().partialProcessing(new PartialProcessingOptionsType().approvals(SKIP));
    assignRole(USER_ADMINISTRATOR_OID, ROLE_CORRECT.oid, SchemaConstants.ORG_APPROVER, noApprovals, task, result);
    assignRole(USER_ADMINISTRATOR_OID, ROLE_CORRECT.oid, SchemaConstants.ORG_OWNER, noApprovals, task, result);
    // recompute the role to set correct policy situation
    recomputeFocus(RoleType.class, ROLE_CORRECT.oid, task, result);
    then();
    assertRoleAfter(ROLE_CORRECT.oid);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractUninitializedCertificationTest(com.evolveum.midpoint.certification.test.AbstractUninitializedCertificationTest)

Example 59 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class TestPolicyDrivenRoleLifecycle method test060AssignOwnerAndApproverToCorrectHighRiskRole.

@Test
public void test060AssignOwnerAndApproverToCorrectHighRiskRole() throws Exception {
    // GIVEN
    Task task = getTestTask();
    task.setOwner(userAdministrator.asPrismObject());
    OperationResult result = task.getResult();
    // WHEN+THEN
    when();
    then();
    ModelExecuteOptions noApprovals = executeOptions().partialProcessing(new PartialProcessingOptionsType().approvals(SKIP));
    assignRole(USER_ADMINISTRATOR_OID, roleCorrectHighRiskOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result);
    assignRole(userJackOid, roleCorrectHighRiskOid, SchemaConstants.ORG_APPROVER, noApprovals, task, result);
    assignRole(USER_ADMINISTRATOR_OID, roleCorrectHighRiskOid, SchemaConstants.ORG_OWNER, noApprovals, task, result);
    // recompute the role to set correct policy situation
    recomputeFocus(RoleType.class, roleCorrectHighRiskOid, task, result);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractUninitializedCertificationTest(com.evolveum.midpoint.certification.test.AbstractUninitializedCertificationTest)

Example 60 with ModelExecuteOptions

use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.

the class AddExecutor method execute.

@Override
public PipelineData execute(ActionExpressionType action, PipelineData input, ExecutionContext context, OperationResult globalResult) throws ScriptExecutionException, SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
    ModelExecuteOptions options = operationsHelper.getOptions(action, input, context, globalResult);
    boolean dryRun = operationsHelper.getDryRun(action, input, context, globalResult);
    iterateOverObjects(input, context, globalResult, (object, item, result) -> add(object, dryRun, options, context, result), (object, exception) -> context.println("Failed to add " + object + drySuffix(dryRun) + exceptionSuffix(exception)));
    return input;
}
Also used : ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions)

Aggregations

ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)80 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)47 Task (com.evolveum.midpoint.task.api.Task)45 Test (org.testng.annotations.Test)30 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)21 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)13 RestartResponseException (org.apache.wicket.RestartResponseException)6 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)5 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)4 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)4 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)4 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)4 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)3 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)3 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)3 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)3 ExecuteChangeOptionsDto (com.evolveum.midpoint.web.page.admin.users.component.ExecuteChangeOptionsDto)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)3 NotNull (org.jetbrains.annotations.NotNull)3