[SYNCOPE-1299] Small cleanup
authorFrancesco Chicchiriccò <ilgrosso@apache.org>
Wed, 18 Apr 2018 08:21:26 +0000 (10:21 +0200)
committerFrancesco Chicchiriccò <ilgrosso@apache.org>
Wed, 18 Apr 2018 08:26:37 +0000 (10:26 +0200)
client/console/src/main/java/org/apache/syncope/client/console/commons/status/StatusUtils.java
client/console/src/main/java/org/apache/syncope/client/console/status/AnyStatusDirectoryPanel.java
client/console/src/main/java/org/apache/syncope/client/console/status/ReconStatusPanel.java
client/console/src/main/java/org/apache/syncope/client/console/wizards/any/StatusPanel.java
common/lib/src/main/java/org/apache/syncope/common/lib/to/ReconStatus.java
core/logic/src/main/java/org/apache/syncope/core/logic/ReconciliationLogic.java

index 7ba310e..85df442 100644 (file)
@@ -25,6 +25,7 @@ import java.util.Objects;
 import java.util.Optional;
 import java.util.stream.Collectors;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
 import org.apache.syncope.client.console.commons.ConnIdSpecialName;
 import org.apache.syncope.client.console.commons.Constants;
 import org.apache.syncope.client.console.panels.LabelPanel;
@@ -52,12 +53,12 @@ public final class StatusUtils implements Serializable {
 
     private static final ReconciliationRestClient RECONCILIATION_REST_CLIENT = new ReconciliationRestClient();
 
-    public static List<ReconStatus> getReconStatuses(
+    public static List<Pair<String, ReconStatus>> getReconStatuses(
             final AnyTypeKind anyTypeKind, final String anyKey, final Collection<String> resources) {
 
         return resources.stream().map(resource -> {
             try {
-                return RECONCILIATION_REST_CLIENT.status(anyTypeKind, anyKey, resource);
+                return Pair.of(resource, RECONCILIATION_REST_CLIENT.status(anyTypeKind, anyKey, resource));
             } catch (Exception e) {
                 LOG.warn("Unexpected error for {} {} on {}", anyTypeKind, anyKey, resource, e);
                 return null;
index f39e823..bd54f00 100644 (file)
@@ -25,6 +25,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.stream.Collectors;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
 import org.apache.syncope.client.console.commons.Constants;
 import org.apache.syncope.client.console.commons.DirectoryDataProvider;
 import org.apache.syncope.client.console.commons.status.AbstractStatusBeanProvider;
@@ -286,7 +287,7 @@ public class AnyStatusDirectoryPanel
             final AnyTO actual = restClient.read(anyTO.getKey());
 
             List<StatusBean> statusBeans = actual.getResources().stream().map(resource -> {
-                List<ReconStatus> statuses = Collections.emptyList();
+                List<Pair<String, ReconStatus>> statuses = Collections.emptyList();
                 if (statusOnly) {
                     statuses = StatusUtils.
                             getReconStatuses(anyTypeKind, anyTO.getKey(), Arrays.asList(resource));
@@ -295,7 +296,7 @@ public class AnyStatusDirectoryPanel
                 return StatusUtils.getStatusBean(
                         actual,
                         resource,
-                        statuses.isEmpty() ? null : statuses.get(0).getOnResource(),
+                        statuses.isEmpty() ? null : statuses.get(0).getRight().getOnResource(),
                         actual instanceof GroupTO);
             }).collect(Collectors.toList());
 
index 91dc9ac..2f05ce7 100644 (file)
@@ -60,9 +60,11 @@ public class ReconStatusPanel extends RemoteObjectPanel {
 
     @Override
     protected Pair<ConnObjectTO, ConnObjectTO> getConnObjectTOs() {
-        List<ReconStatus> statuses =
+        List<Pair<String, ReconStatus>> statuses =
                 StatusUtils.getReconStatuses(anyTypeKind, anyKey, Arrays.asList(resource));
 
-        return statuses.isEmpty() ? null : Pair.of(statuses.get(0).getOnSyncope(), statuses.get(0).getOnResource());
+        return statuses.isEmpty()
+                ? null
+                : Pair.of(statuses.get(0).getRight().getOnSyncope(), statuses.get(0).getRight().getOnResource());
     }
 }
index 93a338a..41ba1e3 100644 (file)
@@ -72,8 +72,8 @@ public class StatusPanel extends Panel {
         init(any, model, StatusUtils.getReconStatuses(
                 AnyTypeKind.fromTOClass(any.getClass()), any.getKey(), any.getResources()).stream().
                 map(status -> Triple.<ConnObjectTO, ConnObjectWrapper, String>of(
-                status.getOnSyncope(),
-                new ConnObjectWrapper(any, status.getResource(), status.getOnResource()),
+                status.getRight().getOnSyncope(),
+                new ConnObjectWrapper(any, status.getLeft(), status.getRight().getOnResource()),
                 null)).
                 collect(Collectors.toList()), pageRef, false);
     }
index de48cac..da601c0 100644 (file)
@@ -26,28 +26,17 @@ import javax.xml.bind.annotation.XmlType;
 /**
  * Reconciliation status.
  */
-@XmlRootElement(name = "reconciliationStatus")
+@XmlRootElement(name = "reconStatus")
 @XmlType
 public class ReconStatus extends AbstractBaseBean {
 
     private static final long serialVersionUID = -8516345256596521490L;
 
-    private String resource;
-
     private ConnObjectTO onSyncope;
 
     private ConnObjectTO onResource;
 
     @Schema(accessMode = Schema.AccessMode.READ_ONLY)
-    public String getResource() {
-        return resource;
-    }
-
-    public void setResource(final String resource) {
-        this.resource = resource;
-    }
-
-    @Schema(accessMode = Schema.AccessMode.READ_ONLY)
     public ConnObjectTO getOnSyncope() {
         return onSyncope;
     }
index d2315c5..88adeaa 100644 (file)
@@ -171,7 +171,6 @@ public class ReconciliationLogic extends AbstractTransactionalLogic<AbstractBase
         Pair<Any<?>, Provision> init = init(anyTypeKind, anyKey, resourceKey);
 
         ReconStatus status = new ReconStatus();
-        status.setResource(resourceKey);
         status.setOnSyncope(getOnSyncope(init.getLeft(), init.getRight(), resourceKey));
         status.setOnResource(getOnResource(init.getLeft(), init.getRight()));