use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class TreeTablePanel method recomputePerformed.
private void recomputePerformed(SelectableBean<OrgType> orgToRecompute, AjaxRequestTarget target) {
Task task = getPageBase().createSimpleTask(OPERATION_RECOMPUTE);
OperationResult result = new OperationResult(OPERATION_RECOMPUTE);
if (orgToRecompute.getValue() == null) {
return;
}
try {
ObjectDelta emptyDelta = ObjectDelta.createEmptyModifyDelta(OrgType.class, orgToRecompute.getValue().getOid(), getPageBase().getPrismContext());
ModelExecuteOptions options = new ModelExecuteOptions();
options.setReconcile(true);
getPageBase().getModelService().executeChanges(WebComponentUtil.createDeltaCollection(emptyDelta), options, task, result);
result.recordSuccess();
} catch (Exception e) {
result.recordFatalError(getString("TreeTablePanel.message.recomputeError"), e);
LoggingUtils.logUnexpectedException(LOGGER, getString("TreeTablePanel.message.recomputeError"), e);
}
getPageBase().showResult(result);
target.add(getPageBase().getFeedbackPanel());
getTreePanel().refreshTabbedPanel(target);
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class SynchronizationServiceImpl method reactToChange.
private <F extends FocusType> SynchronizationSituationType reactToChange(Class<F> focusClass, ResourceObjectShadowChangeDescription change, ObjectSynchronizationType synchronizationPolicy, SynchronizationSituation<F> situation, ResourceType resource, boolean logDebug, PrismObject<SystemConfigurationType> configuration, Task task, OperationResult parentResult) throws ConfigurationException, ObjectNotFoundException, SchemaException, PolicyViolationException, ExpressionEvaluationException, ObjectAlreadyExistsException, CommunicationException, SecurityViolationException {
SynchronizationSituationType newSituation = situation.getSituation();
SynchronizationReactionType reactionDefinition = findReactionDefinition(synchronizationPolicy, situation, change.getSourceChannel(), resource);
if (reactionDefinition == null) {
LOGGER.trace("No reaction is defined for situation {} in {}", situation.getSituation(), resource);
return newSituation;
}
// seems to be unused so commented it out [med]
// PrismObject<? extends ObjectType> shadow = null;
// if (change.getCurrentShadow() != null) {
// shadow = change.getCurrentShadow();
// } else if (change.getOldShadow() != null) {
// shadow = change.getOldShadow();
// }
Boolean doReconciliation = determineReconciliation(synchronizationPolicy, reactionDefinition);
if (doReconciliation == null) {
// shadow.
if (change.getObjectDelta() == null) {
doReconciliation = true;
}
}
Boolean limitPropagation = determinePropagationLimitation(synchronizationPolicy, reactionDefinition, change.getSourceChannel());
ModelExecuteOptions options = new ModelExecuteOptions();
options.setReconcile(doReconciliation);
options.setLimitPropagation(limitPropagation);
final boolean willSynchronize = isSynchronize(reactionDefinition);
LensContext<F> lensContext = null;
if (willSynchronize) {
lensContext = createLensContext(focusClass, change, reactionDefinition, synchronizationPolicy, situation, options, configuration, parentResult);
}
if (LOGGER.isTraceEnabled() && lensContext != null) {
LOGGER.trace("---[ SYNCHRONIZATION context before action execution ]-------------------------\n" + "{}\n------------------------------------------", lensContext.debugDump());
}
if (willSynchronize) {
// there's no point in calling executeAction without context - so
// the actions are executed only if synchronize == true
executeActions(reactionDefinition, lensContext, situation, BeforeAfterType.BEFORE, resource, logDebug, task, parentResult);
Iterator<LensProjectionContext> iterator = lensContext.getProjectionContextsIterator();
LensProjectionContext originalProjectionContext = iterator.hasNext() ? iterator.next() : null;
try {
clockwork.run(lensContext, task, parentResult);
} catch (ConfigurationException | ObjectNotFoundException | SchemaException | PolicyViolationException | ExpressionEvaluationException | ObjectAlreadyExistsException | CommunicationException | SecurityViolationException e) {
LOGGER.error("SYNCHRONIZATION: Error in synchronization on {} for situation {}: {}: {}. Change was {}", new Object[] { resource, situation.getSituation(), e.getClass().getSimpleName(), e.getMessage(), change, e });
// what to do here? We cannot throw the error back. All that the notifyChange method
// could do is to convert it to SystemException. But that indicates an internal error and it will
// break whatever code called the notifyChange in the first place. We do not want that.
// If the clockwork could not do anything with the exception then perhaps nothing can be done at all.
// So just log the error (the error should be remembered in the result and task already)
// and then just go on.
}
// note: actions "AFTER" seem to be useless here (basically they
// modify lens context - which is relevant only if followed by
// clockwork run)
executeActions(reactionDefinition, lensContext, situation, BeforeAfterType.AFTER, resource, logDebug, task, parentResult);
if (originalProjectionContext != null) {
newSituation = originalProjectionContext.getSynchronizationSituationResolved();
}
} else {
LOGGER.trace("Skipping clockwork run on {} for situation {}, synchronize is set to false.", new Object[] { resource, situation.getSituation() });
}
return newSituation;
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class RecomputeTaskHandler method getOptions.
private ModelExecuteOptions getOptions(Task coordinatorTask) throws SchemaException {
ModelExecuteOptions modelExecuteOptions = Utils.getModelExecuteOptions(coordinatorTask);
if (modelExecuteOptions == null) {
// Make reconcile the default (for compatibility). If there are no options
// then assume reconcile.
modelExecuteOptions = ModelExecuteOptions.createReconcile();
}
LOGGER.trace("ModelExecuteOptions: {}", modelExecuteOptions);
return modelExecuteOptions;
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class Utils method getModelExecuteOptions.
public static ModelExecuteOptions getModelExecuteOptions(Task task) throws SchemaException {
Validate.notNull(task, "Task must not be null.");
if (task.getExtension() == null) {
return null;
}
//LOGGER.info("Task:\n{}",task.debugDump(1));
PrismProperty<ModelExecuteOptionsType> item = task.getExtensionProperty(SchemaConstants.C_MODEL_EXECUTE_OPTIONS);
if (item == null || item.isEmpty()) {
return null;
}
//LOGGER.info("Item:\n{}",item.debugDump(1));
if (item.getValues().size() > 1) {
throw new SchemaException("Unexpected number of values for option 'modelExecuteOptions'.");
}
ModelExecuteOptionsType modelExecuteOptionsType = item.getValues().iterator().next().getValue();
if (modelExecuteOptionsType == null) {
return null;
}
//LOGGER.info("modelExecuteOptionsType: {}",modelExecuteOptionsType);
ModelExecuteOptions modelExecuteOptions = ModelExecuteOptions.fromModelExecutionOptionsType(modelExecuteOptionsType);
//LOGGER.info("modelExecuteOptions: {}",modelExecuteOptions);
return modelExecuteOptions;
}
use of com.evolveum.midpoint.model.api.ModelExecuteOptions in project midpoint by Evolveum.
the class AbstractModelIntegrationTest method modifyRoleAddInducementTarget.
protected void modifyRoleAddInducementTarget(String roleOid, String targetOid, boolean reconcileAffected, Task task) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException {
if (task == null) {
task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddInducementTarget");
}
OperationResult result = task.getResult();
AssignmentType inducement = new AssignmentType();
ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(targetOid);
inducement.setTargetRef(targetRef);
ObjectDelta<RoleType> roleDelta = ObjectDelta.createModificationAddContainer(RoleType.class, roleOid, new ItemPath(new NameItemPathSegment(RoleType.F_INDUCEMENT)), prismContext, inducement);
ModelExecuteOptions options = new ModelExecuteOptions();
options.setReconcileAffected(reconcileAffected);
modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), options, task, result);
result.computeStatus();
if (reconcileAffected) {
TestUtil.assertInProgressOrSuccess(result);
} else {
TestUtil.assertSuccess(result);
}
}
Aggregations