nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcgil...@apache.org
Subject incubator-nifi git commit: NIFI-250: - Ensuring requests are not attempted to be replicated if a custom UI provides an invalid component id.
Date Wed, 25 Mar 2015 13:57:58 GMT
Repository: incubator-nifi
Updated Branches:
  refs/heads/NIFI-250 2dccb5b4d -> b8b9f2c25


NIFI-250:
- Ensuring requests are not attempted to be replicated if a custom UI provides an invalid
component id.

Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/b8b9f2c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/b8b9f2c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/b8b9f2c2

Branch: refs/heads/NIFI-250
Commit: b8b9f2c2509d8101d2f749e4ce7c58ed7a52be96
Parents: 2dccb5b
Author: Matt Gilman <matt.c.gilman@gmail.com>
Authored: Wed Mar 25 09:57:37 2015 -0400
Committer: Matt Gilman <matt.c.gilman@gmail.com>
Committed: Wed Mar 25 09:57:37 2015 -0400

----------------------------------------------------------------------
 .../StandardNiFiWebConfigurationContext.java    | 36 ++++++++++++++++++++
 1 file changed, 36 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/b8b9f2c2/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java
index 5ef9780..8f67666 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java
@@ -393,6 +393,12 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
             if (controllerServiceLookup.getControllerService(id) != null) {
                 controllerService = serviceFacade.getControllerService(id);
             } else {
+                // if this is a standalone instance the service should have been found above...
there should
+                // no cluster to replicate the request to
+                if (!properties.isClusterManager()) {
+                    throw new ResourceNotFoundException(String.format("Controller service[%s]
could not be found on this NiFi.", id));
+                }
+                
                 // create the request URL
                 URI requestUrl;
                 try {
@@ -437,6 +443,18 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
                 final ConfigurationSnapshot<ControllerServiceDTO> response = serviceFacade.updateControllerService(revision,
controllerServiceDto);
                 controllerService = response.getConfiguration();
             } else {
+                // if this is a standalone instance the service should have been found above...
there should
+                // no cluster to replicate the request to
+                if (!properties.isClusterManager()) {
+                    throw new ResourceNotFoundException(String.format("Controller service[%s]
could not be found on this NiFi.", id));
+                }
+                
+                // since this PUT request can be interpreted as a request to create a controller
service
+                // we need to be sure that this service exists on the node before the request
is replicated.
+                // this is done by attempting to get the details. if the service doesn't
exist it will
+                // throw a ResourceNotFoundException
+                getComponentDetails(requestContext);
+                
                 // create the request URL
                 URI requestUrl;
                 try {
@@ -509,6 +527,12 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
             if (reportingTaskProvider.getReportingTaskNode(id) != null) {
                 reportingTask = serviceFacade.getReportingTask(id);
             } else {
+                // if this is a standalone instance the task should have been found above...
there should
+                // no cluster to replicate the request to
+                if (!properties.isClusterManager()) {
+                    throw new ResourceNotFoundException(String.format("Reporting task[%s]
could not be found on this NiFi.", id));
+                }
+                
                 // create the request URL
                 URI requestUrl;
                 try {
@@ -553,6 +577,18 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration
                 final ConfigurationSnapshot<ReportingTaskDTO> response = serviceFacade.updateReportingTask(revision,
reportingTaskDto);
                 reportingTask = response.getConfiguration();
             } else {
+                // if this is a standalone instance the task should have been found above...
there should
+                // no cluster to replicate the request to
+                if (!properties.isClusterManager()) {
+                    throw new ResourceNotFoundException(String.format("Reporting task[%s]
could not be found on this NiFi.", id));
+                }
+                
+                // since this PUT request can be interpreted as a request to create a reporting
task
+                // we need to be sure that this task exists on the node before the request
is replicated.
+                // this is done by attempting to get the details. if the service doesn't
exist it will
+                // throw a ResourceNotFoundException
+                getComponentDetails(requestContext);
+                
                 // create the request URL
                 URI requestUrl;
                 try {


Mime
View raw message