You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by np...@apache.org on 2018/06/14 08:09:55 UTC
[sling-org-apache-sling-pipes] branch master updated: SLING-7704
call reference.before only if plain ref
This is an automated email from the ASF dual-hosted git repository.
npeltier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-pipes.git
The following commit(s) were added to refs/heads/master by this push:
new 088de1f SLING-7704 call reference.before only if plain ref
088de1f is described below
commit 088de1f1ff09b4a4afad5f6e3cdc2c665047ad78
Author: Nicolas Peltier <pe...@gmail.com>
AuthorDate: Thu Jun 14 10:09:36 2018 +0200
SLING-7704 call reference.before only if plain ref
---
src/main/java/org/apache/sling/pipes/BasePipe.java | 10 ++++++++--
src/main/java/org/apache/sling/pipes/PipeBindings.java | 10 +++++++++-
.../java/org/apache/sling/pipes/internal/ReferencePipe.java | 8 ++++++++
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/sling/pipes/BasePipe.java b/src/main/java/org/apache/sling/pipes/BasePipe.java
index a10c84c..04ebff6 100644
--- a/src/main/java/org/apache/sling/pipes/BasePipe.java
+++ b/src/main/java/org/apache/sling/pipes/BasePipe.java
@@ -137,12 +137,18 @@ public class BasePipe implements Pipe {
}
/**
+ * @return configured expression (not computed)
+ */
+ public String getRawExpression() {
+ return properties.get(PN_EXPR, "");
+ }
+
+ /**
* Get pipe's expression, instanciated or not
* @return configured expression
*/
public String getExpr() throws ScriptException {
- String rawExpression = properties.get(PN_EXPR, "");
- return bindings.instantiateExpression(rawExpression);
+ return bindings.instantiateExpression(getRawExpression());
}
/**
diff --git a/src/main/java/org/apache/sling/pipes/PipeBindings.java b/src/main/java/org/apache/sling/pipes/PipeBindings.java
index 7f852af..eb5826a 100644
--- a/src/main/java/org/apache/sling/pipes/PipeBindings.java
+++ b/src/main/java/org/apache/sling/pipes/PipeBindings.java
@@ -173,9 +173,17 @@ public class PipeBindings {
}
/**
+ * @param expr expression with or without ${} use
+ * @return true if the expression is 'just' a plain string
+ */
+ public boolean isPlainString(String expr){
+ return computeECMA5Expression(expr) == null;
+ }
+
+ /**
* Doesn't look like nashorn likes template strings :-(
* @param expr ECMA like expression <code>blah${'some' + 'ecma' + 'expression'}</code>
- * @return computed expression
+ * @return computed expression, null if the expression is a plain string
*/
protected String computeECMA5Expression(String expr){
Matcher matcher = INJECTED_SCRIPT.matcher(expr);
diff --git a/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java b/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java
index 6c0cd7a..523af51 100644
--- a/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java
+++ b/src/main/java/org/apache/sling/pipes/internal/ReferencePipe.java
@@ -73,4 +73,12 @@ public class ReferencePipe extends SuperPipe {
return reference.getOutput();
}
+ @Override
+ public void before() throws Exception {
+ if (bindings.isPlainString(getRawExpression())){
+ //we only support raw references, as there are good chances
+ //compute fails at that stage
+ super.before();
+ }
+ }
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
npeltier@apache.org.