diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/init/proxy/ScriptServiceProxy.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/init/proxy/ScriptServiceProxy.java index e74b40a41e1..72971f46a90 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/init/proxy/ScriptServiceProxy.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/init/proxy/ScriptServiceProxy.java @@ -12,6 +12,7 @@ import org.elasticsearch.watcher.shield.ShieldIntegration; import org.elasticsearch.watcher.support.Script; import org.elasticsearch.watcher.support.init.InitializingService; +import java.util.Collections; import java.util.Map; /** @@ -46,7 +47,7 @@ public class ScriptServiceProxy implements InitializingService.Initializable { } public CompiledScript compile(org.elasticsearch.script.Script script) { - return service.compile(script, WatcherScriptContext.CTX, contextAndHeaderHolder); + return service.compile(script, WatcherScriptContext.CTX, contextAndHeaderHolder, Collections.emptyMap()); } public ExecutableScript executable(CompiledScript compiledScript, Map vars) { @@ -55,7 +56,7 @@ public class ScriptServiceProxy implements InitializingService.Initializable { public ExecutableScript executable(org.elasticsearch.script.Script script) { - return service.executable(script, WatcherScriptContext.CTX, contextAndHeaderHolder); + return service.executable(script, WatcherScriptContext.CTX, contextAndHeaderHolder, Collections.emptyMap()); } public static final ScriptContext.Plugin INSTANCE = new ScriptContext.Plugin("elasticsearch-watcher", "watch"); diff --git a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheScriptEngineService.java b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheScriptEngineService.java index afbf5116721..6875864f944 100644 --- a/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheScriptEngineService.java +++ b/elasticsearch/x-pack/watcher/src/main/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheScriptEngineService.java @@ -50,7 +50,7 @@ public class XMustacheScriptEngineService extends AbstractComponent implements S * @return a compiled template object for later execution. * */ @Override - public Object compile(String template) { + public Object compile(String template, Map params) { /** Factory to generate Mustache objects from. */ XContentType xContentType = detectContentType(template); template = trimContentType(template); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java index 064fa1a83d6..a55ee8f3354 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/script/SleepScriptEngine.java @@ -56,7 +56,7 @@ public class SleepScriptEngine implements ScriptEngineService { } @Override - public Object compile(String script) { + public Object compile(String script, Map params) { return script; } diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheScriptEngineTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheScriptEngineTests.java index 6096a7cb57c..848db7177c4 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheScriptEngineTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheScriptEngineTests.java @@ -16,6 +16,7 @@ import org.junit.Before; import java.io.StringWriter; import java.io.Writer; import java.nio.charset.Charset; +import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -36,7 +37,7 @@ public class XMustacheScriptEngineTests extends ESTestCase { + "\"negative\": {\"term\": {\"body\": {\"value\": \"solr\"}" + "}}, \"negative_boost\": {{boost_val}} } }}"; Map vars = new HashMap<>(); vars.put("boost_val", "0.3"); - CompiledScript compiledScript = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template)); + CompiledScript compiledScript = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template, Collections.emptyMap())); BytesReference o = (BytesReference) engine.executable(compiledScript, vars).run(); assertEquals("GET _search {\"query\": {\"boosting\": {\"positive\": {\"match\": {\"body\": \"gift\"}}," + "\"negative\": {\"term\": {\"body\": {\"value\": \"solr\"}}}, \"negative_boost\": 0.3 } }}", @@ -48,7 +49,7 @@ public class XMustacheScriptEngineTests extends ESTestCase { Map vars = new HashMap<>(); vars.put("boost_val", "0.3"); vars.put("body_val", "\"quick brown\""); - CompiledScript compiledScript = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template)); + CompiledScript compiledScript = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template, Collections.emptyMap())); BytesReference o = (BytesReference) engine.executable(compiledScript, vars).run(); assertEquals("GET _search {\"query\": {\"boosting\": {\"positive\": {\"match\": {\"body\": \"gift\"}}," + "\"negative\": {\"term\": {\"body\": {\"value\": \"\\\"quick brown\\\"\"}}}, \"negative_boost\": 0.3 } }}", @@ -73,7 +74,7 @@ public class XMustacheScriptEngineTests extends ESTestCase { vars.put("test_var1", var1Writer.toString()); vars.put("test_var2", var2Writer.toString()); - CompiledScript compiledScript = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template)); + CompiledScript compiledScript = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template, Collections.emptyMap())); BytesReference o = (BytesReference) engine.executable(compiledScript, vars).run(); String s1 = o.toUtf8(); String s2 = prefix + " " + var1Writer.toString() + " " + var2Writer.toString(); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheTests.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheTests.java index b23064e4608..ee921b10da8 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheTests.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/support/text/xmustache/XMustacheTests.java @@ -46,7 +46,7 @@ public class XMustacheTests extends ESTestCase { public void testArrayAccess() throws Exception { String template = "{{data.0}} {{data.1}}"; - CompiledScript mustache = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template)); + CompiledScript mustache = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template, Collections.emptyMap())); Map vars = new HashMap<>(); Object data = randomFrom( new String[] { "foo", "bar" }, @@ -72,7 +72,7 @@ public class XMustacheTests extends ESTestCase { public void testArrayInArrayAccess() throws Exception { String template = "{{data.0.0}} {{data.0.1}}"; - CompiledScript mustache = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template)); + CompiledScript mustache = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template, Collections.emptyMap())); Map vars = new HashMap<>(); Object data = randomFrom( new String[][] { new String[] { "foo", "bar" }}, @@ -89,7 +89,7 @@ public class XMustacheTests extends ESTestCase { public void testMapInArrayAccess() throws Exception { String template = "{{data.0.key}} {{data.1.key}}"; - CompiledScript mustache = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template)); + CompiledScript mustache = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template, Collections.emptyMap())); Map vars = new HashMap<>(); Object data = randomFrom( new Map[] { singletonMap("key", "foo"), singletonMap("key", "bar") }, @@ -156,7 +156,7 @@ public class XMustacheTests extends ESTestCase { Map dataMap = new HashMap<>(); dataMap.put("data", unescaped.toString()); - CompiledScript mustache = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template)); + CompiledScript mustache = new CompiledScript(ScriptService.ScriptType.INLINE, "inline", "mustache", engine.compile(template, Collections.emptyMap())); Object output = engine.executable(mustache, dataMap).run(); assertThat(output, notNullValue());