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-unsubscr...@syncope.apache.org

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

Reply via email to