From f43b989c99fc94c54b39ebd64ff7d6b7484997b8 Mon Sep 17 00:00:00 2001 From: Matt Burgess Date: Mon, 17 Oct 2022 12:46:37 -0400 Subject: [PATCH] NIFI-10617: Add missing DynamicProperty annotation to processors that use them (#6509) This closes #6509 --- .../nifi/elasticsearch/ElasticSearchLookupService.java | 3 +++ .../java/org/apache/nifi/processors/email/ConsumeEWS.java | 1 + .../nifi/processors/standard/CalculateRecordStats.java | 7 ++++++- .../org/apache/nifi/processors/standard/ForkRecord.java | 4 ++++ .../apache/nifi/processors/standard/PutDatabaseRecord.java | 1 + .../nifi/lookup/DistributedMapCacheLookupService.java | 1 + .../java/org/apache/nifi/processors/gettcp/GetTCP.java | 3 +++ 7 files changed, 19 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java b/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java index abe2c2e607..0a3fc67b6f 100644 --- a/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java +++ b/nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchLookupService.java @@ -19,6 +19,7 @@ package org.apache.nifi.elasticsearch; import com.fasterxml.jackson.databind.ObjectMapper; import com.jayway.jsonpath.JsonPath; +import org.apache.nifi.annotation.behavior.DynamicProperty; import org.apache.nifi.annotation.documentation.CapabilityDescription; import org.apache.nifi.annotation.documentation.Tags; import org.apache.nifi.annotation.lifecycle.OnEnabled; @@ -51,6 +52,8 @@ import java.util.stream.Collectors; @CapabilityDescription("Lookup a record from Elasticsearch Server associated with the specified document ID. " + "The coordinates that are passed to the lookup must contain the key 'id'.") @Tags({"lookup", "enrich", "record", "elasticsearch"}) +@DynamicProperty(name = "A JSONPath expression", value = "A Record Path expression", + description = "Retrieves an object using JSONPath from the result document and places it in the return Record at the specified Record Path.") public class ElasticSearchLookupService extends JsonInferenceSchemaRegistryService implements LookupService { public static final PropertyDescriptor CLIENT_SERVICE = new PropertyDescriptor.Builder() .name("el-rest-client-service") diff --git a/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ConsumeEWS.java b/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ConsumeEWS.java index bfcd5784db..22e5080d8c 100644 --- a/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ConsumeEWS.java +++ b/nifi-nar-bundles/nifi-email-bundle/nifi-email-processors/src/main/java/org/apache/nifi/processors/email/ConsumeEWS.java @@ -302,6 +302,7 @@ public class ConsumeEWS extends AbstractProcessor { return service; } + // TODO remove this at next major release as dynamic properties are not used by this processor @Override protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { return new PropertyDescriptor.Builder() diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/CalculateRecordStats.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/CalculateRecordStats.java index a602ff3c51..0ba35a4040 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/CalculateRecordStats.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/CalculateRecordStats.java @@ -17,6 +17,7 @@ package org.apache.nifi.processors.standard; +import org.apache.nifi.annotation.behavior.DynamicProperty; import org.apache.nifi.annotation.behavior.InputRequirement; import org.apache.nifi.annotation.behavior.WritesAttribute; import org.apache.nifi.annotation.behavior.WritesAttributes; @@ -55,8 +56,12 @@ import java.util.stream.Collectors; @CapabilityDescription("A processor that can count the number of items in a record set, as well as provide counts based on " + "user-defined criteria on subsets of the record set.") @InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED) +@DynamicProperty(name = "Record Path property", value = "The Record Path value", + expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, + description = "A Record Path value, pointing to a field to be counted") + @WritesAttributes({ - @WritesAttribute(attribute = CalculateRecordStats.RECORD_COUNT_ATTR, description = "A count of the records in the record set in the flowfile."), + @WritesAttribute(attribute = CalculateRecordStats.RECORD_COUNT_ATTR, description = "A count of the records in the record set in the FlowFile."), @WritesAttribute(attribute = "recordStats..count", description = "A count of the records that contain a value for the user defined property."), @WritesAttribute(attribute = "recordStats...count", description = "Each value discovered for the user defined property will have its own count attribute. " + diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ForkRecord.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ForkRecord.java index 5d69ea6136..8d4466ccdd 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ForkRecord.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ForkRecord.java @@ -18,6 +18,7 @@ package org.apache.nifi.processors.standard; import org.apache.commons.lang3.StringUtils; +import org.apache.nifi.annotation.behavior.DynamicProperty; import org.apache.nifi.annotation.behavior.InputRequirement; import org.apache.nifi.annotation.behavior.InputRequirement.Requirement; import org.apache.nifi.annotation.behavior.SideEffectFree; @@ -86,6 +87,9 @@ import java.util.concurrent.atomic.AtomicInteger; + "all the fields of the parent records from the root level to the extracted record. This assumes that the fields to add in " + "the record are defined in the schema of the Record Writer controller service. See examples in the additional details " + "documentation of this processor.") +@DynamicProperty(name = "Record Path property", value = "The Record Path value", + expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES, + description = "A Record Path value, pointing to a field of type ARRAY containing RECORD objects") @WritesAttributes({ @WritesAttribute(attribute = "record.count", description = "The generated FlowFile will have a 'record.count' attribute indicating " + "the number of records that were written to the FlowFile."), diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutDatabaseRecord.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutDatabaseRecord.java index bcb26ceca5..8c5649b921 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutDatabaseRecord.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/PutDatabaseRecord.java @@ -420,6 +420,7 @@ public class PutDatabaseRecord extends AbstractProcessor { return propDescriptors; } + // TODO remove this at next major release as dynamic properties are not used by this processor @Override protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { return new Builder() diff --git a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/DistributedMapCacheLookupService.java b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/DistributedMapCacheLookupService.java index 3b2ffa233d..24fb327fa9 100644 --- a/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/DistributedMapCacheLookupService.java +++ b/nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/DistributedMapCacheLookupService.java @@ -86,6 +86,7 @@ public class DistributedMapCacheLookupService extends AbstractControllerService return STANDARD_CHARSETS.stream().map(c -> c.displayName()).collect(Collectors.toSet()); } + // TODO remove this at next major release as dynamic properties are not used by this component @Override protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final String propertyDescriptorName) { return new PropertyDescriptor.Builder() diff --git a/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/GetTCP.java b/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/GetTCP.java index d85febe260..a746a21af6 100644 --- a/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/GetTCP.java +++ b/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/GetTCP.java @@ -16,6 +16,7 @@ */ package org.apache.nifi.processors.gettcp; +import org.apache.nifi.annotation.behavior.DynamicProperty; import org.apache.nifi.annotation.behavior.InputRequirement; import org.apache.nifi.annotation.behavior.SideEffectFree; import org.apache.nifi.annotation.behavior.TriggerSerially; @@ -55,6 +56,8 @@ import java.util.concurrent.TimeUnit; @Tags({"get", "fetch", "poll", "tcp", "ingest", "source", "input"}) @InputRequirement(InputRequirement.Requirement.INPUT_FORBIDDEN) @CapabilityDescription("Connects over TCP to the provided endpoint(s). Received data will be written as content to the FlowFile") +@DynamicProperty(name = "A FlowFile attribute to set", value = "The value to set it to", + description = "Sets a FlowFile attribute specified by the Dynamic Property's key with the value specified by the Dynamic Property's value") @WritesAttribute(attribute = "source.endpoint", description = "The address of the source endpoint the message came from") public class GetTCP extends AbstractSessionFactoryProcessor {