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());
}
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;
}
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;
}
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;
}
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;
}
Aggregations