This is an automated email from the ASF dual-hosted git repository.

pvillard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new c093ea54b7 NIFI-12862 When building FlowAnalysisRuleViolationDTO 
objects (in StandardNiFiServiceFacade), violating component details will be 
left blank when user has no read permission for that component.
c093ea54b7 is described below

commit c093ea54b77c816d94a23c7af19f97f96baa7d2f
Author: tpalfy <tpa...@apache.org>
AuthorDate: Tue Mar 5 17:48:08 2024 +0100

    NIFI-12862 When building FlowAnalysisRuleViolationDTO objects (in 
StandardNiFiServiceFacade), violating component details will be left blank when 
user has no read permission for that component.
    
    NIFI-12862 Expose subjectComponentType to frontend.
    
    Signed-off-by: Pierre Villard <pierre.villard...@gmail.com>
    
    This closes #8475.
---
 .../web/api/dto/FlowAnalysisRuleViolationDTO.java  | 13 ++++++++++++
 .../apache/nifi/web/StandardNiFiServiceFacade.java | 24 ++++++++++++++--------
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowAnalysisRuleViolationDTO.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowAnalysisRuleViolationDTO.java
index 4e1762f42a..0201a0dc24 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowAnalysisRuleViolationDTO.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowAnalysisRuleViolationDTO.java
@@ -35,6 +35,8 @@ public class FlowAnalysisRuleViolationDTO {
     private String issueId;
     private String violationMessage;
 
+    private String subjectComponentType;
+
     private PermissionsDTO subjectPermissionDto;
 
     private boolean enabled;
@@ -129,6 +131,17 @@ public class FlowAnalysisRuleViolationDTO {
     }
 
 
+    /**
+     * @return the type of the subject that violated the rule
+     */
+    public String getSubjectComponentType() {
+        return subjectComponentType;
+    }
+
+    public void setSubjectComponentType(String subjectComponentType) {
+        this.subjectComponentType = subjectComponentType;
+    }
+
     /**
      * @return true if this result should be in effect, false otherwise
      */
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
index 78dbc4caa3..96ec627f61 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java
@@ -6478,23 +6478,29 @@ public class StandardNiFiServiceFacade implements 
NiFiServiceFacade {
             .map(ruleViolation -> {
                 FlowAnalysisRuleViolationDTO ruleViolationDto = new 
FlowAnalysisRuleViolationDTO();
 
-                
ruleViolationDto.setEnforcementPolicy(ruleViolation.getEnforcementPolicy().toString());
+                String subjectId = ruleViolation.getSubjectId();
+                String groupId = ruleViolation.getGroupId();
+
                 ruleViolationDto.setScope(ruleViolation.getScope());
+                ruleViolationDto.setSubjectId(subjectId);
                 ruleViolationDto.setRuleId(ruleViolation.getRuleId());
                 ruleViolationDto.setIssueId(ruleViolation.getIssueId());
-                
ruleViolationDto.setViolationMessage(ruleViolation.getViolationMessage());
 
-                String subjectId = ruleViolation.getSubjectId();
-                String groupId = ruleViolation.getGroupId();
+                
ruleViolationDto.setSubjectComponentType(ruleViolation.getSubjectComponentType().name());
+                
ruleViolationDto.setEnforcementPolicy(ruleViolation.getEnforcementPolicy().toString());
 
-                ruleViolationDto.setSubjectId(subjectId);
-                ruleViolationDto.setGroupId(groupId);
-                
ruleViolationDto.setSubjectDisplayName(ruleViolation.getSubjectDisplayName());
-                ruleViolationDto.setSubjectPermissionDto(createPermissionDto(
+                PermissionsDTO subjectPermissionDto = createPermissionDto(
                         subjectId,
                         ruleViolation.getSubjectComponentType(),
                         groupId
-                ));
+                );
+                ruleViolationDto.setSubjectPermissionDto(subjectPermissionDto);
+
+                if (subjectPermissionDto.getCanRead()) {
+                    ruleViolationDto.setGroupId(groupId);
+                    
ruleViolationDto.setSubjectDisplayName(ruleViolation.getSubjectDisplayName());
+                    
ruleViolationDto.setViolationMessage(ruleViolation.getViolationMessage());
+                }
 
                 return ruleViolationDto;
             })

Reply via email to