Search in sources :

Example 11 with ModelExecuteOptions

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

the class PageAssignmentsList method getAssignmentConflicts.

private List<ConflictDto> getAssignmentConflicts() {
    ObjectDelta<UserType> delta;
    OperationResult result = new OperationResult(OPERATION_PREVIEW_ASSIGNMENT_CONFLICTS);
    Task task = createSimpleTask(OPERATION_PREVIEW_ASSIGNMENT_CONFLICTS);
    Map<String, ConflictDto> conflictsMap = new HashMap<>();
    try {
        PrismObject<UserType> user = getTargetUser();
        delta = user.createModifyDelta();
        PrismContainerDefinition def = user.getDefinition().findContainerDefinition(UserType.F_ASSIGNMENT);
        handleAssignmentDeltas(delta, getSessionStorage().getRoleCatalog().getAssignmentShoppingCart(), def);
        PartialProcessingOptionsType partialProcessing = new PartialProcessingOptionsType();
        partialProcessing.setInbound(SKIP);
        partialProcessing.setProjection(SKIP);
        ModelExecuteOptions recomputeOptions = executeOptions().partialProcessing(partialProcessing);
        ModelContext<UserType> modelContext = getModelInteractionService().previewChanges(MiscUtil.createCollection(delta), recomputeOptions, task, result);
        DeltaSetTriple<? extends EvaluatedAssignment> evaluatedAssignmentTriple = modelContext.getEvaluatedAssignmentTriple();
        if (evaluatedAssignmentTriple != null) {
            Collection<? extends EvaluatedAssignment> addedAssignments = evaluatedAssignmentTriple.getPlusSet();
            for (EvaluatedAssignment<UserType> evaluatedAssignment : addedAssignments) {
                for (EvaluatedPolicyRule policyRule : evaluatedAssignment.getAllTargetsPolicyRules()) {
                    if (!policyRule.containsEnabledAction()) {
                        continue;
                    }
                    // everything other than 'enforce' is a warning
                    boolean isWarning = !policyRule.containsEnabledAction(EnforcementPolicyActionType.class);
                    fillInConflictedObjects(evaluatedAssignment, policyRule.getAllTriggers(), isWarning, conflictsMap);
                }
            }
        } else if (!result.isSuccess() && StringUtils.isNotEmpty(getSubresultWarningMessages(result))) {
            getFeedbackMessages().warn(PageAssignmentsList.this, createStringResource("PageAssignmentsList.conflictsWarning").getString() + " " + getSubresultWarningMessages(result));
            conflictProblemExists = true;
        }
    } catch (Exception e) {
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't get assignments conflicts. Reason: ", e);
        error("Couldn't get assignments conflicts. Reason: " + e);
    }
    return new ArrayList<>(conflictsMap.values());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) AssignmentConflictDto(com.evolveum.midpoint.web.page.self.dto.AssignmentConflictDto) ConflictDto(com.evolveum.midpoint.web.page.self.dto.ConflictDto) ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) SchemaException(com.evolveum.midpoint.util.exception.SchemaException)

Example 12 with ModelExecuteOptions

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

the class DeltaExecution method createRepoAddOptions.

@NotNull
private RepoAddOptions createRepoAddOptions() {
    ModelExecuteOptions options = context.getOptions();
    RepoAddOptions addOpt = new RepoAddOptions();
    if (ModelExecuteOptions.isOverwrite(options)) {
        addOpt.setOverwrite(true);
    }
    if (ModelExecuteOptions.isNoCrypt(options)) {
        addOpt.setAllowUnencryptedValues(true);
    }
    return addOpt;
}
Also used : ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) RepoAddOptions(com.evolveum.midpoint.repo.api.RepoAddOptions) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with ModelExecuteOptions

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

the class DeltaExecution method getProvisioningOptions.

// endregion
// region Provisioning options
private ProvisioningOperationOptions getProvisioningOptions() throws SecurityViolationException {
    ModelExecuteOptions modelOptions = context.getOptions();
    ProvisioningOperationOptions provisioningOptions = copyFromModelOptions(modelOptions);
    E existingObject = asObjectable(elementContext.getObjectCurrent());
    if (existingObject instanceof ShadowType) {
        ShadowType existingShadow = (ShadowType) existingObject;
        if (isExecuteAsSelf(existingShadow)) {
            LOGGER.trace("Setting 'execute as self' provisioning option for {}", existingShadow);
            provisioningOptions.setRunAsAccountOid(existingShadow.getOid());
        }
    }
    if (context.getChannel() != null) {
        if (context.getChannel().equals(QNameUtil.qNameToUri(SchemaConstants.CHANNEL_RECON))) {
            // TODO: this is probably wrong. We should not have special case
            // for recon channel! This should be handled by the provisioning task
            // setting the right options there.
            provisioningOptions.setCompletePostponed(false);
        }
        if (context.getChannel().equals(SchemaConstants.CHANNEL_DISCOVERY_URI)) {
            // We want to avoid endless loops in error handling.
            provisioningOptions.setDoNotDiscovery(true);
        }
    }
    return provisioningOptions;
}
Also used : ModelExecuteOptions(com.evolveum.midpoint.model.api.ModelExecuteOptions) ProvisioningOperationOptions(com.evolveum.midpoint.provisioning.api.ProvisioningOperationOptions)

Example 14 with ModelExecuteOptions

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

the class DeleteExecutor method execute.

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

Example 15 with ModelExecuteOptions

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

the class EnableDisableExecutor 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);
    boolean isEnable = NAME_ENABLE.equals(getActionType(action));
    iterateOverObjects(input, context, globalResult, (object, item, result) -> enableOrDisable(object.asObjectable(), dryRun, options, isEnable, context, result), (object, exception) -> context.println("Failed to " + (isEnable ? "enable" : "disable") + 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