syncope-commits mailing list archives

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

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


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

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

    [SYNCOPE-1444] Passing SyncDelta as argument
---
 .../implementations/MyPullCorrelationRule.groovy   |  4 +--
 .../persistence/api/dao/PullCorrelationRule.java   |  6 ++--
 .../jpa/dao/DefaultPullCorrelationRule.java        |  6 ++--
 .../provisioning/java/ConnectorFacadeProxy.java    |  1 -
 .../java/pushpull/AbstractPullResultHandler.java   |  2 +-
 .../pushpull/DefaultRealmPullResultHandler.java    |  2 +-
 .../core/provisioning/java/pushpull/PullUtils.java | 38 ++++++++++++++--------
 .../core/reference/DummyPullCorrelationRule.java   |  4 +--
 .../src/test/resources/TestPullRule.groovy         |  6 ++--
 9 files changed, 40 insertions(+), 29 deletions(-)

diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/implementations/MyPullCorrelationRule.groovy
b/client/console/src/main/resources/org/apache/syncope/client/console/implementations/MyPullCorrelationRule.groovy
index bb56ebe..383afc2 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/implementations/MyPullCorrelationRule.groovy
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/implementations/MyPullCorrelationRule.groovy
@@ -20,13 +20,13 @@ import groovy.transform.CompileStatic
 import org.apache.syncope.core.persistence.api.dao.PullCorrelationRule
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond
 import org.apache.syncope.core.persistence.api.entity.resource.Provision
-import org.identityconnectors.framework.common.objects.ConnectorObject
+import org.identityconnectors.framework.common.objects.SyncDelta
 
 @CompileStatic
 class MyPullCorrelationRule implements PullCorrelationRule {
 
   @Override
-  SearchCond getSearchCond(ConnectorObject connObj, Provision provision) {
+  SearchCond getSearchCond(SyncDelta syncDelta, Provision provision) {
     
   }
 }
diff --git a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PullCorrelationRule.java
b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PullCorrelationRule.java
index 83a82f7..24c13e3 100644
--- a/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PullCorrelationRule.java
+++ b/core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/dao/PullCorrelationRule.java
@@ -21,7 +21,7 @@ package org.apache.syncope.core.persistence.api.dao;
 import org.apache.syncope.common.lib.policy.PullCorrelationRuleConf;
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.SyncDelta;
 
 /**
  * Interface for correlation rule to be evaluated during PullJob execution.
@@ -34,9 +34,9 @@ public interface PullCorrelationRule {
     /**
      * Return a search condition.
      *
-     * @param connObj connector object.
+     * @param syncDelta change operation, including external attributes
      * @param provision resource provision
      * @return search condition.
      */
-    SearchCond getSearchCond(ConnectorObject connObj, Provision provision);
+    SearchCond getSearchCond(SyncDelta syncDelta, Provision provision);
 }
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/DefaultPullCorrelationRule.java
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/DefaultPullCorrelationRule.java
index 502d1b0..16302ec 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/DefaultPullCorrelationRule.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/DefaultPullCorrelationRule.java
@@ -31,9 +31,9 @@ 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.persistence.api.dao.PullCorrelationRule;
 import org.apache.syncope.core.persistence.api.dao.PullCorrelationRuleConfClass;
+import org.identityconnectors.framework.common.objects.SyncDelta;
 
 @PullCorrelationRuleConfClass(DefaultPullCorrelationRuleConf.class)
 public class DefaultPullCorrelationRule implements PullCorrelationRule {
@@ -51,7 +51,7 @@ public class DefaultPullCorrelationRule implements PullCorrelationRule {
     }
 
     @Override
-    public SearchCond getSearchCond(final ConnectorObject connObj, final Provision provision)
{
+    public SearchCond getSearchCond(final SyncDelta syncDelta, final Provision provision)
{
         Map<String, Item> mappingItems = provision.getMapping().getItems().stream().
                 collect(Collectors.toMap(Item::getIntAttrName, Function.identity()));
 
@@ -62,7 +62,7 @@ public class DefaultPullCorrelationRule implements PullCorrelationRule {
             Item item = mappingItems.get(schema);
             Attribute attr = item == null
                     ? null
-                    : connObj.getAttributeByName(item.getExtAttrName());
+                    : syncDelta.getObject().getAttributeByName(item.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/ConnectorFacadeProxy.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/ConnectorFacadeProxy.java
index 44dddaa..a53174a 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
@@ -339,7 +339,6 @@ public class ConnectorFacadeProxy implements Connector {
             public boolean handle(final ConnectorObject object) {
                 return handler.handle(new SyncDeltaBuilder().
                         setObject(object).
-                        setUid(object.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 c585dfe..96c69e1 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
@@ -782,7 +782,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 cbaa6b1..43c2eb8 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/PullUtils.java
b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/PullUtils.java
index f71cc55..dd43800 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
@@ -68,6 +68,10 @@ 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.filter.FilterBuilder;
+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.spi.SearchResultsHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -158,7 +162,13 @@ public class PullUtils {
 
             ConnectorObject connObj = found.iterator().next();
             try {
-                List<String> anyKeys = match(connObj, provision.get(), anyUtils);
+                List<String> anyKeys = match(
+                        new SyncDeltaBuilder().
+                                setToken(new SyncToken("")).
+                                setDeltaType(SyncDeltaType.CREATE_OR_UPDATE).
+                                setObject(connObj).
+                                build(),
+                        provision.get(), anyUtils);
                 if (anyKeys.isEmpty()) {
                     LOG.debug("No matching {} found for {}, aborting", anyUtils.anyTypeKind(),
connObj);
                 } else {
@@ -177,13 +187,14 @@ 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;
 
         Optional<? extends MappingItem> connObjectKeyItem = MappingUtils.getConnObjectKeyItem(provision);
         if (connObjectKeyItem.isPresent()) {
-            Attribute connObjectKeyAttr = connObj.getAttributeByName(connObjectKeyItem.get().getExtAttrName());
+            Attribute connObjectKeyAttr = syncDelta.getObject().
+                    getAttributeByName(connObjectKeyItem.get().getExtAttrName());
             if (connObjectKeyAttr != null) {
                 connObjectKey = AttributeUtil.getStringValue(connObjectKeyAttr);
             }
@@ -303,25 +314,25 @@ public class PullUtils {
     }
 
     private List<String> findByCorrelationRule(
-            final ConnectorObject connObj,
+            final SyncDelta syncDelta,
             final Provision provision,
             final PullCorrelationRule rule,
             final AnyTypeKind type) {
 
-        return searchDAO.search(rule.getSearchCond(connObj, provision), type).stream().
+        return searchDAO.search(rule.getSearchCond(syncDelta, provision), type).stream().
                 map(Entity::getKey).collect(Collectors.toList());
     }
 
     /**
      * 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) {
 
@@ -340,10 +351,10 @@ public class PullUtils {
 
         try {
             return rule.isPresent()
-                    ? findByCorrelationRule(connObj, provision, rule.get(), anyUtils.anyTypeKind())
-                    : findByConnObjectKey(connObj, provision, anyUtils);
+                    ? findByCorrelationRule(syncDelta, provision, rule.get(), anyUtils.anyTypeKind())
+                    : findByConnObjectKey(syncDelta, provision, anyUtils);
         } 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();
         }
     }
@@ -351,19 +362,20 @@ 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;
 
         Optional<? extends OrgUnitItem> connObjectKeyItem = orgUnit.getConnObjectKeyItem();
         if (connObjectKeyItem.isPresent()) {
-            Attribute connObjectKeyAttr = connObj.getAttributeByName(connObjectKeyItem.get().getExtAttrName());
+            Attribute connObjectKeyAttr = syncDelta.getObject().
+                    getAttributeByName(connObjectKeyItem.get().getExtAttrName());
             if (connObjectKeyAttr != null) {
                 connObjectKey = AttributeUtil.getStringValue(connObjectKeyAttr);
             }
diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/DummyPullCorrelationRule.java
b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/DummyPullCorrelationRule.java
index e55033a..c37bda3 100644
--- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/DummyPullCorrelationRule.java
+++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/DummyPullCorrelationRule.java
@@ -22,13 +22,13 @@ import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
 import org.apache.syncope.core.persistence.api.dao.PullCorrelationRule;
 import org.apache.syncope.core.persistence.api.dao.PullCorrelationRuleConfClass;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision;
-import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.SyncDelta;
 
 @PullCorrelationRuleConfClass(DummyPullCorrelationRuleConf.class)
 public class DummyPullCorrelationRule implements PullCorrelationRule {
 
     @Override
-    public SearchCond getSearchCond(final ConnectorObject connObj, final Provision provision)
{
+    public SearchCond getSearchCond(final SyncDelta syncDelta, final Provision provision)
{
         return new SearchCond();
     }
 }
diff --git a/fit/core-reference/src/test/resources/TestPullRule.groovy b/fit/core-reference/src/test/resources/TestPullRule.groovy
index 2c8308f..222480e 100644
--- a/fit/core-reference/src/test/resources/TestPullRule.groovy
+++ b/fit/core-reference/src/test/resources/TestPullRule.groovy
@@ -22,7 +22,7 @@ import org.apache.syncope.core.persistence.api.dao.PullCorrelationRule
 import org.apache.syncope.core.persistence.api.dao.search.AttributeCond;
 import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
 import org.apache.syncope.core.persistence.api.entity.resource.Provision
-import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.identityconnectors.framework.common.objects.SyncDelta
 
 /**
  * Test pull rule relying on {@code email} attribute value.
@@ -31,11 +31,11 @@ import org.identityconnectors.framework.common.objects.ConnectorObject;
 class TestPullRule implements PullCorrelationRule {
 
   @Override
-  SearchCond getSearchCond(final ConnectorObject connObj, final Provision provision) {
+  SearchCond getSearchCond(final SyncDelta syncDelta, final Provision provision) {
     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