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:01 UTC

[syncope] branch 2_0_X updated (45b3f96 -> 80123cc)

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

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


    from 45b3f96  [SYNCOPE-1407] Passing conversion pattern to AjaxDatePicker (but not AjaxDateTimePicker)
     new e990064  [SYNCOPE-1407] Fix test
     new 80123cc  [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      | 68 +++++++++++++++++++---
 .../console/wizards/any/GroupWizardBuilder.java    |  2 +-
 .../console/wizards/any/UserWizardBuilder.java     |  2 +-
 .../apache/syncope/fit/console/UsersITCase.java    |  2 +-
 5 files changed, 65 insertions(+), 11 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_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit e9900646034ef273a9d27abf0f69d28614108dbc
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 075e01b..d385e53 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
@@ -372,7 +372,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_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 80123cc0bb8849c0b1edb7c38079fda22e3056af
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      | 68 +++++++++++++++++++---
 .../console/wizards/any/GroupWizardBuilder.java    |  2 +-
 .../console/wizards/any/UserWizardBuilder.java     |  2 +-
 4 files changed, 64 insertions(+), 10 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 4ba73c8..835bb7a 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
@@ -53,7 +53,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 a316510..b5de085 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.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.Predicate;
 import org.apache.syncope.client.console.layout.AbstractAnyFormLayout;
@@ -33,6 +31,8 @@ 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.MembershipTO;
 import org.apache.syncope.common.lib.to.UserTO;
 import org.apache.wicket.PageReference;
 import org.apache.wicket.extensions.wizard.WizardModel;
@@ -177,16 +177,70 @@ 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();
-        CollectionUtils.filterInverse(newPlainAttrs, new Predicate<AttrTO>() {
+    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
+        for (AttrTO attr : original.getPlainAttrs()) {
+            if (updated.getPlainAttr(attr.getSchema()) == null) {
+                updated.getPlainAttrs().add(attr);
+            }
+        }
+        for (AttrTO attr : original.getVirAttrs()) {
+            if (updated.getVirAttr(attr.getSchema()) == null) {
+                updated.getVirAttrs().add(attr);
+            }
+        }
+        if (updated instanceof GroupableRelatableTO && original instanceof GroupableRelatableTO) {
+            for (MembershipTO oMemb : GroupableRelatableTO.class.cast(original).getMemberships()) {
+                MembershipTO uMemb = GroupableRelatableTO.class.cast(updated).getMembership(oMemb.getGroupKey());
+                if (uMemb != null) {
+                    for (AttrTO attr : oMemb.getPlainAttrs()) {
+                        if (uMemb.getPlainAttr(attr.getSchema()) == null) {
+                            uMemb.getPlainAttrs().add(attr);
+                        }
+                    }
+                    for (AttrTO attr : oMemb.getVirAttrs()) {
+                        if (uMemb.getVirAttr(attr.getSchema()) == null) {
+                            uMemb.getVirAttrs().add(attr);
+                        }
+                    }
+                }
+            }
+        }
+
+        // remove from the updated object any plain or virtual attribute without values, thus triggering for removal in
+        // the generated patch
+        CollectionUtils.filterInverse(updated.getPlainAttrs(), new Predicate<AttrTO>() {
 
             @Override
             public boolean evaluate(final AttrTO attr) {
                 return attr.getValues().isEmpty();
             }
         });
-        return newPlainAttrs;
+        CollectionUtils.filterInverse(updated.getVirAttrs(), new Predicate<AttrTO>() {
+
+            @Override
+            public boolean evaluate(final AttrTO attr) {
+                return attr.getValues().isEmpty();
+            }
+        });
+        if (updated instanceof GroupableRelatableTO) {
+            for (MembershipTO memb : GroupableRelatableTO.class.cast(updated).getMemberships()) {
+                CollectionUtils.filterInverse(memb.getPlainAttrs(), new Predicate<AttrTO>() {
+
+                    @Override
+                    public boolean evaluate(final AttrTO attr) {
+                        return attr.getValues().isEmpty();
+                    }
+                });
+                CollectionUtils.filterInverse(memb.getVirAttrs(), new Predicate<AttrTO>() {
+
+                    @Override
+                    public boolean evaluate(final AttrTO attr) {
+                        return 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 52fd40c..a1593d9 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
@@ -72,7 +72,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 603f7fe..62d4468 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())) {