Skip to content

Commit

Permalink
Explain "link" sync action failure cause
Browse files Browse the repository at this point in the history
This resolves MID-7906.
  • Loading branch information
mederly committed Oct 4, 2022
1 parent 0f271b9 commit 0e746c8
Showing 1 changed file with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

import com.evolveum.midpoint.xml.ns._public.common.common_3.LinkSynchronizationActionType;

import com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType;

import org.jetbrains.annotations.NotNull;

import com.evolveum.midpoint.model.impl.lens.LensContext;
Expand All @@ -21,6 +23,8 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.xml.ns._public.common.common_3.FocusType;

import static com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationSituationType.UNLINKED;

/**
* @author semancik
*
Expand All @@ -38,10 +42,19 @@ public LinkAction(@NotNull ActionInstantiationContext<F> ctx) {
@Override
public void prepareContext(@NotNull LensContext<F> context, @NotNull OperationResult result) {

// Just add the candidate focus to the context. It will be linked in
// synchronization.

// Just add the candidate focus to the context. It will be linked in synchronization.
F focus = syncCtx.getCorrelatedOwner();

if (focus == null) {
String problem = "Couldn't invoke the 'link' action because there is no correlated owner.";
SynchronizationSituationType situation = syncCtx.getSituation();
if (situation != UNLINKED) {
throw new IllegalStateException(problem + " This action is supported only for UNLINKED situation. "
+ "In this case the situation is " + situation + ".");
} else {
throw new IllegalStateException(problem);
}
}
LensFocusContext<F> focusContext = context.createFocusContext();
//noinspection unchecked
focusContext.setInitialObject((PrismObject<F>) focus.asPrismObject());
Expand Down

0 comments on commit 0e746c8

Please sign in to comment.