syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [2/3] syncope git commit: [SYNCOPE-1380] Raise IgnoreProvisionException, more appropriate
Date Wed, 10 Oct 2018 07:00:57 GMT
[SYNCOPE-1380] Raise IgnoreProvisionException, more appropriate


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

Branch: refs/heads/master
Commit: 2c48533389ee654602effc6deb78ae4587d0c3e1
Parents: cf5a502
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
Authored: Wed Oct 10 08:52:07 2018 +0200
Committer: Francesco Chicchiriccò <ilgrosso@apache.org>
Committed: Wed Oct 10 08:52:23 2018 +0200

----------------------------------------------------------------------
 .../api/pushpull/IgnoreProvisionException.java  | 10 ++++--
 .../pushpull/AbstractPullResultHandler.java     | 34 +++++++++++---------
 .../pushpull/AbstractPushResultHandler.java     | 20 ++++++------
 .../pushpull/DefaultRealmPullResultHandler.java |  3 +-
 4 files changed, 39 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/2c485333/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/IgnoreProvisionException.java
----------------------------------------------------------------------
diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/IgnoreProvisionException.java
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/IgnoreProvisionException.java
index bf56246..95d37e8 100644
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/IgnoreProvisionException.java
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/IgnoreProvisionException.java
@@ -19,11 +19,17 @@
 package org.apache.syncope.core.provisioning.api.pushpull;
 
 /**
- * Raised by {@link PullActions} or {@link PushActions} methods when the given any object
is to be ignored for
- * pull / push.
+ * Raised when the given any object is to be ignored for pull / push.
  */
 public class IgnoreProvisionException extends RuntimeException {
 
     private static final long serialVersionUID = -8803817097998786364L;
 
+    public IgnoreProvisionException() {
+        super();
+    }
+
+    public IgnoreProvisionException(final String message) {
+        super(message);
+    }
 }

http://git-wip-us.apache.org/repos/asf/syncope/blob/2c485333/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 2ea3da9..c02077d 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
@@ -154,6 +154,7 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
             ignoreResult.setAnyType(provision == null
                     ? getAnyUtils().anyTypeKind().name() : provision.getAnyType().getKey());
             ignoreResult.setStatus(ProvisioningReport.Status.IGNORE);
+            ignoreResult.setMessage(e.getMessage());
             ignoreResult.setKey(null);
             ignoreResult.setName(delta.getObject().getName().getNameValue());
             profile.getResults().add(ignoreResult);
@@ -781,21 +782,22 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
                 processed.getDeltaType(), processed.getUid().getUidValue(), processed.getObject().getObjectClass());
 
         try {
-            List<String> anyKeys = pullUtils.match(processed.getObject(), provision,
anyUtils);
+            List<String> keys = pullUtils.match(processed.getObject(), provision, anyUtils);
             LOG.debug("Match(es) found for {} as {}: {}",
-                    processed.getUid().getUidValue(), processed.getObject().getObjectClass(),
anyKeys);
+                    processed.getUid().getUidValue(), processed.getObject().getObjectClass(),
keys);
 
-            if (anyKeys.size() > 1) {
+            if (keys.size() > 1) {
                 switch (profile.getConflictResolutionAction()) {
                     case IGNORE:
-                        throw new IllegalStateException("More than one match: " + anyKeys);
+                        throw new IgnoreProvisionException("More than one match found for
"
+                                + processed.getObject().getUid().getUidValue() + ": " + keys);
 
                     case FIRSTMATCH:
-                        anyKeys = anyKeys.subList(0, 1);
+                        keys = keys.subList(0, 1);
                         break;
 
                     case LASTMATCH:
-                        anyKeys = anyKeys.subList(anyKeys.size() - 1, anyKeys.size());
+                        keys = keys.subList(keys.size() - 1, keys.size());
                         break;
 
                     default:
@@ -804,7 +806,7 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
             }
 
             if (SyncDeltaType.CREATE_OR_UPDATE == processed.getDeltaType()) {
-                if (anyKeys.isEmpty()) {
+                if (keys.isEmpty()) {
                     switch (profile.getTask().getUnmatchingRule()) {
                         case ASSIGN:
                             profile.getResults().addAll(assign(processed, provision, anyUtils));
@@ -825,7 +827,7 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
                     // update VirAttrCache
                     for (VirSchema virSchema : virSchemaDAO.findByProvision(provision)) {
                         Attribute attr = processed.getObject().getAttributeByName(virSchema.getExtAttrName());
-                        for (String anyKey : anyKeys) {
+                        for (String anyKey : keys) {
                             if (attr == null) {
                                 virAttrCache.expire(
                                         provision.getAnyType().getKey(),
@@ -845,27 +847,27 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
 
                     switch (profile.getTask().getMatchingRule()) {
                         case UPDATE:
-                            profile.getResults().addAll(update(processed, anyKeys, provision));
+                            profile.getResults().addAll(update(processed, keys, provision));
                             break;
 
                         case DEPROVISION:
-                            profile.getResults().addAll(deprovision(processed, anyKeys, provision,
false));
+                            profile.getResults().addAll(deprovision(processed, keys, provision,
false));
                             break;
 
                         case UNASSIGN:
-                            profile.getResults().addAll(deprovision(processed, anyKeys, provision,
true));
+                            profile.getResults().addAll(deprovision(processed, keys, provision,
true));
                             break;
 
                         case LINK:
-                            profile.getResults().addAll(link(processed, anyKeys, provision,
false));
+                            profile.getResults().addAll(link(processed, keys, provision,
false));
                             break;
 
                         case UNLINK:
-                            profile.getResults().addAll(link(processed, anyKeys, provision,
true));
+                            profile.getResults().addAll(link(processed, keys, provision,
true));
                             break;
 
                         case IGNORE:
-                            profile.getResults().addAll(ignore(processed, anyKeys, provision,
true));
+                            profile.getResults().addAll(ignore(processed, keys, provision,
true));
                             break;
 
                         default:
@@ -873,11 +875,11 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
                     }
                 }
             } else if (SyncDeltaType.DELETE == processed.getDeltaType()) {
-                if (anyKeys.isEmpty()) {
+                if (keys.isEmpty()) {
                     finalize(ResourceOperation.DELETE.name().toLowerCase(), Result.SUCCESS,
null, null, processed);
                     LOG.debug("No match found for deletion");
                 } else {
-                    profile.getResults().addAll(delete(processed, anyKeys, provision));
+                    profile.getResults().addAll(delete(processed, keys, provision));
                 }
             }
         } catch (IllegalStateException | IllegalArgumentException e) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/2c485333/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
index 6c48702..8ad473e 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/AbstractPushResultHandler.java
@@ -208,20 +208,21 @@ public abstract class AbstractPushResultHandler extends AbstractSyncopeResultHan
             doHandle(any, provision);
             return true;
         } catch (IgnoreProvisionException e) {
-            ProvisioningReport result = profile.getResults().stream().
+            ProvisioningReport ignoreResult = profile.getResults().stream().
                     filter(report -> anyKey.equalsIgnoreCase(report.getKey())).
                     findFirst().
                     orElse(null);
-            if (result == null) {
-                result = new ProvisioningReport();
-                result.setKey(anyKey);
-                result.setAnyType(any == null ? null : any.getType().getKey());
+            if (ignoreResult == null) {
+                ignoreResult = new ProvisioningReport();
+                ignoreResult.setKey(anyKey);
+                ignoreResult.setAnyType(any == null ? null : any.getType().getKey());
 
-                profile.getResults().add(result);
+                profile.getResults().add(ignoreResult);
             }
 
-            result.setOperation(ResourceOperation.NONE);
-            result.setStatus(ProvisioningReport.Status.IGNORE);
+            ignoreResult.setOperation(ResourceOperation.NONE);
+            ignoreResult.setStatus(ProvisioningReport.Status.IGNORE);
+            ignoreResult.setMessage(e.getMessage());
 
             LOG.warn("Ignoring during push", e);
             return true;
@@ -249,7 +250,8 @@ public abstract class AbstractPushResultHandler extends AbstractSyncopeResultHan
         if (connObjs.size() > 1) {
             switch (profile.getConflictResolutionAction()) {
                 case IGNORE:
-                    throw new IllegalStateException("More than one match: " + connObjs);
+                    throw new IgnoreProvisionException("More than one match found for "
+                            + any.getKey() + ": " + connObjs);
 
                 case FIRSTMATCH:
                     connObjs = connObjs.subList(0, 1);

http://git-wip-us.apache.org/repos/asf/syncope/blob/2c485333/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 0c5bb6b..fb29bd4 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
@@ -687,7 +687,8 @@ public class DefaultRealmPullResultHandler
         if (keys.size() > 1) {
             switch (profile.getConflictResolutionAction()) {
                 case IGNORE:
-                    throw new IllegalStateException("More than one match " + keys);
+                        throw new IgnoreProvisionException("More than one match found for
"
+                                + processed.getObject().getUid().getUidValue() + ": " + keys);
 
                 case FIRSTMATCH:
                     keys = keys.subList(0, 1);


Mime
View raw message