syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmarte...@apache.org
Subject syncope git commit: [SYNCOPE-1333] same fix on Derived and Plain + code improving
Date Tue, 10 Jul 2018 10:29:34 GMT
Repository: syncope
Updated Branches:
  refs/heads/master 2d233d197 -> 2c3754b2c


[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/2c3754b2
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/2c3754b2
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/2c3754b2

Branch: refs/heads/master
Commit: 2c3754b2c195e414dd1c6c28604a6a94b635fed2
Parents: 2d233d1
Author: fmartelli <fabio.martelli@gmail.com>
Authored: Tue Jul 10 12:23:52 2018 +0200
Committer: fmartelli <fabio.martelli@gmail.com>
Committed: Tue Jul 10 12:24:28 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/2c3754b2/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/2c3754b2/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/2c3754b2/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();


Mime
View raw message