This is an automated email from the ASF dual-hosted git repository.
mattyb149 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new ce019071a4 NIFI-11713 Removed Deprecated ECMAScript Support
ce019071a4 is described below
commit ce019071a447f7cd819f453e8e97bfdc6d654aaf
Author: exceptionfactory <[email protected]>
AuthorDate: Fri Jun 16 10:15:55 2023 -0500
NIFI-11713 Removed Deprecated ECMAScript Support
Signed-off-by: Matt Burgess <[email protected]>
This closes #7394
---
.../nifi/lookup/script/ScriptedLookupService.java | 2 +-
.../lookup/script/SimpleScriptedLookupService.java | 2 +-
.../nifi/processors/script/ExecuteScript.java | 2 +-
.../processors/script/InvokeScriptedProcessor.java | 2 +-
.../apache/nifi/record/script/ScriptedReader.java | 2 +-
.../record/script/ScriptedRecordSetWriter.java | 2 +-
.../record/sink/script/ScriptedRecordSink.java | 2 +-
.../reporting/script/ScriptedReportingTask.java | 2 +-
.../rules/engine/script/ScriptedRulesEngine.java | 2 +-
.../handlers/script/ScriptedActionHandler.java | 2 +-
.../apache/nifi/script/ScriptRunnerFactory.java | 7 +-
.../nifi/script/impl/JavascriptScriptRunner.java | 41 -----
...nifi.processors.script.ScriptEngineConfigurator | 1 -
.../additionalDetails.html | 136 ---------------
.../processors/script/TestExecuteJavascript.java | 61 -------
.../processors/script/TestInvokeJavascript.java | 187 ---------------------
.../javascript/testInvokeScriptCausesException.js | 58 -------
.../javascript/testScriptRoutesToFailure.js | 79 ---------
.../test/resources/javascript/test_onTrigger.js | 21 ---
.../src/test/resources/javascript/test_reader.js | 110 ------------
20 files changed, 11 insertions(+), 710 deletions(-)
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/lookup/script/ScriptedLookupService.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/lookup/script/ScriptedLookupService.java
index 3965ed6413..a87b4fae97 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/lookup/script/ScriptedLookupService.java
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/lookup/script/ScriptedLookupService.java
@@ -33,7 +33,7 @@ import java.util.Set;
/**
* A Controller service that allows the user to script the lookup operation to
be performed (by LookupRecord, e.g.)
*/
-@Tags({"lookup", "record", "script", "invoke", "groovy", "python", "jython",
"jruby", "ruby", "javascript", "js", "lua", "luaj"})
+@Tags({"lookup", "record", "script", "invoke", "groovy", "python", "jython",
"jruby", "ruby", "lua", "luaj"})
@CapabilityDescription("Allows the user to provide a scripted LookupService
instance in order to enrich records from " +
"an incoming flow file. Please note, that due to a bug in Jython that
remains unresolved, it is not possible to use " +
"Jython to write a script for this service in Python.")
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/lookup/script/SimpleScriptedLookupService.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/lookup/script/SimpleScriptedLookupService.java
index e6e43b2df0..3420650bf8 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/lookup/script/SimpleScriptedLookupService.java
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/lookup/script/SimpleScriptedLookupService.java
@@ -33,7 +33,7 @@ import java.util.Set;
/**
* A Controller service that allows the user to script the lookup operation to
be performed (by LookupAttribute, e.g.)
*/
-@Tags({"lookup", "script", "invoke", "groovy", "python", "jython", "jruby",
"ruby", "javascript", "js", "lua", "luaj"})
+@Tags({"lookup", "script", "invoke", "groovy", "python", "jython", "jruby",
"ruby", "lua", "luaj"})
@CapabilityDescription("Allows the user to provide a scripted LookupService
instance in order to enrich records from "
+ "an incoming flow file. The script is expected to return an optional
string value rather than an arbitrary object (record, e.g.). "
+ "Also the scripted lookup service should implement
StringLookupService, otherwise the getValueType() method must be implemented
even "
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/ExecuteScript.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/ExecuteScript.java
index 998766a1d6..0a3f531689 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/ExecuteScript.java
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/ExecuteScript.java
@@ -64,7 +64,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-@Tags({"script", "execute", "groovy", "python", "jython", "jruby", "ruby",
"javascript", "js", "lua", "luaj", "clojure"})
+@Tags({"script", "execute", "groovy", "python", "jython", "jruby", "ruby",
"lua", "luaj", "clojure"})
@CapabilityDescription("Experimental - Executes a script given the flow file
and a process session. The script is responsible for "
+ "handling the incoming flow file (transfer to SUCCESS or remove,
e.g.) as well as any flow files created by "
+ "the script. If the handling is incomplete or incorrect, the session
will be rolled back. Experimental: "
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/InvokeScriptedProcessor.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/InvokeScriptedProcessor.java
index 5e083e7b74..815bc04a32 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/InvokeScriptedProcessor.java
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/InvokeScriptedProcessor.java
@@ -68,7 +68,7 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
-@Tags({"script", "invoke", "groovy", "python", "jython", "jruby", "ruby",
"javascript", "js", "lua", "luaj"})
+@Tags({"script", "invoke", "groovy", "python", "jython", "jruby", "ruby",
"lua", "luaj"})
@CapabilityDescription("Experimental - Invokes a script engine for a Processor
defined in the given script. The script must define "
+ "a valid class that implements the Processor interface, and it must
set a variable 'processor' to an instance of "
+ "the class. Processor methods such as onTrigger() will be delegated
to the scripted Processor instance. Also any "
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/script/ScriptedReader.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/script/ScriptedReader.java
index 17b06af8c0..386949dbd3 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/script/ScriptedReader.java
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/script/ScriptedReader.java
@@ -47,7 +47,7 @@ import java.util.Map;
/**
* A RecordReader implementation that allows the user to script the
RecordReader instance
*/
-@Tags({"record", "recordFactory", "script", "invoke", "groovy", "python",
"jython", "jruby", "ruby", "javascript", "js", "lua", "luaj"})
+@Tags({"record", "recordFactory", "script", "invoke", "groovy", "python",
"jython", "jruby", "ruby", "lua", "luaj"})
@CapabilityDescription("Allows the user to provide a scripted
RecordReaderFactory instance in order to read/parse/generate records from an
incoming flow file.")
@DynamicProperty(name = "Script Engine Binding property", value = "Binding
property value passed to Script Runner",
expressionLanguageScope = ExpressionLanguageScope.VARIABLE_REGISTRY,
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/script/ScriptedRecordSetWriter.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/script/ScriptedRecordSetWriter.java
index d7461f23b5..1dd88c38fd 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/script/ScriptedRecordSetWriter.java
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/script/ScriptedRecordSetWriter.java
@@ -47,7 +47,7 @@ import java.util.Map;
/**
* A RecordSetWriter implementation that allows the user to script the
RecordWriter instance
*/
-@Tags({"record", "writer", "script", "invoke", "groovy", "python", "jython",
"jruby", "ruby", "javascript", "js", "lua", "luaj"})
+@Tags({"record", "writer", "script", "invoke", "groovy", "python", "jython",
"jruby", "ruby", "lua", "luaj"})
@CapabilityDescription("Allows the user to provide a scripted
RecordSetWriterFactory instance in order to write records to an outgoing flow
file.")
@DynamicProperty(name = "Script Engine Binding property", value = "Binding
property value passed to Script Runner",
expressionLanguageScope = ExpressionLanguageScope.VARIABLE_REGISTRY,
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/sink/script/ScriptedRecordSink.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/sink/script/ScriptedRecordSink.java
index c8eb10e4f1..8469c73d93 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/sink/script/ScriptedRecordSink.java
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/record/sink/script/ScriptedRecordSink.java
@@ -50,7 +50,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
-@Tags({"record", "record sink", "script", "invoke", "groovy", "python",
"jython", "jruby", "ruby", "javascript", "js", "lua", "luaj"})
+@Tags({"record", "record sink", "script", "invoke", "groovy", "python",
"jython", "jruby", "ruby", "lua", "luaj"})
@CapabilityDescription("Allows the user to provide a scripted
RecordSinkService instance in order to transmit records to the desired target.
The script must set a variable 'recordSink' to an "
+ "implementation of RecordSinkService.")
@DynamicProperty(name = "Script Engine Binding property", value = "Binding
property value passed to Script Runner",
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/reporting/script/ScriptedReportingTask.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/reporting/script/ScriptedReportingTask.java
index 941200863f..8ad89b874a 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/reporting/script/ScriptedReportingTask.java
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/reporting/script/ScriptedReportingTask.java
@@ -56,7 +56,7 @@ import java.util.Map;
* A Reporting task whose body is provided by a script (via supported JSR-223
script engines)
*/
@SupportsSensitiveDynamicProperties
-@Tags({"reporting", "script", "execute", "groovy", "python", "jython",
"jruby", "ruby", "javascript", "js", "lua", "luaj"})
+@Tags({"reporting", "script", "execute", "groovy", "python", "jython",
"jruby", "ruby", "lua", "luaj"})
@CapabilityDescription("Provides reporting and status information to a script.
ReportingContext, ComponentLog, and VirtualMachineMetrics objects are made
available "
+ "as variables (context, log, and vmMetrics, respectively) to the
script for further processing. The context makes various information available
such "
+ "as events, provenance, bulletins, controller services, process
groups, Java Virtual Machine metrics, etc.")
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/rules/engine/script/ScriptedRulesEngine.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/rules/engine/script/ScriptedRulesEngine.java
index c117597917..ee4c6955bb 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/rules/engine/script/ScriptedRulesEngine.java
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/rules/engine/script/ScriptedRulesEngine.java
@@ -45,7 +45,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
-@Tags({"rules", "rules engine", "script", "invoke", "groovy", "python",
"jython", "jruby", "ruby", "javascript", "js", "lua", "luaj"})
+@Tags({"rules", "rules engine", "script", "invoke", "groovy", "python",
"jython", "jruby", "ruby", "lua", "luaj"})
@CapabilityDescription("Allows the user to provide a scripted
RulesEngineService for custom firing of rules depending on the supplied facts.
The script must set a variable 'rulesEngine' to an "
+ "implementation of RulesEngineService.")
@DynamicProperty(name = "Script Engine Binding property", value = "Binding
property value passed to Script Runner",
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/rules/handlers/script/ScriptedActionHandler.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/rules/handlers/script/ScriptedActionHandler.java
index a56aa09751..d2a7230ae3 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/rules/handlers/script/ScriptedActionHandler.java
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/rules/handlers/script/ScriptedActionHandler.java
@@ -47,7 +47,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
-@Tags({"rules", "rules engine", "action", "action handler", "script",
"invoke", "groovy", "python", "jython", "jruby", "ruby", "javascript", "js",
"lua", "luaj"})
+@Tags({"rules", "rules engine", "action", "action handler", "script",
"invoke", "groovy", "python", "jython", "jruby", "ruby", "lua", "luaj"})
@CapabilityDescription("Allows the user to provide a scripted ActionHandler
for custom firing of rules depending on the supplied facts. The script must set
a variable 'actionHandler' to an "
+ "implementation of ActionHandler.")
@DynamicProperty(name = "Script Engine Binding property", value = "Binding
property value passed to Script Runner",
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/ScriptRunnerFactory.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/ScriptRunnerFactory.java
index 6bd2fe6aa9..a9f6f1fe4e 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/ScriptRunnerFactory.java
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/ScriptRunnerFactory.java
@@ -21,7 +21,6 @@ import org.apache.nifi.processors.script.ScriptRunner;
import org.apache.nifi.script.impl.ClojureScriptRunner;
import org.apache.nifi.script.impl.GenericScriptRunner;
import org.apache.nifi.script.impl.GroovyScriptRunner;
-import org.apache.nifi.script.impl.JavascriptScriptRunner;
import org.apache.nifi.script.impl.JythonScriptRunner;
import javax.script.ScriptEngine;
@@ -58,9 +57,6 @@ public class ScriptRunnerFactory {
if ("Clojure".equals(scriptEngineName)) {
return new ClojureScriptRunner(scriptEngine, scriptToRun, null);
}
- if ("ECMAScript".equals(scriptEngineName)) {
- return new JavascriptScriptRunner(scriptEngine, scriptToRun, null);
- }
return new GenericScriptRunner(scriptEngine, scriptToRun, null);
}
@@ -78,8 +74,7 @@ public class ScriptRunnerFactory {
public URL[] getModuleURLsForClasspath(String scriptEngineName, String[]
modulePaths, ComponentLog log) {
if (!"Clojure".equals(scriptEngineName)
- && !"Groovy".equals(scriptEngineName)
- && !"ECMAScript".equals(scriptEngineName)) {
+ && !"Groovy".equals(scriptEngineName)) {
return new URL[0];
}
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/impl/JavascriptScriptRunner.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/impl/JavascriptScriptRunner.java
deleted file mode 100644
index 39dc3b4370..0000000000
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/impl/JavascriptScriptRunner.java
+++ /dev/null
@@ -1,41 +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.nifi.script.impl;
-
-import javax.script.Bindings;
-import javax.script.ScriptEngine;
-import javax.script.ScriptException;
-
-/**
- * This class offers methods to perform Javascript-specific operations during
the script runner lifecycle.
- */
-public class JavascriptScriptRunner extends BaseScriptRunner {
-
- public JavascriptScriptRunner(ScriptEngine engine, String scriptBody,
String[] modulePaths) {
- super(engine, scriptBody, modulePaths);
- }
-
- @Override
- public String getScriptEngineName() {
- return "ECMAScript";
- }
-
- @Override
- public void run(Bindings bindings) throws ScriptException {
- scriptEngine.eval(scriptBody);
- }
-}
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/resources/META-INF/services/org.apache.nifi.processors.script.ScriptEngineConfigurator
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/resources/META-INF/services/org.apache.nifi.processors.script.ScriptEngineConfigurator
index 5ee7038f3a..3d82a2e8ee 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/resources/META-INF/services/org.apache.nifi.processors.script.ScriptEngineConfigurator
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/resources/META-INF/services/org.apache.nifi.processors.script.ScriptEngineConfigurator
@@ -16,4 +16,3 @@
org.apache.nifi.script.impl.ClojureScriptRunner
org.apache.nifi.script.impl.JythonScriptRunner
org.apache.nifi.script.impl.GroovyScriptRunner
-org.apache.nifi.script.impl.JavascriptScriptRunner
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/resources/docs/org.apache.nifi.processors.script.ExecuteScript/additionalDetails.html
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/resources/docs/org.apache.nifi.processors.script.ExecuteScript/additionalDetails.html
index 24494ba1d2..b262fd00c6 100644
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/resources/docs/org.apache.nifi.processors.script.ExecuteScript/additionalDetails.html
+++
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/resources/docs/org.apache.nifi.processors.script.ExecuteScript/additionalDetails.html
@@ -48,7 +48,6 @@ td {text-align: left}
<li>The engine listed as "python" in the list of available script engines
is actually Jython, not Python. When using Jython, you cannot import pure
(CPython) modules such as pandas</li>
<li>Lua does not allow for referencing static members of a class, so the
REL_SUCCESS and REL_FAILURE relationships are made available via script
bindings (aka variables), see the Variable Bindings section for more
details</li>
<li>ExecuteScript uses the JSR-223 Script Engine API to evaluate scripts,
so the use of idiomatic language structure is sometimes limited. For example,
in the case of Groovy, there is a separate ExecuteGroovyScript processor that
allows you to do many more idiomatic Groovy tasks. For example, it's easier to
interact with Controller Services via ExecuteGroovyScript vs. ExecuteScript
(see the ExecuteGroovyScript documentation for more details)</li>
- <li>JavaScript is provided by the Nashorn engine, which is not available
in later Java versions, so it may not show up in the Script Engines list
depending on the JRE used</li>
</ul>
</p>
<h3>Variable Bindings</h3>
@@ -109,12 +108,6 @@ if (flowFile != None):
# All processing code starts at this indent
# implicit return at the end
</pre>
-<p><em> Javascript</em></p>
-<pre>var flowFile = session.get();
-if (flowFile != null) {
- // All processing code goes here
-}
-</pre>
<p><em> JRuby</em></p>
<pre>flowFile = session.get()
if flowFile != nil
@@ -141,14 +134,6 @@ if not flowFileList.isEmpty():
for flowFile in flowFileList:
# Process each FlowFile here
</pre>
-<p><em>Javascript</em></p>
-<pre>flowFileList = session.get(100)
-if(!flowFileList.isEmpty()) {
- for each (var flowFile in flowFileList) {
- // Process each FlowFile here
- }
-}
-</pre>
<p><em>JRuby</em></p>
<pre>flowFileList = session.get(100)
if !(flowFileList.isEmpty())
@@ -171,10 +156,6 @@ end
<pre>flowFile = session.create()
# Additional processing here
</pre>
-<p><em>Javascript</em></p>
-<pre>var flowFile = session.create();
-// Additional processing here
-</pre>
<p><em>JRuby</em></p>
<pre>flowFile = session.create()
# Additional processing here
@@ -197,13 +178,6 @@ if (flowFile != None):
newFlowFile = session.create(flowFile)
# Additional processing here
</pre>
-<p><em>Javascript</em></p>
-<pre>var flowFile = session.get();
-if (flowFile != null) {
- var newFlowFile = session.create(flowFile);
- // Additional processing here
-}
-</pre>
<p><em>JRuby</em></p>
<pre>flowFile = session.get()
if flowFile != nil
@@ -229,12 +203,6 @@ if (flowFile != None):
flowFile = session.putAttribute(flowFile, 'myAttr', 'myValue')
# implicit return at the end
</pre>
-<p><em>Javascript</em></p>
-<pre>var flowFile = session.get();
-if (flowFile != null) {
- flowFile = session.putAttribute(flowFile, 'myAttr', 'myValue')
-}
-</pre>
<p><em>JRuby</em></p>
<pre>flowFile = session.get()
if flowFile != nil
@@ -261,14 +229,6 @@ if (flowFile != None):
flowFile = session.putAllAttributes(flowFile, attrMap)
# implicit return at the end
</pre>
-<p><em>Javascript</em></p>
-<pre>var number2 = 2;
-var attrMap = {'myAttr1':'1', 'myAttr2': number2.toString()}
-var flowFile = session.get()
-if (flowFile != null) {
- flowFile = session.putAllAttributes(flowFile, attrMap)
-}
-</pre>
<p><em>JRuby</em></p>
<pre>attrMap = {'myAttr1' => '1', 'myAttr2' => 2.to_s}
flowFile = session.get()
@@ -293,12 +253,6 @@ if (flowFile != None):
myAttr = flowFile.getAttribute('filename')
# implicit return at the end
</pre>
-<p><em>Javascript</em></p>
-<pre>var flowFile = session.get()
-if (flowFile != null) {
- var myAttr = flowFile.getAttribute('filename')
-}
-</pre>
<p><em>JRuby</em></p>
<pre>flowFile = session.get()
if flowFile != nil
@@ -325,15 +279,6 @@ if (flowFile != None):
# Do something with key and/or value
# implicit return at the end
</pre>
-<p><em>Javascript</em></p>
-<pre>var flowFile = session.get()
-if (flowFile != null) {
- var attrs = flowFile.getAttributes();
- for each (var attrKey in attrs.keySet()) {
- // Do something with attrKey (the key) and/or attrs[attrKey] (the value)
- }
-}
-</pre>
<p><em>JRuby</em></p>
<pre>flowFile = session.get()
if flowFile != nil
@@ -369,18 +314,6 @@ if (flowFile != None):
session.transfer(flowFile, REL_SUCCESS)
# implicit return at the end
</pre>
-<p><em>Javascript</em></p>
-<pre>var flowFile = session.get();
-if (flowFile != null) {
- // All processing code goes here
- if(errorOccurred) {
- session.transfer(flowFile, REL_FAILURE)
- }
- else {
- session.transfer(flowFile, REL_SUCCESS)
- }
-}
-</pre>
<p><em>JRuby</em></p>
<pre>flowFile = session.get()
if flowFile != nil
@@ -407,14 +340,6 @@ objArray = ['Hello',1,True]
javaArray = array(objArray, Object)
log.info('Found these things: {} {} {}', javaArray)
</pre>
-<p><em>Javascript</em></p>
-<pre>var ObjectArrayType = Java.type("java.lang.Object[]");
-var objArray = new ObjectArrayType(3);
-objArray[0] = 'Hello';
-objArray[1] = 1;
-objArray[2] = true;
-log.info('Found these things: {} {} {}', objArray)
-</pre>
<p><em>JRuby</em></p>
<pre>log.info('Found these things: {} {} {}', ['Hello',1,true].to_java)
</pre>
@@ -452,21 +377,6 @@ flowFile = session.get()
if(flowFile != None):
session.read(flowFile, PyInputStreamCallback())
# implicit return at the end</pre>
-<p><em>Javascript</em></p>
-
-<pre>var InputStreamCallback =
Java.type("org.apache.nifi.processor.io.InputStreamCallback")
-var IOUtils = Java.type("org.apache.commons.io.IOUtils")
-var StandardCharsets = Java.type("java.nio.charset.StandardCharsets")
-
-var flowFile = session.get();
-if(flowFile != null) {
- // Create a new InputStreamCallback, passing in a function to define the
interface method
- session.read(flowFile,
- new InputStreamCallback(function(inputStream) {
- var text = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
- // Do something with text here
- }));
-}</pre>
<p><em>JRuby</em></p>
@@ -521,21 +431,6 @@ if(flowFile != None):
flowFile = session.write(flowFile, PyOutputStreamCallback())
# implicit return at the end</pre>
-<p><em>Javascript</em></p>
-
-<pre>var OutputStreamCallback =
Java.type("org.apache.nifi.processor.io.OutputStreamCallback");
-var IOUtils = Java.type("org.apache.commons.io.IOUtils");
-var StandardCharsets = Java.type("java.nio.charset.StandardCharsets");
-
-var flowFile = session.get();
-if(flowFile != null) {
- // Create a new OutputStreamCallback, passing in a function to define the
interface method
- flowFile = session.write(flowFile,
- new OutputStreamCallback(function(outputStream) {
- outputStream.write("Hello World!".getBytes(StandardCharsets.UTF_8))
- }));
-}</pre>
-
<p><em>JRuby</em></p>
<pre>java_import org.apache.commons.io.IOUtils
@@ -595,22 +490,6 @@ if(flowFile != None):
flowFile = session.write(flowFile, PyStreamCallback())
# implicit return at the end</pre>
-<p><em>Javascript</em></p>
-
-<pre>var StreamCallback =
Java.type("org.apache.nifi.processor.io.StreamCallback");
-var IOUtils = Java.type("org.apache.commons.io.IOUtils");
-var StandardCharsets = Java.type("java.nio.charset.StandardCharsets");
-
-var flowFile = session.get();
-if(flowFile != null) {
- // Create a new StreamCallback, passing in a function to define the
interface method
- flowFile = session.write(flowFile,
- new StreamCallback(function(inputStream, outputStream) {
- var text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)
-
outputStream.write(text.split("").reverse().join("").getBytes(StandardCharsets.UTF_8))
- }));
-}</pre>
-
<p><em>JRuby</em></p>
<pre>java_import org.apache.commons.io.IOUtils
@@ -664,21 +543,6 @@ if(flowFile != None):
session.transfer(flowFile, REL_FAILURE)
# implicit return at the end</pre>
-<p><em>Javascript</em></p>
-
-<pre>var flowFile = session.get();
-if(flowFile != null) {
- try {
- // Something that might throw an exception here
-
- // Last operation is transfer to success (failures handled in the catch
block)
- session.transfer(flowFile, REL_SUCCESS)
-} catch(e) {
- log.error('Something went wrong', e)
- session.transfer(flowFile, REL_FAILURE)
-}
-}</pre>
-
<p><em>JRuby</em></p>
<pre>flowFile = session.get()
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestExecuteJavascript.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestExecuteJavascript.java
deleted file mode 100644
index 5c828d202b..0000000000
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestExecuteJavascript.java
+++ /dev/null
@@ -1,61 +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.nifi.processors.script;
-
-import org.apache.nifi.script.ScriptingComponentUtils;
-import org.apache.nifi.util.MockFlowFile;
-import org.apache.nifi.util.TestRunner;
-import org.apache.nifi.util.TestRunners;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledForJreRange;
-import org.junit.jupiter.api.condition.JRE;
-
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-
-@DisabledForJreRange(min = JRE.JAVA_15, disabledReason = "Java 15 removed
Nashorn Engine")
-public class TestExecuteJavascript extends BaseScriptTest {
-
- @BeforeEach
- public void setup() throws Exception {
- super.setupExecuteScript();
- }
-
- /**
- * Tests a script that has provides the body of an onTrigger() function.
- *
- */
- @Test
- public void testReadFlowFileContentAndStoreInFlowFileAttribute() {
- final TestRunner runner = TestRunners.newTestRunner(new
ExecuteScript());
- runner.setValidateExpressionUsage(false);
-
runner.setProperty(scriptingComponent.getScriptingComponentHelper().SCRIPT_ENGINE,
"ECMAScript");
- runner.setProperty(ScriptingComponentUtils.SCRIPT_FILE,
"target/test/resources/javascript/test_onTrigger.js");
- // Use basic manipulation to validate that EL is working
- runner.setProperty(ScriptingComponentUtils.MODULES,
"target/test/resources/${literal('JAVASCRIPT'):toLower()}");
-
- runner.assertValid();
- runner.enqueue("test content".getBytes(StandardCharsets.UTF_8));
- runner.run();
-
- runner.assertAllFlowFilesTransferred("success", 1);
- final List<MockFlowFile> result =
runner.getFlowFilesForRelationship("success");
- result.get(0).assertAttributeEquals("from-content", "test content");
- }
-
-}
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeJavascript.java
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeJavascript.java
deleted file mode 100644
index 6955c57349..0000000000
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/java/org/apache/nifi/processors/script/TestInvokeJavascript.java
+++ /dev/null
@@ -1,187 +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.nifi.processors.script;
-
-import org.apache.nifi.components.PropertyDescriptor;
-import org.apache.nifi.processor.Relationship;
-import org.apache.nifi.script.ScriptingComponentUtils;
-import org.apache.nifi.util.MockFlowFile;
-import org.apache.nifi.util.TestRunner;
-import org.apache.nifi.util.TestRunners;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.condition.DisabledForJreRange;
-import org.junit.jupiter.api.condition.JRE;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-@DisabledForJreRange(min = JRE.JAVA_15, disabledReason = "Java 15 removed
Nashorn Engine")
-public class TestInvokeJavascript extends BaseScriptTest {
-
- @BeforeEach
- public void setup() throws Exception {
- super.setupInvokeScriptProcessor();
- }
-
- /**
- * Tests a scripted processor written in Javascript that reads the first
line of text from the flowfiles content
- * and stores the value in an attribute of the outgoing flowfile.
- * Confirms that the scripted processor transfers the incoming flowfile
with an attribute added.
- *
- * @Any error encountered while testing
- */
- @Test
- public void testReadFlowFileContentAndStoreInFlowFileAttribute() {
- setScriptProperties();
-
- runner.assertValid();
- runner.enqueue("test content".getBytes(StandardCharsets.UTF_8));
- runner.run();
-
- runner.assertAllFlowFilesTransferred("test", 1);
- final List<MockFlowFile> result =
runner.getFlowFilesForRelationship("test");
- result.get(0).assertAttributeEquals("from-content", "test content");
- }
-
- /**
- * Tests a scripted processor written in Javascript that reads the first
line of text from the flowfiles content and
- * stores the value in an attribute of the outgoing flowfile.
- * Confirms that the scripted processor can return property descriptors
defined in it.
- *
- * @Any error encountered while testing
- */
- @Test
- public void testScriptDefinedAttribute() {
- setScriptProperties();
- runner.assertValid();
-
- List<PropertyDescriptor> descriptors =
runner.getProcessor().getPropertyDescriptors();
- assertNotNull(descriptors);
- assertTrue(descriptors.size() > 0);
- boolean found = false;
- for (PropertyDescriptor descriptor : descriptors) {
- if (descriptor.getName().equals("test-attribute")) {
- found = true;
- break;
- }
- }
- assertTrue(found);
- }
-
- /**
- * Tests a scripted processor written in Javascript reads the first line
of text from the flowfiles content and
- * stores the value in an attribute of the outgoing flowfile.
- * Confirms that the scripted processor can return relationships defined
in it.
- *
- * @Any error encountered while testing
- */
- @Test
- public void testScriptDefinedRelationshipWithExternalJar() {
- setScriptProperties();
- runner.assertValid();
-
- Set<Relationship> relationships =
runner.getProcessor().getRelationships();
- assertNotNull(relationships);
- assertTrue(relationships.size() > 0);
- boolean found = false;
- for (Relationship relationship : relationships) {
- if (relationship.getName().equals("test")) {
- found = true;
- break;
- }
- }
- assertTrue(found);
- }
-
- /**
- * Tests a script that throws a ProcessException within.
- * The expected result is that the exception will be propagated.
- *
- */
- @Test
- public void testInvokeScriptCausesException() {
- final TestRunner runner = TestRunners.newTestRunner(new
InvokeScriptedProcessor());
-
runner.setProperty(scriptingComponent.getScriptingComponentHelper().SCRIPT_ENGINE,
"ECMAScript");
- runner.setProperty(ScriptingComponentUtils.SCRIPT_BODY,
getFileContentsAsString(
- TEST_RESOURCE_LOCATION +
"javascript/testInvokeScriptCausesException.js")
- );
- runner.assertValid();
- runner.enqueue("test content".getBytes(StandardCharsets.UTF_8));
- assertThrows(AssertionError.class, () -> runner.run());
- }
-
- /**
- * Tests a script that routes the FlowFile to failure.
- *
- * @Any error encountered while testing
- */
- @Test
- public void testScriptRoutesToFailure() {
-
runner.setProperty(scriptingComponent.getScriptingComponentHelper().SCRIPT_ENGINE,
"ECMAScript");
- runner.setProperty(ScriptingComponentUtils.SCRIPT_BODY,
getFileContentsAsString(
- TEST_RESOURCE_LOCATION +
"javascript/testScriptRoutesToFailure.js")
- );
- runner.assertValid();
- runner.enqueue("test content".getBytes(StandardCharsets.UTF_8));
- runner.run();
-
- runner.assertAllFlowFilesTransferred("FAILURE", 1);
- final List<MockFlowFile> result =
runner.getFlowFilesForRelationship("FAILURE");
- assertFalse(result.isEmpty());
- }
-
- /**
- * Tests an empty script with Nashorn (which throws an NPE if it is
loaded), this test verifies an empty script is not attempted to be loaded.
- *
- * @Any error encountered while testing
- */
- @Test
- public void testEmptyScript() {
-
runner.setProperty(scriptingComponent.getScriptingComponentHelper().SCRIPT_ENGINE,
"ECMAScript");
- runner.setProperty(ScriptingComponentUtils.SCRIPT_BODY, "");
- runner.assertNotValid();
- }
-
- private void setScriptProperties() {
-
runner.setProperty(scriptingComponent.getScriptingComponentHelper().SCRIPT_ENGINE,
"ECMAScript");
- runner.setProperty(ScriptingComponentUtils.SCRIPT_FILE,
getResource("/javascript/test_reader.js"));
- runner.setProperty(ScriptingComponentUtils.MODULES,
getResource("/jar"));
- }
-
- private String getResource(final String resourcePath) {
- final URL resourceUrl =
Objects.requireNonNull(TestInvokeJavascript.class.getResource(resourcePath),
resourcePath);
- final URI resourceUri;
- try {
- resourceUri = resourceUrl.toURI();
- } catch (final URISyntaxException e) {
- throw new RuntimeException(e);
- }
- return Paths.get(resourceUri).toString();
- }
-}
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/testInvokeScriptCausesException.js
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/testInvokeScriptCausesException.js
deleted file mode 100644
index 7cc17a1ec3..0000000000
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/testInvokeScriptCausesException.js
+++ /dev/null
@@ -1,58 +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.
- */
-
-var Set = Java.type("java.util.HashSet");
-
-var processor = new Object() {
- logger: null,
-
- // Processor
- initialize: function(context) {
- },
-
- getRelationships: function() {
- return new Set();
- },
-
- onTrigger: function(context, sessionFactory) {
- throw new Error("Failed!");
- },
-
- // ConfigurableComponent
- validate: function(context) {
- return [];
- },
-
- getPropertyDescriptor: function(name) {
- return null;
- },
-
- onPropertyModified: function(descriptor, oldValue, newValue) {
- },
-
- getPropertyDescriptors: function() {
- return [];
- },
-
- getIdentifier: function() {
- return null;
- },
-
- setLogger: function(logger) {
- this.logger = logger;
- }
-};
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/testScriptRoutesToFailure.js
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/testScriptRoutesToFailure.js
deleted file mode 100644
index d61e09f724..0000000000
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/testScriptRoutesToFailure.js
+++ /dev/null
@@ -1,79 +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.
- */
-
-/*
-var processor = new org.apache.nifi.processor.Processor() {
-This will cause following error:
-'ScriptValidation' validated against
'target/test/resources/javascript/test_reader.js' is invalid because Unable to
load script due to getInterface cannot be called on non-script object
-*/
-
-var Set = Java.type("java.util.HashSet");
-var Relationship = Java.type("org.apache.nifi.processor.Relationship");
-
-var REL_FAILURE = new Relationship.Builder()
- .name("FAILURE")
- .description("A FAILURE relationship")
- .build();
-
-var processor = new Object() {
- logger: null,
-
- // Processor
- initialize: function(context) {
- },
-
- getRelationships: function() {
- var relationships = new Set();
- relationships.addAll([REL_FAILURE]);
- return relationships;
- },
-
- onTrigger: function(context, sessionFactory) {
- var session = sessionFactory.createSession()
- var flowFile = session.get();
- if (flowFile == null) {
- return;
- }
- // transfer
- session.transfer(flowFile, REL_FAILURE)
- session.commitAsync()
- },
-
- // ConfigurableComponent
- validate: function(context) {
- return [];
- },
-
- getPropertyDescriptor: function(name) {
- return null;
- },
-
- onPropertyModified: function(descriptor, oldValue, newValue) {
- },
-
- getPropertyDescriptors: function() {
- return [];
- },
-
- getIdentifier: function() {
- return null;
- },
-
- setLogger: function(logger) {
- this.logger = logger;
- }
-};
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/test_onTrigger.js
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/test_onTrigger.js
deleted file mode 100644
index b0418ca0a5..0000000000
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/test_onTrigger.js
+++ /dev/null
@@ -1,21 +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.
- */
-flowFile = session.get();
-if (flowFile != null) {
- flowFile = session.putAttribute(flowFile, "from-content", "test content")
- session.transfer(flowFile, REL_SUCCESS)
-}
\ No newline at end of file
diff --git
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/test_reader.js
b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/test_reader.js
deleted file mode 100644
index f82a31a569..0000000000
---
a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/test/resources/javascript/test_reader.js
+++ /dev/null
@@ -1,110 +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.
- */
-
-/*
-var processor = new org.apache.nifi.processor.Processor() {
-This will cause following error:
-'ScriptValidation' validated against
'target/test/resources/javascript/test_reader.js' is invalid because Unable to
load script due to getInterface cannot be called on non-script object
-*/
-
-var String = Java.type("java.lang.String");
-var Set = Java.type("java.util.HashSet");
-var Relationship = Java.type("org.apache.nifi.processor.Relationship");
-var PropertyDescriptor =
Java.type("org.apache.nifi.components.PropertyDescriptor");
-var StandardValidators =
Java.type("org.apache.nifi.processor.util.StandardValidators");
-var StreamUtils = Java.type("org.apache.nifi.stream.io.StreamUtils");
-var Primes = Java.type("org.apache.commons.math3.primes.Primes")
-
-var REL_TEST = new Relationship.Builder()
- .name("test")
- .description("A test relationship")
- .build();
-
-var PROP_TEST_ATTRIBUTE = new PropertyDescriptor.Builder()
-
.name("test-attribute").addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build()
-
-var propertyDescriptors = [PROP_TEST_ATTRIBUTE];
-
-var processor = new Object() {
- logger: null,
-
- // Processor
- initialize: function(context) {
- },
-
- getRelationships: function() {
- var relationships = new Set();
- relationships.addAll([REL_TEST]);
- return relationships;
- },
-
- onTrigger: function(context, sessionFactory) {
- var session = sessionFactory.createSession()
- var flowFile = session.get();
- if (flowFile == null) {
- return;
- }
-
- // Set local logger variable so that read callback can use it.
- var logger = this.logger;
-
- // Read content from flowFile using Java classes.
- var content;
- session.read(flowFile, function (inputStream) {
- var buffer = Java.to(new Array(flowFile.getSize()), "byte[]");
- logger.info("Reading from inputStream, size={}, {}",
[flowFile.getSize(), inputStream]);
- StreamUtils.fillBuffer(inputStream, buffer, false);
- content = new String(buffer, "UTF-8");
- })
-
- this.logger.info("Read content={}", [content]);
-
- flowFile = session.putAttribute(flowFile, "from-content", content);
- flowFile = session.putAttribute(flowFile, "is3Prime",
Primes.isPrime(3))
- // transfer
- session.transfer(flowFile, REL_TEST)
- session.commitAsync()
- },
-
- // ConfigurableComponent
- validate: function(context) {
- return [];
- },
-
- getPropertyDescriptor: function(name) {
- for (var i = 0; i < propertyDescriptors.length; i++) {
- if (name === p.getName) return p;
- }
- return null;
- },
-
- onPropertyModified: function(descriptor, oldValue, newValue) {
- },
-
- getPropertyDescriptors: function() {
- return propertyDescriptors;
- },
-
- getIdentifier: function() {
- return null;
- },
-
- setLogger: function(logger) {
- this.logger = logger;
- this.logger.info("logger is set! logger={}", [logger]);
- }
-};