NIFI-12452 Improved support for DescribedValue in Descriptors

- Removed calls to Builder.defaultValue(null) in several Components

This closes #8102

Signed-off-by: David Handermann <exceptionfactory@apache.org>
This commit is contained in:
EndzeitBegins 2023-12-02 00:49:44 +01:00 committed by exceptionfactory
parent 5b664147ee
commit c272574dcc
No known key found for this signature in database
30 changed files with 131 additions and 43 deletions

View File

@ -313,6 +313,24 @@ public final class PropertyDescriptor implements Comparable<PropertyDescriptor>
return this; return this;
} }
/**
* Specifies the initial value and the default value that will be used
* if the user does not specify a value. When {@link #build()} is
* called, if Allowable Values have been set (see
* {@link #allowableValues(AllowableValue...)})
* and the "Value" of the {@link DescribedValue} object is not
* the "Value" of one of those Allowable Values, an Exception will be thrown.
* If the Allowable Values have been set using the
* {@link #allowableValues(AllowableValue...)} method, the default value
* should be set providing the {@link AllowableValue} to this method.
*
* @param value default value holder
* @return the builder
*/
public Builder defaultValue(final DescribedValue value) {
return defaultValue(value != null ? value.getValue() : null);
}
public Builder dynamic(final boolean dynamic) { public Builder dynamic(final boolean dynamic) {
this.dynamic = dynamic; this.dynamic = dynamic;
return this; return this;

View File

@ -134,6 +134,18 @@ public interface PropertyValue {
*/ */
ResourceReferences asResources(); ResourceReferences asResources();
/**
* @param <E> the generic type of the enum used as allowable values
* @param enumType the class of the enum used as allowable values
* @return the DescribedValue enum entry whose value is the raw value of the
* <code>this</code>, or <code>null</code> if the value is not set.
* Throws an IllegalArgumentException if none of the enum entries correspond to the specified raw value.
*
* @throws IllegalArgumentException if the value of <code>this</code>
* does not point to any of the entries of the specified enum type.
*/
<E extends Enum<E> & DescribedValue> E asDescribedValue(Class<E> enumType) throws IllegalArgumentException;
/** /**
* @return <code>true</code> if the user has configured a value, or if the * @return <code>true</code> if the user has configured a value, or if the
* {@link PropertyDescriptor} for the associated property has a default * {@link PropertyDescriptor} for the associated property has a default

View File

@ -69,6 +69,17 @@ public class TestPropertyDescriptor {
assertNotNull(validDescriptorBuilder.build()); assertNotNull(validDescriptorBuilder.build());
} }
@Test
void testDefaultValueWithDescribedValue() {
final PropertyDescriptor propertyDescriptor = new PropertyDescriptor.Builder()
.name("defaultDescribedValueDescriptor")
.defaultValue(EnumAllowableValue.GREEN)
.build();
assertNotNull(propertyDescriptor);
assertEquals(EnumAllowableValue.GREEN.getValue(), propertyDescriptor.getDefaultValue());
}
@Test @Test
void testAllowableValuesWithEnumClass() { void testAllowableValuesWithEnumClass() {
final PropertyDescriptor propertyDescriptor = new PropertyDescriptor.Builder() final PropertyDescriptor propertyDescriptor = new PropertyDescriptor.Builder()

View File

@ -19,6 +19,8 @@ package org.apache.nifi.attribute.expression.language;
import java.time.Duration; import java.time.Duration;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.nifi.components.DescribedValue;
import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.PropertyValue; import org.apache.nifi.components.PropertyValue;
import org.apache.nifi.components.resource.ResourceContext; import org.apache.nifi.components.resource.ResourceContext;
@ -234,6 +236,21 @@ public class StandardPropertyValue implements PropertyValue {
return resourceContext.getResourceReferenceFactory().createResourceReferences(rawValue, propertyDescriptor.getResourceDefinition()); return resourceContext.getResourceReferenceFactory().createResourceReferences(rawValue, propertyDescriptor.getResourceDefinition());
} }
@Override
public <E extends Enum<E> & DescribedValue> E asDescribedValue(Class<E> enumType) throws IllegalArgumentException {
if (rawValue == null) {
return null;
}
for (E enumConstant : enumType.getEnumConstants()) {
if (enumConstant.getValue().equals(rawValue)) {
return enumConstant;
}
}
throw new IllegalArgumentException(String.format("%s does not have an entry with value %s", enumType.getSimpleName(), rawValue));
}
@Override @Override
public boolean isSet() { public boolean isSet() {
return rawValue != null; return rawValue != null;

View File

@ -25,6 +25,7 @@ import org.apache.nifi.annotation.behavior.InputRequirement;
import org.apache.nifi.attribute.expression.language.Query; import org.apache.nifi.attribute.expression.language.Query;
import org.apache.nifi.attribute.expression.language.Query.Range; import org.apache.nifi.attribute.expression.language.Query.Range;
import org.apache.nifi.attribute.expression.language.StandardPropertyValue; import org.apache.nifi.attribute.expression.language.StandardPropertyValue;
import org.apache.nifi.components.DescribedValue;
import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.PropertyValue; import org.apache.nifi.components.PropertyValue;
import org.apache.nifi.components.resource.ResourceContext; import org.apache.nifi.components.resource.ResourceContext;
@ -322,6 +323,11 @@ public class MockPropertyValue implements PropertyValue {
return new StandardResourceReferenceFactory().createResourceReferences(rawValue, propertyDescriptor.getResourceDefinition()); return new StandardResourceReferenceFactory().createResourceReferences(rawValue, propertyDescriptor.getResourceDefinition());
} }
@Override
public <E extends Enum<E> & DescribedValue> E asDescribedValue(Class<E> enumType) throws IllegalArgumentException {
ensureExpressionsEvaluated();
return stdPropValue.asDescribedValue(enumType);
}
@Override @Override
public boolean isSet() { public boolean isSet() {

View File

@ -27,6 +27,7 @@ import org.apache.nifi.annotation.lifecycle.OnShutdown;
import org.apache.nifi.annotation.lifecycle.OnStopped; import org.apache.nifi.annotation.lifecycle.OnStopped;
import org.apache.nifi.annotation.lifecycle.OnUnscheduled; import org.apache.nifi.annotation.lifecycle.OnUnscheduled;
import org.apache.nifi.components.AllowableValue; import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.DescribedValue;
import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext; import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult; import org.apache.nifi.components.ValidationResult;
@ -579,7 +580,7 @@ public class StandardProcessorTestRunner implements TestRunner {
} }
@Override @Override
public ValidationResult setProperty(final PropertyDescriptor descriptor, final AllowableValue value) { public ValidationResult setProperty(final PropertyDescriptor descriptor, final DescribedValue value) {
return context.setProperty(descriptor, value.getValue()); return context.setProperty(descriptor, value.getValue());
} }

View File

@ -17,6 +17,7 @@
package org.apache.nifi.util; package org.apache.nifi.util;
import org.apache.nifi.components.AllowableValue; import org.apache.nifi.components.AllowableValue;
import org.apache.nifi.components.DescribedValue;
import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationResult; import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.controller.ControllerService; import org.apache.nifi.controller.ControllerService;
@ -247,7 +248,7 @@ public interface TestRunner {
* @param value allowable valu * @param value allowable valu
* @return result * @return result
*/ */
ValidationResult setProperty(PropertyDescriptor descriptor, AllowableValue value); ValidationResult setProperty(PropertyDescriptor descriptor, DescribedValue value);
/** /**
* Sets the annotation data. * Sets the annotation data.

View File

@ -99,7 +99,6 @@ public class PutAzureEventHub extends AbstractProcessor implements AzureEventHub
.required(false) .required(false)
.expressionLanguageSupported(ExpressionLanguageScope.NONE) .expressionLanguageSupported(ExpressionLanguageScope.NONE)
.addValidator(StandardValidators.ATTRIBUTE_KEY_VALIDATOR) .addValidator(StandardValidators.ATTRIBUTE_KEY_VALIDATOR)
.defaultValue(null)
.build(); .build();
static final PropertyDescriptor MAX_BATCH_SIZE = new PropertyDescriptor.Builder() static final PropertyDescriptor MAX_BATCH_SIZE = new PropertyDescriptor.Builder()
.name("max-batch-size") .name("max-batch-size")

View File

@ -256,7 +256,6 @@ public class CaptureChangeMySQL extends AbstractSessionFactoryProcessor {
.displayName("MySQL Driver Location(s)") .displayName("MySQL Driver Location(s)")
.description("Comma-separated list of files/folders and/or URLs containing the MySQL driver JAR and its dependencies (if any). " .description("Comma-separated list of files/folders and/or URLs containing the MySQL driver JAR and its dependencies (if any). "
+ "For example '/var/tmp/mysql-connector-java-5.1.38-bin.jar'") + "For example '/var/tmp/mysql-connector-java-5.1.38-bin.jar'")
.defaultValue(null)
.required(false) .required(false)
.identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE, ResourceType.DIRECTORY, ResourceType.URL) .identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE, ResourceType.DIRECTORY, ResourceType.URL)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)

View File

@ -38,7 +38,6 @@ public final class DBCPProperties {
.name("Database Connection URL") .name("Database Connection URL")
.description("A database connection URL used to connect to a database. May contain database system name, host, port, database name and some parameters." .description("A database connection URL used to connect to a database. May contain database system name, host, port, database name and some parameters."
+ " The exact syntax of a database connection URL is specified by your DBMS.") + " The exact syntax of a database connection URL is specified by your DBMS.")
.defaultValue(null)
.addValidator(new ConnectionUrlValidator()) .addValidator(new ConnectionUrlValidator())
.required(true) .required(true)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
@ -47,7 +46,6 @@ public final class DBCPProperties {
public static final PropertyDescriptor DB_USER = new PropertyDescriptor.Builder() public static final PropertyDescriptor DB_USER = new PropertyDescriptor.Builder()
.name("Database User") .name("Database User")
.description("Database user name") .description("Database user name")
.defaultValue(null)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.build(); .build();
@ -55,7 +53,6 @@ public final class DBCPProperties {
public static final PropertyDescriptor DB_PASSWORD = new PropertyDescriptor.Builder() public static final PropertyDescriptor DB_PASSWORD = new PropertyDescriptor.Builder()
.name("Password") .name("Password")
.description("The password for the database user") .description("The password for the database user")
.defaultValue(null)
.required(false) .required(false)
.sensitive(true) .sensitive(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
@ -66,7 +63,6 @@ public final class DBCPProperties {
public static final PropertyDescriptor DB_DRIVERNAME = new PropertyDescriptor.Builder() public static final PropertyDescriptor DB_DRIVERNAME = new PropertyDescriptor.Builder()
.name("Database Driver Class Name") .name("Database Driver Class Name")
.description("Database driver class name") .description("Database driver class name")
.defaultValue(null)
.required(true) .required(true)
.addValidator(new DriverClassValidator()) .addValidator(new DriverClassValidator())
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
@ -76,7 +72,6 @@ public final class DBCPProperties {
.name("database-driver-locations") .name("database-driver-locations")
.displayName("Database Driver Location(s)") .displayName("Database Driver Location(s)")
.description("Comma-separated list of files/folders and/or URLs containing the driver JAR and its dependencies (if any). For example '/var/tmp/mariadb-java-client-1.1.7.jar'") .description("Comma-separated list of files/folders and/or URLs containing the driver JAR and its dependencies (if any). For example '/var/tmp/mariadb-java-client-1.1.7.jar'")
.defaultValue(null)
.required(false) .required(false)
.identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE, ResourceType.DIRECTORY, ResourceType.URL) .identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE, ResourceType.DIRECTORY, ResourceType.URL)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)

View File

@ -40,11 +40,11 @@ import java.util.List;
@SystemResourceConsideration(resource = SystemResource.MEMORY, description = "") @SystemResourceConsideration(resource = SystemResource.MEMORY, description = "")
public class FullyDocumentedControllerService extends AbstractControllerService implements SampleService { public class FullyDocumentedControllerService extends AbstractControllerService implements SampleService {
public static final PropertyDescriptor KEYSTORE = new PropertyDescriptor.Builder().name("Keystore Filename").description("The fully-qualified filename of the Keystore").defaultValue(null) public static final PropertyDescriptor KEYSTORE = new PropertyDescriptor.Builder().name("Keystore Filename").description("The fully-qualified filename of the Keystore")
.addValidator(StandardValidators.FILE_EXISTS_VALIDATOR).sensitive(false).build(); .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR).sensitive(false).build();
public static final PropertyDescriptor KEYSTORE_TYPE = new PropertyDescriptor.Builder().name("Keystore Type").description("The Type of the Keystore").allowableValues("JKS", "PKCS12") public static final PropertyDescriptor KEYSTORE_TYPE = new PropertyDescriptor.Builder().name("Keystore Type").description("The Type of the Keystore").allowableValues("JKS", "PKCS12")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR).defaultValue("JKS").sensitive(false).build(); .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).defaultValue("JKS").sensitive(false).build();
public static final PropertyDescriptor KEYSTORE_PASSWORD = new PropertyDescriptor.Builder().name("Keystore Password").defaultValue(null).description("The password for the Keystore") public static final PropertyDescriptor KEYSTORE_PASSWORD = new PropertyDescriptor.Builder().name("Keystore Password").description("The password for the Keystore")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR).sensitive(true).build(); .addValidator(StandardValidators.NON_EMPTY_VALIDATOR).sensitive(true).build();
private static final List<PropertyDescriptor> properties; private static final List<PropertyDescriptor> properties;

View File

@ -24,6 +24,8 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.nifi.components.DescribedValue;
import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.PropertyValue; import org.apache.nifi.components.PropertyValue;
import org.apache.nifi.components.resource.ResourceReference; import org.apache.nifi.components.resource.ResourceReference;
@ -151,6 +153,11 @@ public class ConnectableProcessContext implements ProcessContext {
return null; return null;
} }
@Override
public <E extends Enum<E> & DescribedValue> E asDescribedValue(Class<E> enumType) throws IllegalArgumentException {
return null;
}
@Override @Override
public boolean isSet() { public boolean isSet() {
return false; return false;

View File

@ -16,6 +16,7 @@
*/ */
package org.apache.nifi.processor; package org.apache.nifi.processor;
import org.apache.nifi.components.DescribedValue;
import org.apache.nifi.parameter.ParameterLookup; import org.apache.nifi.parameter.ParameterLookup;
import org.apache.nifi.attribute.expression.language.StandardPropertyValue; import org.apache.nifi.attribute.expression.language.StandardPropertyValue;
import org.apache.nifi.components.PropertyValue; import org.apache.nifi.components.PropertyValue;
@ -32,6 +33,7 @@ import java.util.Set;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertThrows;
@ -108,6 +110,23 @@ public class TestStandardPropertyValue {
assertThrows(NumberFormatException.class, substituted::asInteger); assertThrows(NumberFormatException.class, substituted::asInteger);
} }
@Test
public void testGetValueAsDescribedValue() {
for (ExamplePropertyEnum enumValue : ExamplePropertyEnum.values()) {
final PropertyValue value = new StandardPropertyValue(enumValue.getValue(), lookup, ParameterLookup.EMPTY);
assertEquals(enumValue, value.asDescribedValue(ExamplePropertyEnum.class));
}
final PropertyValue nullValue = new StandardPropertyValue(null, lookup, ParameterLookup.EMPTY);
assertNull(nullValue.asDescribedValue(ExamplePropertyEnum.class));
IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
final PropertyValue invalidValue = new StandardPropertyValue("FOO", lookup, ParameterLookup.EMPTY);
invalidValue.asDescribedValue(ExamplePropertyEnum.class);
});
assertEquals("ExamplePropertyEnum does not have an entry with value FOO", exception.getMessage());
}
@Test @Test
public void testFileSize() { public void testFileSize() {
final PropertyValue value = new StandardPropertyValue("${fileSize}", lookup, ParameterLookup.EMPTY); final PropertyValue value = new StandardPropertyValue("${fileSize}", lookup, ParameterLookup.EMPTY);
@ -177,4 +196,35 @@ public class TestStandardPropertyValue {
} }
} }
private enum ExamplePropertyEnum implements DescribedValue {
ONE("One Value", "One Display", "One Description"),
OTHER("Other Value", "Other Display", "Other Description"),
ANOTHER("Another Value", "Another Display", "Another Description");
private final String value;
private final String displayName;
private final String description;
ExamplePropertyEnum(final String value, final String displayName, final String description) {
this.value = value;
this.displayName = displayName;
this.description = description;
}
@Override
public String getValue() {
return this.value;
}
@Override
public String getDisplayName() {
return this.displayName;
}
@Override
public String getDescription() {
return this.description;
}
}
} }

View File

@ -189,7 +189,6 @@ public class TinkerpopClientService extends AbstractControllerService implements
"classes specified in the YAML file. Additionally, any custom classes required for the groovy script to " + "classes specified in the YAML file. Additionally, any custom classes required for the groovy script to " +
"work in the bytecode submission setting should also be contained in these JAR files.") "work in the bytecode submission setting should also be contained in these JAR files.")
.dependsOn(CONNECTION_SETTINGS, YAML_SETTINGS) .dependsOn(CONNECTION_SETTINGS, YAML_SETTINGS)
.defaultValue(null)
.identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE, ResourceType.DIRECTORY, ResourceType.URL) .identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE, ResourceType.DIRECTORY, ResourceType.URL)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.dynamicallyModifiesClasspath(true) .dynamicallyModifiesClasspath(true)

View File

@ -106,7 +106,6 @@ public class Hive3ConnectionPool extends AbstractControllerService implements Hi
.description("A database connection URL used to connect to a database. May contain database system name, host, port, database name and some parameters." .description("A database connection URL used to connect to a database. May contain database system name, host, port, database name and some parameters."
+ " The exact syntax of a database connection URL is specified by the Hive documentation. For example, the server principal is often included " + " The exact syntax of a database connection URL is specified by the Hive documentation. For example, the server principal is often included "
+ "as a connection parameter when connecting to a secure Hive server.") + "as a connection parameter when connecting to a secure Hive server.")
.defaultValue(null)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.required(true) .required(true)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
@ -127,7 +126,6 @@ public class Hive3ConnectionPool extends AbstractControllerService implements Hi
.name("hive-db-user") .name("hive-db-user")
.displayName("Database User") .displayName("Database User")
.description("Database user name") .description("Database user name")
.defaultValue(null)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.build(); .build();
@ -136,7 +134,6 @@ public class Hive3ConnectionPool extends AbstractControllerService implements Hi
.name("hive-db-password") .name("hive-db-password")
.displayName("Password") .displayName("Password")
.description("The password for the database user") .description("The password for the database user")
.defaultValue(null)
.required(false) .required(false)
.sensitive(true) .sensitive(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)

View File

@ -375,7 +375,6 @@ public abstract class AbstractKuduProcessor extends AbstractProcessor {
alterTable.addColumn(new ColumnSchema.ColumnSchemaBuilder(columnName, toKuduType(nifiType)) alterTable.addColumn(new ColumnSchema.ColumnSchemaBuilder(columnName, toKuduType(nifiType))
.nullable(true) .nullable(true)
.defaultValue(null)
.typeAttributes(getKuduTypeAttributes(nifiType)) .typeAttributes(getKuduTypeAttributes(nifiType))
.build()); .build());

View File

@ -107,7 +107,6 @@ public class GetSNMP extends AbstractSNMPProcessor {
"the outgoing flowfile.") "the outgoing flowfile.")
.required(false) .required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR) .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.defaultValue(null)
.build(); .build();
public static final Relationship REL_SUCCESS = new Relationship.Builder() public static final Relationship REL_SUCCESS = new Relationship.Builder()

View File

@ -153,7 +153,6 @@ public class LivySessionController extends AbstractControllerService implements
.required(false) .required(false)
.identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE) .identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.defaultValue(null)
.build(); .build();
public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder() public static final PropertyDescriptor SSL_CONTEXT_SERVICE = new PropertyDescriptor.Builder()

View File

@ -197,7 +197,7 @@ public class ListenHTTP extends AbstractSessionFactoryProcessor {
.description("HTTP Protocols supported for Application Layer Protocol Negotiation with TLS") .description("HTTP Protocols supported for Application Layer Protocol Negotiation with TLS")
.required(true) .required(true)
.allowableValues(HttpProtocolStrategy.class) .allowableValues(HttpProtocolStrategy.class)
.defaultValue(HttpProtocolStrategy.HTTP_1_1.getValue()) .defaultValue(HttpProtocolStrategy.HTTP_1_1)
.dependsOn(SSL_CONTEXT_SERVICE) .dependsOn(SSL_CONTEXT_SERVICE)
.build(); .build();
public static final PropertyDescriptor HEADERS_AS_ATTRIBUTES_REGEX = new PropertyDescriptor.Builder() public static final PropertyDescriptor HEADERS_AS_ATTRIBUTES_REGEX = new PropertyDescriptor.Builder()
@ -414,7 +414,7 @@ public class ListenHTTP extends AbstractSessionFactoryProcessor {
// get the configured port // get the configured port
final int port = context.getProperty(PORT).evaluateAttributeExpressions().asInteger(); final int port = context.getProperty(PORT).evaluateAttributeExpressions().asInteger();
final HttpProtocolStrategy httpProtocolStrategy = HttpProtocolStrategy.valueOf(context.getProperty(HTTP_PROTOCOL_STRATEGY).getValue()); final HttpProtocolStrategy httpProtocolStrategy = context.getProperty(HTTP_PROTOCOL_STRATEGY).asDescribedValue(HttpProtocolStrategy.class);
final ServerConnector connector = createServerConnector(server, final ServerConnector connector = createServerConnector(server,
port, port,
sslContextService, sslContextService,

View File

@ -325,7 +325,6 @@ public class MergeContent extends BinFiles {
.required(false) .required(false)
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.addValidator(StandardValidators.ATTRIBUTE_KEY_VALIDATOR) .addValidator(StandardValidators.ATTRIBUTE_KEY_VALIDATOR)
.defaultValue(null)
.dependsOn(MERGE_STRATEGY, MERGE_STRATEGY_BIN_PACK) .dependsOn(MERGE_STRATEGY, MERGE_STRATEGY_BIN_PACK)
.build(); .build();

View File

@ -220,7 +220,6 @@ public class MergeRecord extends AbstractSessionFactoryProcessor {
.required(false) .required(false)
.expressionLanguageSupported(ExpressionLanguageScope.NONE) .expressionLanguageSupported(ExpressionLanguageScope.NONE)
.addValidator(StandardValidators.ATTRIBUTE_KEY_VALIDATOR) .addValidator(StandardValidators.ATTRIBUTE_KEY_VALIDATOR)
.defaultValue(null)
.build(); .build();
public static final PropertyDescriptor MIN_SIZE = new PropertyDescriptor.Builder() public static final PropertyDescriptor MIN_SIZE = new PropertyDescriptor.Builder()
.name("min-bin-size") .name("min-bin-size")

View File

@ -96,7 +96,6 @@ public class ScanAttribute extends AbstractProcessor {
+ "the dictionary will be used and each term will consist of the text of the entire line in the file") + "the dictionary will be used and each term will consist of the text of the entire line in the file")
.required(false) .required(false)
.addValidator(StandardValidators.createRegexValidator(0, 1, false)) .addValidator(StandardValidators.createRegexValidator(0, 1, false))
.defaultValue(null)
.build(); .build();
private List<PropertyDescriptor> properties; private List<PropertyDescriptor> properties;

View File

@ -201,7 +201,6 @@ public class ValidateRecord extends AbstractProcessor {
.required(false) .required(false)
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
.addValidator(StandardValidators.ATTRIBUTE_KEY_VALIDATOR) .addValidator(StandardValidators.ATTRIBUTE_KEY_VALIDATOR)
.defaultValue(null)
.build(); .build();
static final PropertyDescriptor MAX_VALIDATION_DETAILS_LENGTH = new PropertyDescriptor.Builder() static final PropertyDescriptor MAX_VALIDATION_DETAILS_LENGTH = new PropertyDescriptor.Builder()
.name("maximum-validation-details-length") .name("maximum-validation-details-length")

View File

@ -236,7 +236,7 @@ public class TestListenHTTP {
configureProcessorSslContextService(ListenHTTP.ClientAuthentication.AUTO, serverNoTruststoreConfiguration); configureProcessorSslContextService(ListenHTTP.ClientAuthentication.AUTO, serverNoTruststoreConfiguration);
runner.setProperty(ListenHTTP.BASE_PATH, HTTP_BASE_PATH); runner.setProperty(ListenHTTP.BASE_PATH, HTTP_BASE_PATH);
runner.setProperty(ListenHTTP.HTTP_PROTOCOL_STRATEGY, HttpProtocolStrategy.H2_HTTP_1_1.getValue()); runner.setProperty(ListenHTTP.HTTP_PROTOCOL_STRATEGY, HttpProtocolStrategy.H2_HTTP_1_1);
runner.assertValid(); runner.assertValid();
testPOSTRequestsReceived(HttpServletResponse.SC_OK, true, false); testPOSTRequestsReceived(HttpServletResponse.SC_OK, true, false);
@ -248,7 +248,7 @@ public class TestListenHTTP {
runner.setProperty(ListenHTTP.BASE_PATH, HTTP_BASE_PATH); runner.setProperty(ListenHTTP.BASE_PATH, HTTP_BASE_PATH);
runner.setProperty(ListenHTTP.RETURN_CODE, Integer.toString(HttpServletResponse.SC_NO_CONTENT)); runner.setProperty(ListenHTTP.RETURN_CODE, Integer.toString(HttpServletResponse.SC_NO_CONTENT));
runner.setProperty(ListenHTTP.HTTP_PROTOCOL_STRATEGY, HttpProtocolStrategy.H2.getValue()); runner.setProperty(ListenHTTP.HTTP_PROTOCOL_STRATEGY, HttpProtocolStrategy.H2);
runner.assertValid(); runner.assertValid();
testPOSTRequestsReceived(HttpServletResponse.SC_NO_CONTENT, true, false); testPOSTRequestsReceived(HttpServletResponse.SC_NO_CONTENT, true, false);

View File

@ -134,7 +134,6 @@ public class MonitorMemory extends AbstractReportingTask {
.description("Indicates how often this reporting task should report bulletins while the memory utilization exceeds the configured threshold") .description("Indicates how often this reporting task should report bulletins while the memory utilization exceeds the configured threshold")
.required(false) .required(false)
.addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
.defaultValue(null)
.build(); .build();
public static final Pattern PERCENTAGE_PATTERN = Pattern.compile("\\d{1,2}%"); public static final Pattern PERCENTAGE_PATTERN = Pattern.compile("\\d{1,2}%");

View File

@ -42,7 +42,6 @@ public class DisallowComponentType extends AbstractFlowAnalysisRule {
" Either the simple or the fully qualified name of the type should be provided.") " Either the simple or the fully qualified name of the type should be provided.")
.required(true) .required(true)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR) .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.defaultValue(null)
.build(); .build();
private final static List<PropertyDescriptor> propertyDescriptors; private final static List<PropertyDescriptor> propertyDescriptors;

View File

@ -86,7 +86,6 @@ public class HikariCPConnectionPool extends AbstractControllerService implements
.displayName("Database Connection URL") .displayName("Database Connection URL")
.description("A database connection URL used to connect to a database. May contain database system name, host, port, database name and some parameters." .description("A database connection URL used to connect to a database. May contain database system name, host, port, database name and some parameters."
+ " The exact syntax of a database connection URL is specified by your DBMS.") + " The exact syntax of a database connection URL is specified by your DBMS.")
.defaultValue(null)
.addValidator(new ConnectionUrlValidator()) .addValidator(new ConnectionUrlValidator())
.required(true) .required(true)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
@ -96,7 +95,6 @@ public class HikariCPConnectionPool extends AbstractControllerService implements
.name("hikaricp-driver-classname") .name("hikaricp-driver-classname")
.displayName("Database Driver Class Name") .displayName("Database Driver Class Name")
.description("The fully-qualified class name of the JDBC driver. Example: com.mysql.jdbc.Driver") .description("The fully-qualified class name of the JDBC driver. Example: com.mysql.jdbc.Driver")
.defaultValue(null)
.required(true) .required(true)
.addValidator(new DriverClassValidator()) .addValidator(new DriverClassValidator())
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
@ -106,7 +104,6 @@ public class HikariCPConnectionPool extends AbstractControllerService implements
.name("hikaricp-driver-locations") .name("hikaricp-driver-locations")
.displayName("Database Driver Location(s)") .displayName("Database Driver Location(s)")
.description("Comma-separated list of files/folders and/or URLs containing the driver JAR and its dependencies (if any). For example '/var/tmp/mariadb-java-client-1.1.7.jar'") .description("Comma-separated list of files/folders and/or URLs containing the driver JAR and its dependencies (if any). For example '/var/tmp/mariadb-java-client-1.1.7.jar'")
.defaultValue(null)
.required(false) .required(false)
.identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE, ResourceType.DIRECTORY, ResourceType.URL) .identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE, ResourceType.DIRECTORY, ResourceType.URL)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
@ -117,7 +114,6 @@ public class HikariCPConnectionPool extends AbstractControllerService implements
.name("hikaricp-username") .name("hikaricp-username")
.displayName("Database User") .displayName("Database User")
.description("Database user name") .description("Database user name")
.defaultValue(null)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.build(); .build();
@ -126,7 +122,6 @@ public class HikariCPConnectionPool extends AbstractControllerService implements
.name("hikaricp-password") .name("hikaricp-password")
.displayName("Password") .displayName("Password")
.description("The password for the database user") .description("The password for the database user")
.defaultValue(null)
.required(false) .required(false)
.sensitive(true) .sensitive(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)

View File

@ -104,7 +104,6 @@ public class HadoopDBCPConnectionPool extends AbstractControllerService implemen
.name("Database Connection URL") .name("Database Connection URL")
.description("A database connection URL used to connect to a database. May contain database system name, host, port, database name and some parameters." .description("A database connection URL used to connect to a database. May contain database system name, host, port, database name and some parameters."
+ " The exact syntax of a database connection URL is specified by your DBMS.") + " The exact syntax of a database connection URL is specified by your DBMS.")
.defaultValue(null)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.required(true) .required(true)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
@ -113,7 +112,6 @@ public class HadoopDBCPConnectionPool extends AbstractControllerService implemen
public static final PropertyDescriptor DB_DRIVERNAME = new PropertyDescriptor.Builder() public static final PropertyDescriptor DB_DRIVERNAME = new PropertyDescriptor.Builder()
.name("Database Driver Class Name") .name("Database Driver Class Name")
.description("Database driver class name") .description("Database driver class name")
.defaultValue(null)
.required(true) .required(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
@ -125,7 +123,6 @@ public class HadoopDBCPConnectionPool extends AbstractControllerService implemen
.description("Comma-separated list of files/folders and/or URLs containing the driver JAR and its dependencies (if any). " + .description("Comma-separated list of files/folders and/or URLs containing the driver JAR and its dependencies (if any). " +
"For example '/var/tmp/phoenix-client.jar'. NOTE: It is required that the resources specified by this property provide " + "For example '/var/tmp/phoenix-client.jar'. NOTE: It is required that the resources specified by this property provide " +
"the classes from hadoop-common, such as Configuration and UserGroupInformation.") "the classes from hadoop-common, such as Configuration and UserGroupInformation.")
.defaultValue(null)
.required(true) .required(true)
.identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE, ResourceType.DIRECTORY, ResourceType.URL) .identifiesExternalResource(ResourceCardinality.MULTIPLE, ResourceType.FILE, ResourceType.DIRECTORY, ResourceType.URL)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
@ -147,7 +144,6 @@ public class HadoopDBCPConnectionPool extends AbstractControllerService implemen
public static final PropertyDescriptor DB_USER = new PropertyDescriptor.Builder() public static final PropertyDescriptor DB_USER = new PropertyDescriptor.Builder()
.name("Database User") .name("Database User")
.description("The user for the database") .description("The user for the database")
.defaultValue(null)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.build(); .build();
@ -155,7 +151,6 @@ public class HadoopDBCPConnectionPool extends AbstractControllerService implemen
public static final PropertyDescriptor DB_PASSWORD = new PropertyDescriptor.Builder() public static final PropertyDescriptor DB_PASSWORD = new PropertyDescriptor.Builder()
.name("Password") .name("Password")
.description("The password for the database user") .description("The password for the database user")
.defaultValue(null)
.required(false) .required(false)
.sensitive(true) .sensitive(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)

View File

@ -94,7 +94,6 @@ public class JsonTreeReader extends SchemaRegistryService implements RecordReade
.description("Skips forward to the given nested JSON field (array or object) to begin processing.") .description("Skips forward to the given nested JSON field (array or object) to begin processing.")
.required(false) .required(false)
.addValidator(StandardValidators.NON_BLANK_VALIDATOR) .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
.defaultValue(null)
.dependsOn(STARTING_FIELD_STRATEGY, StartingFieldStrategy.NESTED_FIELD.name()) .dependsOn(STARTING_FIELD_STRATEGY, StartingFieldStrategy.NESTED_FIELD.name())
.build(); .build();

View File

@ -71,7 +71,6 @@ public class StandardSSLContextService extends AbstractControllerService impleme
.name("Truststore Filename") .name("Truststore Filename")
.description("The fully-qualified filename of the Truststore") .description("The fully-qualified filename of the Truststore")
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.defaultValue(null)
.identifiesExternalResource(ResourceCardinality.SINGLE, ResourceType.FILE) .identifiesExternalResource(ResourceCardinality.SINGLE, ResourceType.FILE)
.sensitive(false) .sensitive(false)
.build(); .build();
@ -85,7 +84,6 @@ public class StandardSSLContextService extends AbstractControllerService impleme
public static final PropertyDescriptor TRUSTSTORE_PASSWORD = new PropertyDescriptor.Builder() public static final PropertyDescriptor TRUSTSTORE_PASSWORD = new PropertyDescriptor.Builder()
.name("Truststore Password") .name("Truststore Password")
.description("The password for the Truststore") .description("The password for the Truststore")
.defaultValue(null)
.addValidator(Validator.VALID) .addValidator(Validator.VALID)
.required(false) .required(false)
.sensitive(true) .sensitive(true)
@ -94,7 +92,6 @@ public class StandardSSLContextService extends AbstractControllerService impleme
.name("Keystore Filename") .name("Keystore Filename")
.description("The fully-qualified filename of the Keystore") .description("The fully-qualified filename of the Keystore")
.expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT) .expressionLanguageSupported(ExpressionLanguageScope.ENVIRONMENT)
.defaultValue(null)
.identifiesExternalResource(ResourceCardinality.SINGLE, ResourceType.FILE) .identifiesExternalResource(ResourceCardinality.SINGLE, ResourceType.FILE)
.sensitive(false) .sensitive(false)
.build(); .build();
@ -107,7 +104,6 @@ public class StandardSSLContextService extends AbstractControllerService impleme
.build(); .build();
public static final PropertyDescriptor KEYSTORE_PASSWORD = new PropertyDescriptor.Builder() public static final PropertyDescriptor KEYSTORE_PASSWORD = new PropertyDescriptor.Builder()
.name("Keystore Password") .name("Keystore Password")
.defaultValue(null)
.description("The password for the Keystore") .description("The password for the Keystore")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR) .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.sensitive(true) .sensitive(true)