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 09:43:35 GMT
Repository: syncope
Updated Branches:
  refs/heads/2_0_X 5415d2019 -> 42592f079


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

Branch: refs/heads/2_0_X
Commit: 42592f0792f0e1bf8a1296ac54d69492bb500305
Parents: 5415d20
Author: fmartelli <fabio.martelli@gmail.com>
Authored: Tue Jul 10 11:43:14 2018 +0200
Committer: fmartelli <fabio.martelli@gmail.com>
Committed: Tue Jul 10 11:43:14 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/42592f07/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 fe6444d..a43e263 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 org.apache.commons.lang3.StringUtils;
@@ -29,6 +30,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;
@@ -134,7 +136,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())
== null) {
+            attrMap = new HashMap<>();
+        } else {
+            attrMap = EntityTOUtils.buildAttrMap(
+                    GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).getDerAttrs());
+        }
 
         for (DerSchemaTO schema : membershipSchemas.get(membershipTO.getGroupKey()).values())
{
             AttrTO attrTO = new AttrTO();

http://git-wip-us.apache.org/repos/asf/syncope/blob/42592f07/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 a778026..d7beff2 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
@@ -21,6 +21,7 @@ package org.apache.syncope.client.console.wizards.any;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import org.apache.commons.collections4.ListUtils;
@@ -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;
@@ -194,14 +196,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())
== null) {
+            attrMap = new HashMap<>();
+        } else {
+            attrMap = EntityTOUtils.buildAttrMap(
+                    GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).getPlainAttrs());
+        }
 
         for (PlainSchemaTO schema : membershipSchemas.get(membershipTO.getGroupKey()).values())
{
             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/42592f07/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 1909613..06f55f5 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 org.apache.commons.collections4.CollectionUtils;
@@ -147,8 +148,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()).getVirAttrs());
+        final Map<String, AttrTO> attrMap;
+        if (GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey())
== null) {
+            attrMap = new HashMap<>();
+        } else {
+            attrMap = EntityTOUtils.buildAttrMap(
+                    GroupableRelatableTO.class.cast(anyTO).getMembership(membershipTO.getGroupKey()).getVirAttrs());
+        }
 
         for (VirSchemaTO schema : membershipSchemas.get(membershipTO.getGroupKey()).values())
{
             AttrTO attrTO = new AttrTO();


Mime
View raw message