NIFI-5197 Fixed a bunch of EL scope bugs.

Signed-off-by: Matthew Burgess <mattyb149@apache.org>

This closes #2712
This commit is contained in:
Mike Thomsen 2018-05-15 20:54:51 -04:00 committed by Matthew Burgess
parent 5613bf4012
commit f5108ea839
18 changed files with 51 additions and 33 deletions

View File

@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.util.StandardValidators;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -35,20 +36,20 @@ public class TestCustomNotificationService extends AbstractNotificationService {
.name("Custom Hostname")
.description("The hostname of the Custom Server that is used to send notifications")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.required(true)
.build();
public static final PropertyDescriptor CUSTOM_USERNAME = new PropertyDescriptor.Builder()
.name("Custom Username")
.description("Username for the account")
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.required(false)
.build();
public static final PropertyDescriptor CUSTOM_PASSWORD = new PropertyDescriptor.Builder()
.name("Custom Password")
.description("Password for the account")
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.required(false)
.sensitive(true)

View File

@ -45,6 +45,7 @@ import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.AbstractProcessor;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.Relationship;
@ -79,7 +80,7 @@ public abstract class AbstractAWSProcessor<ClientType extends AmazonWebServiceCl
public static final PropertyDescriptor PROXY_HOST = new PropertyDescriptor.Builder()
.name("Proxy Host")
.description("Proxy host name or IP")
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.required(false)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
@ -87,7 +88,7 @@ public abstract class AbstractAWSProcessor<ClientType extends AmazonWebServiceCl
public static final PropertyDescriptor PROXY_HOST_PORT = new PropertyDescriptor.Builder()
.name("Proxy Host Port")
.description("Proxy host port")
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.required(false)
.addValidator(StandardValidators.PORT_VALIDATOR)
.build();
@ -118,7 +119,7 @@ public abstract class AbstractAWSProcessor<ClientType extends AmazonWebServiceCl
.description("Endpoint URL to use instead of the AWS default including scheme, host, port, and path. " +
"The AWS libraries select an endpoint URL based on the AWS region, but this property overrides " +
"the selected endpoint URL, allowing use with other S3-compatible endpoints.")
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.required(false)
.addValidator(StandardValidators.URL_VALIDATOR)
.build();

View File

@ -20,6 +20,7 @@ import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.controller.ControllerService;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.util.StandardValidators;
import org.apache.nifi.ssl.SSLContextService;
@ -33,7 +34,7 @@ public interface ElasticSearchClientService extends ControllerService {
.displayName("HTTP Hosts")
.description("A comma-separated list of HTTP hosts that host ElasticSearch query nodes.")
.required(true)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
PropertyDescriptor PROP_SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder()
@ -49,7 +50,7 @@ public interface ElasticSearchClientService extends ControllerService {
.displayName("Username")
.description("The username to use with XPack security.")
.required(false)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
PropertyDescriptor PASSWORD = new PropertyDescriptor.Builder()
@ -58,7 +59,7 @@ public interface ElasticSearchClientService extends ControllerService {
.description("The password to use with XPack security.")
.required(false)
.sensitive(true)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
PropertyDescriptor CONNECT_TIMEOUT = new PropertyDescriptor.Builder()

View File

@ -128,7 +128,7 @@ public class DeleteMongo extends AbstractMongoProcessor {
public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException {
FlowFile flowFile = session.get();
final WriteConcern writeConcern = getWriteConcern(context);
final MongoCollection<Document> collection = getCollection(context).withWriteConcern(writeConcern);
final MongoCollection<Document> collection = getCollection(context, flowFile).withWriteConcern(writeConcern);
final String deleteMode = context.getProperty(DELETE_MODE).getValue();
final String deleteAttr = flowFile.getAttribute("mongodb.delete.mode");
final Boolean failMode = context.getProperty(FAIL_ON_NO_DELETE).asBoolean();

View File

@ -297,7 +297,7 @@ public class GetMongo extends AbstractMongoProcessor {
configureMapper(jsonTypeSetting);
final MongoCollection<Document> collection = getCollection(context);
final MongoCollection<Document> collection = getCollection(context, input);
try {
final FindIterable<Document> it = query != null ? collection.find(query) : collection.find();

View File

@ -113,7 +113,7 @@ public class PutMongoRecord extends AbstractMongoProcessor {
final WriteConcern writeConcern = getWriteConcern(context);
final MongoCollection<Document> collection = getCollection(context).withWriteConcern(writeConcern);
final MongoCollection<Document> collection = getCollection(context, flowFile).withWriteConcern(writeConcern);
List<Document> inserts = new ArrayList<>();
int ceiling = context.getProperty(INSERT_COUNT).asInteger();

View File

@ -172,7 +172,7 @@ public class RunMongoAggregation extends AbstractMongoProcessor {
attrs.put(queryAttr, query);
}
MongoCollection<Document> collection = getCollection(context);
MongoCollection<Document> collection = getCollection(context, flowFile);
MongoCursor<Document> iter = null;
try {

View File

@ -18,6 +18,7 @@ package org.apache.nifi.processors.standard;
import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.AbstractProcessor;
import org.apache.nifi.processor.util.StandardValidators;
@ -41,7 +42,7 @@ public abstract class AbstractSyslogProcessor extends AbstractProcessor {
.description("The port for Syslog communication. Note that Expression language is not evaluated per FlowFile.")
.required(true)
.addValidator(StandardValidators.PORT_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor CHARSET = new PropertyDescriptor.Builder()
.name("Character Set")
@ -49,7 +50,7 @@ public abstract class AbstractSyslogProcessor extends AbstractProcessor {
.required(true)
.defaultValue("UTF-8")
.addValidator(StandardValidators.CHARACTER_SET_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor TIMEOUT = new PropertyDescriptor.Builder()
.name("Timeout")
@ -57,7 +58,7 @@ public abstract class AbstractSyslogProcessor extends AbstractProcessor {
.required(false)
.defaultValue("10 seconds")
.addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();

View File

@ -29,6 +29,7 @@ import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.annotation.lifecycle.OnScheduled;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.processor.AbstractProcessor;
@ -88,7 +89,7 @@ public class AttributesToJSON extends AbstractProcessor {
+ "the matching attributes. This property can be used in combination with the attributes "
+ "list property.")
.required(false)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.createRegexValidator(0, Integer.MAX_VALUE, true))
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();

View File

@ -42,6 +42,7 @@ import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.logging.ComponentLog;
@ -134,7 +135,7 @@ public class EncryptContent extends AbstractProcessor {
.description("In a PGP decrypt mode, this is the private keyring passphrase")
.required(false)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.sensitive(true)
.build();
public static final PropertyDescriptor RAW_KEY_HEX = new PropertyDescriptor.Builder()

View File

@ -233,7 +233,7 @@ public final class InvokeHTTP extends AbstractProcessor {
.displayName("Proxy Type")
.description("The type of the proxy we are connecting to. Must be either " + HTTP + " or " + HTTPS)
.defaultValue(HTTP)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(StandardValidators.NON_EMPTY_EL_VALIDATOR)
.build();

View File

@ -30,6 +30,7 @@ import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.processor.AbstractProcessor;
@ -102,7 +103,7 @@ public class ListenTCPRecord extends AbstractProcessor {
.description("The port to listen on for communication.")
.required(true)
.addValidator(StandardValidators.PORT_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
static final PropertyDescriptor READ_TIMEOUT = new PropertyDescriptor.Builder()

View File

@ -28,6 +28,7 @@ import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.components.Validator;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.DataUnit;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.util.StandardValidators;
@ -69,7 +70,7 @@ public class ListenUDP extends AbstractListenEventBatchingProcessor<StandardEven
.description("IP, or name, of a remote host. Only Datagrams from the specified Sending Host Port and this host will "
+ "be accepted. Improves Performance. May be a system property or an environment variable.")
.addValidator(new HostValidator())
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor SENDING_HOST_PORT = new PropertyDescriptor.Builder()
@ -77,7 +78,7 @@ public class ListenUDP extends AbstractListenEventBatchingProcessor<StandardEven
.description("Port being used by remote host to send Datagrams. Only Datagrams from the specified Sending Host and "
+ "this port will be accepted. Improves Performance. May be a system property or an environment variable.")
.addValidator(StandardValidators.PORT_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final String UDP_PORT_ATTR = "udp.port";

View File

@ -38,6 +38,7 @@ import org.apache.nifi.annotation.behavior.SideEffectFree;
import org.apache.nifi.annotation.behavior.SupportsBatching;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.logging.ComponentLog;
import org.apache.nifi.processor.AbstractProcessor;
@ -110,14 +111,14 @@ public class LogAttribute extends AbstractProcessor {
.required(false)
.description("Log prefix appended to the log lines. It helps to distinguish the output of multiple LogAttribute processors.")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.build();
public static final PropertyDescriptor CHARSET = new PropertyDescriptor.Builder()
.name("character-set")
.displayName("Character Set")
.description("The name of the CharacterSet to use")
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.addValidator(StandardValidators.CHARACTER_SET_VALIDATOR)
.defaultValue(Charset.defaultCharset().name())
.required(true)

View File

@ -78,7 +78,7 @@ public class PutSyslog extends AbstractSyslogProcessor {
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.defaultValue("localhost")
.required(true)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor MAX_SOCKET_SEND_BUFFER_SIZE = new PropertyDescriptor.Builder()
@ -89,7 +89,7 @@ public class PutSyslog extends AbstractSyslogProcessor {
.addValidator(StandardValidators.DATA_SIZE_VALIDATOR)
.defaultValue("1 MB")
.required(true)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor BATCH_SIZE = new PropertyDescriptor
.Builder().name("Batch Size")
@ -97,7 +97,7 @@ public class PutSyslog extends AbstractSyslogProcessor {
.required(true)
.defaultValue("25")
.addValidator(StandardValidators.POSITIVE_INTEGER_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor IDLE_EXPIRATION = new PropertyDescriptor
.Builder().name("Idle Connection Expiration")
@ -105,7 +105,7 @@ public class PutSyslog extends AbstractSyslogProcessor {
.required(true)
.defaultValue("5 seconds")
.addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build();
public static final PropertyDescriptor MSG_PRIORITY = new PropertyDescriptor
.Builder().name("Message Priority")

View File

@ -35,6 +35,7 @@ import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.flowfile.attributes.CoreAttributes;
import org.apache.nifi.processor.AbstractProcessor;
@ -142,7 +143,7 @@ public class ValidateRecord extends AbstractProcessor {
.displayName("Schema Name")
.description("Specifies the name of the schema to lookup in the Schema Registry property")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.defaultValue("${schema.name}")
.required(false)
.build();
@ -151,7 +152,7 @@ public class ValidateRecord extends AbstractProcessor {
.displayName("Schema Text")
.description("The text of an Avro-formatted Schema")
.addValidator(new AvroSchemaValidator())
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.defaultValue("${avro.schema}")
.required(false)
.build();

View File

@ -19,6 +19,7 @@ package org.apache.nifi.processors.standard;
import org.apache.commons.lang3.StringUtils;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.Validator;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.ProcessSession;
import org.apache.nifi.processor.ProcessSessionFactory;
@ -253,7 +254,13 @@ public class TestListenSyslog {
public List<PropertyDescriptor> getSupportedPropertyDescriptors() {
final List<PropertyDescriptor> properties = new ArrayList<>(super.getSupportedPropertyDescriptors());
properties.remove(PORT);
properties.add(new PropertyDescriptor.Builder().name(PORT.getName()).expressionLanguageSupported(true).addValidator(Validator.VALID).build());
properties.add(
new PropertyDescriptor.Builder()
.name(PORT.getName())
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.addValidator(Validator.VALID)
.build()
);
return properties;
}

View File

@ -34,6 +34,7 @@ import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ConfigurationContext;
import org.apache.nifi.controller.ControllerServiceInitializationContext;
import org.apache.nifi.expression.ExpressionLanguageScope;
import org.apache.nifi.processor.util.StandardValidators;
import org.apache.nifi.reporting.InitializationException;
@ -51,7 +52,7 @@ public class KeytabCredentialsService extends AbstractControllerService implemen
.name("Kerberos Principal")
.description("Kerberos principal to authenticate as. Requires nifi.kerberos.krb5.file to be set in your nifi.properties")
.addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.required(true)
.build();
@ -59,7 +60,7 @@ public class KeytabCredentialsService extends AbstractControllerService implemen
.name("Kerberos Keytab")
.description("Kerberos keytab associated with the principal. Requires nifi.kerberos.krb5.file to be set in your nifi.properties")
.addValidator(StandardValidators.FILE_EXISTS_VALIDATOR)
.expressionLanguageSupported(true)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.required(true)
.build();