You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2019/02/01 18:34:34 UTC

[nifi] branch master updated: NIFI-5995 Updated ScriptedLookupService documentation to warn about Jython and removed Jython from the list of supported script engines for it because it's broken now.

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

mattyb149 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/master by this push:
     new fef41b3  NIFI-5995 Updated ScriptedLookupService documentation to warn about Jython and removed Jython from the list of supported script engines for it because it's broken now.
fef41b3 is described below

commit fef41b302216934886817fd9335ea4b5d62c4c1e
Author: Mike Thomsen <mi...@gmail.com>
AuthorDate: Fri Feb 1 10:53:30 2019 -0500

    NIFI-5995 Updated ScriptedLookupService documentation to warn about Jython and removed Jython from the list of supported script engines for it because it's broken now.
    
    Signed-off-by: Matthew Burgess <ma...@apache.org>
    
    This closes #3287
---
 .../nifi/lookup/script/ScriptedLookupService.java    | 20 ++++++++++++++++++--
 .../apache/nifi/script/ScriptingComponentHelper.java |  6 ++++++
 2 files changed, 24 insertions(+), 2 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 25ac39a..956a9ce 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
@@ -22,6 +22,7 @@ import org.apache.nifi.annotation.documentation.CapabilityDescription;
 import org.apache.nifi.annotation.documentation.Tags;
 import org.apache.nifi.annotation.lifecycle.OnDisabled;
 import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.AllowableValue;
 import org.apache.nifi.components.ConfigurableComponent;
 import org.apache.nifi.components.PropertyDescriptor;
 import org.apache.nifi.components.RequiredPermission;
@@ -53,12 +54,15 @@ import java.util.Map;
 import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 /**
  * 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"})
-@CapabilityDescription("Allows the user to provide a scripted LookupService instance in order to enrich records from an incoming flow file.")
+@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.")
 @Restricted(
         restrictions = {
                 @Restriction(
@@ -116,7 +120,19 @@ public class ScriptedLookupService extends AbstractScriptedControllerService imp
             }
         }
         List<PropertyDescriptor> supportedPropertyDescriptors = new ArrayList<>();
-        supportedPropertyDescriptors.addAll(scriptingComponentHelper.getDescriptors());
+        List<PropertyDescriptor> _temp = new ArrayList<>();
+        _temp.addAll(scriptingComponentHelper.getDescriptors());
+        _temp.remove(scriptingComponentHelper.SCRIPT_ENGINE);
+
+        PropertyDescriptor.Builder jythonLessEngineProp = new PropertyDescriptor
+            .Builder().fromPropertyDescriptor(scriptingComponentHelper.SCRIPT_ENGINE);
+        List<AllowableValue> filtered = scriptingComponentHelper.getScriptEngineAllowableValues()
+            .stream().filter(allowableValue -> !allowableValue.getValue().contains("ython"))
+            .collect(Collectors.toList());
+        jythonLessEngineProp.allowableValues(filtered.toArray(new AllowableValue[filtered.size()]));
+
+        supportedPropertyDescriptors.add(jythonLessEngineProp.build());
+        supportedPropertyDescriptors.addAll(_temp);
 
         final ConfigurableComponent instance = lookupService.get();
         if (instance != null) {
diff --git a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/ScriptingComponentHelper.java b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/ScriptingComponentHelper.java
index 831d305..dc9255e 100644
--- a/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/ScriptingComponentHelper.java
+++ b/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/ScriptingComponentHelper.java
@@ -70,6 +70,7 @@ public class ScriptingComponentHelper {
     private String scriptBody;
     private String[] modules;
     private List<PropertyDescriptor> descriptors;
+    private List<AllowableValue> engineAllowableValues;
 
     public BlockingQueue<ScriptEngine> engineQ = null;
 
@@ -109,6 +110,10 @@ public class ScriptingComponentHelper {
         return descriptors;
     }
 
+    public List<AllowableValue> getScriptEngineAllowableValues() {
+        return engineAllowableValues;
+    }
+
     public void setDescriptors(List<PropertyDescriptor> descriptors) {
         this.descriptors = descriptors;
     }
@@ -167,6 +172,7 @@ public class ScriptingComponentHelper {
                 return o1.getValue().compareTo(o2.getValue());
             });
 
+            engineAllowableValues = engineList;
             AllowableValue[] engines = engineList.toArray(new AllowableValue[engineList.size()]);
 
             SCRIPT_ENGINE = new PropertyDescriptor.Builder()