use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.
the class SynchronizationServiceImpl method determineSituationWithCorrelation.
/**
* account is not linked to user. you have to use correlation and
* confirmation rule to be sure user for this account doesn't exists
* resourceShadow only contains the data that were in the repository before
* the change. But the correlation/confirmation should work on the updated
* data. Therefore let's apply the changes before running
* correlation/confirmation
*/
private <F extends FocusType> SynchronizationSituation determineSituationWithCorrelation(Class<F> focusType, ResourceObjectShadowChangeDescription change, ObjectSynchronizationType synchronizationPolicy, PrismObject<F> owner, SystemConfigurationType configurationType, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
if (ChangeType.DELETE.equals(getModificationType(change))) {
// account was deleted and we know it didn't have owner
return new SynchronizationSituation<>(owner == null ? null : owner.asObjectable(), null, SynchronizationSituationType.DELETED);
}
PrismObject<? extends ShadowType> resourceShadow = change.getCurrentShadow();
ObjectDelta syncDelta = change.getObjectDelta();
if (resourceShadow == null && syncDelta != null && ChangeType.ADD.equals(syncDelta.getChangeType())) {
LOGGER.trace("Trying to compute current shadow from change delta add.");
PrismObject<ShadowType> shadow = syncDelta.computeChangedObject(syncDelta.getObjectToAdd());
resourceShadow = shadow;
change.setCurrentShadow(shadow);
}
Validate.notNull(resourceShadow, "Current shadow must not be null.");
ResourceType resource = change.getResource().asObjectable();
validateResourceInShadow(resourceShadow.asObjectable(), resource);
SynchronizationSituationType state = null;
LOGGER.trace("SYNCHRONIZATION: CORRELATION: Looking for list of {} objects based on correlation rule.", focusType.getSimpleName());
List<PrismObject<F>> users = correlationConfirmationEvaluator.findFocusesByCorrelationRule(focusType, resourceShadow.asObjectable(), synchronizationPolicy.getCorrelation(), resource, configurationType, task, result);
if (users == null) {
users = new ArrayList<>();
}
if (users.size() > 1) {
if (synchronizationPolicy.getConfirmation() == null) {
LOGGER.trace("SYNCHRONIZATION: CONFIRMATION: no confirmation defined.");
} else {
LOGGER.debug("SYNCHRONIZATION: CONFIRMATION: Checking objects from correlation with confirmation rule.");
users = correlationConfirmationEvaluator.findUserByConfirmationRule(focusType, users, resourceShadow.asObjectable(), resource, configurationType, synchronizationPolicy.getConfirmation(), task, result);
}
}
F user = null;
switch(users.size()) {
case 0:
state = SynchronizationSituationType.UNMATCHED;
break;
case 1:
switch(getModificationType(change)) {
case ADD:
case MODIFY:
state = SynchronizationSituationType.UNLINKED;
break;
case DELETE:
state = SynchronizationSituationType.DELETED;
break;
}
user = users.get(0).asObjectable();
break;
default:
state = SynchronizationSituationType.DISPUTED;
}
return new SynchronizationSituation(null, user, state);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.
the class SynchronizationServiceImpl method matchUserCorrelationRule.
/**
* Tries to match specified focus and shadow. Return true if it matches,
* false otherwise.
*/
@Override
public <F extends FocusType> boolean matchUserCorrelationRule(PrismObject<ShadowType> shadow, PrismObject<F> focus, ResourceType resourceType, PrismObject<SystemConfigurationType> configuration, Task task, OperationResult result) throws ConfigurationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
ObjectSynchronizationType synchronizationPolicy = determineSynchronizationPolicy(resourceType, shadow, configuration, task, result);
Class<F> focusClass;
// be null...
if (synchronizationPolicy != null) {
focusClass = determineFocusClass(synchronizationPolicy, resourceType);
} else {
focusClass = (Class) focus.asObjectable().getClass();
}
return correlationConfirmationEvaluator.matchUserCorrelationRule(focusClass, shadow, focus, synchronizationPolicy, resourceType, configuration == null ? null : configuration.asObjectable(), task, result);
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.
the class CorrelationConfirmationEvaluator method satisfyCondition.
private boolean satisfyCondition(ShadowType currentShadow, ConditionalSearchFilterType conditionalFilter, ResourceType resourceType, SystemConfigurationType configurationType, String shortDesc, Task task, OperationResult parentResult) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
if (conditionalFilter.getCondition() == null) {
return true;
}
ExpressionType condition = conditionalFilter.getCondition();
ExpressionVariables variables = Utils.getDefaultExpressionVariables(null, currentShadow, resourceType, configurationType);
ItemDefinition outputDefinition = new PrismPropertyDefinitionImpl(ExpressionConstants.OUTPUT_ELEMENT_NAME, DOMUtil.XSD_BOOLEAN, prismContext);
PrismPropertyValue<Boolean> satisfy = (PrismPropertyValue) ExpressionUtil.evaluateExpression(variables, outputDefinition, condition, expressionFactory, shortDesc, task, parentResult);
if (satisfy.getValue() == null) {
return false;
}
return satisfy.getValue();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.
the class ModelTUtil method mockGetSystemConfiguration.
@SuppressWarnings("unchecked")
public static void mockGetSystemConfiguration(RepositoryService repository, File file) throws JAXBException, ObjectNotFoundException, SchemaException, IOException {
SystemConfigurationType systemConfiguration = (SystemConfigurationType) PrismTestUtil.parseObject(file).asObjectable();
when(repository.getObject(eq(SystemConfigurationType.class), eq(SystemObjectsType.SYSTEM_CONFIGURATION.value()), any(Collection.class), any(OperationResult.class))).thenReturn(systemConfiguration.asPrismObject());
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType in project midpoint by Evolveum.
the class CustomTransport method send.
@Override
public void send(Message message, String transportName, Event event, Task task, OperationResult parentResult) {
OperationResult result = parentResult.createSubresult(DOT_CLASS + "send");
result.addCollectionOfSerializablesAsParam("message recipient(s)", message.getTo());
result.addParam("message subject", message.getSubject());
SystemConfigurationType systemConfiguration = NotificationFunctionsImpl.getSystemConfiguration(cacheRepositoryService, result);
if (systemConfiguration == null || systemConfiguration.getNotificationConfiguration() == null) {
String msg = "No notifications are configured. Custom notification to " + message.getTo() + " will not be sent.";
LOGGER.warn(msg);
result.recordWarning(msg);
return;
}
// after "sms:"
String configName = transportName.length() > NAME.length() ? transportName.substring(NAME.length() + 1) : null;
CustomTransportConfigurationType configuration = systemConfiguration.getNotificationConfiguration().getCustomTransport().stream().filter(transportConfigurationType -> java.util.Objects.equals(configName, transportConfigurationType.getName())).findFirst().orElse(null);
if (configuration == null) {
String msg = "Custom configuration '" + configName + "' not found. Custom notification to " + message.getTo() + " will not be sent.";
LOGGER.warn(msg);
result.recordWarning(msg);
return;
}
String file = configuration.getRedirectToFile();
if (file != null) {
writeToFile(message, file, result);
return;
}
try {
evaluateExpression(configuration.getExpression(), getDefaultVariables(message, event), "custom transport expression", task, result);
LOGGER.trace("Custom transport expression execution finished");
result.recordSuccess();
} catch (Throwable t) {
String msg = "Couldn't execute custom transport expression";
LoggingUtils.logException(LOGGER, msg, t);
result.recordFatalError(msg + ": " + t.getMessage(), t);
}
}
Aggregations