diff options
Diffstat (limited to 'qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid')
23 files changed, 79 insertions, 48 deletions
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js index 9e433bbb34..441d6776e7 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js @@ -25,6 +25,7 @@ define(["dojo/_base/xhr", "dojo/json", "dojo/dom-construct", "dojo/dom-geometry", + "dojo/dom-style", "dojo/window", "dojo/query", "dojo/parser", @@ -47,7 +48,7 @@ define(["dojo/_base/xhr", "dojox/validate/web", "dojo/domReady!" ], - function (xhr, array, event, lang, json, dom, geometry, win, query, parser, Memory, entities, metadata, widgetconfigurer, registry) { + function (xhr, array, event, lang, json, dom, geometry, domStyle, win, query, parser, Memory, entities, metadata, widgetconfigurer, registry) { var util = {}; if (Array.isArray) { util.isArray = function (object) { @@ -140,7 +141,7 @@ define(["dojo/_base/xhr", function(error) {success = false; failureReason = error;}); if(!success ) { - alert("Error:" + failureReason); + util.xhrErrorHandler(failureReason); } } } @@ -286,7 +287,8 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); + } return false; } @@ -331,36 +333,63 @@ define(["dojo/_base/xhr", util.xhrErrorHandler = function(error) { + const fallback = "Unexpected error - see server logs"; + var statusCodeNode = dojo.byId("errorDialog.statusCode"); + var errorMessageNode = dojo.byId("errorDialog.errorMessage"); + var userMustReauth = false; + if (error) { if (error.hasOwnProperty("status")) { + var hasMessage = error.hasOwnProperty("message"); + var message; + if (error.status == 401) { - dojo.byId("statusMessage").innerHTML = "401 - Authentication required."; + message = hasMessage ? error.message : "Authentication required"; + userMustReauth = true; } else if (error.status == 403) { - dojo.byId("statusMessage").innerHTML = "403 - Access denied."; + message = hasMessage ? error.message : "Forbidden"; + userMustReauth = true; } else { - dojo.byId("statusMessage").innerHTML = "HTTP status code: " + error.status; + message = hasMessage ? error.message : fallback; + + // Try for a more detail error sent by the Broker as json + if (error.hasOwnProperty("responseText")) + { + try + { + var errorObj = json.parse(error.responseText); + message = errorObj.hasOwnProperty("errorMessage") ? errorObj.errorMessage : errorMessageNode; + } + catch (e) + { + // Ignore + } + } } + + errorMessageNode.innerHTML = entities.encode(message ? message : fallback); + statusCodeNode.innerHTML = entities.encode(String(error.status)); + + dojo.byId("errorDialog.advice.retry").style.display = userMustReauth ? "none" : "block"; + dojo.byId("errorDialog.advice.reconnect").style.display = userMustReauth ? "block" : "none"; + + domStyle.set(registry.byId("errorDialog.button.cancel").domNode, 'display', userMustReauth ? "none" : "block"); + domStyle.set(registry.byId("errorDialog.button.relogin").domNode, 'display', userMustReauth ? "block" : "none"); + } else { - dojo.byId("statusMessage").innerHTML = ""; - } - if (error.hasOwnProperty("message")) - { - dojo.byId("errorDetailsMessage").innerHTML = error.message; - dojo.byId("errorDetails").style.display = "block"; - } - else - { - dojo.byId("errorDetails").style.display = "none"; + statusCodeNode.innerHTML = ""; + errorMessageNode.innerHTML = fallback; } + var dialog = dijit.byId("errorDialog"); if (!dialog.open) { @@ -412,7 +441,7 @@ define(["dojo/_base/xhr", if (syncRequired && !success) { - alert("Error:" + failureReason); + util.xhrErrorHandler(failureReason); } return success; } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js index adc066c270..1d4cc1447b 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js @@ -87,7 +87,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js index c3e567e902..34e3516180 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js @@ -112,7 +112,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js index 80116d3141..cfa985f551 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js @@ -288,7 +288,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js index 74f7209d9d..09473524b5 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/GroupProvider.js @@ -93,7 +93,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js index 9f0ba9c16e..ebec5bc47f 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/KeyStore.js @@ -153,7 +153,7 @@ define(["dojo/dom", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js index ebcee4afa2..250b85b59f 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js @@ -93,7 +93,7 @@ define(["dojo/dom", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js index 48feccbced..d7b028f1a5 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProvider.js @@ -103,7 +103,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js index 1fa1d603de..afd05aeda3 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/PreferencesProviderFields.js @@ -182,7 +182,7 @@ define(["dojo/_base/xhr", headers: { "Content-Type": "application/json"}, putData: json.stringify(data), load: function(x) {success = true;}, - error: function(error) {success = false; alert("Preferences Provider Error: " + error);}}); + error: function(error) {success = false; util.xhrErrorHandler(error);}}); } return success; }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js index 59e49f3302..b4ef7b4403 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Queue.js @@ -547,7 +547,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js index dfe276cae2..000a487b13 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/TrustStore.js @@ -154,7 +154,7 @@ define(["dojo/dom", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js index 30bd4c22d0..c59e86aaa1 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addAuthenticationProvider.js @@ -194,7 +194,7 @@ define(["dojo/_base/xhr", } else { - alert("Authentication Provider Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; }else{ diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js index ac4937da68..56950c88b0 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addBinding.js @@ -28,6 +28,7 @@ define(["dojo/_base/connect", "dojo/_base/declare", "dojo/store/Memory", "dijit/form/FilteringSelect", + "qpid/common/util", "dijit/form/NumberSpinner", // required by the form /* dojox/ validate resources */ "dojox/validate/us", "dojox/validate/web", @@ -44,7 +45,7 @@ define(["dojo/_base/connect", "dojox/grid/EnhancedGrid", "dojo/data/ObjectStore", "dojo/domReady!"], - function (connect, xhr, dom, construct, win, registry, parser, array, event, json, lang, declare, Memory, FilteringSelect) { + function (connect, xhr, dom, construct, win, registry, parser, array, event, json, lang, declare, Memory, FilteringSelect, util) { var noLocalValues = new Memory({ data: [ @@ -325,7 +326,7 @@ define(["dojo/_base/connect", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js index 65c9a9f6f6..c7f281b8dc 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addExchange.js @@ -26,7 +26,8 @@ define(["dojo/_base/xhr", "dojo/parser", "dojo/_base/array", "dojo/_base/event", - 'dojo/_base/json', + "dojo/_base/json", + "qpid/common/util", "dijit/form/NumberSpinner", // required by the form /* dojox/ validate resources */ "dojox/validate/us", "dojox/validate/web", @@ -41,7 +42,7 @@ define(["dojo/_base/xhr", /* basic dojox classes */ "dojox/form/BusyButton", "dojox/form/CheckedMultiSelect", "dojo/domReady!"], - function (xhr, dom, construct, win, registry, parser, array, event, json) { + function (xhr, dom, construct, win, registry, parser, array, event, json, util) { var addExchange = {}; @@ -123,7 +124,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js index 0c8a4660fd..4a635b1c0d 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js @@ -321,7 +321,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js index c66b99ee4c..444ed67d63 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addQueue.js @@ -178,7 +178,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js index ede0c4bc48..02eb8cd2b6 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js @@ -255,8 +255,7 @@ define(["dojo/_base/xhr", } else { - // What if VHN creation was successful but VH was not - alert("Error:" + failureReason); + util.xhrErrorHandler(failureReason); } } else diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/PrincipalDatabaseAuthenticationManager.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/PrincipalDatabaseAuthenticationManager.js index c5875d59ea..96083843fa 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/PrincipalDatabaseAuthenticationManager.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/authenticationprovider/PrincipalDatabaseAuthenticationManager.js @@ -146,7 +146,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!that.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } @@ -210,7 +210,7 @@ define(["dojo/_base/xhr", if(that.success === true) { registry.byId("addUser").hide(); } else { - alert("Error:" + that.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; @@ -267,7 +267,7 @@ define(["dojo/_base/xhr", if(that.success === true) { registry.byId("setPassword").hide(); } else { - alert("Error:" + that.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js index a959586655..f25be2d57e 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js @@ -130,7 +130,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + failureReason); + util.xhrErrorHandler(failureReason); } } else diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js index 3c78eaa29c..545be75fff 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js @@ -121,7 +121,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + failureReason); + util.xhrErrorHandler(failureReason); } } else diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js index 485502e81c..8f63a8c935 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/Group.js @@ -195,7 +195,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!this.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/addGroupMember.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/addGroupMember.js index d965fd35a8..0a8e6a2e11 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/addGroupMember.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/group/addGroupMember.js @@ -26,7 +26,8 @@ define(["dojo/_base/xhr", "dojo/parser", "dojo/_base/array", "dojo/_base/event", - 'dojo/_base/json', + "dojo/_base/json", + "qpid/common/util", "dijit/form/NumberSpinner", // required by the form /* dojox/ validate resources */ "dojox/validate/us", "dojox/validate/web", @@ -41,7 +42,7 @@ define(["dojo/_base/xhr", /* basic dojox classes */ "dojox/form/BusyButton", "dojox/form/CheckedMultiSelect", "dojo/domReady!"], - function (xhr, dom, construct, win, registry, parser, array, event, json) { + function (xhr, dom, construct, win, registry, parser, array, event, json, util) { var addGroupMember = {}; @@ -83,7 +84,7 @@ define(["dojo/_base/xhr", } else { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/FileGroupManager.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/FileGroupManager.js index c8f991260c..4ee411633f 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/FileGroupManager.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/groupprovider/FileGroupManager.js @@ -163,7 +163,7 @@ define(["dojo/_base/xhr", }, function(error) {that.success = false; that.failureReason = error;}); if(!that.success ) { - alert("Error:" + this.failureReason); + util.xhrErrorHandler(this.failureReason); } } } @@ -238,7 +238,7 @@ define(["dojo/_base/xhr", if(that.success === true) { registry.byId("addGroup").hide(); } else { - alert("Error:" + that.failureReason); + util.xhrErrorHandler(this.failureReason); } return false; |