You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@syncope.apache.org by GitBox <gi...@apache.org> on 2022/08/24 14:19:49 UTC

[GitHub] [syncope] ilgrosso opened a new pull request, #370: [SYNCOPE-1692] Refactoring the propagation process to allow for ConnId's updateDelta

ilgrosso opened a new pull request, #370:
URL: https://github.com/apache/syncope/pull/370

   Missing:
   
   - [ ] additional tests
   - [ ] docs update


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [syncope] ilgrosso merged pull request #370: [SYNCOPE-1692] Refactoring the propagation process to allow for ConnId's updateDelta

Posted by GitBox <gi...@apache.org>.
ilgrosso merged PR #370:
URL: https://github.com/apache/syncope/pull/370


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [syncope] github-code-scanning[bot] commented on a diff in pull request #370: [SYNCOPE-1692] Refactoring the propagation process to allow for ConnId's updateDelta

Posted by GitBox <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #370:
URL: https://github.com/apache/syncope/pull/370#discussion_r957493705


##########
core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/DefaultPropagationReporter.java:
##########
@@ -77,19 +76,16 @@
 
         LOG.debug("Propagation error: {} priority resource failed to propagate", failingResource);
 
-        Optional<PropagationTaskInfo> propagationTask = taskInfos.stream().
-                filter(task -> task.getResource().equals(failingResource)).findFirst();
-
-        if (propagationTask.isPresent()) {
-            PropagationStatus status = new PropagationStatus();
-            status.setResource(propagationTask.get().getResource());
-            status.setStatus(ExecStatus.FAILURE);
-            status.setFailureReason(
-                    "Propagation error: " + failingResource + " priority resource failed to propagate.");
-            add(status);
-        } else {
-            LOG.error("Could not find {} for {}", PropagationTask.class.getName(), failingResource);
-        }
+        taskInfos.stream().filter(task -> task.getResource().equals(failingResource)).findFirst().ifPresentOrElse(

Review Comment:
   ## Equals on incomparable types
   
   Call to equals() comparing incomparable types ExternalResource and String.
   
   [Show more details](https://github.com/apache/syncope/security/code-scanning/1141)



##########
core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/propagation/PropagationActions.java:
##########
@@ -65,22 +63,22 @@
      * This method can throw {@link org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException} to
      * ignore the reported error and continue.
      *
-     * @param task propagation task
+     * @param taskInfo propagation task
      * @param execution execution result
      * @param error propagation error
      */
-    default void onError(PropagationTask task, TaskExec execution, Exception error) {
+    default void onError(PropagationTaskInfo taskInfo, TaskExec execution, Exception error) {
         // do nothing
     }
 
     /**
      * Executes logic after actual propagation.
      *
-     * @param task propagation task
+     * @param taskInfo propagation task
      * @param execution execution result
      * @param afterObj connector object read after propagation
      */
-    default void after(PropagationTask task, TaskExec execution, ConnectorObject afterObj) {
+    default void after(PropagationTaskInfo taskInfo, TaskExec execution, ConnectorObject afterObj) {

Review Comment:
   ## Useless parameter
   
   The parameter afterObj is unused.
   
   [Show more details](https://github.com/apache/syncope/security/code-scanning/1133)



##########
core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/AbstractPropagationTaskExecutor.java:
##########
@@ -660,110 +706,116 @@
~    /**
~     * Check whether an execution has to be stored, for a given task.
~     *
~     * @param task propagation task
      * @param execution to be decide whether to store or not
      * @return true if execution has to be store, false otherwise
      */
-    protected boolean hasToBeregistered(final PropagationTask task, final TaskExec execution) {
+    protected Optional<PropagationTask> hasToBeregistered(
+            final PropagationTaskInfo taskInfo, final TaskExec execution) {
+
         boolean result;
 
         boolean failed = ExecStatus.valueOf(execution.getStatus()) != ExecStatus.SUCCESS;
 
-        switch (task.getOperation()) {
+        ExternalResource resource = taskInfo.getResource();
+
+        switch (taskInfo.getOperation()) {
 
             case CREATE:
-                result = (failed && task.getResource().getCreateTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal())
-                        || task.getResource().getCreateTraceLevel() == TraceLevel.ALL;
+                result = (failed && resource.getCreateTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal())
+                        || resource.getCreateTraceLevel() == TraceLevel.ALL;
                 break;
 
             case UPDATE:
-                result = (failed && task.getResource().getUpdateTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal())
-                        || task.getResource().getUpdateTraceLevel() == TraceLevel.ALL;
+                result = (failed && resource.getUpdateTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal())
+                        || resource.getUpdateTraceLevel() == TraceLevel.ALL;
                 break;
 
             case DELETE:
-                result = (failed && task.getResource().getDeleteTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal())
-                        || task.getResource().getDeleteTraceLevel() == TraceLevel.ALL;
+                result = (failed && resource.getDeleteTraceLevel().ordinal() >= TraceLevel.FAILURES.ordinal())
+                        || resource.getDeleteTraceLevel() == TraceLevel.ALL;
                 break;
 
             default:
                 result = false;
         }
 
-        return result;
+        if (!result) {
+            return Optional.empty();
+        }
+
+        PropagationTask task = entityFactory.newEntity(PropagationTask.class);
+        task.setResource(resource);
+        task.setObjectClassName(taskInfo.getObjectClass().getObjectClassValue());
+        task.setAnyTypeKind(taskInfo.getAnyTypeKind());
+        task.setAnyType(taskInfo.getAnyType());
+        task.setEntityKey(taskInfo.getEntityKey());
+        task.setOperation(taskInfo.getOperation());
+        task.setConnObjectKey(taskInfo.getConnObjectKey());
+        task.setOldConnObjectKey(taskInfo.getOldConnObjectKey());
+        task.setPropagationData(taskInfo.getPropagationData());
+
+        return Optional.of(task);
     }
 
     /**
      * Get remote object for given task.
      *
-     * @param connector connector facade proxy.
-     * @param task current propagation task.
+     * @param connector connector facade proxy
+     * @param taskInfo current propagation task
      * @param provision provision
      * @param actions propagation actions
      * @param latest 'FALSE' to retrieve object using old connObjectKey if not null.
      * @return remote connector object.
      */
     protected ConnectorObject getRemoteObject(
-            final PropagationTask task,
+            final PropagationTaskInfo taskInfo,
             final Connector connector,
             final Provision provision,
             final List<PropagationActions> actions,
             final boolean latest) {
 
-        if (task.getResource().getPropagationPolicy() != null
-                && !task.getResource().getPropagationPolicy().isPrefetch()) {
+        String connObjectKeyValue = latest || taskInfo.getOldConnObjectKey() == null
+                ? taskInfo.getConnObjectKey()
+                : taskInfo.getOldConnObjectKey();
 
-            LOG.debug("Skipping because of configured PropagationPolicy");
-            return null;
-        }
-
-        String connObjectKeyValue = latest || task.getOldConnObjectKey() == null
-                ? task.getConnObjectKey()
-                : task.getOldConnObjectKey();
-
-        List<ConnectorObject> matches = outboundMatcher.match(task, connector, provision, actions, connObjectKeyValue);
-        LOG.debug("Found for propagation task {}: {}", task, matches);
+        List<ConnectorObject> matches =
+                outboundMatcher.match(taskInfo, connector, provision, actions, connObjectKeyValue);
+        LOG.debug("Found for propagation task {}: {}", taskInfo, matches);

Review Comment:
   ## Use of default toString()
   
   Default toString(): PropagationTaskInfo inherits toString() from Object, and so is not suitable for printing.
   
   [Show more details](https://github.com/apache/syncope/security/code-scanning/1143)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [syncope] github-code-scanning[bot] commented on a diff in pull request #370: [SYNCOPE-1692] Refactoring the propagation process to allow for ConnId's updateDelta

Posted by GitBox <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #370:
URL: https://github.com/apache/syncope/pull/370#discussion_r953914138


##########
core/provisioning-api/src/main/java/org/apache/syncope/core/provisioning/api/serialization/AbstractValueSerializer.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.api.serialization;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import java.io.IOException;
+import java.util.Base64;
+import java.util.List;
+import org.identityconnectors.common.security.GuardedString;
+
+public abstract class AbstractValueSerializer<T extends Object> extends JsonSerializer<T> {
+
+    public static final String BYTE_ARRAY_PREFIX = "<binary>";
+
+    public static final String BYTE_ARRAY_SUFFIX = "</binary>";
+
+    protected void doSerialize(final List<Object> value, final JsonGenerator jgen) throws IOException {
+        if (value == null) {
+            jgen.writeNull();
+        } else {
+            jgen.writeStartArray();
+            for (Object v : value) {
+                if (v == null) {

Review Comment:
   ## Chain of 'instanceof' tests
   
   This if block performs a chain of 6 type tests - consider alternatives, e.g. polymorphism or the visitor pattern.
   
   [Show more details](https://github.com/apache/syncope/security/code-scanning/1123)



##########
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/PropagationData.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.api.entity.task;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.io.Serializable;
+import java.util.Set;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.AttributeDelta;
+
+public class PropagationData implements Serializable {
+
+    private static final long serialVersionUID = -6193849782964810456L;
+
+    public static class Builder {
+
+        private final PropagationData instance;
+
+        public Builder() {
+            instance = new PropagationData();
+        }
+
+        public Builder attributes(final Set<Attribute> attributes) {
+            instance.setAttributes(attributes);
+            return this;
+        }
+
+        public Builder attributeDeltas(final Set<AttributeDelta> attributeDeltas) {
+            instance.setAttributeDeltas(attributeDeltas);
+            return this;
+        }
+
+        public PropagationData build() {
+            return instance;
+        }
+    }
+
+    private Set<Attribute> attributes;
+
+    private Set<AttributeDelta> attributeDeltas;
+
+    public Set<Attribute> getAttributes() {

Review Comment:
   ## Exposing internal representation
   
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](1).
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](2).
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](3).
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](4).
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](5).
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](6).
   
   [Show more details](https://github.com/apache/syncope/security/code-scanning/1124)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [syncope] github-code-scanning[bot] commented on a diff in pull request #370: [SYNCOPE-1692] Refactoring the propagation process to allow for ConnId's updateDelta

Posted by GitBox <gi...@apache.org>.
github-code-scanning[bot] commented on code in PR #370:
URL: https://github.com/apache/syncope/pull/370#discussion_r954765216


##########
core/persistence-api/src/main/java/org/apache/syncope/core/persistence/api/entity/task/PropagationData.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.api.entity.task;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.io.Serializable;
+import java.util.Set;
+import org.identityconnectors.framework.common.objects.Attribute;
+import org.identityconnectors.framework.common.objects.AttributeDelta;
+
+public class PropagationData implements Serializable {
+
+    private static final long serialVersionUID = -6193849782964810456L;
+
+    private final Set<Attribute> attributes;
+
+    private Set<AttributeDelta> attributeDeltas;
+
+    @JsonCreator
+    public PropagationData(@JsonProperty("attributes") final Set<Attribute> attributes) {
+        this.attributes = attributes;
+    }
+
+    public Set<Attribute> getAttributes() {

Review Comment:
   ## Exposing internal representation
   
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](1).
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](2).
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](3).
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](4).
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](5).
   getAttributes exposes the internal representation stored in field attributes. The value may be modified [after this call to getAttributes](6).
   
   [Show more details](https://github.com/apache/syncope/security/code-scanning/1125)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org