tpalfy commented on code in PR #7191:
URL: https://github.com/apache/nifi/pull/7191#discussion_r1186167096


##########
nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractComponentNode.java:
##########
@@ -776,6 +779,23 @@ protected Collection<ValidationResult> 
computeValidationErrors(final ValidationC
             final Collection<ValidationResult> 
referencedServiceValidationResults = 
validateReferencedControllerServices(validationContext);
             validationResults.addAll(referencedServiceValidationResults);
 
+            analyze();
+
+            
Optional.ofNullable(getValidationContextFactory().getRuleViolationsManager())
+                .map(ruleViolationsManager -> 
ruleViolationsManager.getRuleViolationsForSubject(getIdentifier()))
+                .map(Collection::stream)
+                .ifPresent(ruleViolationStream -> ruleViolationStream
+                    .filter(ruleViolation -> 
ruleViolation.getEnforcementPolicy() == EnforcementPolicy.ENFORCE)
+                    .filter(RuleViolation::isEnabled)
+                    .forEach(ruleViolation -> validationResults.add(
+                        new ValidationResult.Builder()
+                            .subject(getComponent().getClass().getSimpleName())
+                            .valid(false)
+                            .explanation(ruleViolation.getViolationMessage())
+                            .build()
+                    )
+                ));

Review Comment:
   Again, this makes sense if we consider Validation as the validation of the 
component itself. Enforcing rules have the duty to invalidate violating 
components. I see no better place than doing it during validation.



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