exceptionfactory commented on code in PR #10018:
URL: https://github.com/apache/nifi/pull/10018#discussion_r2160091618


##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ProcessGroupAuditor.java:
##########
@@ -257,6 +260,7 @@ public void enableComponentsAdvice(ProceedingJoinPoint 
proceedingJoinPoint, Stri
         + "execution(void activateControllerServices(String, 
org.apache.nifi.controller.service.ControllerServiceState, 
java.util.Collection<String>)) && "
         + "args(groupId, state, serviceIds)")
     public void activateControllerServicesAdvice(ProceedingJoinPoint 
proceedingJoinPoint, String groupId, ControllerServiceState state, 
Collection<String> serviceIds) throws Throwable {
+        List<ControllerServiceNode> controllerServiceNodes = 
getControllerServicesChangingState(groupId, state, serviceIds);

Review Comment:
   ```suggestion
           final List<ControllerServiceNode> controllerServiceNodes = 
getControllerServicesChangingState(groupId, state, serviceIds);
   ```



##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ProcessGroupAuditor.java:
##########
@@ -268,7 +272,33 @@ public void 
activateControllerServicesAdvice(ProceedingJoinPoint proceedingJoinP
             operation = Operation.Disable;
         }
 
-        saveUpdateAction(groupId, operation);
+        saveUpdateProcessGroupAction(groupId, operation);
+        for (ControllerServiceNode csNode : controllerServiceNodes) {

Review Comment:
   ```suggestion
           for (final ControllerServiceNode serviceNode : 
controllerServiceNodes) {
   ```



##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ProcessGroupAuditor.java:
##########
@@ -268,7 +272,33 @@ public void 
activateControllerServicesAdvice(ProceedingJoinPoint proceedingJoinP
             operation = Operation.Disable;
         }
 
-        saveUpdateAction(groupId, operation);
+        saveUpdateProcessGroupAction(groupId, operation);
+        for (ControllerServiceNode csNode : controllerServiceNodes) {
+            saveUpdateControllerServiceAction(csNode, operation);
+        }
+    }
+
+    private List<ControllerServiceNode> 
getControllerServicesChangingState(final String groupId, final 
ControllerServiceState state, Collection<String> serviceIds) throws Throwable {
+        ProcessGroupDAO processGroupDAO = getProcessGroupDAO();
+        ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);
+        List<ControllerServiceNode> csNodes = new ArrayList<>();

Review Comment:
   ```suggestion
           final ProcessGroupDAO processGroupDAO = getProcessGroupDAO();
           final ProcessGroup processGroup = 
processGroupDAO.getProcessGroup(groupId);
           final List<ControllerServiceNode> csNodes = new ArrayList<>();
   ```



##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ProcessGroupAuditor.java:
##########
@@ -268,7 +272,33 @@ public void 
activateControllerServicesAdvice(ProceedingJoinPoint proceedingJoinP
             operation = Operation.Disable;
         }
 
-        saveUpdateAction(groupId, operation);
+        saveUpdateProcessGroupAction(groupId, operation);
+        for (ControllerServiceNode csNode : controllerServiceNodes) {
+            saveUpdateControllerServiceAction(csNode, operation);
+        }
+    }
+
+    private List<ControllerServiceNode> 
getControllerServicesChangingState(final String groupId, final 
ControllerServiceState state, Collection<String> serviceIds) throws Throwable {
+        ProcessGroupDAO processGroupDAO = getProcessGroupDAO();
+        ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);
+        List<ControllerServiceNode> csNodes = new ArrayList<>();
+        for (String serviceId : serviceIds) {
+            ControllerServiceNode csNode = 
processGroup.findControllerService(serviceId, true, true);
+            if (csNode != null) {
+                if ((isControllerServiceDisabled(csNode) && 
state.equals(ControllerServiceState.ENABLED)) || 
isControllerServiceEnabled(csNode) && 
state.equals(ControllerServiceState.DISABLED)) {

Review Comment:
   It would be helpful to encapsulate this check further with a method named 
something along the lines of `isControllerServiceStateChanged`



##########
nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/audit/ProcessGroupAuditor.java:
##########
@@ -268,7 +272,33 @@ public void 
activateControllerServicesAdvice(ProceedingJoinPoint proceedingJoinP
             operation = Operation.Disable;
         }
 
-        saveUpdateAction(groupId, operation);
+        saveUpdateProcessGroupAction(groupId, operation);
+        for (ControllerServiceNode csNode : controllerServiceNodes) {
+            saveUpdateControllerServiceAction(csNode, operation);
+        }
+    }
+
+    private List<ControllerServiceNode> 
getControllerServicesChangingState(final String groupId, final 
ControllerServiceState state, Collection<String> serviceIds) throws Throwable {
+        ProcessGroupDAO processGroupDAO = getProcessGroupDAO();
+        ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);
+        List<ControllerServiceNode> csNodes = new ArrayList<>();
+        for (String serviceId : serviceIds) {
+            ControllerServiceNode csNode = 
processGroup.findControllerService(serviceId, true, true);

Review Comment:
   ```suggestion
               final ControllerServiceNode csNode = 
processGroup.findControllerService(serviceId, true, true);
   ```



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