use of com.evolveum.midpoint.model.impl.sync.SynchronizationContext in project midpoint by Evolveum.
the class MidpointFunctionsImpl method getFocusesByCorrelationRule.
@Override
public <F extends FocusType> List<F> getFocusesByCorrelationRule(Class<F> type, String resourceOid, ShadowKindType kind, String intent, ShadowType shadow) {
ResourceType resource;
try {
resource = getObject(ResourceType.class, resourceOid, GetOperationOptions.createNoFetchCollection());
} catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException e) {
LOGGER.error("Cannot get resource, reason: {}", e.getMessage(), e);
return null;
}
SynchronizationType synchronization = resource.getSynchronization();
if (synchronization == null) {
return null;
}
ObjectSynchronizationDiscriminatorType discriminator = new ObjectSynchronizationDiscriminatorType();
discriminator.setKind(kind);
discriminator.setIntent(intent);
SynchronizationContext<F> syncCtx = new SynchronizationContext<>(shadow.asPrismObject(), null, resource.asPrismObject(), getCurrentTask().getChannel(), beans, getCurrentTask(), null);
ObjectSynchronizationType applicablePolicy = null;
OperationResult result = getCurrentResult();
try {
SystemConfigurationType systemConfiguration = modelInteractionService.getSystemConfiguration(result);
syncCtx.setSystemConfiguration(systemConfiguration.asPrismObject());
for (ObjectSynchronizationType objectSync : synchronization.getObjectSynchronization()) {
if (SynchronizationServiceUtils.isPolicyApplicable(objectSync, discriminator, expressionFactory, syncCtx, result)) {
applicablePolicy = objectSync;
break;
}
}
if (applicablePolicy == null) {
return null;
}
List<PrismObject<F>> correlatedFocuses = correlationConfirmationEvaluator.findFocusesByCorrelationRule(type, shadow, applicablePolicy.getCorrelation(), resource, systemConfiguration, syncCtx.getTask(), result);
return MiscSchemaUtil.toObjectableList(correlatedFocuses);
} catch (SchemaException | ExpressionEvaluationException | ObjectNotFoundException | CommunicationException | ConfigurationException | SecurityViolationException e) {
LOGGER.error("Cannot find applicable policy for kind={}, intent={}. Reason: {}", kind, intent, e.getMessage(), e);
return null;
}
}
Aggregations