diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/FetchParams.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/FetchParams.java index 761e06a268..938c890f4f 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/FetchParams.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/FetchParams.java @@ -23,11 +23,13 @@ import org.apache.nifi.toolkit.cli.api.CommandException; import org.apache.nifi.toolkit.cli.api.Context; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClient; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; +import org.apache.nifi.toolkit.cli.impl.client.nifi.ParamContextClient; import org.apache.nifi.toolkit.cli.impl.client.nifi.ParamProviderClient; import org.apache.nifi.toolkit.cli.impl.command.CommandOption; import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand; import org.apache.nifi.toolkit.cli.impl.result.nifi.ParamProviderResult; import org.apache.nifi.toolkit.cli.impl.util.JacksonUtils; +import org.apache.nifi.web.api.entity.ParameterContextsEntity; import org.apache.nifi.web.api.entity.ParameterProviderApplyParametersRequestEntity; import org.apache.nifi.web.api.entity.ParameterProviderEntity; import org.apache.nifi.web.api.entity.ParameterProviderParameterApplicationEntity; @@ -81,6 +83,8 @@ public class FetchParams extends AbstractNiFiCommand { parameterApplicationEntity = objectMapper.readValue(parameterApplicationJson, ParameterProviderParameterApplicationEntity.class); } final ParamProviderClient paramProviderClient = client.getParamProviderClient(); + final ParamContextClient paramContextClient = client.getParamContextClient(); + final ParameterContextsEntity paramContextEntity = paramContextClient.getParamContexts(); final ParameterProviderEntity existingParameterProvider = paramProviderClient.getParamProvider(paramProviderId); final ParameterProviderParameterFetchEntity fetchEntity = new ParameterProviderParameterFetchEntity(); @@ -92,7 +96,7 @@ public class FetchParams extends AbstractNiFiCommand { applyParametersAndWait(paramProviderClient, fetchedParameterProvider, parameterApplicationEntity, sensitiveParamPattern); } - return new ParamProviderResult(getResultType(properties), fetchedParameterProvider); + return new ParamProviderResult(getResultType(properties), fetchedParameterProvider, paramContextEntity); } private void applyParametersAndWait(final ParamProviderClient paramProviderClient, final ParameterProviderEntity fetchedParameterProvider, diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/GetParamProvider.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/GetParamProvider.java index 32444dc14a..696cbc9119 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/GetParamProvider.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/GetParamProvider.java @@ -21,10 +21,12 @@ import org.apache.nifi.toolkit.cli.api.CommandException; import org.apache.nifi.toolkit.cli.api.Context; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClient; import org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException; +import org.apache.nifi.toolkit.cli.impl.client.nifi.ParamContextClient; import org.apache.nifi.toolkit.cli.impl.client.nifi.ParamProviderClient; import org.apache.nifi.toolkit.cli.impl.command.CommandOption; import org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand; import org.apache.nifi.toolkit.cli.impl.result.nifi.ParamProviderResult; +import org.apache.nifi.web.api.entity.ParameterContextsEntity; import org.apache.nifi.web.api.entity.ParameterProviderEntity; import java.io.IOException; @@ -51,7 +53,9 @@ public class GetParamProvider extends AbstractNiFiCommand { throws NiFiClientException, IOException, MissingOptionException, CommandException { final String paramProviderId = getRequiredArg(properties, CommandOption.PARAM_PROVIDER_ID); final ParamProviderClient paramProviderClient = client.getParamProviderClient(); + final ParamContextClient paramContextClient = client.getParamContextClient(); + final ParameterContextsEntity paramContextEntity = paramContextClient.getParamContexts(); final ParameterProviderEntity parameterProvider = paramProviderClient.getParamProvider(paramProviderId); - return new ParamProviderResult(getResultType(properties), parameterProvider); + return new ParamProviderResult(getResultType(properties), parameterProvider, paramContextEntity); } } diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/RemoveInheritedParamContexts.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/RemoveInheritedParamContexts.java index d48897f551..51e58997ed 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/RemoveInheritedParamContexts.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/RemoveInheritedParamContexts.java @@ -69,6 +69,14 @@ public class RemoveInheritedParamContexts extends AbstractUpdateParamContextComm parameterContextDTO.setId(existingParameterContextEntity.getId()); parameterContextDTO.setParameters(existingParameterContextEntity.getComponent().getParameters()); + // we need to explicitly set null for the sensitive parameters as we are getting **** for the values + // on the client side. This is the only way for the server side to know that the values are not changed + // during the update parameter context request + parameterContextDTO.getParameters() + .stream() + .filter(t -> t.getParameter().getSensitive().booleanValue()) + .forEach(t -> t.getParameter().setValue(null)); + final ParameterContextEntity updatedParameterContextEntity = new ParameterContextEntity(); updatedParameterContextEntity.setId(paramContextId); updatedParameterContextEntity.setComponent(parameterContextDTO); diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetInheritedParamContexts.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetInheritedParamContexts.java index 78953d7616..569a66ddb8 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetInheritedParamContexts.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/command/nifi/params/SetInheritedParamContexts.java @@ -87,6 +87,14 @@ public class SetInheritedParamContexts extends AbstractUpdateParamContextCommand parameterContextDTO.setId(existingParameterContextEntity.getId()); parameterContextDTO.setParameters(existingParameterContextEntity.getComponent().getParameters()); + // we need to explicitly set null for the sensitive parameters as we are getting **** for the values + // on the client side. This is the only way for the server side to know that the values are not changed + // during the update parameter context request + parameterContextDTO.getParameters() + .stream() + .filter(t -> t.getParameter().getSensitive().booleanValue()) + .forEach(t -> t.getParameter().setValue(null)); + final ParameterContextEntity updatedParameterContextEntity = new ParameterContextEntity(); updatedParameterContextEntity.setId(paramContextId); updatedParameterContextEntity.setComponent(parameterContextDTO); diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/result/nifi/ParamProviderResult.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/result/nifi/ParamProviderResult.java index 6f9383bef4..a7827243c2 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/result/nifi/ParamProviderResult.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/result/nifi/ParamProviderResult.java @@ -22,6 +22,7 @@ import org.apache.nifi.toolkit.cli.impl.result.writer.DynamicTableWriter; import org.apache.nifi.toolkit.cli.impl.result.writer.Table; import org.apache.nifi.toolkit.cli.impl.result.writer.TableWriter; import org.apache.nifi.web.api.dto.ParameterProviderDTO; +import org.apache.nifi.web.api.entity.ParameterContextsEntity; import org.apache.nifi.web.api.entity.ParameterGroupConfigurationEntity; import org.apache.nifi.web.api.entity.ParameterProviderEntity; @@ -35,10 +36,13 @@ import java.util.List; public class ParamProviderResult extends AbstractWritableResult { private final ParameterProviderEntity parameterProvider; + private final ParameterContextsEntity parameterContexts; - public ParamProviderResult(final ResultType resultType, final ParameterProviderEntity parameterProvider) { + public ParamProviderResult(final ResultType resultType, final ParameterProviderEntity parameterProvider, + final ParameterContextsEntity paramContextEntity) { super(resultType); this.parameterProvider = parameterProvider; + this.parameterContexts = paramContextEntity; } @Override @@ -59,6 +63,7 @@ public class ParamProviderResult extends AbstractWritableResult fetchedParametersTable.addRow(new String[] { group.getGroupName(), + getParameterContextId(group.getParameterContextName()), group.getParameterContextName(), param })); @@ -83,6 +89,16 @@ public class ParamProviderResult extends AbstractWritableResult t.getComponent().getName().equals(name)) + .findFirst() + .get() + .getComponent() + .getId(); + } + @Override public ParameterProviderEntity getResult() { return parameterProvider;