lkuchars commented on code in PR #10291:
URL: https://github.com/apache/nifi/pull/10291#discussion_r2373544878
##########
nifi-extension-bundles/nifi-protobuf-bundle/nifi-protobuf-services/src/main/java/org/apache/nifi/services/protobuf/StandardProtobufReader.java:
##########
@@ -170,6 +174,84 @@ protected PropertyDescriptor buildSchemaTextProperty() {
return PROTOBUF_SCHEMA_TEXT;
}
+ @Override
+ protected Collection<ValidationResult> customValidate(final
ValidationContext validationContext) {
+ final List<ValidationResult> problems = new
ArrayList<>(super.customValidate(validationContext));
+ final String schemaAccessStrategyValue =
validationContext.getProperty(SCHEMA_ACCESS_STRATEGY).getValue();
+
+ // Only validate when using Schema Text property strategy
+ if (SCHEMA_TEXT_PROPERTY.getValue().equals(schemaAccessStrategyValue))
{
+ final PropertyValue schemaTextProperty =
validationContext.getProperty(SCHEMA_TEXT);
+ final String schemaTextValue = schemaTextProperty.getValue();
+
+ if
(validationContext.isExpressionLanguageSupported(SCHEMA_TEXT.getName())
+ &&
validationContext.isExpressionLanguagePresent(schemaTextValue)) {
+ return Collections.emptyList();
+ }
+
+ if (schemaTextValue == null || schemaTextValue.isBlank()) {
+ problems.add(new ValidationResult.Builder()
+ .subject(SCHEMA_TEXT.getDisplayName())
+ .input(schemaTextValue)
+ .valid(false)
+ .explanation("Schema Text cannot be empty when using \"Use
'Schema Text' Property\" strategy")
Review Comment:
fixed
##########
nifi-extension-bundles/nifi-protobuf-bundle/nifi-protobuf-services/src/main/java/org/apache/nifi/services/protobuf/StandardProtobufReader.java:
##########
@@ -170,6 +174,84 @@ protected PropertyDescriptor buildSchemaTextProperty() {
return PROTOBUF_SCHEMA_TEXT;
}
+ @Override
+ protected Collection<ValidationResult> customValidate(final
ValidationContext validationContext) {
+ final List<ValidationResult> problems = new
ArrayList<>(super.customValidate(validationContext));
+ final String schemaAccessStrategyValue =
validationContext.getProperty(SCHEMA_ACCESS_STRATEGY).getValue();
+
+ // Only validate when using Schema Text property strategy
+ if (SCHEMA_TEXT_PROPERTY.getValue().equals(schemaAccessStrategyValue))
{
+ final PropertyValue schemaTextProperty =
validationContext.getProperty(SCHEMA_TEXT);
+ final String schemaTextValue = schemaTextProperty.getValue();
+
+ if
(validationContext.isExpressionLanguageSupported(SCHEMA_TEXT.getName())
+ &&
validationContext.isExpressionLanguagePresent(schemaTextValue)) {
+ return Collections.emptyList();
+ }
+
+ if (schemaTextValue == null || schemaTextValue.isBlank()) {
+ problems.add(new ValidationResult.Builder()
+ .subject(SCHEMA_TEXT.getDisplayName())
+ .input(schemaTextValue)
+ .valid(false)
+ .explanation("Schema Text cannot be empty when using \"Use
'Schema Text' Property\" strategy")
+ .build());
+ return problems;
+ }
+
+ try {
+ // Try to compile the schema to validate it's valid protobuf
format
Review Comment:
fixed
--
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]