You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2017/10/19 09:34:19 UTC

[2/2] syncope git commit: Small cleanup

Small cleanup


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/0984dfd2
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/0984dfd2
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/0984dfd2

Branch: refs/heads/master
Commit: 0984dfd22cca30034933941fc9f804e5922bb8c1
Parents: ed30ef8
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Thu Oct 19 11:33:59 2017 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Thu Oct 19 11:34:10 2017 +0200

----------------------------------------------------------------------
 .../api/pushpull/ProvisioningProfile.java       |  3 +-
 .../pushpull/AbstractPullResultHandler.java     | 70 +++++++++++++-------
 2 files changed, 48 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/0984dfd2/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/ProvisioningProfile.java
----------------------------------------------------------------------
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/ProvisioningProfile.java b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/ProvisioningProfile.java
index 83eb098..4c02da1 100644
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/ProvisioningProfile.java
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/ProvisioningProfile.java
@@ -19,7 +19,6 @@
 package org.apache.syncope.core.provisioning.api.pushpull;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import org.apache.syncope.common.lib.types.ConflictResolutionAction;
 import org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask;
@@ -52,7 +51,7 @@ public class ProvisioningProfile<T extends ProvisioningTask, A extends Provision
         return task;
     }
 
-    public Collection<ProvisioningReport> getResults() {
+    public List<ProvisioningReport> getResults() {
         return results;
     }
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/0984dfd2/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPullResultHandler.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPullResultHandler.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPullResultHandler.java
index d545994..9ec7edb 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPullResultHandler.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPullResultHandler.java
@@ -295,7 +295,7 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
     }
 
     protected List<ProvisioningReport> update(
-            final SyncDelta delta, final List<String> anys, final Provision provision) throws JobExecutionException {
+            final SyncDelta delta, final List<String> anyKeys, final Provision provision) throws JobExecutionException {
 
         if (!profile.getTask().isPerformUpdate()) {
             LOG.debug("PullTask not configured for update");
@@ -303,12 +303,12 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
             return Collections.<ProvisioningReport>emptyList();
         }
 
-        LOG.debug("About to update {}", anys);
+        LOG.debug("About to update {}", anyKeys);
 
         List<ProvisioningReport> results = new ArrayList<>();
 
         SyncDelta workingDelta = delta;
-        for (String key : anys) {
+        for (String key : anyKeys) {
             LOG.debug("About to update {}", key);
 
             ProvisioningReport result = new ProvisioningReport();
@@ -387,7 +387,7 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
 
     protected List<ProvisioningReport> deprovision(
             final SyncDelta delta,
-            final List<String> anys,
+            final List<String> anyKeys,
             final Provision provision,
             final boolean unlink)
             throws JobExecutionException {
@@ -400,11 +400,11 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
             return Collections.<ProvisioningReport>emptyList();
         }
 
-        LOG.debug("About to deprovision {}", anys);
+        LOG.debug("About to deprovision {}", anyKeys);
 
         final List<ProvisioningReport> results = new ArrayList<>();
 
-        for (String key : anys) {
+        for (String key : anyKeys) {
             LOG.debug("About to unassign resource {}", key);
 
             ProvisioningReport result = new ProvisioningReport();
@@ -500,7 +500,7 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
 
     protected List<ProvisioningReport> link(
             final SyncDelta delta,
-            final List<String> anys,
+            final List<String> anyKeys,
             final Provision provision,
             final boolean unlink)
             throws JobExecutionException {
@@ -513,11 +513,11 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
             return Collections.<ProvisioningReport>emptyList();
         }
 
-        LOG.debug("About to update {}", anys);
+        LOG.debug("About to update {}", anyKeys);
 
         final List<ProvisioningReport> results = new ArrayList<>();
 
-        for (String key : anys) {
+        for (String key : anyKeys) {
             LOG.debug("About to unassign resource {}", key);
 
             ProvisioningReport result = new ProvisioningReport();
@@ -601,7 +601,7 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
 
     protected List<ProvisioningReport> delete(
             final SyncDelta delta,
-            final List<String> anys,
+            final List<String> anyKeys,
             final Provision provision)
             throws JobExecutionException {
 
@@ -611,12 +611,12 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
             return Collections.<ProvisioningReport>emptyList();
         }
 
-        LOG.debug("About to delete {}", anys);
+        LOG.debug("About to delete {}", anyKeys);
 
         List<ProvisioningReport> results = new ArrayList<>();
 
         SyncDelta workingDelta = delta;
-        for (String key : anys) {
+        for (String key : anyKeys) {
             Object output;
             Result resultStatus = Result.FAILURE;
 
@@ -669,27 +669,51 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
         return results;
     }
 
-    protected ProvisioningReport ignore(
+    protected List<ProvisioningReport> ignore(
             final SyncDelta delta,
+            final List<String> anyKeys,
             final Provision provision,
-            final boolean matching)
+            final boolean matching,
+            final String... message)
             throws JobExecutionException {
 
         LOG.debug("Any to ignore {}", delta.getObject().getUid().getUidValue());
 
-        ProvisioningReport result = new ProvisioningReport();
+        List<ProvisioningReport> results = new ArrayList<>();
 
-        result.setKey(null);
-        result.setName(delta.getObject().getUid().getUidValue());
-        result.setOperation(ResourceOperation.NONE);
-        result.setAnyType(provision.getAnyType().getKey());
-        result.setStatus(ProvisioningReport.Status.SUCCESS);
+        if (anyKeys == null) {
+            ProvisioningReport report = new ProvisioningReport();
+            report.setKey(null);
+            report.setName(delta.getObject().getUid().getUidValue());
+            report.setOperation(ResourceOperation.NONE);
+            report.setAnyType(provision.getAnyType().getKey());
+            report.setStatus(ProvisioningReport.Status.SUCCESS);
+            if (message != null && message.length >= 1) {
+                report.setMessage(message[0]);
+            }
+
+            results.add(report);
+        } else {
+            for (String anyKey : anyKeys) {
+                ProvisioningReport report = new ProvisioningReport();
+                report.setKey(anyKey);
+                report.setName(delta.getObject().getUid().getUidValue());
+                report.setOperation(ResourceOperation.NONE);
+                report.setAnyType(provision.getAnyType().getKey());
+                report.setStatus(ProvisioningReport.Status.SUCCESS);
+                if (message != null && message.length >= 1) {
+                    report.setMessage(message[0]);
+                }
+
+                results.add(report);
+            }
+        }
 
         finalize(matching
                 ? MatchingRule.toEventName(MatchingRule.IGNORE)
                 : UnmatchingRule.toEventName(UnmatchingRule.IGNORE), Result.SUCCESS, null, null, delta);
 
-        return result;
+        return results;
     }
 
     /**
@@ -744,7 +768,7 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
                             break;
 
                         case IGNORE:
-                            profile.getResults().add(ignore(delta, provision, false));
+                            profile.getResults().addAll(ignore(delta, null, provision, false));
                             break;
 
                         default:
@@ -794,7 +818,7 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
                             break;
 
                         case IGNORE:
-                            profile.getResults().add(ignore(delta, provision, true));
+                            profile.getResults().addAll(ignore(delta, anyKeys, provision, true));
                             break;
 
                         default: