You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by md...@apache.org on 2019/01/14 10:23:33 UTC

[syncope] branch 2_1_X updated: [SYNCOPE-1408] Fix plain and vir re-add

This is an automated email from the ASF dual-hosted git repository.

mdisabatino 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 4cd21ad  [SYNCOPE-1408] Fix plain and vir re-add
4cd21ad is described below

commit 4cd21ad1862cee6190226a60244f2f640888e585
Author: Marco Di Sabatino Di Diodoro <ma...@tirasa.net>
AuthorDate: Mon Jan 14 11:23:18 2019 +0100

    [SYNCOPE-1408] Fix plain and vir re-add
---
 .../client/console/wizards/any/AnyWizardBuilder.java    | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
index 783aa79..4076d77 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyWizardBuilder.java
@@ -27,6 +27,7 @@ import org.apache.syncope.client.console.layout.UserFormLayoutInfo;
 import org.apache.syncope.client.console.wizards.AjaxWizard;
 import org.apache.syncope.client.console.wizards.AjaxWizardBuilder;
 import org.apache.syncope.common.lib.to.AnyTO;
+import org.apache.syncope.common.lib.to.AttrTO;
 import org.apache.syncope.common.lib.to.GroupTO;
 import org.apache.syncope.common.lib.to.GroupableRelatableTO;
 import org.apache.syncope.common.lib.to.UserTO;
@@ -176,12 +177,16 @@ public abstract class AnyWizardBuilder<A extends AnyTO> extends AjaxWizardBuilde
     protected void fixPlainAndVirAttrs(final AnyTO updated, final AnyTO original) {
         // re-add to the updated object any missing plain or virtual attribute (compared to original): this to cope with
         // form layout, which might have not included some plain or virtual attributes
-        original.getPlainAttrs().stream().
-                filter(attr -> updated.getPlainAttr(attr.getSchema()).isPresent()).
-                forEach(attr -> updated.getPlainAttrs().add(attr));
-        original.getVirAttrs().stream().
-                filter(attr -> updated.getVirAttr(attr.getSchema()).isPresent()).
-                forEach(attr -> updated.getVirAttrs().add(attr));
+        for (AttrTO plainAttrTO : original.getPlainAttrs()) {
+            if (!updated.getPlainAttr(plainAttrTO.getSchema()).isPresent()) {
+                updated.getPlainAttrs().add(plainAttrTO);
+            }
+        }
+        for (AttrTO virAttrTO : original.getVirAttrs()) {
+            if (!updated.getVirAttr(virAttrTO.getSchema()).isPresent()) {
+                updated.getVirAttrs().add(virAttrTO);
+            }
+        }
         if (updated instanceof GroupableRelatableTO && original instanceof GroupableRelatableTO) {
             GroupableRelatableTO.class.cast(original).getMemberships().forEach(oMemb -> {
                 GroupableRelatableTO.class.cast(updated).getMembership(oMemb.getGroupKey()).ifPresent(uMemb -> {