You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ma...@apache.org on 2019/08/28 15:33:35 UTC

[nifi] branch master updated: NIFI-6382 Fix verifyUpdate for parameter contexts to account for deletions

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

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


The following commit(s) were added to refs/heads/master by this push:
     new b78aeb6  NIFI-6382 Fix verifyUpdate for parameter contexts to account for deletions
b78aeb6 is described below

commit b78aeb67a1aa29ff86515467e5e2ffdb463af0c3
Author: Bryan Bende <bb...@apache.org>
AuthorDate: Tue Aug 20 14:12:18 2019 -0400

    NIFI-6382 Fix verifyUpdate for parameter contexts to account for deletions
    
    This closes #3661.
    
    Signed-off-by: Mark Payne <ma...@hotmail.com>
---
 .../web/dao/impl/StandardParameterContextDAO.java    | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardParameterContextDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardParameterContextDAO.java
index 4b02b9d..9ad06a3 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardParameterContextDAO.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardParameterContextDAO.java
@@ -150,21 +150,27 @@ public class StandardParameterContextDAO implements ParameterContextDAO {
             final ParameterReferenceManager referenceManager = currentContext.getParameterReferenceManager();
 
             for (final ProcessorNode processor : referenceManager.getProcessorsReferencing(currentContext, parameterName)) {
-                verifyParameterUpdate(parameterName, processor, parameterDto.getSensitive(), currentContext.getName(), verifyComponentStates, processor.isRunning(), "Processor that is running");
+                verifyParameterUpdate(parameterDto, processor, currentContext.getName(), verifyComponentStates, processor.isRunning(), "Processor that is running");
             }
 
             for (final ControllerServiceNode serviceNode : referenceManager.getControllerServicesReferencing(currentContext, parameterName)) {
-                verifyParameterUpdate(parameterName, serviceNode, parameterDto.getSensitive(), currentContext.getName(), verifyComponentStates,
+                verifyParameterUpdate(parameterDto, serviceNode, currentContext.getName(), verifyComponentStates,
                     serviceNode.getState() != ControllerServiceState.DISABLED, "Controller Service that is enabled");
             }
         }
     }
 
-    private void verifyParameterUpdate(final String parameterName, final ComponentNode component, final Boolean parameterSensitive, final String contextName,
+    private void verifyParameterUpdate(final ParameterDTO parameterDto, final ComponentNode component, final String contextName,
                                             final boolean verifyComponentStates, final boolean active, final String activeExplanation) {
+
+        final String parameterName = parameterDto.getName();
+        final Boolean parameterSensitive = parameterDto.getSensitive();
+        final boolean parameterDeletion = parameterDto.getDescription() == null && parameterDto.getSensitive() == null && parameterDto.getValue() == null;
+
         // For any parameter that is added or modified, we need to ensure that the new configuration will not result in a Sensitive Parameter being referenced by a non-Sensitive Property
         // or a Non-Sensitive Parameter being referenced by a Sensitive Property.
-        // Additionally, if 'verifyComponentStates', we must ensure that any component that references a value that is to be updated is stopped (if a processor) or disabled (if a controller service)
+        // Additionally, if 'verifyComponentStates' or parameter is being deleted, we must ensure that any component that references a value that is to be updated
+        // is stopped (if a processor) or disabled (if a controller service).
         for (final Map.Entry<PropertyDescriptor, PropertyConfiguration> entry : component.getProperties().entrySet()) {
             final PropertyConfiguration configuration = entry.getValue();
             if (configuration == null) {
@@ -174,17 +180,17 @@ public class StandardParameterContextDAO implements ParameterContextDAO {
             for (final ParameterReference reference : configuration.getParameterReferences()) {
                 final String referencedParameterName = reference.getParameterName();
                 if (referencedParameterName.equals(parameterName)) {
-                    if (entry.getKey().isSensitive() && !Boolean.TRUE.equals(parameterSensitive)) {
+                    if (entry.getKey().isSensitive() && !parameterDeletion && !Boolean.TRUE.equals(parameterSensitive)) {
                         throw new IllegalStateException("Cannot update Parameter Context " + contextName + " because the update would add a Non-Sensitive Parameter " +
                             "named '" + parameterName + "' but this Parameter already is referenced by a Sensitive Property.");
                     }
 
-                    if (!entry.getKey().isSensitive() && Boolean.TRUE.equals(parameterSensitive)) {
+                    if (!entry.getKey().isSensitive() && !parameterDeletion && Boolean.TRUE.equals(parameterSensitive)) {
                         throw new IllegalStateException("Cannot update Parameter Context " + contextName + " because the update would add a Sensitive Parameter named " +
                             "'" + parameterName + "' but this Parameter already is referenced by a Non-Sensitive Property.");
                     }
 
-                    if (verifyComponentStates && active) {
+                    if (active && (verifyComponentStates || parameterDeletion)) {
                         throw new IllegalStateException("Cannot update Parameter Context " + contextName + " because it has Parameters that are being referenced by a " +
                             activeExplanation + ".");
                     }