dan-s1 commented on code in PR #8350:
URL: https://github.com/apache/nifi/pull/8350#discussion_r1476296507


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/UnpackContent.java:
##########
@@ -643,4 +672,20 @@ public static PackageFormat getFormat(String textValue) {
             };
         }
     }
+
+  /**
+   * Validates if the given input string is a valid  {@link 
java.nio.charset.Charset} representation
+   */
+  private static class CharsetStringValidator implements Validator {
+        @Override
+        public ValidationResult validate(String subject, String input, 
ValidationContext context) {
+            try {
+                Charsets.toCharset(input);
+                return new 
ValidationResult.Builder().subject(subject).input(input).valid(true).explanation("Valid
 charset").build();
+            } catch (UnsupportedCharsetException e) {
+                return new 
ValidationResult.Builder().subject(subject).input(input).valid(false)
+                    .explanation("Invalid encoding charset: 
"+e.getMessage()).build();
+            }
+        }
+    }
 }

Review Comment:
   I believe there is no need to create this class as 
`nifi-commons/nifi-utils/src/main/java/org/apache/nifi/processor/util/StandardValidators.java`
 already has `CHARACTER_SET_VALIDATOR`



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/UnpackContent.java:
##########
@@ -139,6 +145,20 @@ public class UnpackContent extends AbstractProcessor {
                     PackageFormat.FLOWFILE_STREAM_FORMAT_V2.toString(), 
PackageFormat.FLOWFILE_TAR_FORMAT.toString())
             .defaultValue(PackageFormat.AUTO_DETECT_FORMAT.toString())
             .build();
+    public static final PropertyDescriptor ZIP_FILENAMES_ENCODING = new 
PropertyDescriptor.Builder()
+            .name("zip-filenames-encoding")
+            .displayName("Zip Filenames Encoding")
+            .description(
+                "The encoding used by zip creating utility, for the file names 
inside the zip. Processor will pass this encoding to Zip unpacker. For example 
'Cp437', 'UTF8' etc. Default is to "
+                    + "use platform's encoding. This can be useful for example 
incase a zip was created on Windows with Cp437 and unpacked on Linux machine. 
Without correct encoding value special "
+                    + "characters in filenames will be outputted as `?`")
+            .required(false)
+            .dependsOn(
+                PACKAGING_FORMAT,
+                PackageFormat.ZIP_FORMAT.toString(),
+                PackageFormat.AUTO_DETECT_FORMAT.toString())
+            .addValidator(new CharsetStringValidator())

Review Comment:
   Per earlier comment 
   ```suggestion
               .addValidator(StandardValidators.CHARACTER_SET_VALIDATOR)
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to