Repository: syncope Updated Branches: refs/heads/2_1_X 2a6138672 -> 7c6ab5e9b
[SYNCOPE-1333] same fix on Derived and Plain + code improving Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/7c6ab5e9 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/7c6ab5e9 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/7c6ab5e9 Branch: refs/heads/2_1_X Commit: 7c6ab5e9b780699d50dde340611d790443426e9f Parents: 2a61386 Author: fmartelli <[email protected]> Authored: Tue Jul 10 12:23:52 2018 +0200 Committer: fmartelli <[email protected]> Committed: Tue Jul 10 12:23:52 2018 +0200 ---------------------------------------------------------------------- .../syncope/client/console/wizards/any/DerAttrs.java | 10 +++++++++- .../syncope/client/console/wizards/any/PlainAttrs.java | 12 ++++++++++-- .../syncope/client/console/wizards/any/VirAttrs.java | 10 ++++++++-- 3 files changed, 27 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/7c6ab5e9/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/DerAttrs.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/DerAttrs.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/DerAttrs.java index f064402..dd94bc2 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/DerAttrs.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/DerAttrs.java @@ -20,6 +20,7 @@ package org.apache.syncope.client.console.wizards.any; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -31,6 +32,7 @@ import org.apache.syncope.common.lib.EntityTOUtils; import org.apache.syncope.common.lib.to.AnyTO; import org.apache.syncope.common.lib.to.AttrTO; import org.apache.syncope.common.lib.to.DerSchemaTO; +import org.apache.syncope.common.lib.to.GroupableRelatableTO; import org.apache.syncope.common.lib.to.MembershipTO; import org.apache.syncope.common.lib.types.SchemaType; import org.apache.wicket.extensions.markup.html.tabs.AbstractTab; @@ -135,7 +137,13 @@ public class DerAttrs extends AbstractAttrs<DerSchemaTO> { protected void setAttrs(final MembershipTO membershipTO) { List<AttrTO> attrs = new ArrayList<>(); - Map<String, AttrTO> attrMap = EntityTOUtils.buildAttrMap(anyTO.getDerAttrs()); + final Map<String, AttrTO> attrMap; + if (GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).isPresent()) { + attrMap = EntityTOUtils.buildAttrMap(GroupableRelatableTO.class.cast(anyTO) + .getMembership(membershipTO.getGroupKey()).get().getDerAttrs()); + } else { + attrMap = new HashMap<>(); + } membershipSchemas.get(membershipTO.getGroupKey()).values().forEach(schema -> { AttrTO attrTO = new AttrTO(); http://git-wip-us.apache.org/repos/asf/syncope/blob/7c6ab5e9/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java index 3fcecf5..722adc9 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/PlainAttrs.java @@ -20,6 +20,7 @@ package org.apache.syncope.client.console.wizards.any; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -47,6 +48,7 @@ import org.apache.syncope.common.lib.to.AnyObjectTO; 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.PlainSchemaTO; import org.apache.syncope.common.lib.to.UserTO; @@ -189,14 +191,20 @@ public class PlainAttrs extends AbstractAttrs<PlainSchemaTO> { protected void setAttrs(final MembershipTO membershipTO) { List<AttrTO> attrs = new ArrayList<>(); - Map<String, AttrTO> attrMap = EntityTOUtils.buildAttrMap(membershipTO.getPlainAttrs()); + final Map<String, AttrTO> attrMap; + if (GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).isPresent()) { + attrMap = EntityTOUtils.buildAttrMap(GroupableRelatableTO.class.cast(anyTO) + .getMembership(membershipTO.getGroupKey()).get().getPlainAttrs()); + } else { + attrMap = new HashMap<>(); + } attrs.addAll(membershipSchemas.get(membershipTO.getGroupKey()).values().stream(). map(schema -> { AttrTO attrTO = new AttrTO(); attrTO.setSchema(schema.getKey()); if (attrMap.get(schema.getKey()) == null || attrMap.get(schema.getKey()).getValues().isEmpty()) { - attrTO.getValues().add(""); + attrTO.getValues().add(StringUtils.EMPTY); // is important to set the schema info only after values setting attrTO.setSchemaInfo(schema); http://git-wip-us.apache.org/repos/asf/syncope/blob/7c6ab5e9/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java ---------------------------------------------------------------------- diff --git a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java index 042e61e..d2ceaef 100644 --- a/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java +++ b/client/console/src/main/java/org/apache/syncope/client/console/wizards/any/VirAttrs.java @@ -20,6 +20,7 @@ package org.apache.syncope.client.console.wizards.any; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -146,8 +147,13 @@ public class VirAttrs extends AbstractAttrs<VirSchemaTO> { protected void setAttrs(final MembershipTO membershipTO) { List<AttrTO> attrs = new ArrayList<>(); - Map<String, AttrTO> attrMap = EntityTOUtils.buildAttrMap( - GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).get().getVirAttrs()); + final Map<String, AttrTO> attrMap; + if (GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).isPresent()) { + attrMap = EntityTOUtils.buildAttrMap(GroupableRelatableTO.class.cast(anyTO) + .getMembership(membershipTO.getGroupKey()).get().getVirAttrs()); + } else { + attrMap = new HashMap<>(); + } attrs.addAll(membershipSchemas.get(membershipTO.getGroupKey()).values().stream().map(schema -> { AttrTO attrTO = new AttrTO();
