[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

2022-08-29 Thread GitBox


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 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 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())
+|| 

[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

2022-08-25 Thread GitBox


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 attributes;
+
+private Set attributeDeltas;
+
+@JsonCreator
+public PropagationData(@JsonProperty("attributes") final Set 
attributes) {
+this.attributes = attributes;
+}
+
+public Set 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-unsubscr...@syncope.apache.org

For queries about this service, please contact Infrastructure at:
us...@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

2022-08-24 Thread GitBox


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 extends 
JsonSerializer {
+
+public static final String BYTE_ARRAY_PREFIX = "";
+
+public static final String BYTE_ARRAY_SUFFIX = "";
+
+protected void doSerialize(final List 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 attributes) {
+instance.setAttributes(attributes);
+return this;
+}
+
+public Builder attributeDeltas(final Set 
attributeDeltas) {
+instance.setAttributeDeltas(attributeDeltas);
+return this;
+}
+
+public PropagationData build() {
+return instance;
+}
+}
+
+private Set attributes;
+
+private Set attributeDeltas;
+
+public Set 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