YolandaMDavis commented on a change in pull request #3886: NIFI-6855 - added
action type enforcement option for handlers
URL: https://github.com/apache/nifi/pull/3886#discussion_r347503961
##########
File path:
nifi-nar-bundles/nifi-rules-action-handler-bundle/nifi-rules-action-handler-service/src/main/java/org/apache/nifi/rules/handlers/AbstractActionHandlerService.java
##########
@@ -16,22 +16,54 @@
*/
package org.apache.nifi.rules.handlers;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.context.PropertyContext;
import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.rules.Action;
import org.apache.nifi.rules.PropertyContextActionHandler;
import java.util.Map;
public abstract class AbstractActionHandlerService extends
AbstractControllerService implements PropertyContextActionHandler {
+ protected String enforceActionType;
+
public static enum DebugLevels {
trace, debug, info, warn, error
}
- public abstract void execute(Action action, Map<String, Object> facts);
+
+ public static final PropertyDescriptor ENFORCE_ACTION_TYPE = new
PropertyDescriptor.Builder()
+ .name("action-handler-enforce-type")
+ .displayName("Enforce Action Type")
+ .required(false)
+ .description("The Action Type that should be supported by this
handler. If provided any other type an " +
+ "exception will be thrown")
+ .addValidator(StandardValidators.NON_BLANK_VALIDATOR)
+ .build();
+
+ public void execute(Action action, Map<String, Object> facts){
+ if(actionTypeNotSupported(action)){
+ throw new UnsupportedOperationException("This Action Handler does
not support actions with the provided type: " + action.getType());
Review comment:
The original intent was for users to have a way to ensure that only one type
is supported and to immediately see (and flag as an issue) that something else
is being sent. But I think there is value in giving an option for either mode
(ignore vs enforce).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services