use of com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType in project midpoint by Evolveum.
the class SynchronizationServiceImpl method findReactionDefinition.
private SynchronizationReactionType findReactionDefinition(ObjectSynchronizationType synchronizationPolicy, SynchronizationSituation situation, String channel, ResourceType resource) throws ConfigurationException {
SynchronizationReactionType defaultReaction = null;
for (SynchronizationReactionType reaction : synchronizationPolicy.getReaction()) {
SynchronizationSituationType reactionSituation = reaction.getSituation();
if (reactionSituation == null) {
throw new ConfigurationException("No situation defined for a reaction in " + resource);
}
if (reactionSituation.equals(situation.getSituation())) {
if (reaction.getChannel() != null && !reaction.getChannel().isEmpty()) {
if (reaction.getChannel().contains("") || reaction.getChannel().contains(null)) {
defaultReaction = reaction;
}
if (reaction.getChannel().contains(channel)) {
return reaction;
} else {
LOGGER.trace("Skipping reaction {} because the channel does not match {}", reaction, channel);
continue;
}
} else {
defaultReaction = reaction;
}
}
}
LOGGER.trace("Using default reaction {}", defaultReaction);
return defaultReaction;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType in project midpoint by Evolveum.
the class SynchronizationUtils method createSynchronizationSituationAndDescriptionDelta.
public static List<PropertyDelta<?>> createSynchronizationSituationAndDescriptionDelta(PrismObject object, SynchronizationSituationType situation, String sourceChannel, boolean full) {
XMLGregorianCalendar timestamp = XmlTypeConverter.createXMLGregorianCalendar(System.currentTimeMillis());
List<PropertyDelta<?>> delta = createSynchronizationSituationDescriptionDelta(object, situation, timestamp, sourceChannel, full);
PropertyDelta<XMLGregorianCalendar> timestampDelta = createSynchronizationTimestampDelta(object, ShadowType.F_SYNCHRONIZATION_TIMESTAMP, timestamp);
delta.add(timestampDelta);
if (full) {
timestampDelta = createSynchronizationTimestampDelta(object, ShadowType.F_FULL_SYNCHRONIZATION_TIMESTAMP, timestamp);
delta.add(timestampDelta);
}
PropertyDelta<SynchronizationSituationType> syncSituationDelta = createSynchronizationSituationDelta(object, situation);
if (syncSituationDelta != null) {
delta.add(syncSituationDelta);
}
return delta;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType in project midpoint by Evolveum.
the class SynchronizationUtils method createSynchronizationSituationDescriptionDelta.
public static List<PropertyDelta<?>> createSynchronizationSituationDescriptionDelta(PrismObject object, SynchronizationSituationType situation, XMLGregorianCalendar timestamp, String sourceChannel, boolean full) {
SynchronizationSituationDescriptionType syncSituationDescription = new SynchronizationSituationDescriptionType();
syncSituationDescription.setSituation(situation);
syncSituationDescription.setChannel(sourceChannel);
syncSituationDescription.setTimestamp(timestamp);
syncSituationDescription.setFull(full);
List<PropertyDelta<?>> deltas = new ArrayList<PropertyDelta<?>>();
PropertyDelta syncSituationDelta = PropertyDelta.createDelta(new ItemPath(ShadowType.F_SYNCHRONIZATION_SITUATION_DESCRIPTION), object.getDefinition());
syncSituationDelta.addValueToAdd(new PrismPropertyValue(syncSituationDescription));
deltas.add(syncSituationDelta);
List<PrismPropertyValue<SynchronizationSituationDescriptionType>> oldSituationDescriptions = getSituationFromSameChannel(object, sourceChannel);
if (oldSituationDescriptions != null && !oldSituationDescriptions.isEmpty()) {
syncSituationDelta = PropertyDelta.createDelta(new ItemPath(ShadowType.F_SYNCHRONIZATION_SITUATION_DESCRIPTION), object.getDefinition());
syncSituationDelta.addValuesToDelete(oldSituationDescriptions);
deltas.add(syncSituationDelta);
}
return deltas;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType in project midpoint by Evolveum.
the class AbstractObjTemplateSyncTest method assertShadowOperationalData.
protected void assertShadowOperationalData(PrismObject<ShadowType> shadow, SynchronizationSituationType expectedSituation) {
ShadowType shadowType = shadow.asObjectable();
SynchronizationSituationType actualSituation = shadowType.getSynchronizationSituation();
assertEquals("Wrong situation in shadow " + shadow, expectedSituation, actualSituation);
XMLGregorianCalendar actualTimestampCal = shadowType.getSynchronizationTimestamp();
assert actualTimestampCal != null : "No synchronization timestamp in shadow " + shadow;
long actualTimestamp = XmlTypeConverter.toMillis(actualTimestampCal);
assert actualTimestamp >= timeBeforeSync : "Synchronization timestamp was not updated in shadow " + shadow;
// TODO: assert sync description
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType in project midpoint by Evolveum.
the class SynchronizationServiceImpl method determineSituation.
/**
* XXX: in situation when one account belongs to two different idm users
* (repository returns only first user, method
* {@link com.evolveum.midpoint.model.api.ModelService#findShadowOwner(String, Task, OperationResult)}
* (String, com.evolveum.midpoint.schema.result.OperationResult)} ). It
* should be changed because otherwise we can't find
* {@link SynchronizationSituationType#DISPUTED} situation
*/
private <F extends FocusType> SynchronizationSituation determineSituation(Class<F> focusType, ResourceObjectShadowChangeDescription change, ObjectSynchronizationType synchronizationPolicy, SystemConfigurationType configurationType, Task task, OperationResult result) {
OperationResult subResult = result.createSubresult(CHECK_SITUATION);
LOGGER.trace("Determining situation for resource object shadow.");
SynchronizationSituation situation = null;
try {
String shadowOid = getOidFromChange(change);
Validate.notEmpty(shadowOid, "Couldn't get resource object shadow oid from change.");
PrismObject<F> owner = repositoryService.searchShadowOwner(shadowOid, SelectorOptions.createCollection(GetOperationOptions.createAllowNotFound()), subResult);
if (owner != null) {
F ownerType = owner.asObjectable();
LOGGER.trace("Shadow OID {} does have owner: {}", shadowOid, ownerType.getName());
SynchronizationSituationType state = null;
switch(getModificationType(change)) {
case ADD:
case MODIFY:
// if user is found it means account/group is linked to
// resource
state = SynchronizationSituationType.LINKED;
break;
case DELETE:
state = SynchronizationSituationType.DELETED;
}
situation = new SynchronizationSituation<>(ownerType, null, state);
} else {
LOGGER.trace("Resource object shadow doesn't have owner.");
situation = determineSituationWithCorrelation(focusType, change, synchronizationPolicy, owner, configurationType, task, result);
}
} catch (Exception ex) {
LOGGER.error("Error occurred during resource object shadow owner lookup.");
throw new SystemException("Error occurred during resource object shadow owner lookup, reason: " + ex.getMessage(), ex);
} finally {
subResult.computeStatus();
}
return situation;
}
Aggregations