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


##########
nifi-framework-bundle/nifi-framework/nifi-administration/src/main/java/org/apache/nifi/admin/service/EntityStoreAuditService.java:
##########
@@ -119,6 +129,11 @@ public void addActions(final Collection<Action> actions) {
             }
             logger.debug("Actions added [{}]", actions.size());
         });
+        flowActionReporter.reportFlowActions(
+            actions.stream()
+                .map(actionConverter::convert)
+                .toList()
+        );

Review Comment:
   Since the `FlowActionReporter` is a new optional feature, it seems best to 
avoid this call if it is not configured. That avoids the action conversion. 
Allowing `FlowActionReporter` to be `null` seems like a reasonable way to avoid 
the conversion, and the null check could be added before calling 
`reportFlowActions`



##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/main/java/org/apache/nifi/action/ActionToFlowActionConverter.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.action;
+
+import org.apache.nifi.action.component.details.ComponentDetails;
+import org.apache.nifi.action.component.details.ExtensionDetails;
+import org.apache.nifi.action.component.details.RemoteProcessGroupDetails;
+import org.apache.nifi.action.details.ActionDetails;
+import org.apache.nifi.action.details.ConfigureDetails;
+import org.apache.nifi.action.details.ConnectDetails;
+import org.apache.nifi.action.details.MoveDetails;
+import org.apache.nifi.action.details.PurgeDetails;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Converts an {@link Action} to a {@link FlowAction} using {@link 
FlowActionAttribute} attributes.
+ */
+public class ActionToFlowActionConverter implements ActionConverter {
+
+    @Override
+    public FlowAction convert(Action action) {
+        Map<String, String> attributes = new HashMap<>();
+        attributes.putAll(actionAttributes(action));
+        attributes.putAll(actionDetailsAttributes(action.getActionDetails()));
+        
attributes.putAll(componentDetailsProperties(action.getComponentDetails()));

Review Comment:
   The individual methods create new Maps, but it would be more efficient to 
pass around the initial `attributes` Map to each method.



##########
nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/framework/configuration/FlowControllerConfiguration.java:
##########
@@ -471,4 +476,26 @@ public AssetSynchronizer assetSynchronizer() throws 
Exception {
     public AssetComponentManager affectedComponentManager() throws Exception {
         return new StandardAssetComponentManager(flowController());
     }
+
+    /**
+     * Flow Action Reporter configured from NiFi Application Properties
+     *
+     * @return Flow Action Reporter
+     * @throws Exception Thrown on failures to create Flow Action Reporter
+     */
+    @Bean(destroyMethod = "preDestruction")
+    public FlowActionReporter flowActionReporter() throws Exception {
+        final String configuredClassName = 
properties.getProperty(FLOW_ACTION_REPORTER_IMPLEMENTATION);
+        if (StringUtils.isBlank(configuredClassName)) {
+            throw new IllegalStateException("Cannot create FlowActionReporter 
because the configuration is missing the following property: "
+                + FLOW_ACTION_REPORTER_IMPLEMENTATION);
+        }

Review Comment:
   Instead of throwing an error on a blank value, this method should either 
return `null`, or it should return the `NoOp` implementation. See other 
comments on the potential approach.



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