exceptionfactory commented on code in PR #8038:
URL: https://github.com/apache/nifi/pull/8038#discussion_r1436640748
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EncodeContent.java:
##########
@@ -55,27 +59,105 @@
@CapabilityDescription("Encode or decode the contents of a FlowFile using
Base64, Base32, or hex encoding schemes")
public class EncodeContent extends AbstractProcessor {
- public static final String ENCODE_MODE = "Encode";
- public static final String DECODE_MODE = "Decode";
-
- public static final String BASE64_ENCODING = "base64";
- public static final String BASE32_ENCODING = "base32";
- public static final String HEX_ENCODING = "hex";
+ public static final AllowableValue ENCODE_MODE = new
AllowableValue("encode", "Encode", "Sets the operation mode to 'encode'.");
+ public static final AllowableValue DECODE_MODE = new
AllowableValue("decode", "Decode", "Sets the operation mode to 'decoding'.");
+
+ public static final AllowableValue BASE64_ENCODING = new
AllowableValue("base64", "Base64", "Sets the encoding type to 'Base64'.");
+ public static final AllowableValue BASE32_ENCODING = new
AllowableValue("base32", "Base32", "Sets the encoding type to 'Base32'.");
+ public static final AllowableValue HEX_ENCODING = new
AllowableValue("hex", "Hexadecimal", "Sets the encoding type to
'Hexadecimal'.");
+
+ /**
+ * Represents an allowable value that indicates the encoded FlowFile
content should be output as a single line.
+ * When this value is set, the encoded content will not contain any line
breaks or newlines, ensuring
+ * that the entire content is presented in a single, continuous line.
+ * <p>
+ * This value is particularly useful in scenarios where multiline output
is not desired or could lead to issues,
+ * such as in certain data formats or when interfacing with systems that
expect single-line input.
+ * </p>
+ */
+ static final AllowableValue SINGLE_LINE_OUTPUT_TRUE = new
AllowableValue("true", "True", "The encoded FlowFile content will be output as
a single line.");
+
+
+ /**
+ * Represents an allowable value that indicates the encoded FlowFile
content should be output as multiple lines.
+ * When this value is set, the encoded content will include appropriate
line breaks or newlines, breaking
+ * the content into separate lines as required.
+ * <p>
+ * This setting is useful in scenarios where multi-line formatting is
necessary or preferred, such as for
+ * improved readability, adherence to specific data formats, or
compatibility with systems and tools that
+ * process multi-line input.
+ * </p>
+ */
+ static final AllowableValue SINGLE_LINE_OUTPUT_FALSE = new
AllowableValue("false", "False", "The encoded FlowFile content will be output
as a multiple lines.");
public static final PropertyDescriptor MODE = new
PropertyDescriptor.Builder()
.name("Mode")
.description("Specifies whether the content should be encoded or
decoded")
.required(true)
.allowableValues(ENCODE_MODE, DECODE_MODE)
- .defaultValue(ENCODE_MODE)
+ .defaultValue(ENCODE_MODE.getValue())
.build();
public static final PropertyDescriptor ENCODING = new
PropertyDescriptor.Builder()
.name("Encoding")
.description("Specifies the type of encoding used")
.required(true)
.allowableValues(BASE64_ENCODING, BASE32_ENCODING, HEX_ENCODING)
- .defaultValue(BASE64_ENCODING)
+ .defaultValue(BASE64_ENCODING.getValue())
+ .build();
+
+ // A Boolean property descriptor that allows the user
+ // to choose if the output to encoded FlowFile content should be to a
single line or multiple lines.
+ static final PropertyDescriptor SINGLE_LINE_OUTPUT = new
PropertyDescriptor.Builder()
+ .name("single-line-output")
+ .displayName("Output Content to Single Line")
+ .description("If set to 'true', the encoded FlowFile content will
output as a single line. If set to 'false', "
+ + "it will output as multiple lines. This property is only
applicable when Base64 or Base32 encoding is selected.")
+ .required(false)
+ .defaultValue("false")
+ .allowableValues(SINGLE_LINE_OUTPUT_TRUE, SINGLE_LINE_OUTPUT_FALSE)
+ .addValidator(StandardValidators.BOOLEAN_VALIDATOR)
+ .dependsOn(MODE, ENCODE_MODE)
+ .dependsOn(ENCODING, BASE64_ENCODING, BASE32_ENCODING)
+ .build();
+
+ static final PropertyDescriptor ENCODED_LINE_SEPARATOR = new
PropertyDescriptor.Builder()
+ .name("line-separator")
+ .displayName("Encoded Content Line Separator")
+ .description("Each line of encoded data will be terminated with this
byte sequence (e.g. \\r\\n"
+ + "). This property defaults to the system-dependent line
separator string. If `line-length` <= 0, "
+ + "the `line-separator` property is not used. This property is
not used for `hex` encoding.")
+ .required(false)
+
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+ .defaultValue(System.lineSeparator())
+ .addValidator(Validator.VALID)
+ .dependsOn(MODE, ENCODE_MODE)
+ .dependsOn(ENCODING, BASE64_ENCODING, BASE32_ENCODING)
+ .build();
+
+ static final PropertyDescriptor ENCODED_LINE_LENGTH = new
PropertyDescriptor.Builder()
+ .name("encoded-line-length")
+ .displayName("Encoded Content Line Length")
+ .description("Each line of encoded data will contain
`encoded-line-length` characters (rounded down to the nearest multiple of 4). "
+ + "If `encoded-line-length` <= 0, the encoded data is not divided
into lines. This property is "
+ + "ignored if `single-line-output` is set to True.")
+ .required(false)
+ .defaultValue("76")
+
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+ .addValidator(StandardValidators.INTEGER_VALIDATOR)
+ .dependsOn(MODE, ENCODE_MODE)
+ .dependsOn(ENCODING, BASE64_ENCODING, BASE32_ENCODING)
+ .dependsOn(SINGLE_LINE_OUTPUT, SINGLE_LINE_OUTPUT_FALSE)
+ .build();
+
+ static final PropertyDescriptor FAIL_ON_ZERO_LENGTH_CONTENT = new
PropertyDescriptor.Builder()
Review Comment:
Is there a reason for adding this particular property? It seems better to
avoid introducing it, as other components can handle routing on file size in a
standard flow configuration.
##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/EncodeContent.java:
##########
@@ -55,27 +59,105 @@
@CapabilityDescription("Encode or decode the contents of a FlowFile using
Base64, Base32, or hex encoding schemes")
public class EncodeContent extends AbstractProcessor {
- public static final String ENCODE_MODE = "Encode";
- public static final String DECODE_MODE = "Decode";
-
- public static final String BASE64_ENCODING = "base64";
- public static final String BASE32_ENCODING = "base32";
- public static final String HEX_ENCODING = "hex";
+ public static final AllowableValue ENCODE_MODE = new
AllowableValue("encode", "Encode", "Sets the operation mode to 'encode'.");
+ public static final AllowableValue DECODE_MODE = new
AllowableValue("decode", "Decode", "Sets the operation mode to 'decoding'.");
+
+ public static final AllowableValue BASE64_ENCODING = new
AllowableValue("base64", "Base64", "Sets the encoding type to 'Base64'.");
+ public static final AllowableValue BASE32_ENCODING = new
AllowableValue("base32", "Base32", "Sets the encoding type to 'Base32'.");
+ public static final AllowableValue HEX_ENCODING = new
AllowableValue("hex", "Hexadecimal", "Sets the encoding type to
'Hexadecimal'.");
Review Comment:
Instead of defining AllowableValue instances, it would be helpful to define
an enum that implements `DescribedValue`, which makes it easier to use the
property value during processing.
--
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]