Repository: syncope Updated Branches: refs/heads/master 24a912591 -> be774ee67
anyTO update: plain attributes are deleted when values list is empty (if not incremental edit) Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/c2bbd0a8 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/c2bbd0a8 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/c2bbd0a8 Branch: refs/heads/master Commit: c2bbd0a860c3add02f4bb100ac68f5e11e5c3395 Parents: 24a9125 Author: Andrea Patricelli <[email protected]> Authored: Fri Oct 30 17:14:11 2015 +0100 Committer: Andrea Patricelli <[email protected]> Committed: Fri Oct 30 17:14:11 2015 +0100 ---------------------------------------------------------------------- .../org/apache/syncope/common/lib/AnyOperations.java | 15 ++++++++++++--- .../syncope/fit/core/reference/GroupITCase.java | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/c2bbd0a8/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java ---------------------------------------------------------------------- diff --git a/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java b/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java index 0e5bec3..d2d6891 100644 --- a/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java +++ b/common/lib/src/main/java/org/apache/syncope/common/lib/AnyOperations.java @@ -121,9 +121,18 @@ public final class AnyOperations { } for (AttrTO attrTO : updatedAttrs.values()) { - AttrPatch patch = new AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).attrTO(attrTO).build(); - if (!patch.isEmpty()) { - result.getPlainAttrs().add(patch); + if (attrTO.getValues().isEmpty()) { + if (!incremental) { + result.getPlainAttrs().add(new AttrPatch.Builder(). + operation(PatchOperation.DELETE). + attrTO(new AttrTO.Builder().schema(attrTO.getSchema()).build()). + build()); + } + } else { + AttrPatch patch = new AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).attrTO(attrTO).build(); + if (!patch.isEmpty()) { + result.getPlainAttrs().add(patch); + } } } http://git-wip-us.apache.org/repos/asf/syncope/blob/c2bbd0a8/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java index d247aac..170ca91 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java @@ -222,6 +222,12 @@ public class GroupITCase extends AbstractITCase { assertEquals(modName, groupTO.getName()); assertEquals(2, groupTO.getPlainAttrs().size()); + + groupTO.getPlainAttrMap().get("show").getValues().clear(); + + groupTO = groupService.update(groupTO).readEntity(new GenericType<ProvisioningResult<GroupTO>>(){}).getAny(); + + assertFalse(groupTO.getPlainAttrMap().containsKey("show")); } @Test
