mgaido91 commented on a change in pull request #3634: NIFI-6524 MergeContent 
properties should accept expression language variables
URL: https://github.com/apache/nifi/pull/3634#discussion_r310459319
 
 

 ##########
 File path: 
nifi-nar-bundles/nifi-extension-utils/nifi-processor-utils/src/main/java/org/apache/nifi/processor/util/bin/BinFiles.java
 ##########
 @@ -326,35 +341,104 @@ public final void onScheduled(final ProcessContext 
context) throws IOException {
     protected final Collection<ValidationResult> customValidate(final 
ValidationContext context) {
         final List<ValidationResult> problems = new 
ArrayList<>(super.customValidate(context));
 
-        final long minBytes = 
context.getProperty(MIN_SIZE).asDataSize(DataUnit.B).longValue();
-        final Double maxBytes = 
context.getProperty(MAX_SIZE).asDataSize(DataUnit.B);
-
-        if (maxBytes != null && maxBytes.longValue() < minBytes) {
-            problems.add(
-                    new ValidationResult.Builder()
-                    .subject(MIN_SIZE.getName())
-                    .input(context.getProperty(MIN_SIZE).getValue())
-                    .valid(false)
-                    .explanation("Min Size must be less than or equal to Max 
Size")
-                    .build()
-            );
-        }
-
-        final Long min = context.getProperty(MIN_ENTRIES).asLong();
-        final Long max = context.getProperty(MAX_ENTRIES).asLong();
+        final String minSize = 
context.getProperty(MIN_SIZE).evaluateAttributeExpressions().getValue();
+        final String maxSize = 
context.getProperty(MAX_SIZE).evaluateAttributeExpressions().getValue();
+        if(minSize != null || maxSize != null) {
+            // Keep track of valid formats in order to check their value only 
if they pass the format validation
+            boolean minSizeValidFormat = false;
+            boolean maxSizeValidFormat = false;
+            if(minSize != null) {
+                if (!DATA_SIZE_PATTERN.matcher(minSize).matches())  { // 
Validates both format and non-negativity
+                    problems.add(new ValidationResult.Builder()
+                        .subject("Min Size")
+                        .input(minSize)
+                        .valid(false)
+                        .explanation("<Minimum Group Size> Must be of format 
<Data Size> <Data Unit> where <Data Size>"
+                                + " is a non-negative integer and <Data Unit> 
is a supported Data"
+                                + " Unit, such as: B, KB, MB, GB, TB")
+                        .build());
+                } else {
+                    minSizeValidFormat = true;
+                }
+            }
+            if(maxSize != null) {
 
 Review comment:
   ```suggestion
               if (maxSize != null) {
   ```

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to