Search in sources :

Example 1 with SynchronizationSituationType

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;
}
Also used : SynchronizationSituationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType) SynchronizationReactionType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationReactionType) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException)

Example 2 with SynchronizationSituationType

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;
}
Also used : SynchronizationSituationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta)

Example 3 with SynchronizationSituationType

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;
}
Also used : ArrayList(java.util.ArrayList) SynchronizationSituationDescriptionType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationDescriptionType) PropertyDelta(com.evolveum.midpoint.prism.delta.PropertyDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 4 with SynchronizationSituationType

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
}
Also used : SynchronizationSituationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)

Example 5 with SynchronizationSituationType

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;
}
Also used : SynchronizationSituationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType) SystemException(com.evolveum.midpoint.util.exception.SystemException) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) ConfigurationException(com.evolveum.midpoint.util.exception.ConfigurationException) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) SystemException(com.evolveum.midpoint.util.exception.SystemException) CommunicationException(com.evolveum.midpoint.util.exception.CommunicationException) PolicyViolationException(com.evolveum.midpoint.util.exception.PolicyViolationException) ExpressionEvaluationException(com.evolveum.midpoint.util.exception.ExpressionEvaluationException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException)

Aggregations

SynchronizationSituationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType)6 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)3 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 PropertyDelta (com.evolveum.midpoint.prism.delta.PropertyDelta)2 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)2 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)2 ObjectAlreadyExistsException (com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException)2 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)2 PolicyViolationException (com.evolveum.midpoint.util.exception.PolicyViolationException)2 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)2 SecurityViolationException (com.evolveum.midpoint.util.exception.SecurityViolationException)2 SynchronizationReactionType (com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationReactionType)2 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)2 LoadableModel (com.evolveum.midpoint.gui.api.model.LoadableModel)1 ModelExecuteOptions (com.evolveum.midpoint.model.api.ModelExecuteOptions)1 LensProjectionContext (com.evolveum.midpoint.model.impl.lens.LensProjectionContext)1 PrismPropertyValue (com.evolveum.midpoint.prism.PrismPropertyValue)1 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)1