From 151a9361facfe8d0a71203584b7bf4330e8e8f38 Mon Sep 17 00:00:00 2001 From: Mark Payne Date: Mon, 11 Oct 2021 11:18:42 -0400 Subject: [PATCH] NIFI-9288: Updated data model to use for cnofig verification requests so that only properties are necessary not the full component/config dtos. Also added endpoint necessary for determining which attributes are referenced by a component's properties and removed the referencedAttributes field from the compnoents themselves, since there's now a new endpoint for it. Also fixed a bug that was encountered where the VerifyConfigRequestDTO's complete flag was incorrect in case of failures Signed-off-by: Joe Gresock This closes #5452. --- .../web/api/dto/ConfigurationAnalysisDTO.java | 57 ++++++++ .../web/api/dto/ControllerServiceDTO.java | 11 -- .../nifi/web/api/dto/ProcessorConfigDTO.java | 10 -- ...stDTO.java => VerifyConfigRequestDTO.java} | 28 ++-- ...rifyControllerServiceConfigRequestDTO.java | 69 ---------- .../VerifyReportingTaskConfigRequestDTO.java | 58 -------- ....java => ConfigurationAnalysisEntity.java} | 18 +-- ...ty.java => VerifyConfigRequestEntity.java} | 12 +- ...yControllerServiceConfigRequestEntity.java | 37 ----- .../http/StandardHttpResponseMapper.java | 8 +- ...r.java => VerifyConfigEndpointMerger.java} | 24 ++-- ...ControllerServiceConfigEndpointMerger.java | 73 ---------- ...rifyReportingTaskConfigEndpointMerger.java | 71 ---------- .../controller/AbstractComponentNode.java | 4 +- .../apache/nifi/controller/TemplateUtils.java | 2 - .../apache/nifi/web/NiFiServiceFacade.java | 39 ++++-- .../nifi/web/StandardNiFiServiceFacade.java | 87 +++++++++++- .../web/api/ControllerServiceResource.java | 126 ++++++++++++----- .../nifi/web/api/ProcessorResource.java | 130 +++++++++++++----- .../nifi/web/api/ReportingTaskResource.java | 126 ++++++++++++----- .../api/concurrent/StandardUpdateStep.java | 2 +- .../apache/nifi/web/api/dto/DtoFactory.java | 4 - .../nifi/web/dao/ControllerServiceDAO.java | 4 +- .../org/apache/nifi/web/dao/ProcessorDAO.java | 5 +- .../apache/nifi/web/dao/ReportingTaskDAO.java | 5 +- .../impl/StandardControllerServiceDAO.java | 4 +- .../web/dao/impl/StandardProcessorDAO.java | 4 +- .../dao/impl/StandardReportingTaskDAO.java | 4 +- .../nifi/tests/system/NiFiClientUtil.java | 45 +++--- .../client/nifi/ControllerServicesClient.java | 8 +- .../cli/impl/client/nifi/ProcessorClient.java | 8 +- .../client/nifi/ReportingTasksClient.java | 8 +- .../impl/JerseyControllerServicesClient.java | 22 +-- .../nifi/impl/JerseyProcessorClient.java | 22 +-- .../nifi/impl/JerseyReportingTasksClient.java | 22 +-- 35 files changed, 578 insertions(+), 579 deletions(-) create mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConfigurationAnalysisDTO.java rename nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/{VerifyProcessorConfigRequestDTO.java => VerifyConfigRequestDTO.java} (70%) delete mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyControllerServiceConfigRequestDTO.java delete mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyReportingTaskConfigRequestDTO.java rename nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/{VerifyReportingTaskConfigRequestEntity.java => ConfigurationAnalysisEntity.java} (64%) rename nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/{VerifyProcessorConfigRequestEntity.java => VerifyConfigRequestEntity.java} (73%) delete mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyControllerServiceConfigRequestEntity.java rename nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/{VerifyProcessorConfigEndpointMerger.java => VerifyConfigEndpointMerger.java} (65%) delete mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyControllerServiceConfigEndpointMerger.java delete mode 100644 nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyReportingTaskConfigEndpointMerger.java diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConfigurationAnalysisDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConfigurationAnalysisDTO.java new file mode 100644 index 0000000000..29481f0940 --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ConfigurationAnalysisDTO.java @@ -0,0 +1,57 @@ +/* + * 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.web.api.dto; + +import io.swagger.annotations.ApiModelProperty; + +import javax.xml.bind.annotation.XmlType; +import java.util.Map; + +@XmlType(name = "configurationAnalysis") +public class ConfigurationAnalysisDTO { + private String componentId; + private Map properties; + private Map referencedAttributes; + + @ApiModelProperty("The ID of the component") + public String getComponentId() { + return componentId; + } + + public void setComponentId(final String componentId) { + this.componentId = componentId; + } + + @ApiModelProperty("The configured properties for the component") + public Map getProperties() { + return properties; + } + + public void setProperties(final Map properties) { + this.properties = properties; + } + + @ApiModelProperty("The attributes that are referenced by the properties, mapped to recently used values") + public Map getReferencedAttributes() { + return referencedAttributes; + } + + public void setReferencedAttributes(final Map referencedAttributes) { + this.referencedAttributes = referencedAttributes; + } +} diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java index bf88780f88..cb3824f29a 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerServiceDTO.java @@ -17,7 +17,6 @@ package org.apache.nifi.web.api.dto; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiModelProperty.AccessMode; import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentEntity; import javax.xml.bind.annotation.XmlType; @@ -46,7 +45,6 @@ public class ControllerServiceDTO extends ComponentDTO { private Boolean deprecated; private Boolean isExtensionMissing; private Boolean multipleVersionsAvailable; - private Set referencedAttributes; private Map properties; private Map descriptors; @@ -315,15 +313,6 @@ public class ControllerServiceDTO extends ComponentDTO { this.validationStatus = validationStatus; } - @ApiModelProperty(value = "The set of FlowFile Attributes that are referenced via Expression Language by the configured properties", accessMode = AccessMode.READ_ONLY) - public Set getReferencedAttributes() { - return referencedAttributes; - } - - public void setReferencedAttributes(final Set referencedAttributes) { - this.referencedAttributes = referencedAttributes; - } - @Override public int hashCode() { final String id = getId(); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorConfigDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorConfigDTO.java index 3d40e60ad3..780e8acb70 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorConfigDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ProcessorConfigDTO.java @@ -17,7 +17,6 @@ package org.apache.nifi.web.api.dto; import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiModelProperty.AccessMode; import javax.xml.bind.annotation.XmlType; import java.util.Map; @@ -51,7 +50,6 @@ public class ProcessorConfigDTO { private Map defaultConcurrentTasks; private Map defaultSchedulingPeriod; - private Set referencedAttributes; public ProcessorConfigDTO() { @@ -310,12 +308,4 @@ public class ProcessorConfigDTO { this.defaultSchedulingPeriod = defaultSchedulingPeriod; } - @ApiModelProperty(value = "The set of FlowFile Attributes that are referenced via Expression Language by the configured properties", accessMode = AccessMode.READ_ONLY) - public Set getReferencedAttributes() { - return referencedAttributes; - } - - public void setReferencedAttributes(final Set referencedAttributes) { - this.referencedAttributes = referencedAttributes; - } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyProcessorConfigRequestDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyConfigRequestDTO.java similarity index 70% rename from nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyProcessorConfigRequestDTO.java rename to nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyConfigRequestDTO.java index 744cfadc9c..d10af04bd0 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyProcessorConfigRequestDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyConfigRequestDTO.java @@ -24,29 +24,29 @@ import javax.xml.bind.annotation.XmlType; import java.util.List; import java.util.Map; -@XmlType(name = "verifyProcessorConfigRequest") -public class VerifyProcessorConfigRequestDTO extends AsynchronousRequestDTO { - private String processorId; - private ProcessorConfigDTO processorConfigDTO; +@XmlType(name = "verifyConfigRequest") +public class VerifyConfigRequestDTO extends AsynchronousRequestDTO { + private String componentId; + private Map properties; private Map attributes; private List results; - @ApiModelProperty("The ID of the Processor whose configuration was verified") - public String getProcessorId() { - return processorId; + @ApiModelProperty("The ID of the component whose configuration was verified") + public String getComponentId() { + return componentId; } - public void setProcessorId(final String processorId) { - this.processorId = processorId; + public void setComponentId(final String componentId) { + this.componentId = componentId; } - @ApiModelProperty("The configuration for the Processor") - public ProcessorConfigDTO getProcessorConfig() { - return processorConfigDTO; + @ApiModelProperty("The configured component properties") + public Map getProperties() { + return properties; } - public void setProcessorConfig(final ProcessorConfigDTO processorConfigDTO) { - this.processorConfigDTO = processorConfigDTO; + public void setProperties(final Map properties) { + this.properties = properties; } @ApiModelProperty("FlowFile Attributes that should be used to evaluate Expression Language for resolving property values") diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyControllerServiceConfigRequestDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyControllerServiceConfigRequestDTO.java deleted file mode 100644 index e0bb49c190..0000000000 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyControllerServiceConfigRequestDTO.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.web.api.dto; - -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiModelProperty.AccessMode; - -import javax.xml.bind.annotation.XmlType; -import java.util.List; -import java.util.Map; - -@XmlType(name = "verifyControllerServiceConfigRequest") -public class VerifyControllerServiceConfigRequestDTO extends AsynchronousRequestDTO { - private String controllerServiceId; - private ControllerServiceDTO controllerService; - private Map attributes; - private List results; - - @ApiModelProperty("The ID of the Controller Service whose configuration was verified") - public String getControllerServiceId() { - return controllerServiceId; - } - - public void setControllerServiceId(final String controllerServiceId) { - this.controllerServiceId = controllerServiceId; - } - - @ApiModelProperty("The Controller Service") - public ControllerServiceDTO getControllerService() { - return controllerService; - } - - public void setControllerService(final ControllerServiceDTO controllerService) { - this.controllerService = controllerService; - } - - @ApiModelProperty("FlowFile Attributes that should be used to evaluate Expression Language for resolving property values") - public Map getAttributes() { - return attributes; - } - - public void setAttributes(final Map attributes) { - this.attributes = attributes; - } - - @ApiModelProperty(value="The Results of the verification", accessMode = AccessMode.READ_ONLY) - public List getResults() { - return results; - } - - public void setResults(final List results) { - this.results = results; - } -} diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyReportingTaskConfigRequestDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyReportingTaskConfigRequestDTO.java deleted file mode 100644 index 07a87c8686..0000000000 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/VerifyReportingTaskConfigRequestDTO.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.web.api.dto; - -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiModelProperty.AccessMode; - -import javax.xml.bind.annotation.XmlType; -import java.util.List; - -@XmlType(name = "verifyReportingTaskConfigRequest") -public class VerifyReportingTaskConfigRequestDTO extends AsynchronousRequestDTO { - private String reportingTaskId; - private ReportingTaskDTO reportingTask; - private List results; - - @ApiModelProperty("The ID of the Controller Service whose configuration was verified") - public String getReportingTaskId() { - return reportingTaskId; - } - - public void setReportingTaskId(final String reportingTaskId) { - this.reportingTaskId = reportingTaskId; - } - - @ApiModelProperty("The Controller Service") - public ReportingTaskDTO getReportingTask() { - return reportingTask; - } - - public void setReportingTask(final ReportingTaskDTO reportingTask) { - this.reportingTask = reportingTask; - } - - @ApiModelProperty(value="The Results of the verification", accessMode = AccessMode.READ_ONLY) - public List getResults() { - return results; - } - - public void setResults(final List results) { - this.results = results; - } -} diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyReportingTaskConfigRequestEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConfigurationAnalysisEntity.java similarity index 64% rename from nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyReportingTaskConfigRequestEntity.java rename to nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConfigurationAnalysisEntity.java index 318bf0b19c..ff1b60d8f6 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyReportingTaskConfigRequestEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ConfigurationAnalysisEntity.java @@ -18,20 +18,20 @@ package org.apache.nifi.web.api.entity; import io.swagger.annotations.ApiModelProperty; -import org.apache.nifi.web.api.dto.VerifyReportingTaskConfigRequestDTO; +import org.apache.nifi.web.api.dto.ConfigurationAnalysisDTO; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name="verifyReportingTaskConfigRequest") -public class VerifyReportingTaskConfigRequestEntity extends Entity { - private VerifyReportingTaskConfigRequestDTO request; +@XmlRootElement(name = "configurationAnalysis") +public class ConfigurationAnalysisEntity extends Entity { + private ConfigurationAnalysisDTO configurationAnalysis; - @ApiModelProperty("The request") - public VerifyReportingTaskConfigRequestDTO getRequest() { - return request; + @ApiModelProperty("The configuration analysis") + public ConfigurationAnalysisDTO getConfigurationAnalysis() { + return configurationAnalysis; } - public void setRequest(final VerifyReportingTaskConfigRequestDTO request) { - this.request = request; + public void setConfigurationAnalysis(final ConfigurationAnalysisDTO configurationAnalysis) { + this.configurationAnalysis = configurationAnalysis; } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyProcessorConfigRequestEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyConfigRequestEntity.java similarity index 73% rename from nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyProcessorConfigRequestEntity.java rename to nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyConfigRequestEntity.java index 8b0dd9ae42..c5b444cfb2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyProcessorConfigRequestEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyConfigRequestEntity.java @@ -18,20 +18,20 @@ package org.apache.nifi.web.api.entity; import io.swagger.annotations.ApiModelProperty; -import org.apache.nifi.web.api.dto.VerifyProcessorConfigRequestDTO; +import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO; import javax.xml.bind.annotation.XmlRootElement; -@XmlRootElement(name="verifyProcessorConfigRequest") -public class VerifyProcessorConfigRequestEntity extends Entity { - private VerifyProcessorConfigRequestDTO request; +@XmlRootElement(name="verifyConfigRequest") +public class VerifyConfigRequestEntity extends Entity { + private VerifyConfigRequestDTO request; @ApiModelProperty("The request") - public VerifyProcessorConfigRequestDTO getRequest() { + public VerifyConfigRequestDTO getRequest() { return request; } - public void setRequest(final VerifyProcessorConfigRequestDTO request) { + public void setRequest(final VerifyConfigRequestDTO request) { this.request = request; } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyControllerServiceConfigRequestEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyControllerServiceConfigRequestEntity.java deleted file mode 100644 index 822a689d09..0000000000 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/VerifyControllerServiceConfigRequestEntity.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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.web.api.entity; - -import io.swagger.annotations.ApiModelProperty; -import org.apache.nifi.web.api.dto.VerifyControllerServiceConfigRequestDTO; - -import javax.xml.bind.annotation.XmlRootElement; - -@XmlRootElement(name="verifyControllerServiceConfigRequest") -public class VerifyControllerServiceConfigRequestEntity extends Entity { - private VerifyControllerServiceConfigRequestDTO request; - - @ApiModelProperty("The request") - public VerifyControllerServiceConfigRequestDTO getRequest() { - return request; - } - - public void setRequest(final VerifyControllerServiceConfigRequestDTO request) { - this.request = request; - } -} diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/StandardHttpResponseMapper.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/StandardHttpResponseMapper.java index 76fa4a818a..fde9097b30 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/StandardHttpResponseMapper.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/StandardHttpResponseMapper.java @@ -77,9 +77,7 @@ import org.apache.nifi.cluster.coordination.http.endpoints.UserGroupEndpointMerg import org.apache.nifi.cluster.coordination.http.endpoints.UserGroupsEndpointMerger; import org.apache.nifi.cluster.coordination.http.endpoints.UsersEndpointMerger; import org.apache.nifi.cluster.coordination.http.endpoints.VariableRegistryEndpointMerger; -import org.apache.nifi.cluster.coordination.http.endpoints.VerifyControllerServiceConfigEndpointMerger; -import org.apache.nifi.cluster.coordination.http.endpoints.VerifyProcessorConfigEndpointMerger; -import org.apache.nifi.cluster.coordination.http.endpoints.VerifyReportingTaskConfigEndpointMerger; +import org.apache.nifi.cluster.coordination.http.endpoints.VerifyConfigEndpointMerger; import org.apache.nifi.cluster.coordination.http.replication.RequestReplicator; import org.apache.nifi.cluster.manager.NodeResponse; import org.apache.nifi.stream.io.NullOutputStream; @@ -172,9 +170,7 @@ public class StandardHttpResponseMapper implements HttpResponseMapper { endpointMergers.add(new ParameterContextsEndpointMerger()); endpointMergers.add(new ParameterContextEndpointMerger()); endpointMergers.add(new ParameterContextUpdateEndpointMerger()); - endpointMergers.add(new VerifyProcessorConfigEndpointMerger()); - endpointMergers.add(new VerifyControllerServiceConfigEndpointMerger()); - endpointMergers.add(new VerifyReportingTaskConfigEndpointMerger()); + endpointMergers.add(new VerifyConfigEndpointMerger()); } @Override diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyProcessorConfigEndpointMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyConfigEndpointMerger.java similarity index 65% rename from nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyProcessorConfigEndpointMerger.java rename to nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyConfigEndpointMerger.java index 40db2307b3..0c45becb06 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyProcessorConfigEndpointMerger.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyConfigEndpointMerger.java @@ -20,8 +20,8 @@ package org.apache.nifi.cluster.coordination.http.endpoints; import org.apache.nifi.cluster.manager.NodeResponse; import org.apache.nifi.cluster.protocol.NodeIdentifier; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; -import org.apache.nifi.web.api.dto.VerifyProcessorConfigRequestDTO; -import org.apache.nifi.web.api.entity.VerifyProcessorConfigRequestEntity; +import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO; +import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; import java.net.URI; import java.util.List; @@ -29,24 +29,28 @@ import java.util.Map; import java.util.Set; import java.util.regex.Pattern; -public class VerifyProcessorConfigEndpointMerger extends AbstractSingleEntityEndpoint { +public class VerifyConfigEndpointMerger extends AbstractSingleEntityEndpoint { public static final Pattern VERIFY_PROCESSOR_CONFIG_URI_PATTERN = Pattern.compile("/nifi-api/processors/[a-f0-9\\-]{36}/config/verification-requests(/[a-f0-9\\-]{36})?"); + public static final Pattern VERIFY_CONTROLLER_SERVICE_CONFIG_URI_PATTERN = Pattern.compile("/nifi-api/controller-services/[a-f0-9\\-]{36}/config/verification-requests(/[a-f0-9\\-]{36})?"); + public static final Pattern VERIFY_REPORTING_TASK_CONFIG_URI_PATTERN = Pattern.compile("/nifi-api/reporting-tasks/[a-f0-9\\-]{36}/config/verification-requests(/[a-f0-9\\-]{36})?"); @Override - protected Class getEntityClass() { - return VerifyProcessorConfigRequestEntity.class; + protected Class getEntityClass() { + return VerifyConfigRequestEntity.class; } @Override public boolean canHandle(final URI uri, final String method) { - return VERIFY_PROCESSOR_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches(); + return VERIFY_PROCESSOR_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches() + || VERIFY_CONTROLLER_SERVICE_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches() + || VERIFY_REPORTING_TASK_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches(); } @Override - protected void mergeResponses(final VerifyProcessorConfigRequestEntity clientEntity, final Map entityMap, + protected void mergeResponses(final VerifyConfigRequestEntity clientEntity, final Map entityMap, final Set successfulResponses, final Set problematicResponses) { - final VerifyProcessorConfigRequestDTO requestDto = clientEntity.getRequest(); + final VerifyConfigRequestDTO requestDto = clientEntity.getRequest(); final List results = requestDto.getResults(); // If the result hasn't been set, the task is not yet complete, so we don't have to bother merging the results. @@ -56,9 +60,9 @@ public class VerifyProcessorConfigEndpointMerger extends AbstractSingleEntityEnd // Aggregate the Config Verification Results across all nodes into a single List final ConfigVerificationResultMerger resultMerger = new ConfigVerificationResultMerger(); - for (final Map.Entry entry : entityMap.entrySet()) { + for (final Map.Entry entry : entityMap.entrySet()) { final NodeIdentifier nodeId = entry.getKey(); - final VerifyProcessorConfigRequestEntity entity = entry.getValue(); + final VerifyConfigRequestEntity entity = entry.getValue(); final List nodeResults = entity.getRequest().getResults(); resultMerger.addNodeResults(nodeId, nodeResults); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyControllerServiceConfigEndpointMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyControllerServiceConfigEndpointMerger.java deleted file mode 100644 index cee27b2ccb..0000000000 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyControllerServiceConfigEndpointMerger.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.cluster.coordination.http.endpoints; - -import org.apache.nifi.cluster.manager.NodeResponse; -import org.apache.nifi.cluster.protocol.NodeIdentifier; -import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; -import org.apache.nifi.web.api.dto.VerifyControllerServiceConfigRequestDTO; -import org.apache.nifi.web.api.entity.VerifyControllerServiceConfigRequestEntity; - -import java.net.URI; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Pattern; - -public class VerifyControllerServiceConfigEndpointMerger extends AbstractSingleEntityEndpoint { - public static final Pattern VERIFY_PROCESSOR_CONFIG_URI_PATTERN = Pattern.compile("/nifi-api/controller-services/[a-f0-9\\-]{36}/config/verification-requests(/[a-f0-9\\-]{36})?"); - - @Override - protected Class getEntityClass() { - return VerifyControllerServiceConfigRequestEntity.class; - } - - @Override - public boolean canHandle(final URI uri, final String method) { - return VERIFY_PROCESSOR_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches(); - } - - @Override - protected void mergeResponses(final VerifyControllerServiceConfigRequestEntity clientEntity, final Map entityMap, - final Set successfulResponses, final Set problematicResponses) { - - final VerifyControllerServiceConfigRequestDTO requestDto = clientEntity.getRequest(); - final List results = requestDto.getResults(); - - // If the result hasn't been set, the task is not yet complete, so we don't have to bother merging the results. - if (results == null) { - return; - } - - // Aggregate the Config Verification Results across all nodes into a single List - final ConfigVerificationResultMerger resultMerger = new ConfigVerificationResultMerger(); - for (final Map.Entry entry : entityMap.entrySet()) { - final NodeIdentifier nodeId = entry.getKey(); - final VerifyControllerServiceConfigRequestEntity entity = entry.getValue(); - - final List nodeResults = entity.getRequest().getResults(); - resultMerger.addNodeResults(nodeId, nodeResults); - } - - final List aggregateResults = resultMerger.computeAggregateResults(); - - - clientEntity.getRequest().setResults(aggregateResults); - } - -} diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyReportingTaskConfigEndpointMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyReportingTaskConfigEndpointMerger.java deleted file mode 100644 index eef079b283..0000000000 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/VerifyReportingTaskConfigEndpointMerger.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.cluster.coordination.http.endpoints; - -import org.apache.nifi.cluster.manager.NodeResponse; -import org.apache.nifi.cluster.protocol.NodeIdentifier; -import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; -import org.apache.nifi.web.api.dto.VerifyReportingTaskConfigRequestDTO; -import org.apache.nifi.web.api.entity.VerifyReportingTaskConfigRequestEntity; - -import java.net.URI; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Pattern; - -public class VerifyReportingTaskConfigEndpointMerger extends AbstractSingleEntityEndpoint { - public static final Pattern VERIFY_REPORTING_TASK_CONFIG_URI_PATTERN = Pattern.compile("/nifi-api/reporting-tasks/[a-f0-9\\-]{36}/config/verification-requests(/[a-f0-9\\-]{36})?"); - - @Override - protected Class getEntityClass() { - return VerifyReportingTaskConfigRequestEntity.class; - } - - @Override - public boolean canHandle(final URI uri, final String method) { - return VERIFY_REPORTING_TASK_CONFIG_URI_PATTERN.matcher(uri.getPath()).matches(); - } - - @Override - protected void mergeResponses(final VerifyReportingTaskConfigRequestEntity clientEntity, final Map entityMap, - final Set successfulResponses, final Set problematicResponses) { - - final VerifyReportingTaskConfigRequestDTO requestDto = clientEntity.getRequest(); - final List results = requestDto.getResults(); - - // If the result hasn't been set, the task is not yet complete, so we don't have to bother merging the results. - if (results == null) { - return; - } - - // Aggregate the Config Verification Results across all nodes into a single List - final ConfigVerificationResultMerger resultMerger = new ConfigVerificationResultMerger(); - for (final Map.Entry entry : entityMap.entrySet()) { - final NodeIdentifier nodeId = entry.getKey(); - final VerifyReportingTaskConfigRequestEntity entity = entry.getValue(); - - final List nodeResults = entity.getRequest().getResults(); - resultMerger.addNodeResults(nodeId, nodeResults); - } - - final List aggregateResults = resultMerger.computeAggregateResults(); - clientEntity.getRequest().setResults(aggregateResults); - } - -} diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractComponentNode.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractComponentNode.java index 603dec208b..399a484078 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractComponentNode.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/controller/AbstractComponentNode.java @@ -563,7 +563,9 @@ public abstract class AbstractComponentNode implements ComponentNode { final Map props = new LinkedHashMap<>(); for (final PropertyDescriptor descriptor : supported) { - props.put(descriptor, null); + if (descriptor != null) { + props.put(descriptor, descriptor.getDefaultValue()); + } } properties.forEach((descriptor, config) -> props.put(descriptor, valueFunction.apply(config))); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java index f7053d47d1..26db5c8d6d 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/TemplateUtils.java @@ -238,7 +238,6 @@ public class TemplateUtils { processorConfig.setCustomUiUrl(null); processorConfig.setDefaultConcurrentTasks(null); processorConfig.setDefaultSchedulingPeriod(null); - processorConfig.setReferencedAttributes(null); processorConfig.setAutoTerminatedRelationships(null); } @@ -307,7 +306,6 @@ public class TemplateUtils { serviceDTO.setCustomUiUrl(null); serviceDTO.setValidationErrors(null); serviceDTO.setValidationStatus(null); - serviceDTO.setReferencedAttributes(null); } } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java index 84c22302f2..6e5f42517c 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java @@ -25,13 +25,13 @@ import org.apache.nifi.components.ConfigurableComponent; import org.apache.nifi.controller.ScheduledState; import org.apache.nifi.controller.repository.claim.ContentDirection; import org.apache.nifi.controller.service.ControllerServiceState; +import org.apache.nifi.flow.VersionedProcessGroup; import org.apache.nifi.groups.ProcessGroup; import org.apache.nifi.parameter.ParameterContext; import org.apache.nifi.registry.flow.ExternalControllerServiceReference; import org.apache.nifi.registry.flow.VersionedFlow; import org.apache.nifi.registry.flow.VersionedFlowSnapshot; import org.apache.nifi.registry.flow.VersionedParameterContext; -import org.apache.nifi.flow.VersionedProcessGroup; import org.apache.nifi.web.api.dto.AccessPolicyDTO; import org.apache.nifi.web.api.dto.AffectedComponentDTO; import org.apache.nifi.web.api.dto.BulletinBoardDTO; @@ -59,7 +59,6 @@ import org.apache.nifi.web.api.dto.NodeDTO; import org.apache.nifi.web.api.dto.ParameterContextDTO; import org.apache.nifi.web.api.dto.PortDTO; import org.apache.nifi.web.api.dto.ProcessGroupDTO; -import org.apache.nifi.web.api.dto.ProcessorConfigDTO; import org.apache.nifi.web.api.dto.ProcessorDTO; import org.apache.nifi.web.api.dto.PropertyDescriptorDTO; import org.apache.nifi.web.api.dto.RegistryDTO; @@ -89,6 +88,7 @@ import org.apache.nifi.web.api.entity.AffectedComponentEntity; import org.apache.nifi.web.api.entity.BucketEntity; import org.apache.nifi.web.api.entity.BulletinEntity; import org.apache.nifi.web.api.entity.ComponentValidationResultEntity; +import org.apache.nifi.web.api.entity.ConfigurationAnalysisEntity; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ConnectionStatisticsEntity; import org.apache.nifi.web.api.entity.ConnectionStatusEntity; @@ -638,11 +638,19 @@ public interface NiFiServiceFacade { /** * Performs verification of the given Processor Configuration for the Processor with the given ID * @param processorId the id of the processor - * @param processorConfig the configuration to verify + * @param properties the configured properties to verify * @param attributes a map of values that can be used for resolving FlowFile attributes for Expression Language * @return verification results */ - List verifyProcessorConfiguration(String processorId, ProcessorConfigDTO processorConfig, Map attributes); + List verifyProcessorConfiguration(String processorId, Map properties, Map attributes); + + /** + * Performs analysis of the given properties, determining which attributes are referenced by properties + * @param processorId the ID of the processor + * @param properties the properties + * @return analysis results + */ + ConfigurationAnalysisEntity analyzeProcessorConfiguration(String processorId, Map properties); /** * Verifies the specified processor can be removed. @@ -2046,12 +2054,19 @@ public interface NiFiServiceFacade { /** * Performs verification of the given Configuration for the Controller Service with the given ID * @param controllerServiceId the id of the controller service - * @param controllerService the configuration to verify + * @param properties the configured properties to verify * @param variables a map of values that can be used for resolving FlowFile attributes for Expression Language * @return verification results */ - List verifyControllerServiceConfiguration(String controllerServiceId, ControllerServiceDTO controllerService, Map variables); + List verifyControllerServiceConfiguration(String controllerServiceId, Map properties, Map variables); + /** + * Performs analysis of the given properties, determining which attributes are referenced by properties + * @param controllerServiceId the ID of the Controller Service + * @param properties the properties + * @return analysis results + */ + ConfigurationAnalysisEntity analyzeControllerServiceConfiguration(String controllerServiceId, Map properties); /** * Deletes the specified label. @@ -2141,10 +2156,18 @@ public interface NiFiServiceFacade { /** * Performs verification of the given Configuration for the Reporting Task with the given ID * @param reportingTaskId the id of the reporting task - * @param reportingTask the configuration to verify + * @param properties the configured properties to verify * @return verification results */ - List verifyReportingTaskConfiguration(String reportingTaskId, ReportingTaskDTO reportingTask); + List verifyReportingTaskConfiguration(String reportingTaskId, Map properties); + + /** + * Performs analysis of the given properties, determining which attributes are referenced by properties + * @param reportingTaskId the ID of the Reporting Task + * @param properties the properties + * @return analysis results + */ + ConfigurationAnalysisEntity analyzeReportingTaskConfiguration(String reportingTaskId, Map properties); /** * Deletes the specified reporting task. diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java index 4d31a11a9f..721d6a03c1 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiServiceFacade.java @@ -25,6 +25,7 @@ import org.apache.nifi.action.FlowChangeAction; import org.apache.nifi.action.Operation; import org.apache.nifi.action.details.FlowChangePurgeDetails; import org.apache.nifi.admin.service.AuditService; +import org.apache.nifi.attribute.expression.language.Query; import org.apache.nifi.authorization.AccessDeniedException; import org.apache.nifi.authorization.AccessPolicy; import org.apache.nifi.authorization.AuthorizableLookup; @@ -74,6 +75,8 @@ import org.apache.nifi.controller.ControllerService; import org.apache.nifi.controller.Counter; import org.apache.nifi.controller.FlowController; import org.apache.nifi.controller.ProcessorNode; +import org.apache.nifi.controller.PropertyConfiguration; +import org.apache.nifi.controller.PropertyConfigurationMapper; import org.apache.nifi.controller.ReportingTaskNode; import org.apache.nifi.controller.ScheduledState; import org.apache.nifi.controller.Snippet; @@ -91,6 +94,7 @@ import org.apache.nifi.controller.status.ProcessGroupStatus; import org.apache.nifi.controller.status.ProcessorStatus; import org.apache.nifi.diagnostics.SystemDiagnostics; import org.apache.nifi.events.BulletinFactory; +import org.apache.nifi.expression.ExpressionLanguageScope; import org.apache.nifi.flow.VersionedComponent; import org.apache.nifi.flow.VersionedConfigurableComponent; import org.apache.nifi.flow.VersionedConnection; @@ -111,6 +115,7 @@ import org.apache.nifi.parameter.Parameter; import org.apache.nifi.parameter.ParameterContext; import org.apache.nifi.parameter.ParameterContextLookup; import org.apache.nifi.parameter.ParameterDescriptor; +import org.apache.nifi.parameter.ParameterLookup; import org.apache.nifi.parameter.ParameterReferenceManager; import org.apache.nifi.parameter.StandardParameterContext; import org.apache.nifi.prometheus.util.BulletinMetricsRegistry; @@ -174,6 +179,7 @@ import org.apache.nifi.web.api.dto.ComponentRestrictionPermissionDTO; import org.apache.nifi.web.api.dto.ComponentStateDTO; import org.apache.nifi.web.api.dto.ComponentValidationResultDTO; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; +import org.apache.nifi.web.api.dto.ConfigurationAnalysisDTO; import org.apache.nifi.web.api.dto.ConnectionDTO; import org.apache.nifi.web.api.dto.ControllerConfigurationDTO; import org.apache.nifi.web.api.dto.ControllerDTO; @@ -251,6 +257,7 @@ import org.apache.nifi.web.api.entity.BucketEntity; import org.apache.nifi.web.api.entity.BulletinEntity; import org.apache.nifi.web.api.entity.ComponentReferenceEntity; import org.apache.nifi.web.api.entity.ComponentValidationResultEntity; +import org.apache.nifi.web.api.entity.ConfigurationAnalysisEntity; import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ConnectionStatisticsEntity; import org.apache.nifi.web.api.entity.ConnectionStatusEntity; @@ -765,8 +772,59 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } @Override - public List verifyProcessorConfiguration(final String processorId, final ProcessorConfigDTO processorConfig, final Map attributes) { - return processorDAO.verifyProcessorConfiguration(processorId, processorConfig, attributes); + public List verifyProcessorConfiguration(final String processorId, final Map properties, final Map attributes) { + return processorDAO.verifyProcessorConfiguration(processorId, properties, attributes); + } + + @Override + public ConfigurationAnalysisEntity analyzeProcessorConfiguration(final String processorId, final Map properties) { + final ProcessorNode processorNode = processorDAO.getProcessor(processorId); + final ProcessGroup processGroup = processorNode.getProcessGroup(); + final ParameterContext parameterContext = processGroup.getParameterContext(); + + final ConfigurationAnalysisEntity configurationAnalysisEntity = analyzeConfiguration(processorNode, properties, parameterContext); + return configurationAnalysisEntity; + } + + private ConfigurationAnalysisEntity analyzeConfiguration(final ComponentNode componentNode, final Map properties, final ParameterContext parameterContext) { + final Map referencedAttributes = determineReferencedAttributes(properties, componentNode, parameterContext); + + final ConfigurationAnalysisDTO dto = new ConfigurationAnalysisDTO(); + dto.setComponentId(componentNode.getIdentifier()); + dto.setProperties(properties); + dto.setReferencedAttributes(referencedAttributes); + + final ConfigurationAnalysisEntity entity = new ConfigurationAnalysisEntity(); + entity.setConfigurationAnalysis(dto); + return entity; + } + + private Map determineReferencedAttributes(final Map properties, final ComponentNode componentNode, final ParameterContext parameterContext) { + final Map mergedProperties = new LinkedHashMap<>(); + componentNode.getRawPropertyValues().forEach((desc, value) -> mergedProperties.put(desc.getName(), value)); + mergedProperties.putAll(properties); + + final Set propertiesNotSupportingEL = new HashSet<>(); + for (final String propertyName : mergedProperties.keySet()) { + final PropertyDescriptor descriptor = componentNode.getPropertyDescriptor(propertyName); + final boolean allowsAttributes = descriptor.isExpressionLanguageSupported() || descriptor.getExpressionLanguageScope() == ExpressionLanguageScope.FLOWFILE_ATTRIBUTES; + if (descriptor.isSensitive() || !allowsAttributes) { + propertiesNotSupportingEL.add(propertyName); + } + } + propertiesNotSupportingEL.forEach(mergedProperties::remove); + + final PropertyConfigurationMapper configurationMapper = new PropertyConfigurationMapper(); + final Map configurationMap = configurationMapper.mapRawPropertyValuesToPropertyConfiguration(componentNode, mergedProperties); + + final Map referencedAttributes = new HashMap<>(); + for (final PropertyConfiguration propertyConfiguration : configurationMap.values()) { + final String effectiveValue = propertyConfiguration.getEffectiveValue(parameterContext == null ? ParameterLookup.EMPTY : parameterContext); + final Set attributes = Query.prepareWithParametersPreEvaluated(effectiveValue).getExplicitlyReferencedAttributes(); + attributes.forEach(attr -> referencedAttributes.put(attr, null)); + } + + return referencedAttributes; } private void awaitValidationCompletion(final ComponentNode component) { @@ -2776,8 +2834,18 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } @Override - public List verifyControllerServiceConfiguration(final String controllerServiceId, final ControllerServiceDTO controllerService, final Map variables) { - return controllerServiceDAO.verifyConfiguration(controllerServiceId, controllerService, variables); + public List verifyControllerServiceConfiguration(final String controllerServiceId, final Map properties, final Map variables) { + return controllerServiceDAO.verifyConfiguration(controllerServiceId, properties, variables); + } + + @Override + public ConfigurationAnalysisEntity analyzeControllerServiceConfiguration(final String controllerServiceId, final Map properties) { + final ControllerServiceNode serviceNode = controllerServiceDAO.getControllerService(controllerServiceId); + final ProcessGroup processGroup = serviceNode.getProcessGroup(); + final ParameterContext parameterContext = processGroup == null ? null : processGroup.getParameterContext(); + + final ConfigurationAnalysisEntity configurationAnalysisEntity = analyzeConfiguration(serviceNode, properties, parameterContext); + return configurationAnalysisEntity; } @Override @@ -3159,8 +3227,15 @@ public class StandardNiFiServiceFacade implements NiFiServiceFacade { } @Override - public List verifyReportingTaskConfiguration(final String reportingTaskId, final ReportingTaskDTO reportingTask) { - return reportingTaskDAO.verifyConfiguration(reportingTaskId, reportingTask); + public List verifyReportingTaskConfiguration(final String reportingTaskId, final Map properties) { + return reportingTaskDAO.verifyConfiguration(reportingTaskId, properties); + } + + @Override + public ConfigurationAnalysisEntity analyzeReportingTaskConfiguration(final String reportingTaskId, final Map properties) { + final ReportingTaskNode taskNode = reportingTaskDAO.getReportingTask(reportingTaskId); + final ConfigurationAnalysisEntity configurationAnalysisEntity = analyzeConfiguration(taskNode, properties, null); + return configurationAnalysisEntity; } @Override diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java index 324cffde91..8e89ada04c 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ControllerServiceResource.java @@ -49,17 +49,19 @@ import org.apache.nifi.web.api.concurrent.UpdateStep; import org.apache.nifi.web.api.dto.BundleDTO; import org.apache.nifi.web.api.dto.ComponentStateDTO; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; +import org.apache.nifi.web.api.dto.ConfigurationAnalysisDTO; import org.apache.nifi.web.api.dto.ControllerServiceDTO; import org.apache.nifi.web.api.dto.PropertyDescriptorDTO; import org.apache.nifi.web.api.dto.RevisionDTO; -import org.apache.nifi.web.api.dto.VerifyControllerServiceConfigRequestDTO; +import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO; import org.apache.nifi.web.api.entity.ComponentStateEntity; +import org.apache.nifi.web.api.entity.ConfigurationAnalysisEntity; import org.apache.nifi.web.api.entity.ControllerServiceEntity; import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentsEntity; import org.apache.nifi.web.api.entity.ControllerServiceRunStatusEntity; import org.apache.nifi.web.api.entity.PropertyDescriptorEntity; import org.apache.nifi.web.api.entity.UpdateControllerServiceReferenceRequestEntity; -import org.apache.nifi.web.api.entity.VerifyControllerServiceConfigRequestEntity; +import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; import org.apache.nifi.web.api.request.ClientIdParameter; import org.apache.nifi.web.api.request.LongParameter; import org.slf4j.Logger; @@ -102,7 +104,7 @@ public class ControllerServiceResource extends ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(ControllerServiceResource.class); private static final String VERIFICATION_REQUEST_TYPE = "verification-request"; - private RequestManager> updateRequestManager = + private RequestManager> updateRequestManager = new AsyncRequestManager<>(100, TimeUnit.MINUTES.toMillis(1L), "Verify Controller Service Config Thread"); private NiFiServiceFacade serviceFacade; @@ -841,6 +843,66 @@ public class ControllerServiceResource extends ApplicationResource { ); } + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/{id}/config/analysis") + @ApiOperation( + value = "Performs analysis of the component's configuration, providing information about which attributes are referenced.", + response = ConfigurationAnalysisEntity.class, + authorizations = { + @Authorization(value = "Read - /controller-services/{uuid}") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) + public Response analyzeConfiguration( + @ApiParam(value = "The controller service id.", required = true) @PathParam("id") final String controllerServiceId, + @ApiParam(value = "The configuration analysis request.", required = true) final ConfigurationAnalysisEntity configurationAnalysis) { + + if (configurationAnalysis == null || configurationAnalysis.getConfigurationAnalysis() == null) { + throw new IllegalArgumentException("Controller Service's configuration must be specified"); + } + + final ConfigurationAnalysisDTO dto = configurationAnalysis.getConfigurationAnalysis(); + if (dto.getComponentId() == null) { + throw new IllegalArgumentException("Controller Service's identifier must be specified in the request"); + } + + if (!dto.getComponentId().equals(controllerServiceId)) { + throw new IllegalArgumentException("Controller Service's identifier in the request must match the identifier provided in the URL"); + } + + if (dto.getProperties() == null) { + throw new IllegalArgumentException("Controller Service's properties must be specified in the request"); + } + + if (isReplicateRequest()) { + return replicate(HttpMethod.POST, configurationAnalysis); + } + + return withWriteLock( + serviceFacade, + configurationAnalysis, + lookup -> { + final ComponentAuthorizable controllerService = lookup.getControllerService(controllerServiceId); + controllerService.getAuthorizable().authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser()); + }, + () -> { }, + entity -> { + final ConfigurationAnalysisDTO analysis = entity.getConfigurationAnalysis(); + final ConfigurationAnalysisEntity resultsEntity = serviceFacade.analyzeControllerServiceConfiguration(analysis.getComponentId(), analysis.getProperties()); + return generateOkResponse(resultsEntity).build(); + } + ); + } @POST @Consumes(MediaType.APPLICATION_JSON) @@ -848,7 +910,7 @@ public class ControllerServiceResource extends ApplicationResource { @Path("/{id}/config/verification-requests") @ApiOperation( value = "Performs verification of the Controller Service's configuration", - response = VerifyControllerServiceConfigRequestEntity.class, + response = VerifyConfigRequestEntity.class, notes = "This will initiate the process of verifying a given Controller Service configuration. This may be a long-running task. As a result, this endpoint will immediately return a " + "ControllerServiceConfigVerificationRequestEntity, and the process of performing the verification will occur asynchronously in the background. " + "The client may then periodically poll the status of the request by " + @@ -869,22 +931,22 @@ public class ControllerServiceResource extends ApplicationResource { ) public Response submitConfigVerificationRequest( @ApiParam(value = "The controller service id.", required = true) @PathParam("id") final String controllerServiceId, - @ApiParam(value = "The controller service configuration verification request.", required = true) final VerifyControllerServiceConfigRequestEntity controllerServiceConfigRequest) { + @ApiParam(value = "The controller service configuration verification request.", required = true) final VerifyConfigRequestEntity controllerServiceConfigRequest) { if (controllerServiceConfigRequest == null) { throw new IllegalArgumentException("Controller Service's configuration must be specified"); } - final VerifyControllerServiceConfigRequestDTO requestDto = controllerServiceConfigRequest.getRequest(); - if (requestDto == null || requestDto.getControllerService() == null) { - throw new IllegalArgumentException("Controller Service must be specified"); + final VerifyConfigRequestDTO requestDto = controllerServiceConfigRequest.getRequest(); + if (requestDto == null || requestDto.getProperties() == null) { + throw new IllegalArgumentException("Controller Service properties must be specified"); } - if (requestDto.getControllerServiceId() == null) { + if (requestDto.getComponentId() == null) { throw new IllegalArgumentException("Controller Service's identifier must be specified in the request"); } - if (!requestDto.getControllerServiceId().equals(controllerServiceId)) { + if (!requestDto.getComponentId().equals(controllerServiceId)) { throw new IllegalArgumentException("Controller Service's identifier in the request must match the identifier provided in the URL"); } @@ -914,7 +976,7 @@ public class ControllerServiceResource extends ApplicationResource { @Path("{id}/config/verification-requests/{requestId}") @ApiOperation( value = "Returns the Verification Request with the given ID", - response = VerifyControllerServiceConfigRequestEntity.class, + response = VerifyConfigRequestEntity.class, notes = "Returns the Verification Request with the given ID. Once an Verification Request has been created, " + "that request can subsequently be retrieved via this endpoint, and the request that is fetched will contain the updated state, such as percent complete, the " + "current state of the request, and any failures. ", @@ -939,10 +1001,10 @@ public class ControllerServiceResource extends ApplicationResource { final NiFiUser user = NiFiUserUtils.getNiFiUser(); // request manager will ensure that the current is the user that submitted this request - final AsynchronousWebRequest> asyncRequest = + final AsynchronousWebRequest> asyncRequest = updateRequestManager.getRequest(VERIFICATION_REQUEST_TYPE, requestId, user); - final VerifyControllerServiceConfigRequestEntity updateRequestEntity = createVerifyControllerServiceConfigRequestEntity(asyncRequest, requestId); + final VerifyConfigRequestEntity updateRequestEntity = createVerifyControllerServiceConfigRequestEntity(asyncRequest, requestId); return generateOkResponse(updateRequestEntity).build(); } @@ -953,7 +1015,7 @@ public class ControllerServiceResource extends ApplicationResource { @Path("{id}/config/verification-requests/{requestId}") @ApiOperation( value = "Deletes the Verification Request with the given ID", - response = VerifyControllerServiceConfigRequestEntity.class, + response = VerifyConfigRequestEntity.class, notes = "Deletes the Verification Request with the given ID. After a request is created, it is expected " + "that the client will properly clean up the request by DELETE'ing it, once the Verification process has completed. If the request is deleted before the request " + "completes, then the Verification request will finish the step that it is currently performing and then will cancel any subsequent steps.", @@ -982,7 +1044,7 @@ public class ControllerServiceResource extends ApplicationResource { // If this is a standalone node, or if this is the execution phase of the request, perform the actual request. if (!twoPhaseRequest || executionPhase) { // request manager will ensure that the current is the user that submitted this request - final AsynchronousWebRequest> asyncRequest = + final AsynchronousWebRequest> asyncRequest = updateRequestManager.removeRequest(VERIFICATION_REQUEST_TYPE, requestId, user); if (asyncRequest == null) { @@ -993,7 +1055,7 @@ public class ControllerServiceResource extends ApplicationResource { asyncRequest.cancel(); } - final VerifyControllerServiceConfigRequestEntity updateRequestEntity = createVerifyControllerServiceConfigRequestEntity(asyncRequest, requestId); + final VerifyConfigRequestEntity updateRequestEntity = createVerifyControllerServiceConfigRequestEntity(asyncRequest, requestId); return generateOkResponse(updateRequestEntity).build(); } @@ -1009,22 +1071,22 @@ public class ControllerServiceResource extends ApplicationResource { } - public Response performAsyncConfigVerification(final VerifyControllerServiceConfigRequestEntity configRequest, final NiFiUser user) { + public Response performAsyncConfigVerification(final VerifyConfigRequestEntity configRequest, final NiFiUser user) { // Create an asynchronous request that will occur in the background, because this request may take an indeterminate amount of time. final String requestId = generateUuid(); - final VerifyControllerServiceConfigRequestDTO requestDto = configRequest.getRequest(); - final String serviceId = requestDto.getControllerServiceId(); + final VerifyConfigRequestDTO requestDto = configRequest.getRequest(); + final String serviceId = requestDto.getComponentId(); final List updateSteps = Collections.singletonList(new StandardUpdateStep("Verify Controller Service Configuration")); - final AsynchronousWebRequest> request = + final AsynchronousWebRequest> request = new StandardAsynchronousWebRequest<>(requestId, configRequest, serviceId, user, updateSteps); // Submit the request to be performed in the background - final Consumer>> updateTask = asyncRequest -> { + final Consumer>> updateTask = asyncRequest -> { try { final Map attributes = requestDto.getAttributes() == null ? Collections.emptyMap() : requestDto.getAttributes(); - final List results = serviceFacade.verifyControllerServiceConfiguration(serviceId, requestDto.getControllerService(), attributes); + final List results = serviceFacade.verifyControllerServiceConfiguration(serviceId, requestDto.getProperties(), attributes); asyncRequest.markStepComplete(results); } catch (final Exception e) { logger.error("Failed to verify Controller Service configuration", e); @@ -1035,30 +1097,30 @@ public class ControllerServiceResource extends ApplicationResource { updateRequestManager.submitRequest(VERIFICATION_REQUEST_TYPE, requestId, request, updateTask); // Generate the response - final VerifyControllerServiceConfigRequestEntity resultsEntity = createVerifyControllerServiceConfigRequestEntity(request, requestId); + final VerifyConfigRequestEntity resultsEntity = createVerifyControllerServiceConfigRequestEntity(request, requestId); return generateOkResponse(resultsEntity).build(); } - private VerifyControllerServiceConfigRequestEntity createVerifyControllerServiceConfigRequestEntity( - final AsynchronousWebRequest> asyncRequest, final String requestId) { + private VerifyConfigRequestEntity createVerifyControllerServiceConfigRequestEntity( + final AsynchronousWebRequest> asyncRequest, final String requestId) { - final VerifyControllerServiceConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest(); + final VerifyConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest(); final List resultsList = asyncRequest.getResults(); - final VerifyControllerServiceConfigRequestDTO dto = new VerifyControllerServiceConfigRequestDTO(); - dto.setControllerServiceId(requestDto.getControllerServiceId()); - dto.setControllerService(requestDto.getControllerService()); + final VerifyConfigRequestDTO dto = new VerifyConfigRequestDTO(); + dto.setComponentId(requestDto.getComponentId()); + dto.setProperties(requestDto.getProperties()); dto.setResults(resultsList); - dto.setComplete(resultsList != null); + dto.setComplete(asyncRequest.isComplete()); dto.setFailureReason(asyncRequest.getFailureReason()); dto.setLastUpdated(asyncRequest.getLastUpdated()); dto.setPercentCompleted(asyncRequest.getPercentComplete()); dto.setRequestId(requestId); dto.setState(asyncRequest.getState()); - dto.setUri(generateResourceUri("controller-services", requestDto.getControllerServiceId(), "config", "verification-requests", requestId)); + dto.setUri(generateResourceUri("controller-services", requestDto.getComponentId(), "config", "verification-requests", requestId)); - final VerifyControllerServiceConfigRequestEntity entity = new VerifyControllerServiceConfigRequestEntity(); + final VerifyConfigRequestEntity entity = new VerifyConfigRequestEntity(); entity.setRequest(dto); return entity; } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java index 98b924c865..94906b1b59 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ProcessorResource.java @@ -46,19 +46,21 @@ import org.apache.nifi.web.api.concurrent.UpdateStep; import org.apache.nifi.web.api.dto.BundleDTO; import org.apache.nifi.web.api.dto.ComponentStateDTO; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; +import org.apache.nifi.web.api.dto.ConfigurationAnalysisDTO; import org.apache.nifi.web.api.dto.PositionDTO; import org.apache.nifi.web.api.dto.ProcessorConfigDTO; import org.apache.nifi.web.api.dto.ProcessorDTO; import org.apache.nifi.web.api.dto.PropertyDescriptorDTO; -import org.apache.nifi.web.api.dto.VerifyProcessorConfigRequestDTO; +import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO; import org.apache.nifi.web.api.entity.ComponentStateEntity; +import org.apache.nifi.web.api.entity.ConfigurationAnalysisEntity; import org.apache.nifi.web.api.entity.ProcessorDiagnosticsEntity; import org.apache.nifi.web.api.entity.ProcessorEntity; import org.apache.nifi.web.api.entity.ProcessorRunStatusEntity; import org.apache.nifi.web.api.entity.ProcessorsRunStatusDetailsEntity; import org.apache.nifi.web.api.entity.PropertyDescriptorEntity; import org.apache.nifi.web.api.entity.RunStatusDetailsRequestEntity; -import org.apache.nifi.web.api.entity.VerifyProcessorConfigRequestEntity; +import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; import org.apache.nifi.web.api.request.ClientIdParameter; import org.apache.nifi.web.api.request.LongParameter; import org.slf4j.Logger; @@ -99,7 +101,7 @@ public class ProcessorResource extends ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(ProcessorResource.class); private static final String VERIFICATION_REQUEST_TYPE = "verification-request"; - private RequestManager> updateRequestManager = + private RequestManager> updateRequestManager = new AsyncRequestManager<>(100, TimeUnit.MINUTES.toMillis(1L), "Verify Processor Config Thread"); private NiFiServiceFacade serviceFacade; @@ -547,13 +549,75 @@ public class ProcessorResource extends ApplicationResource { } + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/{id}/config/analysis") + @ApiOperation( + value = "Performs analysis of the component's configuration, providing information about which attributes are referenced.", + response = ConfigurationAnalysisEntity.class, + authorizations = { + @Authorization(value = "Read - /processors/{uuid}") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) + public Response analyzeConfiguration( + @ApiParam(value = "The processor id.", required = true) @PathParam("id") final String processorId, + @ApiParam(value = "The processor configuration analysis request.", required = true) final ConfigurationAnalysisEntity configurationAnalysis) { + + if (configurationAnalysis == null || configurationAnalysis.getConfigurationAnalysis() == null) { + throw new IllegalArgumentException("Processor's configuration must be specified"); + } + + final ConfigurationAnalysisDTO dto = configurationAnalysis.getConfigurationAnalysis(); + if (dto.getComponentId() == null) { + throw new IllegalArgumentException("Processor's identifier must be specified in the request"); + } + + if (!dto.getComponentId().equals(processorId)) { + throw new IllegalArgumentException("Processor's identifier in the request must match the identifier provided in the URL"); + } + + if (dto.getProperties() == null) { + throw new IllegalArgumentException("Processor's properties must be specified in the request"); + } + + if (isReplicateRequest()) { + return replicate(HttpMethod.POST, configurationAnalysis); + } + + return withWriteLock( + serviceFacade, + configurationAnalysis, + lookup -> { + final ComponentAuthorizable processor = lookup.getProcessor(processorId); + processor.getAuthorizable().authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser()); + }, + () -> { }, + entity -> { + final ConfigurationAnalysisDTO analysis = entity.getConfigurationAnalysis(); + final ConfigurationAnalysisEntity resultsEntity = serviceFacade.analyzeProcessorConfiguration(analysis.getComponentId(), analysis.getProperties()); + return generateOkResponse(resultsEntity).build(); + } + ); + } + + @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/{id}/config/verification-requests") @ApiOperation( value = "Performs verification of the Processor's configuration", - response = VerifyProcessorConfigRequestEntity.class, + response = VerifyConfigRequestEntity.class, notes = "This will initiate the process of verifying a given Processor configuration. This may be a long-running task. As a result, this endpoint will immediately return a " + "ProcessorConfigVerificationRequestEntity, and the process of performing the verification will occur asynchronously in the background. " + "The client may then periodically poll the status of the request by " + @@ -574,22 +638,22 @@ public class ProcessorResource extends ApplicationResource { ) public Response submitProcessorVerificationRequest( @ApiParam(value = "The processor id.", required = true) @PathParam("id") final String processorId, - @ApiParam(value = "The processor configuration verification request.", required = true) final VerifyProcessorConfigRequestEntity processorConfigRequest) { + @ApiParam(value = "The processor configuration verification request.", required = true) final VerifyConfigRequestEntity processorConfigRequest) { if (processorConfigRequest == null) { throw new IllegalArgumentException("Processor's configuration must be specified"); } - final VerifyProcessorConfigRequestDTO requestDto = processorConfigRequest.getRequest(); - if (requestDto == null || requestDto.getProcessorConfig() == null) { - throw new IllegalArgumentException("Processor's configuration must be specified"); + final VerifyConfigRequestDTO requestDto = processorConfigRequest.getRequest(); + if (requestDto == null || requestDto.getProperties() == null) { + throw new IllegalArgumentException("Processor's properties must be specified"); } - if (requestDto.getProcessorId() == null) { + if (requestDto.getComponentId() == null) { throw new IllegalArgumentException("Processor's identifier must be specified in the request"); } - if (!requestDto.getProcessorId().equals(processorId)) { + if (!requestDto.getComponentId().equals(processorId)) { throw new IllegalArgumentException("Processor's identifier in the request must match the identifier provided in the URL"); } @@ -619,7 +683,7 @@ public class ProcessorResource extends ApplicationResource { @Path("{id}/config/verification-requests/{requestId}") @ApiOperation( value = "Returns the Verification Request with the given ID", - response = VerifyProcessorConfigRequestEntity.class, + response = VerifyConfigRequestEntity.class, notes = "Returns the Verification Request with the given ID. Once an Verification Request has been created, " + "that request can subsequently be retrieved via this endpoint, and the request that is fetched will contain the updated state, such as percent complete, the " + "current state of the request, and any failures. ", @@ -644,8 +708,8 @@ public class ProcessorResource extends ApplicationResource { final NiFiUser user = NiFiUserUtils.getNiFiUser(); // request manager will ensure that the current is the user that submitted this request - final AsynchronousWebRequest> asyncRequest = updateRequestManager.getRequest(VERIFICATION_REQUEST_TYPE, requestId, user); - final VerifyProcessorConfigRequestEntity updateRequestEntity = createVerifyProcessorConfigRequestEntity(asyncRequest, requestId); + final AsynchronousWebRequest> asyncRequest = updateRequestManager.getRequest(VERIFICATION_REQUEST_TYPE, requestId, user); + final VerifyConfigRequestEntity updateRequestEntity = createVerifyProcessorConfigRequestEntity(asyncRequest, requestId); return generateOkResponse(updateRequestEntity).build(); } @@ -656,7 +720,7 @@ public class ProcessorResource extends ApplicationResource { @Path("{id}/config/verification-requests/{requestId}") @ApiOperation( value = "Deletes the Verification Request with the given ID", - response = VerifyProcessorConfigRequestEntity.class, + response = VerifyConfigRequestEntity.class, notes = "Deletes the Verification Request with the given ID. After a request is created, it is expected " + "that the client will properly clean up the request by DELETE'ing it, once the Verification process has completed. If the request is deleted before the request " + "completes, then the Verification request will finish the step that it is currently performing and then will cancel any subsequent steps.", @@ -685,14 +749,14 @@ public class ProcessorResource extends ApplicationResource { // If this is a standalone node, or if this is the execution phase of the request, perform the actual request. if (!twoPhaseRequest || executionPhase) { // request manager will ensure that the current is the user that submitted this request - final AsynchronousWebRequest> asyncRequest = + final AsynchronousWebRequest> asyncRequest = updateRequestManager.removeRequest(VERIFICATION_REQUEST_TYPE, requestId, user); if (!asyncRequest.isComplete()) { asyncRequest.cancel(); } - final VerifyProcessorConfigRequestEntity updateRequestEntity = createVerifyProcessorConfigRequestEntity(asyncRequest, requestId); + final VerifyConfigRequestEntity updateRequestEntity = createVerifyProcessorConfigRequestEntity(asyncRequest, requestId); return generateOkResponse(updateRequestEntity).build(); } @@ -986,23 +1050,23 @@ public class ProcessorResource extends ApplicationResource { return dto; } - public Response performAsyncConfigVerification(final VerifyProcessorConfigRequestEntity processorConfigRequest, final NiFiUser user) { + public Response performAsyncConfigVerification(final VerifyConfigRequestEntity processorConfigRequest, final NiFiUser user) { // Create an asynchronous request that will occur in the background, because this request may take an indeterminate amount of time. final String requestId = generateUuid(); - logger.debug("Generated Config Verification Request with ID {} for Processor {}", requestId, processorConfigRequest.getRequest().getProcessorId()); + logger.debug("Generated Config Verification Request with ID {} for Processor {}", requestId, processorConfigRequest.getRequest().getComponentId()); - final VerifyProcessorConfigRequestDTO requestDto = processorConfigRequest.getRequest(); - final String processorId = requestDto.getProcessorId(); + final VerifyConfigRequestDTO requestDto = processorConfigRequest.getRequest(); + final String processorId = requestDto.getComponentId(); final List updateSteps = Collections.singletonList(new StandardUpdateStep("Verify Processor Configuration")); - final AsynchronousWebRequest> request = + final AsynchronousWebRequest> request = new StandardAsynchronousWebRequest<>(requestId, processorConfigRequest, processorId, user, updateSteps); // Submit the request to be performed in the background - final Consumer>> updateTask = asyncRequest -> { + final Consumer>> updateTask = asyncRequest -> { try { final Map attributes = requestDto.getAttributes() == null ? Collections.emptyMap() : requestDto.getAttributes(); - final List results = serviceFacade.verifyProcessorConfiguration(processorId, requestDto.getProcessorConfig(), attributes); + final List results = serviceFacade.verifyProcessorConfiguration(processorId, requestDto.getProperties(), attributes); asyncRequest.markStepComplete(results); } catch (final Exception e) { logger.error("Failed to verify Processor configuration", e); @@ -1013,30 +1077,30 @@ public class ProcessorResource extends ApplicationResource { updateRequestManager.submitRequest(VERIFICATION_REQUEST_TYPE, requestId, request, updateTask); // Generate the response - final VerifyProcessorConfigRequestEntity resultsEntity = createVerifyProcessorConfigRequestEntity(request, requestId); + final VerifyConfigRequestEntity resultsEntity = createVerifyProcessorConfigRequestEntity(request, requestId); return generateOkResponse(resultsEntity).build(); } - private VerifyProcessorConfigRequestEntity createVerifyProcessorConfigRequestEntity( - final AsynchronousWebRequest> asyncRequest, + private VerifyConfigRequestEntity createVerifyProcessorConfigRequestEntity( + final AsynchronousWebRequest> asyncRequest, final String requestId) { - final VerifyProcessorConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest(); + final VerifyConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest(); final List resultsList = asyncRequest.getResults(); - final VerifyProcessorConfigRequestDTO dto = new VerifyProcessorConfigRequestDTO(); - dto.setProcessorId(requestDto.getProcessorId()); - dto.setProcessorConfig(requestDto.getProcessorConfig()); + final VerifyConfigRequestDTO dto = new VerifyConfigRequestDTO(); + dto.setComponentId(requestDto.getComponentId()); + dto.setProperties(requestDto.getProperties()); dto.setResults(resultsList); - dto.setComplete(resultsList != null); + dto.setComplete(asyncRequest.isComplete()); dto.setFailureReason(asyncRequest.getFailureReason()); dto.setLastUpdated(asyncRequest.getLastUpdated()); dto.setPercentCompleted(asyncRequest.getPercentComplete()); dto.setRequestId(requestId); dto.setState(asyncRequest.getState()); - dto.setUri(generateResourceUri("processors", requestDto.getProcessorId(), "config", "verification-requests", requestId)); + dto.setUri(generateResourceUri("processors", requestDto.getComponentId(), "config", "verification-requests", requestId)); - final VerifyProcessorConfigRequestEntity entity = new VerifyProcessorConfigRequestEntity(); + final VerifyConfigRequestEntity entity = new VerifyConfigRequestEntity(); entity.setRequest(dto); return entity; } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java index b316f01402..f9459eea56 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/ReportingTaskResource.java @@ -46,14 +46,16 @@ import org.apache.nifi.web.api.concurrent.UpdateStep; import org.apache.nifi.web.api.dto.BundleDTO; import org.apache.nifi.web.api.dto.ComponentStateDTO; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; +import org.apache.nifi.web.api.dto.ConfigurationAnalysisDTO; import org.apache.nifi.web.api.dto.PropertyDescriptorDTO; import org.apache.nifi.web.api.dto.ReportingTaskDTO; -import org.apache.nifi.web.api.dto.VerifyReportingTaskConfigRequestDTO; +import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO; import org.apache.nifi.web.api.entity.ComponentStateEntity; +import org.apache.nifi.web.api.entity.ConfigurationAnalysisEntity; import org.apache.nifi.web.api.entity.PropertyDescriptorEntity; import org.apache.nifi.web.api.entity.ReportingTaskEntity; import org.apache.nifi.web.api.entity.ReportingTaskRunStatusEntity; -import org.apache.nifi.web.api.entity.VerifyReportingTaskConfigRequestEntity; +import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; import org.apache.nifi.web.api.request.ClientIdParameter; import org.apache.nifi.web.api.request.LongParameter; import org.slf4j.Logger; @@ -93,7 +95,7 @@ public class ReportingTaskResource extends ApplicationResource { private static final Logger logger = LoggerFactory.getLogger(ReportingTaskResource.class); private static final String VERIFICATION_REQUEST_TYPE = "verification-request"; - private RequestManager> updateRequestManager = + private RequestManager> updateRequestManager = new AsyncRequestManager<>(100, TimeUnit.MINUTES.toMillis(1L), "Verify Reporting Task Config Thread"); private NiFiServiceFacade serviceFacade; @@ -646,6 +648,66 @@ public class ReportingTaskResource extends ApplicationResource { ); } + @POST + @Consumes(MediaType.APPLICATION_JSON) + @Produces(MediaType.APPLICATION_JSON) + @Path("/{id}/config/analysis") + @ApiOperation( + value = "Performs analysis of the component's configuration, providing information about which attributes are referenced.", + response = ConfigurationAnalysisEntity.class, + authorizations = { + @Authorization(value = "Read - /reporting-tasks/{uuid}") + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), + @ApiResponse(code = 401, message = "Client could not be authenticated."), + @ApiResponse(code = 403, message = "Client is not authorized to make this request."), + @ApiResponse(code = 404, message = "The specified resource could not be found."), + @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") + } + ) + public Response analyzeConfiguration( + @ApiParam(value = "The reporting task id.", required = true) @PathParam("id") final String reportingTaskId, + @ApiParam(value = "The configuration analysis request.", required = true) final ConfigurationAnalysisEntity configurationAnalysis) { + + if (configurationAnalysis == null || configurationAnalysis.getConfigurationAnalysis() == null) { + throw new IllegalArgumentException("Reporting Tasks's configuration must be specified"); + } + + final ConfigurationAnalysisDTO dto = configurationAnalysis.getConfigurationAnalysis(); + if (dto.getComponentId() == null) { + throw new IllegalArgumentException("Reporting Tasks's identifier must be specified in the request"); + } + + if (!dto.getComponentId().equals(reportingTaskId)) { + throw new IllegalArgumentException("Reporting Tasks's identifier in the request must match the identifier provided in the URL"); + } + + if (dto.getProperties() == null) { + throw new IllegalArgumentException("Reporting Tasks's properties must be specified in the request"); + } + + if (isReplicateRequest()) { + return replicate(HttpMethod.POST, configurationAnalysis); + } + + return withWriteLock( + serviceFacade, + configurationAnalysis, + lookup -> { + final ComponentAuthorizable reportingTask = lookup.getReportingTask(reportingTaskId); + reportingTask.getAuthorizable().authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser()); + }, + () -> { }, + entity -> { + final ConfigurationAnalysisDTO analysis = entity.getConfigurationAnalysis(); + final ConfigurationAnalysisEntity resultsEntity = serviceFacade.analyzeReportingTaskConfiguration(analysis.getComponentId(), analysis.getProperties()); + return generateOkResponse(resultsEntity).build(); + } + ); + } @POST @Consumes(MediaType.APPLICATION_JSON) @@ -653,7 +715,7 @@ public class ReportingTaskResource extends ApplicationResource { @Path("/{id}/config/verification-requests") @ApiOperation( value = "Performs verification of the Reporting Task's configuration", - response = VerifyReportingTaskConfigRequestEntity.class, + response = VerifyConfigRequestEntity.class, notes = "This will initiate the process of verifying a given Reporting Task configuration. This may be a long-running task. As a result, this endpoint will immediately return a " + "ReportingTaskConfigVerificationRequestEntity, and the process of performing the verification will occur asynchronously in the background. " + "The client may then periodically poll the status of the request by " + @@ -674,22 +736,22 @@ public class ReportingTaskResource extends ApplicationResource { ) public Response submitConfigVerificationRequest( @ApiParam(value = "The reporting task id.", required = true) @PathParam("id") final String reportingTaskId, - @ApiParam(value = "The reporting task configuration verification request.", required = true) final VerifyReportingTaskConfigRequestEntity reportingTaskConfigRequest) { + @ApiParam(value = "The reporting task configuration verification request.", required = true) final VerifyConfigRequestEntity reportingTaskConfigRequest) { if (reportingTaskConfigRequest == null) { throw new IllegalArgumentException("Reporting Task's configuration must be specified"); } - final VerifyReportingTaskConfigRequestDTO requestDto = reportingTaskConfigRequest.getRequest(); - if (requestDto == null || requestDto.getReportingTask() == null) { - throw new IllegalArgumentException("Reporting Task must be specified"); + final VerifyConfigRequestDTO requestDto = reportingTaskConfigRequest.getRequest(); + if (requestDto == null || requestDto.getProperties() == null) { + throw new IllegalArgumentException("Reporting Task Properties must be specified"); } - if (requestDto.getReportingTaskId() == null) { + if (requestDto.getComponentId() == null) { throw new IllegalArgumentException("Reporting Task's identifier must be specified in the request"); } - if (!requestDto.getReportingTaskId().equals(reportingTaskId)) { + if (!requestDto.getComponentId().equals(reportingTaskId)) { throw new IllegalArgumentException("Reporting Task's identifier in the request must match the identifier provided in the URL"); } @@ -719,7 +781,7 @@ public class ReportingTaskResource extends ApplicationResource { @Path("{id}/config/verification-requests/{requestId}") @ApiOperation( value = "Returns the Verification Request with the given ID", - response = VerifyReportingTaskConfigRequestEntity.class, + response = VerifyConfigRequestEntity.class, notes = "Returns the Verification Request with the given ID. Once an Verification Request has been created, " + "that request can subsequently be retrieved via this endpoint, and the request that is fetched will contain the updated state, such as percent complete, the " + "current state of the request, and any failures. ", @@ -744,10 +806,10 @@ public class ReportingTaskResource extends ApplicationResource { final NiFiUser user = NiFiUserUtils.getNiFiUser(); // request manager will ensure that the current is the user that submitted this request - final AsynchronousWebRequest> asyncRequest = + final AsynchronousWebRequest> asyncRequest = updateRequestManager.getRequest(VERIFICATION_REQUEST_TYPE, requestId, user); - final VerifyReportingTaskConfigRequestEntity updateRequestEntity = createVerifyReportingTaskConfigRequestEntity(asyncRequest, requestId); + final VerifyConfigRequestEntity updateRequestEntity = createVerifyReportingTaskConfigRequestEntity(asyncRequest, requestId); return generateOkResponse(updateRequestEntity).build(); } @@ -758,7 +820,7 @@ public class ReportingTaskResource extends ApplicationResource { @Path("{id}/config/verification-requests/{requestId}") @ApiOperation( value = "Deletes the Verification Request with the given ID", - response = VerifyReportingTaskConfigRequestEntity.class, + response = VerifyConfigRequestEntity.class, notes = "Deletes the Verification Request with the given ID. After a request is created, it is expected " + "that the client will properly clean up the request by DELETE'ing it, once the Verification process has completed. If the request is deleted before the request " + "completes, then the Verification request will finish the step that it is currently performing and then will cancel any subsequent steps.", @@ -787,7 +849,7 @@ public class ReportingTaskResource extends ApplicationResource { // If this is a standalone node, or if this is the execution phase of the request, perform the actual request. if (!twoPhaseRequest || executionPhase) { // request manager will ensure that the current is the user that submitted this request - final AsynchronousWebRequest> asyncRequest = + final AsynchronousWebRequest> asyncRequest = updateRequestManager.removeRequest(VERIFICATION_REQUEST_TYPE, requestId, user); if (asyncRequest == null) { @@ -798,7 +860,7 @@ public class ReportingTaskResource extends ApplicationResource { asyncRequest.cancel(); } - final VerifyReportingTaskConfigRequestEntity updateRequestEntity = createVerifyReportingTaskConfigRequestEntity(asyncRequest, requestId); + final VerifyConfigRequestEntity updateRequestEntity = createVerifyReportingTaskConfigRequestEntity(asyncRequest, requestId); return generateOkResponse(updateRequestEntity).build(); } @@ -815,21 +877,21 @@ public class ReportingTaskResource extends ApplicationResource { - public Response performAsyncConfigVerification(final VerifyReportingTaskConfigRequestEntity configRequest, final NiFiUser user) { + public Response performAsyncConfigVerification(final VerifyConfigRequestEntity configRequest, final NiFiUser user) { // Create an asynchronous request that will occur in the background, because this request may take an indeterminate amount of time. final String requestId = generateUuid(); - final VerifyReportingTaskConfigRequestDTO requestDto = configRequest.getRequest(); - final String taskId = requestDto.getReportingTaskId(); + final VerifyConfigRequestDTO requestDto = configRequest.getRequest(); + final String taskId = requestDto.getComponentId(); final List updateSteps = Collections.singletonList(new StandardUpdateStep("Verify Reporting Task Configuration")); - final AsynchronousWebRequest> request = + final AsynchronousWebRequest> request = new StandardAsynchronousWebRequest<>(requestId, configRequest, taskId, user, updateSteps); // Submit the request to be performed in the background - final Consumer>> updateTask = asyncRequest -> { + final Consumer>> updateTask = asyncRequest -> { try { - final List results = serviceFacade.verifyReportingTaskConfiguration(taskId, requestDto.getReportingTask()); + final List results = serviceFacade.verifyReportingTaskConfiguration(taskId, requestDto.getProperties()); asyncRequest.markStepComplete(results); } catch (final Exception e) { logger.error("Failed to verify Reporting Task configuration", e); @@ -840,30 +902,30 @@ public class ReportingTaskResource extends ApplicationResource { updateRequestManager.submitRequest(VERIFICATION_REQUEST_TYPE, requestId, request, updateTask); // Generate the response - final VerifyReportingTaskConfigRequestEntity resultsEntity = createVerifyReportingTaskConfigRequestEntity(request, requestId); + final VerifyConfigRequestEntity resultsEntity = createVerifyReportingTaskConfigRequestEntity(request, requestId); return generateOkResponse(resultsEntity).build(); } - private VerifyReportingTaskConfigRequestEntity createVerifyReportingTaskConfigRequestEntity( - final AsynchronousWebRequest> asyncRequest, final String requestId) { + private VerifyConfigRequestEntity createVerifyReportingTaskConfigRequestEntity( + final AsynchronousWebRequest> asyncRequest, final String requestId) { - final VerifyReportingTaskConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest(); + final VerifyConfigRequestDTO requestDto = asyncRequest.getRequest().getRequest(); final List resultsList = asyncRequest.getResults(); - final VerifyReportingTaskConfigRequestDTO dto = new VerifyReportingTaskConfigRequestDTO(); - dto.setReportingTaskId(requestDto.getReportingTaskId()); - dto.setReportingTask(requestDto.getReportingTask()); + final VerifyConfigRequestDTO dto = new VerifyConfigRequestDTO(); + dto.setComponentId(requestDto.getComponentId()); + dto.setProperties(requestDto.getProperties()); dto.setResults(resultsList); - dto.setComplete(resultsList != null); + dto.setComplete(asyncRequest.isComplete()); dto.setFailureReason(asyncRequest.getFailureReason()); dto.setLastUpdated(asyncRequest.getLastUpdated()); dto.setPercentCompleted(asyncRequest.getPercentComplete()); dto.setRequestId(requestId); dto.setState(asyncRequest.getState()); - dto.setUri(generateResourceUri("reporting-tasks", requestDto.getReportingTaskId(), "config", "verification-requests", requestId)); + dto.setUri(generateResourceUri("reporting-tasks", requestDto.getComponentId(), "config", "verification-requests", requestId)); - final VerifyReportingTaskConfigRequestEntity entity = new VerifyReportingTaskConfigRequestEntity(); + final VerifyConfigRequestEntity entity = new VerifyConfigRequestEntity(); entity.setRequest(dto); return entity; } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/concurrent/StandardUpdateStep.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/concurrent/StandardUpdateStep.java index 53fbbe54d8..bb6455d510 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/concurrent/StandardUpdateStep.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/concurrent/StandardUpdateStep.java @@ -37,7 +37,7 @@ public class StandardUpdateStep implements UpdateStep { @Override public synchronized String getFailureReason() { - return null; + return failureReason; } @Override diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java index f5009fa00f..6408055c1b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java @@ -1679,7 +1679,6 @@ public final class DtoFactory { dto.getProperties().put(descriptor.getName(), propertyValue); } - dto.setReferencedAttributes(controllerServiceNode.getReferencedAttributeNames()); dto.setValidationStatus(controllerServiceNode.getValidationStatus(1, TimeUnit.MILLISECONDS).name()); // add the validation errors @@ -4014,7 +4013,6 @@ public final class DtoFactory { dto.setSchedulingStrategy(procNode.getSchedulingStrategy().name()); dto.setExecutionNode(procNode.getExecutionNode().name()); dto.setAnnotationData(procNode.getAnnotationData()); - dto.setReferencedAttributes(procNode.getReferencedAttributeNames()); // set up the default values for concurrent tasks and scheduling period final Map defaultConcurrentTasks = new HashMap<>(); @@ -4145,7 +4143,6 @@ public final class DtoFactory { copy.setParentGroupId(original.getParentGroupId()); copy.setName(original.getName()); copy.setProperties(copy(original.getProperties())); - copy.setReferencedAttributes(copy(original.getReferencedAttributes())); copy.setReferencingComponents(copy(original.getReferencingComponents())); copy.setState(original.getState()); copy.setType(original.getType()); @@ -4258,7 +4255,6 @@ public final class DtoFactory { copy.setBulletinLevel(original.getBulletinLevel()); copy.setDefaultConcurrentTasks(original.getDefaultConcurrentTasks()); copy.setDefaultSchedulingPeriod(original.getDefaultSchedulingPeriod()); - copy.setReferencedAttributes(original.getReferencedAttributes()); copy.setLossTolerant(original.isLossTolerant()); return copy; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ControllerServiceDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ControllerServiceDAO.java index 572ec63f69..8b9f0ea607 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ControllerServiceDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ControllerServiceDAO.java @@ -140,11 +140,11 @@ public interface ControllerServiceDAO { /** * Performs verification of the Configuration for the Controller Service with the given ID * @param controllerServiceId the id of the controller service - * @param controllerService the configuration to verify + * @param properties the configured properties to verify * @param variables a map of values that can be used for resolving FlowFile attributes for Expression Language * @return verification results */ - List verifyConfiguration(String controllerServiceId, ControllerServiceDTO controllerService, Map variables); + List verifyConfiguration(String controllerServiceId, Map properties, Map variables); /** * Clears the state of the specified controller service. diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessorDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessorDAO.java index ab4ac1c055..679289f5b6 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessorDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ProcessorDAO.java @@ -20,7 +20,6 @@ import org.apache.nifi.components.state.Scope; import org.apache.nifi.components.state.StateMap; import org.apache.nifi.controller.ProcessorNode; import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; -import org.apache.nifi.web.api.dto.ProcessorConfigDTO; import org.apache.nifi.web.api.dto.ProcessorDTO; import java.util.List; @@ -106,11 +105,11 @@ public interface ProcessorDAO { /** * Performs verification of the given Processor Configuration for the Processor with the given ID * @param processorId the id of the processor - * @param processorConfig the configuration to verify + * @param properties the property configuration to verify * @param attributes a map of values that can be used for resolving FlowFile attributes for Expression Language * @return verification results */ - List verifyProcessorConfiguration(String processorId, ProcessorConfigDTO processorConfig, Map attributes); + List verifyProcessorConfiguration(String processorId, Map properties, Map attributes); /** * Verifies the specified processor can be removed. diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ReportingTaskDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ReportingTaskDAO.java index 8af40dec82..4c06c6278b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ReportingTaskDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/ReportingTaskDAO.java @@ -23,6 +23,7 @@ import org.apache.nifi.web.api.dto.ConfigVerificationResultDTO; import org.apache.nifi.web.api.dto.ReportingTaskDTO; import java.util.List; +import java.util.Map; import java.util.Set; public interface ReportingTaskDAO { @@ -89,10 +90,10 @@ public interface ReportingTaskDAO { /** * Performs verification of the Configuration for the Reporting Task with the given ID * @param reportingTaskId the id of the Reporting Task - * @param reportingTask the configuration to verify + * @param properties the configured properties to verify * @return verification results */ - List verifyConfiguration(String reportingTaskId, ReportingTaskDTO reportingTask); + List verifyConfiguration(String reportingTaskId, Map properties); /** * Determines whether this reporting task can be removed. 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/StandardControllerServiceDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java index 6b9457e6e4..5de890e68b 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardControllerServiceDAO.java @@ -401,7 +401,7 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro } @Override - public List verifyConfiguration(final String controllerServiceId, final ControllerServiceDTO controllerService, final Map variables) { + public List verifyConfiguration(final String controllerServiceId, final Map properties, final Map variables) { final ControllerServiceNode serviceNode = locateControllerService(controllerServiceId); final LogRepository logRepository = new NopLogRepository(); @@ -409,7 +409,7 @@ public class StandardControllerServiceDAO extends ComponentDAO implements Contro final ExtensionManager extensionManager = flowController.getExtensionManager(); final ParameterLookup parameterLookup = serviceNode.getProcessGroup() == null ? ParameterLookup.EMPTY : serviceNode.getProcessGroup().getParameterContext(); - final ConfigurationContext configurationContext = new StandardConfigurationContext(serviceNode, controllerService.getProperties(), controllerService.getAnnotationData(), + final ConfigurationContext configurationContext = new StandardConfigurationContext(serviceNode, properties, serviceNode.getAnnotationData(), parameterLookup, flowController.getControllerServiceProvider(), null, flowController.getVariableRegistry()); final List verificationResults = serviceNode.verifyConfiguration(configurationContext, configVerificationLog, variables, extensionManager); 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/StandardProcessorDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessorDAO.java index 8cfcfc15ec..d4bc543bb8 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessorDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardProcessorDAO.java @@ -442,10 +442,10 @@ public class StandardProcessorDAO extends ComponentDAO implements ProcessorDAO { } @Override - public List verifyProcessorConfiguration(final String processorId, final ProcessorConfigDTO processorConfig, final Map attributes) { + public List verifyProcessorConfiguration(final String processorId, final Map properties, final Map attributes) { final ProcessorNode processor = locateProcessor(processorId); - final ProcessContext processContext = new StandardProcessContext(processor, processorConfig.getProperties(), processorConfig.getAnnotationData(), + final ProcessContext processContext = new StandardProcessContext(processor, properties, processor.getAnnotationData(), processor.getProcessGroup().getParameterContext(), flowController.getControllerServiceProvider(), flowController.getEncryptor(), new NopStateManager(), () -> false, flowController); 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/StandardReportingTaskDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardReportingTaskDAO.java index b7558fdf7a..74d5318753 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardReportingTaskDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardReportingTaskDAO.java @@ -261,7 +261,7 @@ public class StandardReportingTaskDAO extends ComponentDAO implements ReportingT } @Override - public List verifyConfiguration(final String reportingTaskId, final ReportingTaskDTO reportingTask) { + public List verifyConfiguration(final String reportingTaskId, final Map properties) { final ReportingTaskNode taskNode = locateReportingTask(reportingTaskId); final LogRepository logRepository = new NopLogRepository(); @@ -269,7 +269,7 @@ public class StandardReportingTaskDAO extends ComponentDAO implements ReportingT final ExtensionManager extensionManager = flowController.getExtensionManager(); final ParameterLookup parameterLookup = ParameterLookup.EMPTY; - final ConfigurationContext configurationContext = new StandardConfigurationContext(taskNode, reportingTask.getProperties(), reportingTask.getAnnotationData(), + final ConfigurationContext configurationContext = new StandardConfigurationContext(taskNode, properties, taskNode.getAnnotationData(), parameterLookup, flowController.getControllerServiceProvider(), null, flowController.getVariableRegistry()); final List verificationResults = taskNode.verifyConfiguration(configurationContext, configVerificationLog, extensionManager); diff --git a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java index e551e545df..58a86d90ad 100644 --- a/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java +++ b/nifi-system-tests/nifi-system-test-suite/src/test/java/org/apache/nifi/tests/system/NiFiClientUtil.java @@ -50,9 +50,7 @@ import org.apache.nifi.web.api.dto.ReportingTaskDTO; import org.apache.nifi.web.api.dto.RevisionDTO; import org.apache.nifi.web.api.dto.VariableDTO; import org.apache.nifi.web.api.dto.VariableRegistryDTO; -import org.apache.nifi.web.api.dto.VerifyControllerServiceConfigRequestDTO; -import org.apache.nifi.web.api.dto.VerifyProcessorConfigRequestDTO; -import org.apache.nifi.web.api.dto.VerifyReportingTaskConfigRequestDTO; +import org.apache.nifi.web.api.dto.VerifyConfigRequestDTO; import org.apache.nifi.web.api.dto.flow.FlowDTO; import org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO; import org.apache.nifi.web.api.dto.provenance.ProvenanceDTO; @@ -85,9 +83,7 @@ import org.apache.nifi.web.api.entity.ScheduleComponentsEntity; import org.apache.nifi.web.api.entity.VariableEntity; import org.apache.nifi.web.api.entity.VariableRegistryEntity; import org.apache.nifi.web.api.entity.VariableRegistryUpdateRequestEntity; -import org.apache.nifi.web.api.entity.VerifyControllerServiceConfigRequestEntity; -import org.apache.nifi.web.api.entity.VerifyProcessorConfigRequestEntity; -import org.apache.nifi.web.api.entity.VerifyReportingTaskConfigRequestEntity; +import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; import org.junit.Assert; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -985,18 +981,15 @@ public class NiFiClientUtil { public List verifyProcessorConfig(final String processorId, final Map properties, final Map attributes) throws NiFiClientException, IOException, InterruptedException { - final ProcessorConfigDTO processorConfig = new ProcessorConfigDTO(); - processorConfig.setProperties(properties); - - final VerifyProcessorConfigRequestDTO requestDto = new VerifyProcessorConfigRequestDTO(); - requestDto.setProcessorId(processorId); - requestDto.setProcessorConfig(processorConfig); + final VerifyConfigRequestDTO requestDto = new VerifyConfigRequestDTO(); + requestDto.setComponentId(processorId); + requestDto.setProperties(properties); requestDto.setAttributes(attributes); - final VerifyProcessorConfigRequestEntity verificationRequest = new VerifyProcessorConfigRequestEntity(); + final VerifyConfigRequestEntity verificationRequest = new VerifyConfigRequestEntity(); verificationRequest.setRequest(requestDto); - VerifyProcessorConfigRequestEntity results = nifiClient.getProcessorClient().submitConfigVerificationRequest(verificationRequest); + VerifyConfigRequestEntity results = nifiClient.getProcessorClient().submitConfigVerificationRequest(verificationRequest); while (!results.getRequest().isComplete()) { Thread.sleep(50L); results = nifiClient.getProcessorClient().getConfigVerificationRequest(processorId, results.getRequest().getRequestId()); @@ -1019,15 +1012,15 @@ public class NiFiClientUtil { serviceDto.setProperties(properties); serviceDto.setId(serviceId); - final VerifyControllerServiceConfigRequestDTO requestDto = new VerifyControllerServiceConfigRequestDTO(); - requestDto.setControllerService(serviceDto); + final VerifyConfigRequestDTO requestDto = new VerifyConfigRequestDTO(); + requestDto.setComponentId(serviceId); requestDto.setAttributes(attributes); - requestDto.setControllerServiceId(serviceId); + requestDto.setProperties(properties); - final VerifyControllerServiceConfigRequestEntity verificationRequest = new VerifyControllerServiceConfigRequestEntity(); + final VerifyConfigRequestEntity verificationRequest = new VerifyConfigRequestEntity(); verificationRequest.setRequest(requestDto); - VerifyControllerServiceConfigRequestEntity results = nifiClient.getControllerServicesClient().submitConfigVerificationRequest(verificationRequest); + VerifyConfigRequestEntity results = nifiClient.getControllerServicesClient().submitConfigVerificationRequest(verificationRequest); while (!results.getRequest().isComplete()) { Thread.sleep(50L); results = nifiClient.getControllerServicesClient().getConfigVerificationRequest(serviceId, results.getRequest().getRequestId()); @@ -1041,18 +1034,14 @@ public class NiFiClientUtil { public List verifyReportingTaskConfig(final String taskId, final Map properties) throws InterruptedException, IOException,NiFiClientException { - final ReportingTaskDTO taskDto = new ReportingTaskDTO(); - taskDto.setProperties(properties); - taskDto.setId(taskId); + final VerifyConfigRequestDTO requestDto = new VerifyConfigRequestDTO(); + requestDto.setComponentId(taskId); + requestDto.setProperties(properties); - final VerifyReportingTaskConfigRequestDTO requestDto = new VerifyReportingTaskConfigRequestDTO(); - requestDto.setReportingTaskId(taskId); - requestDto.setReportingTask(taskDto); - - final VerifyReportingTaskConfigRequestEntity verificationRequest = new VerifyReportingTaskConfigRequestEntity(); + final VerifyConfigRequestEntity verificationRequest = new VerifyConfigRequestEntity(); verificationRequest.setRequest(requestDto); - VerifyReportingTaskConfigRequestEntity results = nifiClient.getReportingTasksClient().submitConfigVerificationRequest(verificationRequest); + VerifyConfigRequestEntity results = nifiClient.getReportingTasksClient().submitConfigVerificationRequest(verificationRequest); while (!results.getRequest().isComplete()) { Thread.sleep(50L); results = nifiClient.getReportingTasksClient().getConfigVerificationRequest(taskId, results.getRequest().getRequestId()); diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ControllerServicesClient.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ControllerServicesClient.java index 1befb2aa86..f9ad54c1e7 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ControllerServicesClient.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ControllerServicesClient.java @@ -20,7 +20,7 @@ import org.apache.nifi.web.api.entity.ControllerServiceEntity; import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentsEntity; import org.apache.nifi.web.api.entity.ControllerServiceRunStatusEntity; import org.apache.nifi.web.api.entity.UpdateControllerServiceReferenceRequestEntity; -import org.apache.nifi.web.api.entity.VerifyControllerServiceConfigRequestEntity; +import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; import java.io.IOException; @@ -43,10 +43,10 @@ public interface ControllerServicesClient { ControllerServiceReferencingComponentsEntity updateControllerServiceReferences(UpdateControllerServiceReferenceRequestEntity referencesEntity) throws NiFiClientException, IOException; - VerifyControllerServiceConfigRequestEntity submitConfigVerificationRequest(VerifyControllerServiceConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException; + VerifyConfigRequestEntity submitConfigVerificationRequest(VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException; - VerifyControllerServiceConfigRequestEntity getConfigVerificationRequest(String serviceId, String verificationRequestId) throws NiFiClientException, IOException; + VerifyConfigRequestEntity getConfigVerificationRequest(String serviceId, String verificationRequestId) throws NiFiClientException, IOException; - VerifyControllerServiceConfigRequestEntity deleteConfigVerificationRequest(String serviceId, String verificationRequestId) throws NiFiClientException, IOException; + VerifyConfigRequestEntity deleteConfigVerificationRequest(String serviceId, String verificationRequestId) throws NiFiClientException, IOException; } diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ProcessorClient.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ProcessorClient.java index 634aad5540..64f55c80c7 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ProcessorClient.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ProcessorClient.java @@ -17,7 +17,7 @@ package org.apache.nifi.toolkit.cli.impl.client.nifi; import org.apache.nifi.web.api.entity.ProcessorEntity; -import org.apache.nifi.web.api.entity.VerifyProcessorConfigRequestEntity; +import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; import java.io.IOException; @@ -48,10 +48,10 @@ public interface ProcessorClient { ProcessorEntity deleteProcessor(ProcessorEntity processorEntity) throws NiFiClientException, IOException; - VerifyProcessorConfigRequestEntity submitConfigVerificationRequest(VerifyProcessorConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException; + VerifyConfigRequestEntity submitConfigVerificationRequest(VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException; - VerifyProcessorConfigRequestEntity getConfigVerificationRequest(String processorId, String verificationRequestId) throws NiFiClientException, IOException; + VerifyConfigRequestEntity getConfigVerificationRequest(String processorId, String verificationRequestId) throws NiFiClientException, IOException; - VerifyProcessorConfigRequestEntity deleteConfigVerificationRequest(String processorId, String verificationRequestId) throws NiFiClientException, IOException; + VerifyConfigRequestEntity deleteConfigVerificationRequest(String processorId, String verificationRequestId) throws NiFiClientException, IOException; } diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ReportingTasksClient.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ReportingTasksClient.java index 57dc2aa35c..13c61a1e15 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ReportingTasksClient.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/ReportingTasksClient.java @@ -19,7 +19,7 @@ package org.apache.nifi.toolkit.cli.impl.client.nifi; import org.apache.nifi.web.api.entity.ReportingTaskEntity; import org.apache.nifi.web.api.entity.ReportingTaskRunStatusEntity; -import org.apache.nifi.web.api.entity.VerifyReportingTaskConfigRequestEntity; +import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; import java.io.IOException; @@ -34,10 +34,10 @@ public interface ReportingTasksClient { ReportingTaskEntity activateReportingTask(String id, ReportingTaskRunStatusEntity runStatusEntity) throws NiFiClientException, IOException; - VerifyReportingTaskConfigRequestEntity submitConfigVerificationRequest(VerifyReportingTaskConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException; + VerifyConfigRequestEntity submitConfigVerificationRequest(VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException; - VerifyReportingTaskConfigRequestEntity getConfigVerificationRequest(String taskId, String verificationRequestId) throws NiFiClientException, IOException; + VerifyConfigRequestEntity getConfigVerificationRequest(String taskId, String verificationRequestId) throws NiFiClientException, IOException; - VerifyReportingTaskConfigRequestEntity deleteConfigVerificationRequest(String taskId, String verificationRequestId) throws NiFiClientException, IOException; + VerifyConfigRequestEntity deleteConfigVerificationRequest(String taskId, String verificationRequestId) throws NiFiClientException, IOException; } diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyControllerServicesClient.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyControllerServicesClient.java index 2b164c1865..3b787be801 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyControllerServicesClient.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyControllerServicesClient.java @@ -25,7 +25,7 @@ import org.apache.nifi.web.api.entity.ControllerServiceEntity; import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentsEntity; import org.apache.nifi.web.api.entity.ControllerServiceRunStatusEntity; import org.apache.nifi.web.api.entity.UpdateControllerServiceReferenceRequestEntity; -import org.apache.nifi.web.api.entity.VerifyControllerServiceConfigRequestEntity; +import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; @@ -178,35 +178,35 @@ public class JerseyControllerServicesClient extends AbstractJerseyClient impleme } @Override - public VerifyControllerServiceConfigRequestEntity submitConfigVerificationRequest(final VerifyControllerServiceConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException { + public VerifyConfigRequestEntity submitConfigVerificationRequest(final VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException { if (configRequestEntity == null) { throw new IllegalArgumentException("Config Request Entity cannot be null"); } if (configRequestEntity.getRequest() == null) { throw new IllegalArgumentException("Config Request DTO cannot be null"); } - if (configRequestEntity.getRequest().getControllerServiceId() == null) { + if (configRequestEntity.getRequest().getComponentId() == null) { throw new IllegalArgumentException("Controller Service ID cannot be null"); } - if (configRequestEntity.getRequest().getControllerService() == null) { - throw new IllegalArgumentException("Controller Service cannot be null"); + if (configRequestEntity.getRequest().getProperties() == null) { + throw new IllegalArgumentException("Controller Service properties cannot be null"); } return executeAction("Error submitting Config Verification Request", () -> { final WebTarget target = controllerServicesTarget .path("{id}/config/verification-requests") - .resolveTemplate("id", configRequestEntity.getRequest().getControllerServiceId()); + .resolveTemplate("id", configRequestEntity.getRequest().getComponentId()); return getRequestBuilder(target).post( Entity.entity(configRequestEntity, MediaType.APPLICATION_JSON_TYPE), - VerifyControllerServiceConfigRequestEntity.class + VerifyConfigRequestEntity.class ); }); } @Override - public VerifyControllerServiceConfigRequestEntity getConfigVerificationRequest(final String serviceId, final String verificationRequestId) throws NiFiClientException, IOException { + public VerifyConfigRequestEntity getConfigVerificationRequest(final String serviceId, final String verificationRequestId) throws NiFiClientException, IOException { if (verificationRequestId == null) { throw new IllegalArgumentException("Verification Request ID cannot be null"); } @@ -217,12 +217,12 @@ public class JerseyControllerServicesClient extends AbstractJerseyClient impleme .resolveTemplate("id", serviceId) .resolveTemplate("requestId", verificationRequestId); - return getRequestBuilder(target).get(VerifyControllerServiceConfigRequestEntity.class); + return getRequestBuilder(target).get(VerifyConfigRequestEntity.class); }); } @Override - public VerifyControllerServiceConfigRequestEntity deleteConfigVerificationRequest(final String serviceId, final String verificationRequestId) throws NiFiClientException, IOException { + public VerifyConfigRequestEntity deleteConfigVerificationRequest(final String serviceId, final String verificationRequestId) throws NiFiClientException, IOException { if (verificationRequestId == null) { throw new IllegalArgumentException("Verification Request ID cannot be null"); } @@ -233,7 +233,7 @@ public class JerseyControllerServicesClient extends AbstractJerseyClient impleme .resolveTemplate("id", serviceId) .resolveTemplate("requestId", verificationRequestId); - return getRequestBuilder(target).delete(VerifyControllerServiceConfigRequestEntity.class); + return getRequestBuilder(target).delete(VerifyConfigRequestEntity.class); }); } } diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyProcessorClient.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyProcessorClient.java index bf0442cdca..9bb5998f50 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyProcessorClient.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyProcessorClient.java @@ -23,7 +23,7 @@ import org.apache.nifi.toolkit.cli.impl.client.nifi.RequestConfig; import org.apache.nifi.web.api.dto.RevisionDTO; import org.apache.nifi.web.api.entity.ProcessorEntity; import org.apache.nifi.web.api.entity.ProcessorRunStatusEntity; -import org.apache.nifi.web.api.entity.VerifyProcessorConfigRequestEntity; +import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; @@ -181,34 +181,34 @@ public class JerseyProcessorClient extends AbstractJerseyClient implements Proce } @Override - public VerifyProcessorConfigRequestEntity submitConfigVerificationRequest(final VerifyProcessorConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException { + public VerifyConfigRequestEntity submitConfigVerificationRequest(final VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException { if (configRequestEntity == null) { throw new IllegalArgumentException("Config Request Entity cannot be null"); } if (configRequestEntity.getRequest() == null) { throw new IllegalArgumentException("Config Request DTO cannot be null"); } - if (configRequestEntity.getRequest().getProcessorId() == null) { + if (configRequestEntity.getRequest().getComponentId() == null) { throw new IllegalArgumentException("Processor ID cannot be null"); } - if (configRequestEntity.getRequest().getProcessorConfig() == null) { - throw new IllegalArgumentException("Processor Config cannot be null"); + if (configRequestEntity.getRequest().getProperties() == null) { + throw new IllegalArgumentException("Processor properties cannot be null"); } return executeAction("Error submitting Config Verification Request", () -> { final WebTarget target = processorTarget .path("/config/verification-requests") - .resolveTemplate("id", configRequestEntity.getRequest().getProcessorId()); + .resolveTemplate("id", configRequestEntity.getRequest().getComponentId()); return getRequestBuilder(target).post( Entity.entity(configRequestEntity, MediaType.APPLICATION_JSON_TYPE), - VerifyProcessorConfigRequestEntity.class + VerifyConfigRequestEntity.class ); }); } @Override - public VerifyProcessorConfigRequestEntity getConfigVerificationRequest(final String processorId, final String verificationRequestId) throws NiFiClientException, IOException { + public VerifyConfigRequestEntity getConfigVerificationRequest(final String processorId, final String verificationRequestId) throws NiFiClientException, IOException { if (verificationRequestId == null) { throw new IllegalArgumentException("Verification Request ID cannot be null"); } @@ -219,12 +219,12 @@ public class JerseyProcessorClient extends AbstractJerseyClient implements Proce .resolveTemplate("id", processorId) .resolveTemplate("requestId", verificationRequestId); - return getRequestBuilder(target).get(VerifyProcessorConfigRequestEntity.class); + return getRequestBuilder(target).get(VerifyConfigRequestEntity.class); }); } @Override - public VerifyProcessorConfigRequestEntity deleteConfigVerificationRequest(final String processorId, final String verificationRequestId) throws NiFiClientException, IOException { + public VerifyConfigRequestEntity deleteConfigVerificationRequest(final String processorId, final String verificationRequestId) throws NiFiClientException, IOException { if (verificationRequestId == null) { throw new IllegalArgumentException("Verification Request ID cannot be null"); } @@ -235,7 +235,7 @@ public class JerseyProcessorClient extends AbstractJerseyClient implements Proce .resolveTemplate("id", processorId) .resolveTemplate("requestId", verificationRequestId); - return getRequestBuilder(target).delete(VerifyProcessorConfigRequestEntity.class); + return getRequestBuilder(target).delete(VerifyConfigRequestEntity.class); }); } } diff --git a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyReportingTasksClient.java b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyReportingTasksClient.java index 4fc0582bf6..a83e20a7f0 100644 --- a/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyReportingTasksClient.java +++ b/nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/client/nifi/impl/JerseyReportingTasksClient.java @@ -23,7 +23,7 @@ import org.apache.nifi.toolkit.cli.impl.client.nifi.ReportingTasksClient; import org.apache.nifi.toolkit.cli.impl.client.nifi.RequestConfig; import org.apache.nifi.web.api.entity.ReportingTaskEntity; import org.apache.nifi.web.api.entity.ReportingTaskRunStatusEntity; -import org.apache.nifi.web.api.entity.VerifyReportingTaskConfigRequestEntity; +import org.apache.nifi.web.api.entity.VerifyConfigRequestEntity; import javax.ws.rs.client.Entity; import javax.ws.rs.client.WebTarget; @@ -96,34 +96,34 @@ public class JerseyReportingTasksClient extends AbstractJerseyClient implements } @Override - public VerifyReportingTaskConfigRequestEntity submitConfigVerificationRequest(final VerifyReportingTaskConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException { + public VerifyConfigRequestEntity submitConfigVerificationRequest(final VerifyConfigRequestEntity configRequestEntity) throws NiFiClientException, IOException { if (configRequestEntity == null) { throw new IllegalArgumentException("Config Request Entity cannot be null"); } if (configRequestEntity.getRequest() == null) { throw new IllegalArgumentException("Config Request DTO cannot be null"); } - if (configRequestEntity.getRequest().getReportingTaskId() == null) { + if (configRequestEntity.getRequest().getComponentId() == null) { throw new IllegalArgumentException("Reporting Task ID cannot be null"); } - if (configRequestEntity.getRequest().getReportingTask() == null) { - throw new IllegalArgumentException("Reporting Task cannot be null"); + if (configRequestEntity.getRequest().getProperties() == null) { + throw new IllegalArgumentException("Reporting Task properties cannot be null"); } return executeAction("Error submitting Config Verification Request", () -> { final WebTarget target = reportingTasksTarget .path("{id}/config/verification-requests") - .resolveTemplate("id", configRequestEntity.getRequest().getReportingTaskId()); + .resolveTemplate("id", configRequestEntity.getRequest().getComponentId()); return getRequestBuilder(target).post( Entity.entity(configRequestEntity, MediaType.APPLICATION_JSON_TYPE), - VerifyReportingTaskConfigRequestEntity.class + VerifyConfigRequestEntity.class ); }); } @Override - public VerifyReportingTaskConfigRequestEntity getConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException { + public VerifyConfigRequestEntity getConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException { if (verificationRequestId == null) { throw new IllegalArgumentException("Verification Request ID cannot be null"); } @@ -134,12 +134,12 @@ public class JerseyReportingTasksClient extends AbstractJerseyClient implements .resolveTemplate("id", taskId) .resolveTemplate("requestId", verificationRequestId); - return getRequestBuilder(target).get(VerifyReportingTaskConfigRequestEntity.class); + return getRequestBuilder(target).get(VerifyConfigRequestEntity.class); }); } @Override - public VerifyReportingTaskConfigRequestEntity deleteConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException { + public VerifyConfigRequestEntity deleteConfigVerificationRequest(final String taskId, final String verificationRequestId) throws NiFiClientException, IOException { if (verificationRequestId == null) { throw new IllegalArgumentException("Verification Request ID cannot be null"); } @@ -150,7 +150,7 @@ public class JerseyReportingTasksClient extends AbstractJerseyClient implements .resolveTemplate("id", taskId) .resolveTemplate("requestId", verificationRequestId); - return getRequestBuilder(target).delete(VerifyReportingTaskConfigRequestEntity.class); + return getRequestBuilder(target).delete(VerifyConfigRequestEntity.class); }); } }