kaHaleMaKai commented on a change in pull request #3543: NIFI-6388 Add dynamic 
relationships to the ExecuteScript processor.
URL: https://github.com/apache/nifi/pull/3543#discussion_r298681084
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/processors/script/ExecuteScript.java
 ##########
 @@ -133,13 +167,57 @@
      */
     @Override
     protected PropertyDescriptor getSupportedDynamicPropertyDescriptor(final 
String propertyDescriptorName) {
-        return new PropertyDescriptor.Builder()
+        final boolean isRelationship = propertyDescriptorName != null && 
propertyDescriptorName.startsWith(DYNAMIC_RELATIONSHIP_PREFIX);
+        if (isRelationship) {
+            if 
(!DYNAMIC_RELATIONSHIP_PATTERN.matcher(propertyDescriptorName).matches()) {
+                log.warn("dyn. property for relationship is invalid: '{}'. 
accepted patterns: '{}'", new Object[]{propertyDescriptorName, 
DYNAMIC_RELATIONSHIP_PATTERN_AS_STRING});
+                return new PropertyDescriptor.Builder()
+                        .addValidator(new RelationshipInvalidator())
+                        .dynamic(true)
+                        .required(false)
+                        .name(propertyDescriptorName)
+                        .build();
+            }
+        }
+        final Validator validator = isRelationship
+                ? Validator.VALID
+                : StandardValidators.NON_EMPTY_VALIDATOR;
+        final PropertyDescriptor.Builder builder = new 
PropertyDescriptor.Builder()
                 .name(propertyDescriptorName)
                 .required(false)
-                .addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+                .addValidator(validator)
                 
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
-                .dynamic(true)
-                .build();
+                .dynamic(true);
+        if (isRelationship) {
+            builder.description(String.format(
 
 Review comment:
   fixed in 56a97e38c7de86daf56d2488ddbff211bd9ab5cc

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to