You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2018/12/05 12:26:04 UTC

[syncope] branch 2_1_X updated (c666f56 -> 27d507f)

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

ilgrosso pushed a change to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git.


    from c666f56  [SYNCOPE-1381] User requests and user request forms management in enduser UI
     new 9c9ea75  [SYNCOPE-1407] Fix test
     new 27d507f  [SYNCOPE-1408] Ensure all original, unmodified attributes are considered, during patch generation for update

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../wizards/any/AnyObjectWizardBuilder.java        |  2 +-
 .../console/wizards/any/AnyWizardBuilder.java      | 41 +++++++++++++++++-----
 .../console/wizards/any/GroupWizardBuilder.java    |  2 +-
 .../console/wizards/any/UserWizardBuilder.java     |  2 +-
 .../apache/syncope/fit/console/UsersITCase.java    |  2 +-
 5 files changed, 37 insertions(+), 12 deletions(-)


[syncope] 01/02: [SYNCOPE-1407] Fix test

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 9c9ea751f40166b182ece56a6550da5dc217e9fe
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Wed Dec 5 11:22:52 2018 +0100

    [SYNCOPE-1407] Fix test
---
 .../src/test/java/org/apache/syncope/fit/console/UsersITCase.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/UsersITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/UsersITCase.java
index d1c07ba..6e18a45 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/console/UsersITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/console/UsersITCase.java
@@ -371,7 +371,7 @@ public class UsersITCase extends AbstractConsoleITCase {
         formTester.setValue("view:plainSchemas:tabs:0:body:content:schemas:1:panel:field:timepicker", "12:00 AM");
 
         formTester.setValue("view:plainSchemas:tabs:0:body:"
-                + "content:schemas:8:panel:multiValueContainer:innerForm:content:view:0:panel:field", "1/19/17");
+                + "content:schemas:8:panel:multiValueContainer:innerForm:content:view:0:panel:field", "2017-01-19");
 
         formTester.submit("buttons:finish");
 


[syncope] 02/02: [SYNCOPE-1408] Ensure all original, unmodified attributes are considered, during patch generation for update

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 27d507f2b5631bebf152aeb9ebbddccf35718904
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Wed Dec 5 13:07:16 2018 +0100

    [SYNCOPE-1408] Ensure all original, unmodified attributes are considered, during patch generation for update
---
 .../wizards/any/AnyObjectWizardBuilder.java        |  2 +-
 .../console/wizards/any/AnyWizardBuilder.java      | 41 +++++++++++++++++-----
 .../console/wizards/any/GroupWizardBuilder.java    |  2 +-
 .../console/wizards/any/UserWizardBuilder.java     |  2 +-
 4 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectWizardBuilder.java
index 8e21f0f..779b682 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/AnyObjectWizardBuilder.java
@@ -72,7 +72,7 @@ public class AnyObjectWizardBuilder extends AnyWizardBuilder<AnyObjectTO> implem
         if (inner.getKey() == null) {
             result = anyObjectRestClient.create(inner);
         } else {
-            inner.getPlainAttrs().addAll(cleanEmptyPlainAttrs(inner.getPlainAttrs()));
+            fixPlainAndVirAttrs(inner, getOriginalItem().getInnerObject());
             AnyObjectPatch patch = AnyOperations.diff(inner, getOriginalItem().getInnerObject(), false);
 
             // update just if it is changed
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 ec3ff78..783aa79 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
@@ -18,9 +18,7 @@
  */
 package org.apache.syncope.client.console.wizards.any;
 
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 import org.apache.syncope.client.console.layout.AbstractAnyFormLayout;
 import org.apache.syncope.client.console.layout.AnyForm;
 import org.apache.syncope.client.console.layout.AnyObjectFormLayoutInfo;
@@ -29,8 +27,8 @@ 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;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.extensions.wizard.WizardModel;
@@ -175,10 +173,37 @@ public abstract class AnyWizardBuilder<A extends AnyTO> extends AjaxWizardBuilde
         }
     }
 
-    protected Set<AttrTO> cleanEmptyPlainAttrs(final Set<AttrTO> plainAttrs) {
-        Set<AttrTO> newPlainAttrs = new HashSet<>(plainAttrs);
-        plainAttrs.clear();
-        plainAttrs.removeIf(attr -> attr.getValues().isEmpty());
-        return newPlainAttrs;
+    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));
+        if (updated instanceof GroupableRelatableTO && original instanceof GroupableRelatableTO) {
+            GroupableRelatableTO.class.cast(original).getMemberships().forEach(oMemb -> {
+                GroupableRelatableTO.class.cast(updated).getMembership(oMemb.getGroupKey()).ifPresent(uMemb -> {
+                    oMemb.getPlainAttrs().stream().
+                            filter(attr -> uMemb.getPlainAttr(attr.getSchema()).isPresent()).
+                            forEach(attr -> uMemb.getPlainAttrs().add(attr));
+                    oMemb.getVirAttrs().stream().
+                            filter(attr -> uMemb.getVirAttr(attr.getSchema()).isPresent()).
+                            forEach(attr -> uMemb.getVirAttrs().add(attr));
+                });
+            });
+        }
+
+        // remove from the updated object any plain or virtual attribute without values, thus triggering for removal in
+        // the generated patch
+        updated.getPlainAttrs().removeIf(attr -> attr.getValues().isEmpty());
+        updated.getVirAttrs().removeIf(attr -> attr.getValues().isEmpty());
+        if (updated instanceof GroupableRelatableTO) {
+            GroupableRelatableTO.class.cast(updated).getMemberships().forEach(memb -> {
+                memb.getPlainAttrs().removeIf(attr -> attr.getValues().isEmpty());
+                memb.getVirAttrs().removeIf(attr -> attr.getValues().isEmpty());
+            });
+        }
     }
 }
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupWizardBuilder.java
index 81c6648..a29078f 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/GroupWizardBuilder.java
@@ -91,7 +91,7 @@ public class GroupWizardBuilder extends AnyWizardBuilder<GroupTO> implements Gro
         if (inner.getKey() == null) {
             result = groupRestClient.create(inner);
         } else {
-            inner.getPlainAttrs().addAll(cleanEmptyPlainAttrs(inner.getPlainAttrs()));
+            fixPlainAndVirAttrs(inner, getOriginalItem().getInnerObject());
             GroupPatch patch = AnyOperations.diff(inner, getOriginalItem().getInnerObject(), false);
             GroupTO originaObj = getOriginalItem().getInnerObject();
 
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserWizardBuilder.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserWizardBuilder.java
index 12fd4d9..5e17524 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserWizardBuilder.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/UserWizardBuilder.java
@@ -82,7 +82,7 @@ public class UserWizardBuilder extends AnyWizardBuilder<UserTO> implements UserF
                     ? UserWrapper.class.cast(modelObject).isStorePasswordInSyncope()
                     : StringUtils.isNotBlank(inner.getPassword()));
         } else {
-            inner.getPlainAttrs().addAll(cleanEmptyPlainAttrs(inner.getPlainAttrs()));
+            fixPlainAndVirAttrs(inner, getOriginalItem().getInnerObject());
             UserPatch patch = AnyOperations.diff(inner, getOriginalItem().getInnerObject(), false);
 
             if (StringUtils.isNotBlank(inner.getPassword())) {