syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [syncope] branch 2_0_X updated: [SYNCOPE-1444] Passing SyncDelta as argument
Date Wed, 06 Mar 2019 13:53:24 GMT
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 2_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/2_0_X by this push:
     new b791303  [SYNCOPE-1444] Passing SyncDelta as argument
b791303 is described below

commit b7913034c9e37bfd675a34647fdd423b91ed8ffb
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
AuthorDate: Wed Mar 6 14:26:31 2019 +0100

    [SYNCOPE-1444] Passing SyncDelta as argument
---
 .../api/pushpull/PullCorrelationRule.java          |  8 ++---
 .../provisioning/java/ConnectorFacadeProxy.java    |  1 -
 .../java/pushpull/AbstractPullResultHandler.java   |  2 +-
 .../pushpull/DefaultRealmPullResultHandler.java    |  2 +-
 .../pushpull/PlainAttrsPullCorrelationRule.java    |  6 ++--
 .../core/provisioning/java/pushpull/PullUtils.java | 36 ++++++++++++++--------
 .../syncope/fit/core/reference/TestPullRule.java   |  6 ++--
 7 files changed, 35 insertions(+), 26 deletions(-)

diff --git a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/PullCorrelationRule.java
b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/PullCorrelationRule.java
index 5d6d922..210d2ac 100644
--- a/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/PullCorrelationRule.java
+++ b/core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/pushpull/PullCorrelationRule.java
@@ -19,7 +19,7 @@
 package org.apache.syncope.core.provisioning.api.pushpull;
 
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.SyncDelta;
 
 /**
  * Interface for correlation rule to be evaluated during PullJob execution.
@@ -29,8 +29,8 @@ public interface PullCorrelationRule {
     /**
      * Return a search condition.
      *
-     * @param connObj connector object.
-     * @return search condition.
+     * @param syncDelta change operation, including external attributes
+     * @return search condition
      */
-    SearchCond getSearchCond(ConnectorObject connObj);
+    SearchCond getSearchCond(SyncDelta syncDelta);
 }
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
index 46393b5..0e13e6d 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
@@ -335,7 +335,6 @@ public class ConnectorFacadeProxy implements Connector {
             public boolean handle(final ConnectorObject obj) {
                 return handler.handle(new SyncDeltaBuilder().
                         setObject(obj).
-                        setUid(obj.getUid()).
                         setDeltaType(SyncDeltaType.CREATE_OR_UPDATE).
                         setToken(new SyncToken("")).
                         build());
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 f0a2c8d..4995476 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
@@ -729,7 +729,7 @@ public abstract class AbstractPullResultHandler extends AbstractSyncopeResultHan
                 processed.getDeltaType(), processed.getUid().getUidValue(), processed.getObject().getObjectClass());
 
         try {
-            List<String> keys = pullUtils.match(processed.getObject(), provision, anyUtils);
+            List<String> keys = pullUtils.match(processed, provision, anyUtils);
             LOG.debug("Match(es) found for {} as {}: {}",
                     processed.getUid().getUidValue(), processed.getObject().getObjectClass(),
keys);
 
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 e17be3b..8c54fee 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
@@ -678,7 +678,7 @@ public class DefaultRealmPullResultHandler
         LOG.debug("Transformed {} for {} as {}",
                 processed.getDeltaType(), processed.getUid().getUidValue(), processed.getObject().getObjectClass());
 
-        List<String> keys = pullUtils.match(processed.getObject(), orgUnit);
+        List<String> keys = pullUtils.match(processed, orgUnit);
         LOG.debug("Match found for {} as {}: {}",
                 processed.getUid().getUidValue(), processed.getObject().getObjectClass(),
keys);
 
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PlainAttrsPullCorrelationRule.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PlainAttrsPullCorrelationRule.java
index 9c55b03..ba3b850 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PlainAttrsPullCorrelationRule.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PlainAttrsPullCorrelationRule.java
@@ -28,10 +28,10 @@ import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
 import org.apache.syncope.core.persistence.api.entity.resource.Item;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
 import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
 import org.apache.syncope.core.provisioning.api.pushpull.PullCorrelationRule;
 import org.apache.syncope.core.provisioning.java.utils.MappingUtils;
 import org.apache.syncope.core.provisioning.api.data.ItemTransformer;
+import org.identityconnectors.framework.common.objects.SyncDelta;
 
 public class PlainAttrsPullCorrelationRule implements PullCorrelationRule {
 
@@ -45,7 +45,7 @@ public class PlainAttrsPullCorrelationRule implements PullCorrelationRule
{
     }
 
     @Override
-    public SearchCond getSearchCond(final ConnectorObject connObj) {
+    public SearchCond getSearchCond(final SyncDelta syncDelta) {
         Map<String, Item> mappingItems = new HashMap<>();
         for (Item item : provision.getMapping().getItems()) {
             mappingItems.put(item.getIntAttrName(), item);
@@ -58,7 +58,7 @@ public class PlainAttrsPullCorrelationRule implements PullCorrelationRule
{
             Item mappingItem = mappingItems.get(schema);
             Attribute attr = mappingItem == null
                     ? null
-                    : connObj.getAttributeByName(mappingItem.getExtAttrName());
+                    : syncDelta.getObject().getAttributeByName(mappingItem.getExtAttrName());
             if (attr == null) {
                 throw new IllegalArgumentException(
                         "Connector object does not contains the attributes to perform the
search: " + schema);
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PullUtils.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PullUtils.java
index d359ebf..ea98e1d 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PullUtils.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PullUtils.java
@@ -64,6 +64,10 @@ import org.identityconnectors.framework.common.objects.ConnectorObject;
 import org.identityconnectors.framework.common.objects.Name;
 import org.identityconnectors.framework.common.objects.OperationalAttributes;
 import org.identityconnectors.framework.common.objects.SearchResult;
+import org.identityconnectors.framework.common.objects.SyncDelta;
+import org.identityconnectors.framework.common.objects.SyncDeltaBuilder;
+import org.identityconnectors.framework.common.objects.SyncDeltaType;
+import org.identityconnectors.framework.common.objects.SyncToken;
 import org.identityconnectors.framework.common.objects.filter.EqualsFilter;
 import org.identityconnectors.framework.spi.SearchResultsHandler;
 import org.slf4j.Logger;
@@ -150,7 +154,13 @@ public class PullUtils {
 
             ConnectorObject connObj = found.iterator().next();
             try {
-                List<String> anyKeys = match(connObj, provision, anyUtils);
+                List<String> anyKeys = match(
+                        new SyncDeltaBuilder().
+                                setToken(new SyncToken("")).
+                                setDeltaType(SyncDeltaType.CREATE_OR_UPDATE).
+                                setObject(connObj).
+                                build(),
+                        provision, anyUtils);
                 if (anyKeys.isEmpty()) {
                     LOG.debug("No matching {} found for {}, aborting", anyUtils.anyTypeKind(),
connObj);
                 } else {
@@ -169,13 +179,13 @@ public class PullUtils {
     }
 
     private List<String> findByConnObjectKey(
-            final ConnectorObject connObj, final Provision provision, final AnyUtils anyUtils)
{
+            final SyncDelta syncDelta, final Provision provision, final AnyUtils anyUtils)
{
 
         String connObjectKey = null;
 
         MappingItem connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision);
         if (connObjectKeyItem != null) {
-            Attribute connObjectKeyAttr = connObj.getAttributeByName(connObjectKeyItem.getExtAttrName());
+            Attribute connObjectKeyAttr = syncDelta.getObject().getAttributeByName(connObjectKeyItem.getExtAttrName());
             if (connObjectKeyAttr != null) {
                 connObjectKey = AttributeUtil.getStringValue(connObjectKeyAttr);
             }
@@ -268,10 +278,10 @@ public class PullUtils {
     }
 
     private List<String> findByCorrelationRule(
-            final ConnectorObject connObj, final PullCorrelationRule rule, final AnyTypeKind
type) {
+            final SyncDelta syncDelta, final PullCorrelationRule rule, final AnyTypeKind
type) {
 
         List<String> result = new ArrayList<>();
-        for (Any<?> any : searchDAO.search(rule.getSearchCond(connObj), type)) {
+        for (Any<?> any : searchDAO.search(rule.getSearchCond(syncDelta), type)) {
             result.add(any.getKey());
         }
 
@@ -281,13 +291,13 @@ public class PullUtils {
     /**
      * Finds internal entities based on external attributes and mapping.
      *
-     * @param connObj external attributes
+     * @param syncDelta change operation, including external attributes
      * @param provision mapping
      * @param anyUtils any utils
      * @return list of matching users' / groups' / any objects' keys
      */
     public List<String> match(
-            final ConnectorObject connObj,
+            final SyncDelta syncDelta,
             final Provision provision,
             final AnyUtils anyUtils) {
 
@@ -315,10 +325,10 @@ public class PullUtils {
 
         try {
             return pullRule == null
-                    ? findByConnObjectKey(connObj, provision, anyUtils)
-                    : findByCorrelationRule(connObj, pullRule, anyUtils.anyTypeKind());
+                    ? findByConnObjectKey(syncDelta, provision, anyUtils)
+                    : findByCorrelationRule(syncDelta, pullRule, anyUtils.anyTypeKind());
         } catch (RuntimeException e) {
-            LOG.error("Could not match {} with any existing {}", connObj, provision.getAnyType(),
e);
+            LOG.error("Could not match {} with any existing {}", syncDelta, provision.getAnyType(),
e);
             return Collections.<String>emptyList();
         }
     }
@@ -326,19 +336,19 @@ public class PullUtils {
     /**
      * Finds internal realms based on external attributes and mapping.
      *
-     * @param connObj external attributes
+     * @param syncDelta change operation, including external attributes
      * @param orgUnit mapping
      * @return list of matching realms' keys.
      */
     public List<String> match(
-            final ConnectorObject connObj,
+            final SyncDelta syncDelta,
             final OrgUnit orgUnit) {
 
         String connObjectKey = null;
 
         OrgUnitItem connObjectKeyItem = orgUnit.getConnObjectKeyItem();
         if (connObjectKeyItem != null) {
-            Attribute connObjectKeyAttr = connObj.getAttributeByName(connObjectKeyItem.getExtAttrName());
+            Attribute connObjectKeyAttr = syncDelta.getObject().getAttributeByName(connObjectKeyItem.getExtAttrName());
             if (connObjectKeyAttr != null) {
                 connObjectKey = AttributeUtil.getStringValue(connObjectKeyAttr);
             }
diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestPullRule.java
b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestPullRule.java
index 71d36a7..32386d4 100644
--- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestPullRule.java
+++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestPullRule.java
@@ -20,8 +20,8 @@ package org.apache.syncope.fit.core.reference;
 
 import org.apache.syncope.core.persistence.api.dao.search.AttributeCond;
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
 import org.apache.syncope.core.provisioning.api.pushpull.PullCorrelationRule;
+import org.identityconnectors.framework.common.objects.SyncDelta;
 
 /**
  * Test pull rule relying on <tt>email</tt> attribute value.
@@ -29,11 +29,11 @@ import org.apache.syncope.core.provisioning.api.pushpull.PullCorrelationRule;
 public class TestPullRule implements PullCorrelationRule {
 
     @Override
-    public SearchCond getSearchCond(final ConnectorObject connObj) {
+    public SearchCond getSearchCond(final SyncDelta syncDelta) {
         AttributeCond cond = new AttributeCond();
         cond.setSchema("email");
         cond.setType(AttributeCond.Type.EQ);
-        cond.setExpression(connObj.getName().getNameValue());
+        cond.setExpression(syncDelta.getObject().getName().getNameValue());
 
         return SearchCond.getLeafCond(cond);
     }


Mime
View raw message