diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java index c16d557c39..e9aea02da4 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/groups/StandardProcessGroup.java @@ -252,7 +252,7 @@ public final class StandardProcessGroup implements ProcessGroup { @Override public void setName(final String name) { if (StringUtils.isBlank(name)) { - throw new IllegalArgumentException("The name cannot be blank."); + throw new IllegalArgumentException("The name of the process group must be specified."); } this.name.set(name); 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/StandardInputPortDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardInputPortDAO.java index c08cb708a5..c846f2e30e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardInputPortDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardInputPortDAO.java @@ -162,7 +162,7 @@ public class StandardInputPortDAO extends ComponentDAO implements PortDAO { List validationErrors = new ArrayList<>(); if (isNotNull(portDTO.getName()) && portDTO.getName().trim().isEmpty()) { - validationErrors.add("Port name cannot be blank."); + validationErrors.add("The name of the port must be specified."); } if (isNotNull(portDTO.getConcurrentlySchedulableTaskCount()) && portDTO.getConcurrentlySchedulableTaskCount() <= 0) { validationErrors.add("Concurrent tasks must be a positive integer."); 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/StandardOutputPortDAO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardOutputPortDAO.java index f4eea8a49a..613a97f9f2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardOutputPortDAO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/dao/impl/StandardOutputPortDAO.java @@ -158,7 +158,7 @@ public class StandardOutputPortDAO extends ComponentDAO implements PortDAO { List validationErrors = new ArrayList<>(); if (isNotNull(portDTO.getName()) && portDTO.getName().trim().isEmpty()) { - validationErrors.add("Port name cannot be blank."); + validationErrors.add("The name of the port must be specified."); } if (isNotNull(portDTO.getConcurrentlySchedulableTaskCount()) && portDTO.getConcurrentlySchedulableTaskCount() <= 0) { validationErrors.add("Concurrent tasks must be a positive integer."); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-group-component.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-group-component.js index 9f603b2514..346df47267 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-group-component.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-group-component.js @@ -102,7 +102,7 @@ // update the birdseye nfBirdseye.refresh(); - }).fail(nfErrorHandler.handleAjaxError); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); }; function GroupComponent() { @@ -235,18 +235,18 @@ // get the name of the group and clear the textfield var groupName = $('#new-process-group-name').val(); - // hide the dialog - groupComponent.modal.hide(); - // ensure the group name is specified if (nfCommon.isBlank(groupName)) { nfDialog.showOkDialog({ - headerText: 'Create Process Group', - dialogContent: 'The group name is required.' + headerText: 'Configuration Error', + dialogContent: 'The name of the process group must be specified.' }); deferred.reject(); } else { + // hide the dialog + groupComponent.modal.hide(); + // create the group and resolve the deferred accordingly createGroup(groupName, pt).done(function (response) { deferred.resolve(response.component); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-input-port-component.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-input-port-component.js index 9bcc56a3b5..9c441a6aa7 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-input-port-component.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-input-port-component.js @@ -91,12 +91,15 @@ 'selectAll': true }); + // hide the dialog + inputPortComponent.modal.hide(); + // update component visibility nfGraph.updateVisibility(); // update the birdseye nfBirdseye.refresh(); - }).fail(nfErrorHandler.handleAjaxError); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); }; function InputPortComponent() { @@ -217,9 +220,6 @@ // get the name of the input port and clear the textfield var portName = $('#new-port-name').val(); - // hide the dialog - inputPortComponent.modal.hide(); - // create the input port createInputPort(portName, pt); }; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-output-port-component.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-output-port-component.js index 6abf4fbfa9..997a2a3e07 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-output-port-component.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-output-port-component.js @@ -91,12 +91,15 @@ 'selectAll': true }); + // hide the dialog + outputPortComponent.modal.hide(); + // update component visibility nfGraph.updateVisibility(); // update the birdseye nfBirdseye.refresh(); - }).fail(nfErrorHandler.handleAjaxError); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); }; function OutputPortComponent() { @@ -208,9 +211,6 @@ // get the name of the output port and clear the textfield var portName = $('#new-port-name').val(); - // hide the dialog - outputPortComponent.modal.hide(); - // create the output port createOutputPort(portName, pt); }; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-remote-process-group-component.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-remote-process-group-component.js index 30b5ccb531..83949072b2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-remote-process-group-component.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/header/components/nf-ng-remote-process-group-component.js @@ -113,25 +113,7 @@ // update the birdseye nfBirdseye.refresh(); - }).fail(function (xhr, status, error) { - if (xhr.status === 400) { - var errors = xhr.responseText.split('\n'); - - var content; - if (errors.length === 1) { - content = $('').text(errors[0]); - } else { - content = nfCommon.formatUnorderedList(errors); - } - - nfDialog.showOkDialog({ - dialogContent: content, - headerText: 'Configuration Error' - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } - }); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); }; function RemoteProcessGroupComponent() { diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js index cb33ccc496..238ff05129 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-actions.js @@ -1642,8 +1642,8 @@ // ensure the template name is not blank if (nfCommon.isBlank(templateName)) { nfDialog.showOkDialog({ - headerText: 'Create Template', - dialogContent: "The template name cannot be blank." + headerText: 'Configuration Error', + dialogContent: "The name of the template must be specified." }); return; } diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-error-handler.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-error-handler.js index 05519a320a..ad4305f8d5 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-error-handler.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-canvas-error-handler.js @@ -41,17 +41,10 @@ }(this, function (ajaxErrorHandler, nfCommon, nfCanvas, nfContextMenu) { 'use strict'; - return { - - /** - * Method for handling ajax errors. This also closes the canvas. - * - * @argument {object} xhr The XmlHttpRequest - * @argument {string} status The status of the request - * @argument {string} error The error - */ - handleAjaxError: function (xhr, status, error) { - ajaxErrorHandler.handleAjaxError(xhr, status, error); + var disableCanvas = function() { + // In case no further requests will be successful based on the status, + // the canvas is disabled, and the message pane is shown. + if ($('#message-pane').is(':visible')) { nfCommon.showLogoutLink(); // hide the splash screen if required @@ -65,8 +58,36 @@ // shut off the auto refresh nfCanvas.stopPolling(); - // allow page refresh with ctrl-r + // disable page refresh with ctrl-r nfCanvas.disableRefreshHotKey(); } }; + + return { + + /** + * Method for handling ajax errors. This also closes the canvas if necessary. + * + * @argument {object} xhr The XmlHttpRequest + * @argument {string} status The status of the request + * @argument {string} error The error + */ + handleAjaxError: function (xhr, status, error) { + ajaxErrorHandler.handleAjaxError(xhr, status, error); + disableCanvas(); + }, + + /** + * Method for handling ajax errors when submitting configuration update (PUT/POST) requests. + * This method delegates error handling to ajaxErrorHandler. + * + * @argument {object} xhr The XmlHttpRequest + * @argument {string} status The status of the request + * @argument {string} error The error + */ + handleConfigurationUpdateAjaxError: function (xhr, status, error) { + ajaxErrorHandler.handleConfigurationUpdateAjaxError(xhr, status, error); + disableCanvas(); + } + }; })); \ No newline at end of file diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js index 1704fe53d5..df18a7b519 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection-configuration.js @@ -129,9 +129,6 @@ handler: { click: function () { addConnection(getSelectedRelationships()); - - // close the dialog - $('#connection-configuration').modal('hide'); } } }, @@ -195,9 +192,6 @@ click: function () { // add the connection addConnection(); - - // close the dialog - $('#connection-configuration').modal('hide'); } } }, @@ -971,6 +965,9 @@ 'selectAll': true }); + // close the dialog + $('#connection-configuration').modal('hide'); + // reload the connections source/destination components nfCanvasUtils.reloadConnectionSourceAndDestination(sourceComponentId, destinationComponentId); @@ -979,10 +976,7 @@ // update the birdseye nfBirdseye.refresh(); - }).fail(function (xhr, status, error) { - // handle the error - nfErrorHandler.handleAjaxError(xhr, status, error); - }); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); } }; @@ -1051,21 +1045,15 @@ dataType: 'json', contentType: 'application/json' }).done(function (response) { + // close the dialog + $('#connection-configuration').modal('hide'); + // update this connection nfConnection.set(response); // reload the connections source/destination components nfCanvasUtils.reloadConnectionSourceAndDestination(sourceComponentId, destinationComponentId); - }).fail(function (xhr, status, error) { - if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) { - nfDialog.showOkDialog({ - headerText: 'Connection Configuration', - dialogContent: nfCommon.escapeHtml(xhr.responseText), - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } - }); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); } else { return $.Deferred(function (deferred) { deferred.reject(); @@ -1120,7 +1108,7 @@ if (errors.length > 0) { nfDialog.showOkDialog({ - headerText: 'Connection Configuration', + headerText: 'Configuration Error', dialogContent: nfCommon.formatUnorderedList(errors) }); return false; @@ -1495,9 +1483,6 @@ deferred.reject(); }); } - - // close the dialog - $('#connection-configuration').modal('hide'); } } }, diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection.js index 662a918d7c..b325c32037 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-connection.js @@ -1614,16 +1614,7 @@ }).done(function (response) { // request was successful, update the entry nfConnection.set(response); - }).fail(function (xhr, status, error) { - if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) { - nfDialog.showOkDialog({ - headerText: 'Connection', - dialogContent: nfCommon.escapeHtml(xhr.responseText) - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } - }); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); }; // removes the specified connections diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js index 3938d94bd1..e89a212cab 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-controller-service.js @@ -77,33 +77,6 @@ } }; - /** - * Handle any expected controller service configuration errors. - * - * @argument {object} xhr The XmlHttpRequest - * @argument {string} status The status of the request - * @argument {string} error The error - */ - var handleControllerServiceConfigurationError = function (xhr, status, error) { - if (xhr.status === 400) { - var errors = xhr.responseText.split('\n'); - - var content; - if (errors.length === 1) { - content = $('').text(errors[0]); - } else { - content = nfCommon.formatUnorderedList(errors); - } - - nfDialog.showOkDialog({ - dialogContent: content, - headerText: 'Controller Service' - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } - }; - /** * Determines whether the user has made any changes to the controller service configuration * that needs to be saved. @@ -1606,7 +1579,7 @@ $.each(previouslyReferencedServiceIds, function (_, oldServiceReferenceId) { reloadControllerService(serviceTable, oldServiceReferenceId); }); - }).fail(handleControllerServiceConfigurationError); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); } else { return $.Deferred(function (deferred) { deferred.reject(); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-draggable.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-draggable.js index 3c67f6e6c1..37904a3ecd 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-draggable.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-draggable.js @@ -295,15 +295,7 @@ id: d.id }); }).fail(function (xhr, status, error) { - if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) { - nfDialog.showOkDialog({ - headerText: 'Component Position', - dialogContent: nfCommon.escapeHtml(xhr.responseText) - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } - + nfErrorHandler.handleAjaxError(xhr, status, error); deferred.reject(); }); }).promise(); @@ -357,14 +349,7 @@ id: d.id }); }).fail(function (xhr, status, error) { - if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) { - nfDialog.showOkDialog({ - headerText: 'Component Position', - dialogContent: nfCommon.escapeHtml(xhr.responseText) - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } + nfErrorHandler.handleAjaxError(xhr, status, error); deferred.reject(); }); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label-configuration.js index 90633377a6..cbc01206fe 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-label-configuration.js @@ -76,6 +76,7 @@ }, handler: { click: function () { + var self = this; // get the label data var labelData = d3.select('#id-' + labelId).datum(); @@ -109,10 +110,11 @@ // inform Angular app values have changed nfNgBridge.digest(); - }).fail(nfErrorHandler.handleAjaxError); - // reset and hide the dialog - this.modal('hide'); + // reset and hide the dialog + self.modal('hide'); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); + } } }, diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-configuration.js index 0ee0a427c4..77e4798def 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-port-configuration.js @@ -121,32 +121,7 @@ // close the details panel $('#port-configuration').modal('hide'); - }).fail(function (xhr, status, error) { - // handle bad request locally to keep the dialog open, allowing the user - // to make changes. if the request fails for another reason, the dialog - // should be closed so the issue can be addressed (stale flow for instance) - if (xhr.status === 400) { - var errors = xhr.responseText.split('\n'); - - var content; - if (errors.length === 1) { - content = $('').text(errors[0]); - } else { - content = nfCommon.formatUnorderedList(errors); - } - - nfDialog.showOkDialog({ - dialogContent: content, - headerText: 'Port Configuration' - }); - } else { - // close the details panel - $('#port-configuration').modal('hide'); - - // handle the error - nfErrorHandler.handleAjaxError(xhr, status, error); - } - }); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); } } }, diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js index fb6756d7e5..d354096337 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-process-group-configuration.js @@ -129,7 +129,7 @@ }); nfCanvasUtils.reload(); - }).fail(nfErrorHandler.handleAjaxError); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); }; /** diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js index c170fe3d45..54ca51f111 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-processor-configuration.js @@ -140,33 +140,6 @@ }]; }; - /** - * Handle any expected processor configuration errors. - * - * @argument {object} xhr The XmlHttpRequest - * @argument {string} status The status of the request - * @argument {string} error The error - */ - var handleProcessorConfigurationError = function (xhr, status, error) { - if (xhr.status === 400) { - var errors = xhr.responseText.split('\n'); - - var content; - if (errors.length === 1) { - content = $('').text(errors[0]); - } else { - content = nfCommon.formatUnorderedList(errors); - } - - nfDialog.showOkDialog({ - dialogContent: content, - headerText: 'Processor Configuration' - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } - }; - /** * Creates an option for the specified relationship name. * @@ -426,7 +399,7 @@ if (errors.length > 0) { nfDialog.showOkDialog({ dialogContent: nfCommon.formatUnorderedList(errors), - headerText: 'Processor Configuration' + headerText: 'Configuration Error' }); return false; } else { @@ -508,7 +481,7 @@ }).done(function (response) { // set the new processor state based on the response nfProcessor.set(response); - }).fail(handleProcessorConfigurationError); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); } else { return $.Deferred(function (deferred) { deferred.reject(); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-configuration.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-configuration.js index 3f23c38b81..f57ef69d5a 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-configuration.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-configuration.js @@ -110,25 +110,7 @@ // close the details panel $('#remote-process-group-configuration').modal('hide'); - }).fail(function (xhr, status, error) { - if (xhr.status === 400) { - var errors = xhr.responseText.split('\n'); - - var content; - if (errors.length === 1) { - content = $('').text(errors[0]); - } else { - content = nfCommon.formatUnorderedList(errors); - } - - nfDialog.showOkDialog({ - dialogContent: content, - headerText: 'Remote Process Group Configuration' - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } - }); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); } } }, diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-ports.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-ports.js index de9fab5da8..8f87975200 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-ports.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-remote-process-group-ports.js @@ -146,38 +146,16 @@ $('#' + remotePortId + '-batch-size').text(batchSettings.size); $('#' + remotePortId + '-batch-duration').text(batchSettings.duration); - }).fail(function (xhr, status, error) { - if (xhr.status === 400) { - var errors = xhr.responseText.split('\n'); - - var content; - if (errors.length === 1) { - content = $('').text(errors[0]); - } else { - content = nfCommon.formatUnorderedList(errors); - } - - nfDialog.showOkDialog({ - dialogContent: content, - headerText: 'Remote Process Group Ports' - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } - }).always(function () { // close the dialog $('#remote-port-configuration').modal('hide'); - }); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); } else { nfDialog.showOkDialog({ - headerText: 'Remote Process Group Ports', + headerText: 'Configuration Error', dialogContent: portValidationErrors.reduce(function (prev, curr) { return typeof(prev) === 'string' ? prev + ' ' + curr : curr; }) }); - - // close the dialog - $('#remote-port-configuration').modal('hide'); } } } @@ -440,23 +418,8 @@ transmissionSwitch.replaceWith(newTransmissionSwitch); // update transmissionSwitch variable to reference the new switch transmissionSwitch = newTransmissionSwitch; - if (xhr.status === 400) { - var errors = xhr.responseText.split('\n'); - var content; - if (errors.length === 1) { - content = $('').text(errors[0]); - } else { - content = nfCommon.formatUnorderedList(errors); - } - - nfDialog.showOkDialog({ - headerText: 'Remote Process Group Ports', - dialogContent: content - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } + nfErrorHandler.handleConfigurationUpdateAjaxError(xhr, status, error); }); }; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js index 4127f1cfbf..07e59f5afa 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-reporting-task.js @@ -81,33 +81,6 @@ return $('#controller-services-table'); }; - /** - * Handle any expected reporting task configuration errors. - * - * @argument {object} xhr The XmlHttpRequest - * @argument {string} status The status of the request - * @argument {string} error The error - */ - var handleReportingTaskConfigurationError = function (xhr, status, error) { - if (xhr.status === 400) { - var errors = xhr.responseText.split('\n'); - - var content; - if (errors.length === 1) { - content = $('').text(errors[0]); - } else { - content = nfCommon.formatUnorderedList(errors); - } - - nfDialog.showOkDialog({ - dialogContent: content, - headerText: 'Reporting Task' - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } - }; - /** * Determines whether the user has made any changes to the reporting task configuration * that needs to be saved. @@ -322,7 +295,7 @@ }).done(function (response) { // update the reporting task renderReportingTask(response); - }).fail(handleReportingTaskConfigurationError); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); } else { return $.Deferred(function (deferred) { deferred.reject(); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js index a96267f582..d6a57967dc 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-settings.js @@ -108,6 +108,33 @@ return $('#controller-services-table'); }; + /** + * Validates the configured settings. + * + * @argument {object} configuration The settings to validate + */ + var validateSettings = function (configuration) { + var errors = []; + + // ensure numeric fields are specified correctly + if (nfCommon.isDefinedAndNotNull(configuration['maxTimerDrivenThreadCount']) && !$.isNumeric(configuration['maxTimerDrivenThreadCount'])) { + errors.push('Maximum Timer Driven Thread Count must be an integer value'); + } + if (nfCommon.isDefinedAndNotNull(configuration['maxEventDrivenThreadCount']) && !$.isNumeric(configuration['maxEventDrivenThreadCount'])) { + errors.push('Maximum Event Driven Thread Count must be an integer value'); + } + + if (errors.length > 0) { + nfDialog.showOkDialog({ + dialogContent: nfCommon.formatUnorderedList(errors), + headerText: 'Configuration Error' + }); + return false; + } else { + return true; + } + }; + /** * Saves the settings for the controller. * @@ -116,35 +143,38 @@ var saveSettings = function (version) { // marshal the configuration details var configuration = marshalConfiguration(); - var entity = { - 'revision': nfClient.getRevision({ - 'revision': { - 'version': version - } - }), - 'disconnectedNodeAcknowledged': nfStorage.isDisconnectionAcknowledged(), - 'component': configuration - }; + // ensure settings are valid as far as we can tell + if (validateSettings(configuration)) { + var entity = { + 'revision': nfClient.getRevision({ + 'revision': { + 'version': version + } + }), + 'disconnectedNodeAcknowledged': nfStorage.isDisconnectionAcknowledged(), + 'component': configuration + }; - // save the new configuration details - $.ajax({ - type: 'PUT', - url: config.urls.controllerConfig, - data: JSON.stringify(entity), - dataType: 'json', - contentType: 'application/json' - }).done(function (response) { - // close the settings dialog - nfDialog.showOkDialog({ - headerText: 'Settings', - dialogContent: 'Settings successfully applied.' - }); + // save the new configuration details + $.ajax({ + type: 'PUT', + url: config.urls.controllerConfig, + data: JSON.stringify(entity), + dataType: 'json', + contentType: 'application/json' + }).done(function (response) { + // close the settings dialog + nfDialog.showOkDialog({ + headerText: 'Settings', + dialogContent: 'Settings successfully applied.' + }); - // register the click listener for the save button - $('#settings-save').off('click').on('click', function () { - saveSettings(response.revision.version); - }); - }).fail(nfErrorHandler.handleAjaxError); + // register the click listener for the save button + $('#settings-save').off('click').on('click', function () { + saveSettings(response.revision.version); + }); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); + } } /** @@ -519,10 +549,11 @@ var row = registriesData.getRowById(registryEntity.id); nfFilteredDialogCommon.choseRow(registriesGrid, row); registriesGrid.scrollRowIntoView(row); - }).fail(nfErrorHandler.handleAjaxError); - // hide the dialog - $('#registry-configuration-dialog').modal('hide'); + // hide the dialog + $('#registry-configuration-dialog').modal('hide'); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); + return addRegistry; }; @@ -560,10 +591,10 @@ registriesData.updateItem(registryId, $.extend({ type: 'Registry' }, registryEntity)); - }).fail(nfErrorHandler.handleAjaxError); - // hide the dialog - $('#registry-configuration-dialog').modal('hide'); + // hide the dialog + $('#registry-configuration-dialog').modal('hide'); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); return updateRegistry; }; diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-variable-registry.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-variable-registry.js index fa31b5bae9..ad51d3f32e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-variable-registry.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/canvas/nf-variable-registry.js @@ -1503,15 +1503,17 @@ variableGrid.scrollRowIntoView(matchingRow); } } + + // close the new variable dialog + $('#new-variable-dialog').modal('hide'); + } else { nfDialog.showOkDialog({ - headerText: 'Variable Name', - dialogContent: 'Variable name must be specified.' + headerText: 'Configuration Error', + dialogContent: 'The name of the variable must be specified.' }); } - // close the new variable dialog - $('#new-variable-dialog').modal('hide'); }; /** diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-error-handler.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-error-handler.js index f7a538fc5d..1831daf6f2 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-error-handler.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-error-handler.js @@ -37,7 +37,7 @@ }(this, function ($, nfDialog, nfCommon) { 'use strict'; - return { + var self = { /** * Method for handling ajax errors. * @@ -142,6 +142,36 @@ // show the error pane $('#message-pane').show(); } + }, + + /** + * Method for handling ajax errors when submitting configuration update (PUT/POST) requests. + * In addition to what handleAjaxError does, this function splits + * the error message text to display them as an unordered list. + * + * @argument {object} xhr The XmlHttpRequest + * @argument {string} status The status of the request + * @argument {string} error The error + */ + handleConfigurationUpdateAjaxError: function (xhr, status, error) { + if (xhr.status === 400) { + var errors = xhr.responseText.split('\n'); + + var content; + if (errors.length === 1) { + content = $('').text(errors[0]); + } else { + content = nfCommon.formatUnorderedList(errors); + } + + nfDialog.showOkDialog({ + dialogContent: content, + headerText: 'Configuration Error' + }); + } else { + self.handleAjaxError(xhr, status, error); + } } }; + return self; })); \ No newline at end of file diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js index 2a956b659d..30d388fd14 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/nf-processor-details.js @@ -307,16 +307,7 @@ if (processorRelationships.is(':visible') && processorRelationships.get(0).scrollHeight > Math.round(processorRelationships.innerHeight())) { processorRelationships.css('border-width', '1px'); } - }).fail(function (xhr, status, error) { - if (xhr.status === 400 || xhr.status === 404 || xhr.status === 409) { - nfDialog.showOkDialog({ - headerText: 'Error', - dialogContent: nfCommon.escapeHtml(xhr.responseText) - }); - } else { - nfErrorHandler.handleAjaxError(xhr, status, error); - } - }); + }).fail(nfErrorHandler.handleAjaxError); } }; })); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js index 04f480739b..1529779517 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-ui/src/main/webapp/js/nf/users/nf-users-table.js @@ -252,6 +252,8 @@ // if the user was successfully created userXhr.done(function (userEntity) { + $('#user-dialog').modal('hide'); + var xhrs = []; $.each(selectedGroups, function (_, selectedGroup) { var groupEntity = usersData.getItemById(selectedGroup.id) @@ -266,7 +268,7 @@ usersGrid.scrollRowIntoView(row); }); }).fail(nfErrorHandler.handleAjaxError); - }).fail(nfErrorHandler.handleAjaxError); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); }; /** @@ -302,6 +304,8 @@ userXhr.done(function (updatedUserEntity) { + $('#user-dialog').modal('hide'); + // determine what to add/remove var groupsAdded = []; var groupsRemoved = []; @@ -340,7 +344,7 @@ $.when.apply(window, xhrs).always(function () { nfUsersTable.loadUsersTable(); }).fail(nfErrorHandler.handleAjaxError); - }).fail(nfErrorHandler.handleAjaxError); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); }; /** @@ -357,6 +361,7 @@ dataType: 'json', contentType: 'application/json' }).done(function (groupEntity) { + $('#user-dialog').modal('hide'); nfUsersTable.loadUsersTable().done(function () { // add the user var usersGrid = $('#users-table').data('gridInstance'); @@ -367,7 +372,7 @@ usersGrid.setSelectedRows([row]); usersGrid.scrollRowIntoView(row); }); - }).fail(nfErrorHandler.handleAjaxError); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); }; var updateGroup = function (groupId, groupIdentity, selectedUsers) { @@ -394,8 +399,9 @@ dataType: 'json', contentType: 'application/json' }).done(function (groupEntity) { + $('#user-dialog').modal('hide'); nfUsersTable.loadUsersTable(); - }).fail(nfErrorHandler.handleAjaxError); + }).fail(nfErrorHandler.handleConfigurationUpdateAjaxError); }; /** @@ -459,7 +465,6 @@ } } - $('#user-dialog').modal('hide'); } } }, {