[SYNCOPE-1387] Clearing up calls between link() and update()
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/5e854e11 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/5e854e11 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/5e854e11 Branch: refs/heads/2_0_X Commit: 5e854e117594da3a1ba78c0af8d53d89a66a9c5a Parents: 5eb9585 Author: Francesco Chicchiriccò <ilgro...@apache.org> Authored: Tue Oct 23 14:26:52 2018 +0200 Committer: Francesco Chicchiriccò <ilgro...@apache.org> Committed: Tue Oct 23 14:27:06 2018 +0200 ---------------------------------------------------------------------- .../pushpull/DefaultRealmPullResultHandler.java | 28 ++++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/5e854e11/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DefaultRealmPullResultHandler.java ---------------------------------------------------------------------- diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DefaultRealmPullResultHandler.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DefaultRealmPullResultHandler.java index ad45010..c315343 100644 --- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DefaultRealmPullResultHandler.java +++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/DefaultRealmPullResultHandler.java @@ -274,7 +274,7 @@ public class DefaultRealmPullResultHandler finalize(operation, resultStatus, null, output, delta); } - private List<ProvisioningReport> update(final SyncDelta delta, final List<String> keys) + private List<ProvisioningReport> update(final SyncDelta delta, final List<String> keys, final boolean inLink) throws JobExecutionException { if (!profile.getTask().isPerformUpdate()) { @@ -314,8 +314,10 @@ public class DefaultRealmPullResultHandler output = null; } else { try { - for (PullActions action : profile.getActions()) { - action.beforeUpdate(profile, delta, before, null); + if (!inLink) { + for (PullActions action : profile.getActions()) { + action.beforeUpdate(profile, delta, before, null); + } } PropagationByResource propByRes = binder.update(realm, before); @@ -414,15 +416,17 @@ public class DefaultRealmPullResultHandler propByRes.add(ResourceOperation.DELETE, profile.getTask().getResource().getKey()); taskExecutor.execute(propagationManager.createTasks(realm, propByRes, null), false); + RealmTO realmTO; if (unlink) { realm.getResources().remove(profile.getTask().getResource()); - output = binder.getRealmTO(realmDAO.save(realm), true); + realmTO = binder.getRealmTO(realmDAO.save(realm), true); } else { - output = binder.getRealmTO(realm, true); + realmTO = binder.getRealmTO(realm, true); } + output = realmTO; for (PullActions action : profile.getActions()) { - action.after(profile, delta, RealmTO.class.cast(output), result); + action.after(profile, delta, realmTO, result); } resultStatus = Result.SUCCESS; @@ -510,11 +514,7 @@ public class DefaultRealmPullResultHandler } else { realm.add(profile.getTask().getResource()); } - output = update(delta, Collections.singletonList(key)); - - for (PullActions action : profile.getActions()) { - action.after(profile, delta, RealmTO.class.cast(output), result); - } + output = update(delta, Collections.singletonList(key), true); resultStatus = Result.SUCCESS; @@ -687,8 +687,8 @@ public class DefaultRealmPullResultHandler if (keys.size() > 1) { switch (profile.getResAct()) { case IGNORE: - throw new IgnoreProvisionException("More than one match found for " - + processed.getObject().getUid().getUidValue() + ": " + keys); + throw new IgnoreProvisionException("More than one match found for " + + processed.getObject().getUid().getUidValue() + ": " + keys); case FIRSTMATCH: keys = keys.subList(0, 1); @@ -725,7 +725,7 @@ public class DefaultRealmPullResultHandler } else { switch (profile.getTask().getMatchingRule()) { case UPDATE: - profile.getResults().addAll(update(processed, keys)); + profile.getResults().addAll(update(processed, keys, false)); break; case DEPROVISION: