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