Skip to content

Commit

Permalink
fix for MID-5095
Browse files Browse the repository at this point in the history
  • Loading branch information
katkav committed Jan 24, 2019
1 parent 66a6929 commit c51cce9
Showing 1 changed file with 13 additions and 10 deletions.
Expand Up @@ -188,13 +188,13 @@ public <F extends FocusType> void notifyChange(ResourceObjectShadowChangeDescrip

setupSituation(syncCtx, eventInfo, change);

if (!checkDryRunAndUnrelatedChange(syncCtx, eventInfo, now)) {
if (!checkDryRun(syncCtx, eventInfo, change, now)) {
return;
}

// must be here, because when the reaction has no action, the
// situation won't be set.
PrismObject<ShadowType> newCurrentShadow = saveSyncMetadata(syncCtx, change, now);
PrismObject<ShadowType> newCurrentShadow = saveSyncMetadata(syncCtx, change, true, now);
if (newCurrentShadow != null) {
change.setCurrentShadow(newCurrentShadow);
syncCtx.setCurrentShadow(newCurrentShadow);
Expand Down Expand Up @@ -389,12 +389,11 @@ private <F extends FocusType> boolean checkProtected(SynchronizationContext<F> s
return true;
}

private <F extends FocusType> boolean checkDryRunAndUnrelatedChange(SynchronizationContext<F> syncCtx, SynchronizationEventInformation eventInfo, XMLGregorianCalendar now) throws SchemaException {
private <F extends FocusType> boolean checkDryRun(SynchronizationContext<F> syncCtx, SynchronizationEventInformation eventInfo, ResourceObjectShadowChangeDescription change, XMLGregorianCalendar now) throws SchemaException {
OperationResult subResult = syncCtx.getResult();
Task task = syncCtx.getTask();
if (ModelImplUtils.isDryRun(task)) {
List<PropertyDelta<?>> modifications = createShadowIntentAndSynchronizationTimestampDelta(syncCtx, true);
executeShadowModifications(syncCtx.getApplicableShadow(), modifications, task, subResult);
saveSyncMetadata(syncCtx, change, false, now);
subResult.recordSuccess();
eventInfo.record(task);
LOGGER.debug("SYNCHRONIZATION: DONE (dry run) for {}", syncCtx.getApplicableShadow());
Expand Down Expand Up @@ -978,7 +977,7 @@ private <F extends FocusType> void findReactionDefinition(SynchronizationContext
* Saves situation, timestamps, kind and intent (if needed)
*/
private <F extends FocusType> PrismObject<ShadowType> saveSyncMetadata(SynchronizationContext<F> syncCtx, ResourceObjectShadowChangeDescription change,
XMLGregorianCalendar now) {
boolean full, XMLGregorianCalendar now) {
PrismObject<ShadowType> shadow = syncCtx.getCurrentShadow();
if (shadow == null) {
return null;
Expand All @@ -992,15 +991,15 @@ private <F extends FocusType> PrismObject<ShadowType> saveSyncMetadata(Synchroni
// new situation description
List<PropertyDelta<?>> deltas = SynchronizationUtils
.createSynchronizationSituationAndDescriptionDelta(shadow, syncCtx.getSituation(),
change.getSourceChannel(), true, now);
change.getSourceChannel(), full, now);

if (shadowType.getKind() == null) {
if (shadowType.getKind() == null || ShadowKindType.UNKNOWN == shadowType.getKind()) {
PropertyDelta<ShadowKindType> kindDelta = PropertyDelta.createReplaceDelta(shadow.getDefinition(),
ShadowType.F_KIND, syncCtx.getKind());
deltas.add(kindDelta);
}

if (isNullIntentOrIsForceIntent(syncCtx)) {
if (shouldSaveIntent(syncCtx)) {
PropertyDelta<String> intentDelta = PropertyDelta.createReplaceDelta(shadow.getDefinition(),
ShadowType.F_INTENT, syncCtx.getIntent());
deltas.add(intentDelta);
Expand Down Expand Up @@ -1038,12 +1037,16 @@ private <F extends FocusType> PrismObject<ShadowType> saveSyncMetadata(Synchroni
return null;
}

private <F extends FocusType> boolean isNullIntentOrIsForceIntent(SynchronizationContext<F> syncCtx) throws SchemaException {
private <F extends FocusType> boolean shouldSaveIntent(SynchronizationContext<F> syncCtx) throws SchemaException {
ShadowType shadow = syncCtx.getCurrentShadow().asObjectable();
if (shadow.getIntent() == null) {
return true;
}

if (SchemaConstants.INTENT_UNKNOWN.equals(shadow.getIntent())) {
return true;
}

if (syncCtx.isForceIntentChange()) {
String objectSyncIntent = syncCtx.getIntent();
if (!MiscSchemaUtil.equalsIntent(shadow.getIntent(), objectSyncIntent)) {
Expand Down

0 comments on commit c51cce9

Please sign in to comment.