diff --git a/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/AbstractKiteProcessor.java b/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/AbstractKiteProcessor.java index 2113854ab0..56418f4bae 100644 --- a/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/AbstractKiteProcessor.java +++ b/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/AbstractKiteProcessor.java @@ -78,20 +78,24 @@ abstract class AbstractKiteProcessor extends AbstractProcessor { protected static final Validator RECOGNIZED_URI = new Validator() { @Override - public ValidationResult validate(String subject, String uri, - ValidationContext context) { + public ValidationResult validate(String subject, String uri, ValidationContext context) { String message = "not set"; boolean isValid = true; - if (uri == null || uri.isEmpty()) { + + if (uri.trim().isEmpty()) { isValid = false; - } else if (!uri.contains("$")) { - try { - new URIBuilder(URI.create(uri)).build(); - } catch (RuntimeException e) { - message = e.getMessage(); - isValid = false; + } else { + final boolean elPresent = context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(uri); + if (!elPresent) { + try { + new URIBuilder(URI.create(uri)).build(); + } catch (RuntimeException e) { + message = e.getMessage(); + isValid = false; + } } } + return new ValidationResult.Builder() .subject(subject) .input(uri) @@ -157,16 +161,16 @@ abstract class AbstractKiteProcessor extends AbstractProcessor { protected static final Validator SCHEMA_VALIDATOR = new Validator() { @Override public ValidationResult validate(String subject, String uri, ValidationContext context) { - Configuration conf = getConfiguration( - context.getProperty(CONF_XML_FILES).getValue()); - + Configuration conf = getConfiguration(context.getProperty(CONF_XML_FILES).getValue()); String error = null; - if (!uri.contains("$")) { - try { - getSchema(uri, conf); - } catch (SchemaNotFoundException e) { - error = e.getMessage(); - } + + final boolean elPresent = context.isExpressionLanguageSupported(subject) && context.isExpressionLanguagePresent(uri); + if (!elPresent) { + try { + getSchema(uri, conf); + } catch (SchemaNotFoundException e) { + error = e.getMessage(); + } } return new ValidationResult.Builder() .subject(subject) @@ -177,8 +181,7 @@ abstract class AbstractKiteProcessor extends AbstractProcessor { } }; - protected static final List ABSTRACT_KITE_PROPS - = ImmutableList.builder() + protected static final List ABSTRACT_KITE_PROPS = ImmutableList.builder() .add(CONF_XML_FILES) .build(); diff --git a/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/ConvertCSVToAvro.java b/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/ConvertCSVToAvro.java index be8c416fcd..c6f58c7bed 100644 --- a/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/ConvertCSVToAvro.java +++ b/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/ConvertCSVToAvro.java @@ -88,8 +88,7 @@ public class ConvertCSVToAvro extends AbstractKiteProcessor { static final PropertyDescriptor SCHEMA = new PropertyDescriptor.Builder() .name("Record schema") - .description( - "Outgoing Avro schema for each record created from a CSV row") + .description("Outgoing Avro schema for each record created from a CSV row") .addValidator(SCHEMA_VALIDATOR) .expressionLanguageSupported(true) .required(true) @@ -253,7 +252,6 @@ public class ConvertCSVToAvro extends AbstractKiteProcessor { } catch (ProcessException | DatasetIOException e) { getLogger().error("Failed reading or writing", e); session.transfer(flowFile, FAILURE); - } catch (DatasetException e) { getLogger().error("Failed to read FlowFile", e); session.transfer(flowFile, FAILURE); diff --git a/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/ConvertJSONToAvro.java b/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/ConvertJSONToAvro.java index 7e40f14362..7a35e31393 100644 --- a/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/ConvertJSONToAvro.java +++ b/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/ConvertJSONToAvro.java @@ -65,8 +65,7 @@ public class ConvertJSONToAvro extends AbstractKiteProcessor { static final PropertyDescriptor SCHEMA = new PropertyDescriptor.Builder() .name("Record schema") - .description( - "Outgoing Avro schema for each record created from a JSON object") + .description("Outgoing Avro schema for each record created from a JSON object") .addValidator(SCHEMA_VALIDATOR) .expressionLanguageSupported(true) .required(true) diff --git a/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/StoreInKiteDataset.java b/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/StoreInKiteDataset.java index f65e0bce7c..5586de1c5f 100644 --- a/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/StoreInKiteDataset.java +++ b/nifi/nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/main/java/org/apache/nifi/processors/kite/StoreInKiteDataset.java @@ -68,8 +68,7 @@ public class StoreInKiteDataset extends AbstractKiteProcessor { public static final PropertyDescriptor KITE_DATASET_URI = new PropertyDescriptor.Builder() .name("Target dataset URI") - .description( - "URI that identifies a Kite dataset where data will be stored") + .description("URI that identifies a Kite dataset where data will be stored") .addValidator(RECOGNIZED_URI) .expressionLanguageSupported(true) .required(true) diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ControlRate.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ControlRate.java index 2c1a8646ea..83febb52de 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ControlRate.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ControlRate.java @@ -155,7 +155,7 @@ public class ControlRate extends AbstractProcessor { break; } - final ValidationResult rateResult = rateValidator.validate("Maximum Rate", context.getProperty(MAX_RATE).getValue(), null); + final ValidationResult rateResult = rateValidator.validate("Maximum Rate", context.getProperty(MAX_RATE).getValue(), context); if (!rateResult.isValid()) { validationResults.add(rateResult); } diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EvaluateJsonPath.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EvaluateJsonPath.java index e32eb126a0..2634da2913 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EvaluateJsonPath.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EvaluateJsonPath.java @@ -16,10 +16,19 @@ */ package org.apache.nifi.processors.standard; -import com.jayway.jsonpath.DocumentContext; -import com.jayway.jsonpath.InvalidJsonException; -import com.jayway.jsonpath.JsonPath; -import com.jayway.jsonpath.PathNotFoundException; +import java.io.IOException; +import java.io.OutputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import org.apache.commons.lang3.StringUtils; import org.apache.nifi.annotation.behavior.DynamicProperty; @@ -27,7 +36,6 @@ import org.apache.nifi.annotation.behavior.EventDriven; import org.apache.nifi.annotation.behavior.SideEffectFree; import org.apache.nifi.annotation.behavior.SupportsBatching; import org.apache.nifi.annotation.documentation.CapabilityDescription; -import org.apache.nifi.annotation.behavior.DynamicRelationship; import org.apache.nifi.annotation.documentation.Tags; import org.apache.nifi.annotation.lifecycle.OnRemoved; import org.apache.nifi.components.PropertyDescriptor; @@ -44,12 +52,10 @@ import org.apache.nifi.processor.io.OutputStreamCallback; import org.apache.nifi.stream.io.BufferedOutputStream; import org.apache.nifi.util.ObjectHolder; -import java.io.IOException; -import java.io.OutputStream; -import java.nio.charset.StandardCharsets; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; +import com.jayway.jsonpath.DocumentContext; +import com.jayway.jsonpath.InvalidJsonException; +import com.jayway.jsonpath.JsonPath; +import com.jayway.jsonpath.PathNotFoundException; @EventDriven @SideEffectFree diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java index b50ce3bae6..bfe53efa90 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/HandleHttpResponse.java @@ -54,7 +54,7 @@ public class HandleHttpResponse extends AbstractProcessor { .name("HTTP Status Code") .description("The HTTP Status Code to use when responding to the HTTP Request. See Section 10 of RFC 2616 for more information.") .required(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .addValidator(StandardValidators.NON_NEGATIVE_INTEGER_VALIDATOR) .expressionLanguageSupported(true) .build(); public static final PropertyDescriptor HTTP_CONTEXT_MAP = new PropertyDescriptor.Builder() diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java index 63ec0bbdbe..08384d988a 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java @@ -203,7 +203,7 @@ public final class InvokeHTTP extends AbstractProcessor { .description("Remote URL which will be connected to, including scheme, host, port, path.") .required(true) .expressionLanguageSupported(true) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .addValidator(StandardValidators.URL_VALIDATOR) .build(); PropertyDescriptor PROP_CONNECT_TIMEOUT = new PropertyDescriptor.Builder() diff --git a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java index 5f10772df9..d67ed092d9 100644 --- a/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java +++ b/nifi/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PostHTTP.java @@ -146,6 +146,7 @@ public class PostHTTP extends AbstractProcessor { .description("The URL to POST to. The first part of the URL must be static. However, the path of the URL may be defined using the Attribute Expression Language. For example, https://${hostname} is not valid, but https://1.1.1.1:8080/files/${nf.file.name} is valid.") .required(true) .addValidator(StandardValidators.createRegexMatchingValidator(Pattern.compile("https?\\://.*"))) + .addValidator(StandardValidators.URL_VALIDATOR) .expressionLanguageSupported(true) .build(); public static final PropertyDescriptor SEND_AS_FLOWFILE = new PropertyDescriptor.Builder()