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 2015/12/30 14:16:27 UTC
syncope git commit: Upgrading to Commons JEXL 3.0
Repository: syncope
Updated Branches:
refs/heads/master 421c0f8b4 -> 44700ae51
Upgrading to Commons JEXL 3.0
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/44700ae5
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/44700ae5
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/44700ae5
Branch: refs/heads/master
Commit: 44700ae51fb1356120b133baea12cd4a879cfc51
Parents: 421c0f8
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Wed Dec 30 14:16:18 2015 +0100
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Wed Dec 30 14:16:18 2015 +0100
----------------------------------------------------------------------
core/misc/pom.xml | 2 +-
.../core/misc/jexl/ClassFreeUberspect.java | 41 +++++++++++++++++++
.../core/misc/jexl/ClassFreeUberspectImpl.java | 43 --------------------
.../syncope/core/misc/jexl/JexlUtils.java | 29 +++++++------
.../syncope/core/misc/utils/MappingUtils.java | 4 +-
.../persistence/jpa/dao/AbstractAnyDAO.java | 20 ++++-----
.../provisioning/java/DerAttrHandlerImpl.java | 4 +-
.../LDAPMembershipPropagationActions.java | 4 +-
pom.xml | 4 +-
9 files changed, 76 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/44700ae5/core/misc/pom.xml
----------------------------------------------------------------------
diff --git a/core/misc/pom.xml b/core/misc/pom.xml
index d9c6049..44e1df1 100644
--- a/core/misc/pom.xml
+++ b/core/misc/pom.xml
@@ -54,7 +54,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
- <artifactId>commons-jexl</artifactId>
+ <artifactId>commons-jexl3</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
http://git-wip-us.apache.org/repos/asf/syncope/blob/44700ae5/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspect.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspect.java b/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspect.java
new file mode 100644
index 0000000..d115ea9
--- /dev/null
+++ b/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspect.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.misc.jexl;
+
+import org.apache.commons.jexl3.internal.introspection.Uberspect;
+import org.apache.commons.jexl3.introspection.JexlMethod;
+import org.apache.commons.jexl3.introspection.JexlPropertyGet;
+
+class ClassFreeUberspect extends Uberspect {
+
+ ClassFreeUberspect() {
+ super(null, null);
+ }
+
+ @Override
+ public JexlPropertyGet getPropertyGet(final Object obj, final Object identifier) {
+ return "class".equals(identifier) ? null : super.getPropertyGet(obj, identifier);
+ }
+
+ @Override
+ public JexlMethod getMethod(final Object obj, final String method, final Object... args) {
+ return "getClass".equals(method) ? null : super.getMethod(obj, method, args);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/syncope/blob/44700ae5/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspectImpl.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspectImpl.java b/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspectImpl.java
deleted file mode 100644
index 62e3dba..0000000
--- a/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/ClassFreeUberspectImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.misc.jexl;
-
-import org.apache.commons.jexl2.JexlInfo;
-import org.apache.commons.jexl2.introspection.JexlMethod;
-import org.apache.commons.jexl2.introspection.JexlPropertyGet;
-import org.apache.commons.jexl2.introspection.UberspectImpl;
-import org.apache.commons.logging.Log;
-
-class ClassFreeUberspectImpl extends UberspectImpl {
-
- ClassFreeUberspectImpl(final Log runtimeLogger) {
- super(runtimeLogger);
- }
-
- @Override
- public JexlPropertyGet getPropertyGet(final Object obj, final Object identifier, final JexlInfo info) {
- return "class".equals(identifier) ? null : super.getPropertyGet(obj, identifier, info);
- }
-
- @Override
- public JexlMethod getMethod(final Object obj, final String method, final Object[] args, final JexlInfo info) {
- return "getClass".equals(method) ? null : super.getMethod(obj, method, args, info);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/44700ae5/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/JexlUtils.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/JexlUtils.java b/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/JexlUtils.java
index 986adf4..b03c027 100644
--- a/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/JexlUtils.java
+++ b/core/misc/src/main/java/org/apache/syncope/core/misc/jexl/JexlUtils.java
@@ -26,11 +26,12 @@ import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;
-import org.apache.commons.jexl2.Expression;
-import org.apache.commons.jexl2.JexlContext;
-import org.apache.commons.jexl2.JexlEngine;
-import org.apache.commons.jexl2.JexlException;
-import org.apache.commons.jexl2.MapContext;
+import org.apache.commons.jexl3.JexlBuilder;
+import org.apache.commons.jexl3.JexlContext;
+import org.apache.commons.jexl3.JexlEngine;
+import org.apache.commons.jexl3.JexlException;
+import org.apache.commons.jexl3.JexlExpression;
+import org.apache.commons.jexl3.MapContext;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.lib.to.AnyTO;
@@ -58,11 +59,13 @@ public final class JexlUtils {
private static JexlEngine getEngine() {
synchronized (LOG) {
if (JEXL_ENGINE == null) {
- JEXL_ENGINE = new JexlEngine(new ClassFreeUberspectImpl(null), null, null, null);
- JEXL_ENGINE.setClassLoader(new EmptyClassLoader());
- JEXL_ENGINE.setCache(512);
- JEXL_ENGINE.setLenient(true);
- JEXL_ENGINE.setSilent(false);
+ JEXL_ENGINE = new JexlBuilder().
+ uberspect(new ClassFreeUberspect()).
+ loader(new EmptyClassLoader()).
+ cache(512).
+ silent(false).
+ strict(false).
+ create();
}
}
@@ -87,7 +90,7 @@ public final class JexlUtils {
if (StringUtils.isNotBlank(expression) && jexlContext != null) {
try {
- Expression jexlExpression = getEngine().createExpression(expression);
+ JexlExpression jexlExpression = getEngine().createExpression(expression);
Object evaluated = jexlExpression.evaluate(jexlContext);
if (evaluated != null) {
result = evaluated.toString();
@@ -128,8 +131,8 @@ public final class JexlUtils {
context.set(fieldName, fieldValue == null
? StringUtils.EMPTY
: (type.equals(Date.class)
- ? FormatUtils.format((Date) fieldValue, false)
- : fieldValue));
+ ? FormatUtils.format((Date) fieldValue, false)
+ : fieldValue));
LOG.debug("Add field {} with value {}", fieldName, fieldValue);
} catch (Exception iae) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/44700ae5/core/misc/src/main/java/org/apache/syncope/core/misc/utils/MappingUtils.java
----------------------------------------------------------------------
diff --git a/core/misc/src/main/java/org/apache/syncope/core/misc/utils/MappingUtils.java b/core/misc/src/main/java/org/apache/syncope/core/misc/utils/MappingUtils.java
index 2886231..6fde3ea 100644
--- a/core/misc/src/main/java/org/apache/syncope/core/misc/utils/MappingUtils.java
+++ b/core/misc/src/main/java/org/apache/syncope/core/misc/utils/MappingUtils.java
@@ -25,8 +25,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.apache.commons.collections4.ListUtils;
-import org.apache.commons.jexl2.JexlContext;
-import org.apache.commons.jexl2.MapContext;
+import org.apache.commons.jexl3.JexlContext;
+import org.apache.commons.jexl3.MapContext;
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.SerializationUtils;
import org.apache.commons.lang3.StringUtils;
http://git-wip-us.apache.org/repos/asf/syncope/blob/44700ae5/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
----------------------------------------------------------------------
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
index 3db3f61..8a56ad7 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnyDAO.java
@@ -30,9 +30,9 @@ import java.util.regex.Pattern;
import javax.persistence.NoResultException;
import javax.persistence.Query;
import javax.persistence.TemporalType;
-import org.apache.commons.jexl2.parser.Parser;
-import org.apache.commons.jexl2.parser.ParserConstants;
-import org.apache.commons.jexl2.parser.Token;
+import org.apache.commons.jexl3.parser.Parser;
+import org.apache.commons.jexl3.parser.ParserConstants;
+import org.apache.commons.jexl3.parser.Token;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.lib.SyncopeConstants;
import org.apache.syncope.core.persistence.api.dao.AnyDAO;
@@ -226,13 +226,13 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A, Lo
* @return where clauses to use to build the query
*/
private Set<String> getWhereClause(final String expression, final String value) {
- final Parser parser = new Parser(new StringReader(expression));
+ Parser parser = new Parser(new StringReader(expression));
// Schema names
- final List<String> identifiers = new ArrayList<>();
+ List<String> identifiers = new ArrayList<>();
// Literals
- final List<String> literals = new ArrayList<>();
+ List<String> literals = new ArrayList<>();
// Get schema names and literals
for (Token token = parser.getNextToken(); token != null && StringUtils.isNotBlank(token.toString());
@@ -269,7 +269,7 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A, Lo
});
// Split value on provided literals
- final List<String> attrValues = split(value, literals);
+ List<String> attrValues = split(value, literals);
if (attrValues.size() != identifiers.size()) {
LOG.error("Ambiguous JEXL expression resolution.");
@@ -277,13 +277,13 @@ public abstract class AbstractAnyDAO<A extends Any<?>> extends AbstractDAO<A, Lo
}
// clauses to be used with INTERSECTed queries
- final Set<String> clauses = new HashSet<>();
+ Set<String> clauses = new HashSet<>();
// builder to build the clauses
- final StringBuilder bld = new StringBuilder();
+ StringBuilder bld = new StringBuilder();
// Contains used identifiers in order to avoid replications
- final Set<String> used = new HashSet<>();
+ Set<String> used = new HashSet<>();
// Create several clauses: one for eanch identifiers
for (int i = 0; i < identifiers.size(); i++) {
http://git-wip-us.apache.org/repos/asf/syncope/blob/44700ae5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DerAttrHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DerAttrHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DerAttrHandlerImpl.java
index 2711fc0..ccff795 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DerAttrHandlerImpl.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/DerAttrHandlerImpl.java
@@ -22,8 +22,8 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import org.apache.commons.jexl2.JexlContext;
-import org.apache.commons.jexl2.MapContext;
+import org.apache.commons.jexl3.JexlContext;
+import org.apache.commons.jexl3.MapContext;
import org.apache.syncope.core.misc.jexl.JexlUtils;
import org.apache.syncope.core.persistence.api.entity.Any;
import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
http://git-wip-us.apache.org/repos/asf/syncope/blob/44700ae5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/LDAPMembershipPropagationActions.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/LDAPMembershipPropagationActions.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/LDAPMembershipPropagationActions.java
index 0ab0e25..9a7214c 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/LDAPMembershipPropagationActions.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/propagation/LDAPMembershipPropagationActions.java
@@ -22,8 +22,8 @@ import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import org.apache.commons.jexl2.JexlContext;
-import org.apache.commons.jexl2.MapContext;
+import org.apache.commons.jexl3.JexlContext;
+import org.apache.commons.jexl3.MapContext;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.core.persistence.api.dao.UserDAO;
http://git-wip-us.apache.org/repos/asf/syncope/blob/44700ae5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index ca492fd..f722c6d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -356,7 +356,7 @@ under the License.
<commons-io.version>2.4</commons-io.version>
<commons-codec.version>1.10</commons-codec.version>
- <commons-jexl.version>2.1.1</commons-jexl.version>
+ <commons-jexl.version>3.0</commons-jexl.version>
<commons-lang.version>3.4</commons-lang.version>
<commons-collection.version>4.1</commons-collection.version>
<commons-logging.version>1.1.3</commons-logging.version>
@@ -689,7 +689,7 @@ under the License.
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
- <artifactId>commons-jexl</artifactId>
+ <artifactId>commons-jexl3</artifactId>
<version>${commons-jexl.version}</version>
</dependency>
<dependency>