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 2019/03/12 14:55:29 UTC

[syncope] branch 2_1_X updated: [SYNCOPE-1449] if single value, bind to value; if multi-value bind to list of values

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

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


The following commit(s) were added to refs/heads/2_1_X by this push:
     new f60f775  [SYNCOPE-1449] if single value, bind to value; if multi-value bind to list of values
f60f775 is described below

commit f60f77559ff2062aef9530bd3e9dab62dff06987
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Tue Mar 12 15:11:07 2019 +0100

    [SYNCOPE-1449] if single value, bind to value; if multi-value bind to list of values
---
 .../core/provisioning/java/jexl/JexlUtils.java       | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/jexl/JexlUtils.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/jexl/JexlUtils.java
index fc3c9e9..d5cee96 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/jexl/JexlUtils.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/jexl/JexlUtils.java
@@ -198,13 +198,15 @@ public final class JexlUtils {
 
     public static void addAttrTOsToContext(final Collection<AttrTO> attrs, final JexlContext jexlContext) {
         attrs.stream().filter(attr -> attr.getSchema() != null).forEach(attr -> {
-            String expressionValue = attr.getValues().isEmpty()
+            Object value = attr.getValues().isEmpty()
                     ? StringUtils.EMPTY
-                    : attr.getValues().get(0);
+                    : attr.getValues().size() == 1
+                    ? attr.getValues().get(0)
+                    : attr.getValues();
 
-            LOG.debug("Add attribute {} with value {}", attr.getSchema(), expressionValue);
+            LOG.debug("Add attribute {} with value {}", attr.getSchema(), value);
 
-            jexlContext.set(attr.getSchema(), expressionValue);
+            jexlContext.set(attr.getSchema(), value);
         });
     }
 
@@ -213,13 +215,15 @@ public final class JexlUtils {
 
         attrs.stream().filter(attr -> attr.getSchema() != null).forEach(attr -> {
             List<String> attrValues = attr.getValuesAsStrings();
-            String expressionValue = attrValues.isEmpty()
+            Object value = attrValues.isEmpty()
                     ? StringUtils.EMPTY
-                    : attrValues.get(0);
+                    : attrValues.size() == 1
+                    ? attrValues.get(0)
+                    : attrValues;
 
-            LOG.debug("Add attribute {} with value {}", attr.getSchema().getKey(), expressionValue);
+            LOG.debug("Add attribute {} with value {}", attr.getSchema().getKey(), value);
 
-            jexlContext.set(attr.getSchema().getKey(), expressionValue);
+            jexlContext.set(attr.getSchema().getKey(), value);
         });
     }