qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oru...@apache.org
Subject svn commit: r1677590 [2/6] - in /qpid/java/trunk: bdbstore/src/main/java/resources/js/qpid/management/virtualhost/bdb_ha/ bdbstore/src/main/java/resources/js/qpid/management/virtualhostnode/bdb_ha/ broker-plugins/jdbc-store/src/main/java/resources/js/q...
Date Mon, 04 May 2015 12:17:25 GMT
Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js?rev=1677590&r1=1677589&r2=1677590&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js Mon May  4 12:17:23 2015
@@ -33,7 +33,6 @@ define(["dojo/_base/xhr",
         "dojo/window",
         "dojo/on",
         "dojox/html/entities",
-        "qpid/common/metadata",
         "qpid/common/widgetconfigurer",
         "dijit/registry",
         "dijit/TitlePane",
@@ -50,7 +49,7 @@ define(["dojo/_base/xhr",
         "dojox/validate/web",
         "dojo/domReady!"
         ],
-       function (xhr, array, event, lang, json, dom, geometry, domStyle, win, query, parser, Memory, w, on, entities, metadata, widgetconfigurer, registry) {
+       function (xhr, array, event, lang, json, dom, geometry, domStyle, win, query, parser, Memory, w, on, entities, widgetconfigurer, registry) {
            var util = {};
            if (Array.isArray) {
                util.isArray = function (object) {
@@ -89,249 +88,120 @@ define(["dojo/_base/xhr",
                return exchangeName == null || exchangeName == "" || "<<default>>" == exchangeName || exchangeName.indexOf("amq.") == 0 || exchangeName.indexOf("qpid.") == 0;
            };
 
-           util.deleteGridSelections = function(updater, grid, url, confirmationMessageStart, idParam)
+           util.confirmAndDeleteGridSelection = function(grid, confirmationMessageStart, deleteFunction )
            {
-               var data = grid.selection.getSelected();
-               var success = false;
-               if(data.length)
-               {
-                   var confirmationMessage = null;
-                   if (data.length == 1)
-                   {
-                       confirmationMessage = confirmationMessageStart + " '" + data[0].name + "'?";
-                   }
-                   else
-                   {
-                       var names = '';
-                       for(var i = 0; i<data.length; i++)
-                       {
-                           if (names)
-                           {
-                               names += ', ';
-                           }
-                           names += "\""+ data[i].name + "\"";
-                       }
-                       confirmationMessage = confirmationMessageStart + "s " + names + "?";
-                   }
-                   if(confirm(confirmationMessage))
-                   {
-                       var i, queryParam;
-                       for(i = 0; i<data.length; i++)
-                       {
-                           if(queryParam)
-                           {
-                               queryParam += "&";
-                           }
-                           else
-                           {
-                               queryParam = "?";
-                           }
-                           queryParam += ( idParam || "id" ) + "=" + encodeURIComponent(data[i].id);
-                       }
-                       var query = url + queryParam;
-                       var failureReason = "";
-                       xhr.del({url: query, sync: true, handleAs: "json"}).then(
-                           function(data)
-                           {
-                               success = true;
-                               grid.selection.deselectAll();
-                               if (updater)
-                               {
-                                 updater.update();
-                               }
-                           },
-                           function(error) {success = false; failureReason = error;});
-                       if(!success )
-                       {
-                           util.xhrErrorHandler(failureReason);
-                       }
-                   }
-               }
-               return success;
-           }
-
-           util.isProviderManagingUsers = function(type)
-           {
-               return metadata.implementsManagedInterface("AuthenticationProvider", type, "PasswordCredentialManagingAuthenticationProvider");
-           };
+                var data = grid.selection.getSelected();
+                var confirmed = false;
+                if(data.length)
+                {
+                    var confirmationMessage = null;
+                    if (data.length == 1)
+                    {
+                        confirmationMessage = confirmationMessageStart + " '" + data[0].name + "'?";
+                    }
+                    else
+                    {
+                        var names = '';
+                        for(var i = 0; i<data.length; i++)
+                        {
+                            if (names)
+                            {
+                                names += ', ';
+                            }
+                            names += "\""+ data[i].name + "\"";
+                        }
+                        confirmationMessage = confirmationMessageStart + "s " + names + "?";
+                    }
 
-           util.supportsPreferencesProvider = function(type)
-           {
-               return metadata.implementsManagedInterface("AuthenticationProvider", type, "PreferencesSupportingAuthenticationProvider");
-           };
+                    if(confirm(confirmationMessage))
+                    {
+                      confirmed = true;
+                      deleteFunction(data);
+                    }
+                }
+                return confirmed;
+           }
 
-           util.showSetAttributesDialog = function(attributeWidgetFactories, data, putURL, dialogTitle, category, type, appendNameToUrl)
+           util.buildDeleteQuery = function(data, url, idParam)
            {
-              var layout = new dojox.layout.TableContainer({
-                   cols: 1,
-                   "labelWidth": "300",
-                   showLabels: true,
-                   orientation: "horiz",
-                   customClass: "formLabel"
-              });
-              var submitButton = new dijit.form.Button({label: "Submit", type: "submit"});
-              var form = new dijit.form.Form();
-
-              var dialogContent = dom.create("div");
-              var dialogContentArea = dom.create("div", {"style": {width: 600}});
-              var dialogActionBar = dom.create("div", { "class": "dijitDialogPaneActionBar"} );
-              dialogContent.appendChild(dialogContentArea);
-              dialogContent.appendChild(dialogActionBar);
-              dialogContentArea.appendChild(layout.domNode)
-              dialogActionBar.appendChild(submitButton.domNode);
-              form.domNode.appendChild(dialogContent);
-
-              var widgets = {};
-              var requiredFor ={};
-              var groups = {};
-              for(var i in attributeWidgetFactories)
+              var queryParam;
+              for(var i = 0; i<data.length; i++)
               {
-                 var attributeWidgetFactory = attributeWidgetFactories[i];
-                 var widget = attributeWidgetFactory.createWidget(data);
-                 var name = attributeWidgetFactory.name ? attributeWidgetFactory.name : widget.name;
-                 widgets[name] = widget;
-                 var dotPos = name.indexOf(".");
-                 if (dotPos == -1)
-                 {
-                   if (widget instanceof dijit.layout.ContentPane)
-                   {
-                     dialogContentArea.appendChild(widget.domNode);
-                   }
-                   else
-                   {
-                     layout.addChild(widget);
-                   }
-                 }
-                 else
-                 {
-                   var groupName = name.substring(0, dotPos);
-                   var groupFieldContainer = null;
-                   if (groups.hasOwnProperty(groupName))
-                   {
-                       groupFieldContainer = groups[groupName];
-                   }
-                   else
-                   {
-                     groupFieldContainer = new dojox.layout.TableContainer({
-                           cols: 1,
-                           "labelWidth": "300",
-                           showLabels: true,
-                           orientation: "horiz",
-                           customClass: "formLabel"
-                      });
-                     groups[groupName] = groupFieldContainer;
-                     var groupTitle = attributeWidgetFactory.groupName ? attributeWidgetFactory.groupName :
-                                         groupName.charAt(0).toUpperCase() + groupName.slice(1);
-                     var panel = new dijit.TitlePane({title: groupTitle, content: groupFieldContainer.domNode});
-                     dialogContentArea.appendChild(dom.create("br"));
-                     dialogContentArea.appendChild(panel.domNode);
-                   }
-                   groupFieldContainer.addChild(widget);
-                 }
-                 if (attributeWidgetFactory.hasOwnProperty("requiredFor") && !data[name])
-                 {
-                   requiredFor[attributeWidgetFactory.requiredFor] = widget;
-                 }
+                  if(queryParam)
+                  {
+                      queryParam += "&";
+                  }
+                  else
+                  {
+                      queryParam = "?";
+                  }
+                  queryParam += ( idParam || "id" ) + "=" + encodeURIComponent(data[i].id);
               }
+              return url + queryParam;
+           }
 
-              this.applyMetadataToWidgets(dialogContent, category, type);
+           util.deleteSelectedObjects = function(grid, confirmationMessageStart, management, modelObj, updater, idParam, callback)
+           {
+               return util.confirmAndDeleteGridSelection(grid, confirmationMessageStart,
+                                                           function(data)
+                                                           {
+                                                               util.deleteObjects(management, data, modelObj, idParam, grid, updater, callback);
+                                                           });
+           }
 
-              // add onchange handler to set required property for dependent widget
-              for(var widgetName in requiredFor)
-              {
-                var dependent = requiredFor[widgetName];
-                var widget = widgets[widgetName];
-                if (widget)
+           util.deleteObjects = function(management, data, modelObj, idParam, grid, updater, callback)
+           {
+                var name = idParam || "id";
+                var parameters = {};
+                parameters[name] = [];
+                for(var i = 0; i<data.length; i++)
                 {
-                  widget.dependent = dependent;
-                  widget.on("change", function(newValue){
-                    this.dependent.set("required", newValue != "");
-                  });
+                  parameters[name].push(data[i].id);
+
                 }
-              }
-              var setAttributesDialog = new dijit.Dialog({
-                 title: dialogTitle,
-                 content: form
-             });
-             form.on("submit", function(e)
-             {
-               event.stop(e);
-               try
-               {
-                 if(form.validate())
-                 {
-                   var values = {};
-                   var formWidgets = form.getDescendants();
-                   for(var i in formWidgets)
+                management.remove(modelObj, parameters).then(
+                   function(result)
                    {
-                       var widget = formWidgets[i];
-                       var value = widget.value;
-                       var propName = widget.name;
-                       if (propName && !widget.disabled){
-                           if ((widget instanceof dijit.form.CheckBox || widget instanceof dijit.form.RadioButton)) {
-                               if (widget.checked != widget.initialValue) {
-                                   values[ propName ] = widget.checked;
-                               }
-                           } else if (value != widget.initialValue) {
-                               values[ propName ] = value ? value: null;
-                           }
-                       }
-                   }
-
-                     var that = this;
-                     var url = putURL;
-                     if (appendNameToUrl){
-                       url = url + "/" + encodeURIComponent(values["name"]);
-                     }
-                     xhr.put({url: url , sync: true, handleAs: "json",
-                              headers: { "Content-Type": "application/json"},
-                              putData: json.stringify(values),
-                              load: function(x) {that.success = true; },
-                              error: function(error) {that.success = false; that.failureReason = error;}});
-                     if(this.success === true)
-                     {
-                         setAttributesDialog.destroy();
-                     }
-                     else
-                     {
-                         util.xhrErrorHandler(this.failureReason);
-
-                     }
-                     return false;
-                 }
-                 else
-                 {
-                     alert('Form contains invalid data.  Please correct first');
-                     return false;
-                 }
-               }
-               catch(e)
-               {
-                  alert("Unexpected exception:" + e.message);
-                  return false;
-               }
-             });
-             form.connectChildren(true);
-             setAttributesDialog.startup();
-             var formWidgets = form.getDescendants();
-             var aproximateHeight = 0;
-             for(var i in formWidgets){
-                 var widget = formWidgets[i];
-                 var propName = widget.name;
-                 if (propName) {
-                     if ((widget instanceof dijit.form.CheckBox || widget instanceof dijit.form.RadioButton)) {
-                         widget.initialValue = widget.checked;
-                     } else {
-                         widget.initialValue = widget.value;
-                     }
-                     aproximateHeight += 30;
-                 }
-             }
-             dialogContentArea.style.overflow= "auto";
-             dialogContentArea.style.height = "300";
-             setAttributesDialog.on("hide", function(e){setAttributesDialog.destroy();});
-             setAttributesDialog.show();
-           };
+                      grid.selection.deselectAll();
+                      if (updater)
+                      {
+                        updater.update();
+                      }
+                      if (callback)
+                      {
+                        callback(data);
+                      }
+                   },
+                   util.xhrErrorHandler);
+           }
+
+           util.deleteSelectedRows = function(grid, confirmationMessageStart, management, url, updater, idParam, callback)
+           {
+                return util.confirmAndDeleteGridSelection(grid, confirmationMessageStart,
+                                                            function(data)
+                                                            {
+                                                                util.deleteData(management, data, url, idParam, grid, updater, callback);
+                                                            });
+           }
+
+           util.deleteData = function(management, data, url, idParam, grid, updater, callback)
+           {
+                var query = util.buildDeleteQuery(data, url, idParam);
+                management.del({url: query}).then(
+                   function(result)
+                   {
+                      grid.selection.deselectAll();
+                      if (updater)
+                      {
+                        updater.update();
+                      }
+                      if (callback)
+                      {
+                        callback(data);
+                      }
+                   },
+                   util.xhrErrorHandler);
+           }
 
            util.findAllWidgets = function(root)
            {
@@ -347,35 +217,37 @@ define(["dojo/_base/xhr",
 
              if (error)
              {
-               if (error.hasOwnProperty("status"))
+               var status = error.status || error.response ? error.response.status : null;
+               if (status != undefined && status != null)
                {
-                 var hasMessage = error.hasOwnProperty("message");
                  var message;
 
-                 if (error.status == 0)
+                 if (status == 0)
                  {
                    message = "Unable to contact the Broker";
                  }
-                 else if (error.status == 401)
+                 else if (status == 401)
                  {
                    message = "Authentication required";
                    userMustReauth = true;
                  }
-                 else if (error.status == 403)
+                 else if (status == 403)
                  {
                    message =  "Access Forbidden";
                  }
                  else
                  {
-                   message = hasMessage ? error.message : fallback;
+                   message = error.message ? error.message : fallback;
+
+                   var responseText = error.responseText? error.responseText: (error.response ? error.response.text : null);
 
                    // Try for a more detail error sent by the Broker as json
-                   if (error.hasOwnProperty("responseText"))
+                   if (responseText)
                    {
                      try
                      {
-                       var errorObj = json.parse(error.responseText);
-                       message = errorObj.hasOwnProperty("errorMessage") ? errorObj.errorMessage : errorMessageNode;
+                       var errorObj = json.parse(responseText);
+                       message = errorObj.hasOwnProperty("errorMessage") ? errorObj.errorMessage : message;
                      }
                      catch (e)
                      {
@@ -385,7 +257,7 @@ define(["dojo/_base/xhr",
                  }
 
                  errorMessageNode.innerHTML = entities.encode(message ? message : fallback);
-                 statusCodeNode.innerHTML =  entities.encode(String(error.status));
+                 statusCodeNode.innerHTML =  entities.encode(String(status));
 
                  dojo.byId("errorDialog.advice.retry").style.display = userMustReauth ? "none" : "block";
                  dojo.byId("errorDialog.advice.reconnect").style.display = userMustReauth ? "block" : "none";
@@ -408,38 +280,6 @@ define(["dojo/_base/xhr",
              }
            };
 
-           util.sendRequest = function (url, method, attributes, sync)
-           {
-               var success = false;
-               var failureReason = "";
-               var syncRequired = sync == undefined ? true : sync;
-               if (method == "POST" || method == "PUT")
-               {
-                 xhr.put({
-                   url: url,
-                   sync: syncRequired,
-                   handleAs: "json",
-                   headers: { "Content-Type": "application/json"},
-                   putData: json.stringify(attributes),
-                   load: function(x) {success = true; },
-                   error: function(error) {success = false; failureReason = error;}
-                 });
-               }
-               else if (method == "DELETE")
-               {
-                 xhr.del({url: url, sync: syncRequired, handleAs: "json"}).then(
-                       function(data) { success = true; },
-                       function(error) {success = false; failureReason = error;}
-                 );
-               }
-
-               if (syncRequired && !success)
-               {
-                   util.xhrErrorHandler(failureReason);
-               }
-               return success;
-           }
-
            util.equals = function(object1, object2)
            {
              if (object1 && object2)
@@ -533,16 +373,21 @@ define(["dojo/_base/xhr",
                 xhr.get({url: htmlTemplateLocation,
                                   sync: true,
                                   load:  function(template) {
-                                    containerNode.innerHTML = template;
-                                    parser.parse(containerNode).then(function(instances)
-                                                                     {
-                                                                        if (postParseCallback && typeof postParseCallback == "function")
-                                                                        {
-                                                                            postParseCallback();
-                                                                        }
-                                                                     });
+                                    util.parse(containerNode, template, postParseCallback);
                                   }});
            }
+
+           util.parse = function(containerNode, template, postParseCallback)
+           {
+                containerNode.innerHTML = template;
+                parser.parse(containerNode).then(function(instances)
+                             {
+                                if (postParseCallback && typeof postParseCallback == "function")
+                                {
+                                    postParseCallback();
+                                }
+                             });
+           }
            util.buildUI = function(containerNode, parent, htmlTemplateLocation, fieldNames, obj, postParseCallback)
            {
                 this.parseHtmlIntoDiv(containerNode, htmlTemplateLocation,
@@ -579,18 +424,18 @@ define(["dojo/_base/xhr",
              }
            }
 
-           util.applyMetadataToWidgets = function(domRoot, category, type)
+           util.applyMetadataToWidgets = function(domRoot, category, type, meta)
            {
-             this.applyToWidgets(domRoot, category, type, null);
+             this.applyToWidgets(domRoot, category, type, null, meta);
            }
 
-           util.applyToWidgets = function(domRoot, category, type, data)
+           util.applyToWidgets = function(domRoot, category, type, data, meta)
            {
              var widgets = util.findAllWidgets(domRoot);
              array.forEach(widgets,
                function (widget)
                {
-                 widgetconfigurer.config(widget, category, type, data);
+                 widgetconfigurer.config(widget, category, type, data, meta);
                });
            }
 
@@ -791,51 +636,17 @@ define(["dojo/_base/xhr",
                 on(window, "resize", resize);
            }
 
-           util.submit = function(method, resourceUrl, data, successAction, failureAction)
-           {
-                var result = {success: true, failureReason: null};
-                var xhrArguments = {
-                    url: resourceUrl,
-                    sync: true,
-                    handleAs: "json",
-                    headers: { "Content-Type": "application/json"},
-                    load: function(x) {
-                            result.success = true;
-                            result.data = x;
-                            if (successAction)
-                            {
-                                successAction(x);
-                            }
-                          },
-                    error: function(error) {
-                             result.success = false;
-                             result.failureReason = error;
-                             if (failureAction)
-                             {
-                                 failureAction(error);
-                             }
-                             else
-                             {
-                                 util.xhrErrorHandler(error);
-                             }
-                           }
-                }
-                if (data && method != "del")
-                {
-                    xhrArguments[method + "Data"] = json.stringify(data);
-                }
-                xhr[method](xhrArguments);
-                return result;
-           }
-
-           util.post = function(resourceUrl, data, successAction, failureAction)
-           {
-                return util.submit("post", resourceUrl, data, successAction, failureAction)
-           }
-
-           util.put = function(resourceUrl, data, successAction, failureAction)
+           util.setContextData = function(contextUI, management, modelObj, actualData, effectiveData, callback )
            {
-                return util.submit("put", resourceUrl, data, successAction, failureAction)
+                management.load(modelObj, { actuals: true, inheritedActuals: true} ).then(
+                                     function(inheritedActuals){
+                                        contextUI.setData(actualData.context, effectiveData.context, inheritedActuals[0].context);
+                                        if (callback)
+                                        {
+                                            callback();
+                                        }
+                                     },
+                                     util.xhrErrorHandler);
            }
 
            return util;

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/widgetconfigurer.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/widgetconfigurer.js?rev=1677590&r1=1677589&r2=1677590&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/widgetconfigurer.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/common/widgetconfigurer.js Mon May  4 12:17:23 2015
@@ -25,11 +25,10 @@ define(["dojo/_base/xhr",
         "dojo/dom-attr",
         "dijit/registry",
         "qpid/common/properties",
-        "qpid/common/metadata",
         "dojo/text!strings.html",
         "dojo/domReady!"
         ],
-  function (xhr, string, query, dom, domConstruct, domAttr, registry, properties, metadata, template)
+  function (xhr, string, query, dom, domConstruct, domAttr, registry, properties, template)
   {
    var widgetconfigurer =
    {
@@ -43,7 +42,7 @@ define(["dojo/_base/xhr",
 
        domConstruct.destroy(stringsTemplate);
      },
-     _processWidgetPrompt: function (widget, category, type)
+     _processWidgetPrompt: function (widget, category, type, meta)
      {
        var widgetName = widget.name;
        if (widgetName && (widget instanceof dijit.form.ValidationTextBox || widget instanceof dijit.form.FilteringSelect))
@@ -57,7 +56,7 @@ define(["dojo/_base/xhr",
            }
 
            var promptMessage = widget.get("qpid.originalPromptMessage");
-           var defaultValue = metadata.getDefaultValueForAttribute(category, type, widgetName);
+           var defaultValue = meta.getDefaultValueForAttribute(category, type, widgetName);
            if (defaultValue)
            {
                var newPromptMessage = string.substitute(this.promptTemplateWithDefault, { 'default': defaultValue, 'prompt': promptMessage });
@@ -82,7 +81,7 @@ define(["dojo/_base/xhr",
          if (connectWidget)
          {
            var connectWidgetName = connectWidget.get("name");
-           var defaultValue = metadata.getDefaultValueForAttribute(category, type, connectWidgetName);
+           var defaultValue = meta.getDefaultValueForAttribute(category, type, connectWidgetName);
            if (defaultValue)
            {
              var newMessage = string.substitute(this.promptTemplateWithDefault, { 'default': defaultValue, 'prompt': message });
@@ -95,13 +94,12 @@ define(["dojo/_base/xhr",
          }
        }
      },
-     _processWidgetValue: function (widget, category, type, data)
+     _processWidgetValue: function (widget, category, type, data, meta)
      {
        var widgetName = widget.name;
-
        if (widgetName)
        {
-         var defaultValue = metadata.getDefaultValueForAttribute(category, type, widgetName);
+         var defaultValue = meta.getDefaultValueForAttribute(category, type, widgetName);
          var dataValue = data && widgetName in data ? data[widgetName] : null;
 
          // Stash the default value and initial value so we can later differentiate
@@ -139,10 +137,13 @@ define(["dojo/_base/xhr",
          }
        }
      },
-     config: function (widget, category, type, data)
+     config: function (widget, category, type, data, meta)
      {
-         this._processWidgetPrompt(widget, category, type);
-         this._processWidgetValue(widget, category, type, data);
+         this._processWidgetPrompt(widget, category, type, meta);
+         if (data != null)
+         {
+            this._processWidgetValue(widget, category, type, data, meta);
+         }
      }
    };
 

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js?rev=1677590&r1=1677589&r2=1677590&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AccessControlProvider.js Mon May  4 12:17:23 2015
@@ -18,8 +18,7 @@
  * under the License.
  *
  */
-define(["dojo/_base/xhr",
-        "dojo/parser",
+define(["dojo/parser",
         "dojo/query",
         "dojo/_base/connect",
         "qpid/common/properties",
@@ -30,10 +29,11 @@ define(["dojo/_base/xhr",
         "dijit/registry",
         "dojo/_base/event",
         "dojox/html/entities",
+        "dojo/text!showAccessControlProvider.html",
         "dojox/grid/enhanced/plugins/Pagination",
         "dojox/grid/enhanced/plugins/IndirectSelection",
         "dojo/domReady!"],
-       function (xhr, parser, query, connect, properties, updater, util, UpdatableStore, EnhancedGrid, registry, event, entities) {
+       function (parser, query, connect, properties, updater, util, UpdatableStore, EnhancedGrid, registry, event, entities, template) {
 
            function AccessControlProvider(name, parent, controller) {
                this.name = name;
@@ -48,24 +48,19 @@ define(["dojo/_base/xhr",
            AccessControlProvider.prototype.open = function(contentPane) {
                var that = this;
                this.contentPane = contentPane;
-               xhr.get({url: "showAccessControlProvider.html",
-                        sync: true,
-                        load:  function(data) {
-                            contentPane.containerNode.innerHTML = data;
-                            parser.parse(contentPane.containerNode).then(function(instances)
-                            {
-
-                                that.accessControlProviderUpdater = new AccessControlProviderUpdater(contentPane.containerNode, that.modelObj, that.controller);
-
-                                var deleteButton = query(".deleteAccessControlProviderButton", contentPane.containerNode)[0];
-                                var deleteWidget = registry.byNode(deleteButton);
-                                connect.connect(deleteWidget, "onClick",
-                                            function(evt){
-                                                event.stop(evt);
-                                                that.deleteAccessControlProvider();
-                                            });
-                            });
-                        }});
+
+                contentPane.containerNode.innerHTML = template;
+                parser.parse(contentPane.containerNode).then(function(instances)
+                {
+                    that.accessControlProviderUpdater = new AccessControlProviderUpdater(contentPane.containerNode, that.modelObj, that.controller);
+                    var deleteButton = query(".deleteAccessControlProviderButton", contentPane.containerNode)[0];
+                    var deleteWidget = registry.byNode(deleteButton);
+                    connect.connect(deleteWidget, "onClick",
+                                function(evt){
+                                    event.stop(evt);
+                                    that.deleteAccessControlProvider();
+                                });
+                });
            };
 
            AccessControlProvider.prototype.close = function() {
@@ -77,34 +72,30 @@ define(["dojo/_base/xhr",
 
            AccessControlProvider.prototype.deleteAccessControlProvider = function() {
              if(confirm("Are you sure you want to delete access control provider '" + this.name + "'?")) {
-                 var query = "api/latest/accesscontrolprovider/" +encodeURIComponent(this.name);
-                 this.success = true
                  var that = this;
-                 xhr.del({url: query, sync: true, handleAs: "json"}).then(
+                 this.controller.management.remove(this.modelObj).then(
                      function(data) {
                          that.close();
                          that.contentPane.onClose()
                          that.controller.tabContainer.removeChild(that.contentPane);
                          that.contentPane.destroyRecursive();
                      },
-                     function(error) {that.success = false; that.failureReason = error;});
-                 if(!this.success ) {
-                     util.xhrErrorHandler(this.failureReason);
-                 }
+                     util.xhrErrorHandler);
              }
          };
 
            function AccessControlProviderUpdater(node, groupProviderObj, controller)
            {
                this.controller = controller;
+               this.management = controller.management;
+               this.modelObj = groupProviderObj;
                this.name = query(".name", node)[0];
                this.type = query(".type", node)[0];
                this.state = query(".state", node)[0];
-               this.query = "api/latest/accesscontrolprovider/"+encodeURIComponent(groupProviderObj.name);
 
                var that = this;
 
-               xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"})
+               this.management.load(this.modelObj)
                    .then(function(data)
                          {
                              that.accessControlProviderData = data[0];
@@ -118,7 +109,7 @@ define(["dojo/_base/xhr",
                                  function(SpecificProvider) {
                                  that.details = new SpecificProvider(query(".providerDetails", node)[0], groupProviderObj, controller);
                              });
-                         });
+                         }, util.xhrErrorHandler);
            }
 
            AccessControlProviderUpdater.prototype.updateHeader = function()

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js?rev=1677590&r1=1677589&r2=1677590&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/AuthenticationProvider.js Mon May  4 12:17:23 2015
@@ -18,8 +18,7 @@
  * under the License.
  *
  */
-define(["dojo/_base/xhr",
-        "dojo/parser",
+define(["dojo/parser",
         "dojo/query",
         "dojo/_base/connect",
         "qpid/common/properties",
@@ -35,13 +34,15 @@ define(["dojo/_base/xhr",
         "dojo/dom",
         "qpid/management/PreferencesProvider",
         "qpid/management/authenticationprovider/PrincipalDatabaseAuthenticationManager",
+        "dojo/text!showAuthProvider.html",
         "dojo/domReady!"],
-       function (xhr, parser, query, connect, properties, updater, util, UpdatableStore, EnhancedGrid,
-           addAuthenticationProvider, event, registry, domStyle, entities, dom, PreferencesProvider, PrincipalDatabaseAuthenticationManager) {
+       function (parser, query, connect, properties, updater, util, UpdatableStore, EnhancedGrid,
+           addAuthenticationProvider, event, registry, domStyle, entities, dom, PreferencesProvider, PrincipalDatabaseAuthenticationManager, template) {
 
            function AuthenticationProvider(name, parent, controller) {
                this.name = name;
                this.controller = controller;
+               this.management = management;
                this.modelObj = { type: "authenticationprovider", name: name, parent: parent};
            }
 
@@ -52,12 +53,9 @@ define(["dojo/_base/xhr",
            AuthenticationProvider.prototype.open = function(contentPane) {
                var that = this;
                this.contentPane = contentPane;
-               xhr.get({url: "showAuthProvider.html",
-                        sync: true,
-                        load:  function(data) {
-                            contentPane.containerNode.innerHTML = data;
-                            parser.parse(contentPane.containerNode).then(function(instances)
-                            {
+                contentPane.containerNode.innerHTML = template;
+                parser.parse(contentPane.containerNode).then(function(instances)
+                {
 
                             var authProviderUpdater = new AuthProviderUpdater(contentPane.containerNode, that.modelObj, that.controller, that);
                             that.authProviderUpdater = authProviderUpdater;
@@ -67,7 +65,7 @@ define(["dojo/_base/xhr",
                             editButtonWidget.on("click",
                                             function(evt){
                                                 event.stop(evt);
-                                                addAuthenticationProvider.show(authProviderUpdater.authProviderData);
+                                                addAuthenticationProvider.show(that.management, that.modelObj, authProviderUpdater.authProviderData);
                                             });
                             authProviderUpdater.editButton = editButtonWidget;
 
@@ -79,17 +77,26 @@ define(["dojo/_base/xhr",
                                                 that.deleteAuthenticationProvider();
                                             });
 
-                            authProviderUpdater.update();
-                            if (util.isProviderManagingUsers(authProviderUpdater.authProviderData.type))
+                            authProviderUpdater.update( function()
+                            {
+                            if (that.management.metadata.implementsManagedInterface("AuthenticationProvider",
+                                authProviderUpdater.authProviderData.type, "PasswordCredentialManagingAuthenticationProvider"))
                             {
-                                 authProviderUpdater.managingUsersUI = new PrincipalDatabaseAuthenticationManager(contentPane.containerNode, authProviderUpdater.authProviderData, that.controller);
+                                 authProviderUpdater.managingUsersUI = new PrincipalDatabaseAuthenticationManager(contentPane.containerNode, authProviderUpdater.modelObj, that.controller);
                                  authProviderUpdater.managingUsersUI.update(authProviderUpdater.authProviderData);
                             }
 
-                            if (!util.supportsPreferencesProvider(authProviderUpdater.authProviderData.type))
+
+                            var supportsPreferencesProvider = that.management.metadata.implementsManagedInterface("AuthenticationProvider",
+                            authProviderUpdater.authProviderData.type, "PreferencesSupportingAuthenticationProvider");
+                            if (!supportsPreferencesProvider)
                             {
-                                var authenticationProviderPanel =  registry.byNode( query(".preferencesPanel", contentPane.containerNode)[0]);
-                                domStyle.set(authenticationProviderPanel.domNode, "display","none");
+                                var preferencesPanel = query(".preferencesPanel", contentPane.containerNode);
+                                if (preferencesPanel && preferencesPanel[0])
+                                {
+                                    var preferencesProviderPanel =  registry.byNode( preferencesPanel[0]);
+                                    domStyle.set(preferencesProviderPanel.domNode, "display","none");
+                                }
                             }
                             else
                             {
@@ -99,7 +106,7 @@ define(["dojo/_base/xhr",
 
                             updater.add( that.authProviderUpdater );
                             });
-                        }});
+                });
            };
 
            AuthenticationProvider.prototype.close = function() {
@@ -112,26 +119,23 @@ define(["dojo/_base/xhr",
 
            AuthenticationProvider.prototype.deleteAuthenticationProvider = function() {
                if(confirm("Are you sure you want to delete authentication provider '" + this.name + "'?")) {
-                   var query = "api/latest/authenticationprovider/" +encodeURIComponent(this.name);
-                   this.success = true
                    var that = this;
-                   xhr.del({url: query, sync: true, handleAs: "json"}).then(
+                   this.management.remove(this.modelObj).then(
                        function(data) {
                            that.close();
                            that.contentPane.onClose()
                            that.controller.tabContainer.removeChild(that.contentPane);
                            that.contentPane.destroyRecursive();
                        },
-                       function(error) {that.success = false; that.failureReason = error;});
-                   if(!this.success ) {
-                       util.xhrErrorHandler(this.failureReason);
-                   }
+                       util.xhrErrorHandler);
                }
            };
 
            function AuthProviderUpdater(node, authProviderObj, controller, authenticationProvider)
            {
                this.controller = controller;
+               this.management = management;
+               this.modelObj = authProviderObj;
                this.name = query(".name", node)[0];
                this.type = query(".type", node)[0];
                this.state = query(".state", node)[0];
@@ -143,10 +147,7 @@ define(["dojo/_base/xhr",
                this.deletePreferencesProviderButton = query(".deletePreferencesProviderButton", node)[0];
                this.preferencesProviderAttributes = dom.byId("preferencesProviderAttributes")
                this.preferencesNode = query(".preferencesProviderDetails", node)[0];
-
-this.authenticationProviderDetailsContainer = query(".authenticationProviderDetails", node)[0];
-               this.query = "api/latest/authenticationprovider/" + encodeURIComponent(authProviderObj.name);
-
+               this.authenticationProviderDetailsContainer = query(".authenticationProviderDetails", node)[0];
            }
 
            AuthProviderUpdater.prototype.updatePreferencesProvider = function(preferencesProviderData)
@@ -183,10 +184,18 @@ this.authenticationProviderDetailsContai
                this.state.innerHTML = entities.encode(String(this.authProviderData[ "state" ]));
            };
 
-           AuthProviderUpdater.prototype.update = function()
+           AuthProviderUpdater.prototype.update = function(callback)
            {
              var that = this;
-             xhr.get({url: this.query, sync: true, handleAs: "json"}).then(function(data) {that._update(data[0]);});
+             this.management.load(this.modelObj).then(
+                 function(data)
+                 {
+                    that._update(data[0]);
+                    if (callback)
+                    {
+                        callback();
+                    }
+                 });
            };
 
             AuthProviderUpdater.prototype._update = function(data)

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js?rev=1677590&r1=1677589&r2=1677590&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js Mon May  4 12:17:23 2015
@@ -18,8 +18,7 @@
  * under the License.
  *
  */
-define(["dojo/_base/xhr",
-        "dojo/parser",
+define(["dojo/parser",
         "dojo/query",
         "dojo/json",
         "dojo/_base/connect",
@@ -38,6 +37,7 @@ define(["dojo/_base/xhr",
         "qpid/management/addGroupProvider",
         "qpid/management/addAccessControlProvider",
         "qpid/management/editBroker",
+        "dojo/text!showBroker.html",
         "dojox/grid/enhanced/plugins/Pagination",
         "dojox/grid/enhanced/plugins/IndirectSelection",
         "dijit/layout/AccordionContainer",
@@ -51,8 +51,8 @@ define(["dojo/_base/xhr",
         "dijit/Menu",
         "dijit/MenuItem",
         "dojo/domReady!"],
-       function (xhr, parser, query, json, connect, memory, properties, updater, util, UpdatableStore, EnhancedGrid, registry, entities,
-        addAuthenticationProvider, addVirtualHostNodeAndVirtualHost, addPort, addStore, addGroupProvider, addAccessControlProvider, editBroker) {
+       function (parser, query, json, connect, memory, properties, updater, util, UpdatableStore, EnhancedGrid, registry, entities,
+        addAuthenticationProvider, addVirtualHostNodeAndVirtualHost, addPort, addStore, addGroupProvider, addAccessControlProvider, editBroker, template) {
 
            var brokerAttributeNames = ["name", "operatingSystem", "platform", "productVersion", "modelVersion",
                                         "defaultVirtualHost", "statisticsReportingPeriod", "statisticsReportingResetEnabled",
@@ -61,12 +61,8 @@ define(["dojo/_base/xhr",
            function Broker(name, parent, controller) {
                this.name = name;
                this.controller = controller;
+               this.management = controller.management;
                this.modelObj = { type: "broker", name: name };
-
-               if(parent) {
-                    this.modelObj.parent = {};
-                    this.modelObj.parent[ parent.type] = parent;
-               }
            }
 
 
@@ -78,10 +74,8 @@ define(["dojo/_base/xhr",
            Broker.prototype.open = function(contentPane) {
                var that = this;
                this.contentPane = contentPane;
-               xhr.get({url: "showBroker.html",
-                        sync: true,
-                        load:  function(data) {
-                            contentPane.containerNode.innerHTML = data;
+                        {
+                            contentPane.containerNode.innerHTML = template;
                             parser.parse(contentPane.containerNode).then(function(instances)
                             {
                             that.brokerUpdater = new BrokerUpdater(contentPane.containerNode, that.modelObj, that.controller);
@@ -93,7 +87,9 @@ define(["dojo/_base/xhr",
 
 
                             var addProviderButton = query(".addAuthenticationProvider", contentPane.containerNode)[0];
-                            connect.connect(registry.byNode(addProviderButton), "onClick", function(evt){ addAuthenticationProvider.show(); });
+                            connect.connect(registry.byNode(addProviderButton), "onClick", function(evt){
+                                addAuthenticationProvider.show(that.management, that.modelObj);
+                            });
 
                             var deleteProviderButton = query(".deleteAuthenticationProvider", contentPane.containerNode)[0];
                             connect.connect(registry.byNode(deleteProviderButton), "onClick",
@@ -112,31 +108,36 @@ define(["dojo/_base/xhr",
                                           }
                                         }
 
-                                        util.deleteGridSelections(
-                                                that.brokerUpdater,
+                                        util.deleteSelectedObjects(
                                                 that.brokerUpdater.authenticationProvidersGrid.grid,
-                                                "api/latest/authenticationprovider",
-                                                warning + "Are you sure you want to delete authentication provider");
+                                                warning + "Are you sure you want to delete authentication provider",
+                                                that.management,
+                                                {type: "authenticationprovider", parent:that.modelObj},
+                                                that.brokerUpdater);
                                 }
                             );
 
                             var addVHNAndVHButton = query(".addVirtualHostNodeAndVirtualHostButton", contentPane.containerNode)[0];
-                            connect.connect(registry.byNode(addVHNAndVHButton), "onClick", function(evt){ addVirtualHostNodeAndVirtualHost.show(); });
+                            connect.connect(registry.byNode(addVHNAndVHButton), "onClick", function(evt){
+                                addVirtualHostNodeAndVirtualHost.show(that.controller.management);
+                            });
 
                             var addPortButton = query(".addPort", contentPane.containerNode)[0];
                             connect.connect(registry.byNode(addPortButton), "onClick", function(evt){
-                              addPort.show(null, "AMQP", that.brokerUpdater.brokerData.authenticationproviders,
+                              addPort.show(that.management, that.modelObj, "AMQP", that.brokerUpdater.brokerData.authenticationproviders,
                                   that.brokerUpdater.brokerData.keystores, that.brokerUpdater.brokerData.truststores);
                             });
 
                             var deletePort = query(".deletePort", contentPane.containerNode)[0];
                             connect.connect(registry.byNode(deletePort), "onClick",
                                     function(evt){
-                                        util.deleteGridSelections(
-                                                that.brokerUpdater,
+                                        util.deleteSelectedObjects(
                                                 that.brokerUpdater.portsGrid.grid,
-                                                "api/latest/port",
-                                                "Are you sure you want to delete port");
+                                                "Are you sure you want to delete port",
+                                                that.management,
+                                                {type: "port", parent:that.modelObj},
+                                                that.brokerUpdater);
+
                                 }
                             );
 
@@ -144,7 +145,7 @@ define(["dojo/_base/xhr",
                             connect.connect(registry.byNode(editButton), "onClick",
                                 function(evt)
                                 {
-                                  editBroker.show(that.brokerUpdater.brokerData);
+                                  editBroker.show(that.management, that.brokerUpdater.brokerData);
                                 }
                             );
 
@@ -152,18 +153,19 @@ define(["dojo/_base/xhr",
                             connect.connect(registry.byNode(addKeystoreButton), "onClick",
                                 function(evt)
                                 {
-                                    addStore.setupTypeStore("KeyStore");
+                                    addStore.setupTypeStore(that.management, "KeyStore", that.modelObj);
                                     addStore.show();
                                 });
 
                             var deleteKeystore = query(".deleteKeystore", contentPane.containerNode)[0];
                             connect.connect(registry.byNode(deleteKeystore), "onClick",
                                     function(evt){
-                                        util.deleteGridSelections(
-                                                that.brokerUpdater,
+                                        util.deleteSelectedObjects(
                                                 that.brokerUpdater.keyStoresGrid.grid,
-                                                "api/latest/keystore",
-                                                "Are you sure you want to delete key store");
+                                                "Are you sure you want to delete key store",
+                                                that.management,
+                                                {type: "keystore", parent:that.modelObj},
+                                                that.brokerUpdater);
                                 }
                             );
 
@@ -171,24 +173,25 @@ define(["dojo/_base/xhr",
                             connect.connect(registry.byNode(addTruststoreButton), "onClick",
                                 function(evt)
                                 {
-                                    addStore.setupTypeStore("TrustStore");
+                                    addStore.setupTypeStore(that.management, "TrustStore", that.modelObj);
                                     addStore.show();
                                 });
 
                             var deleteTruststore = query(".deleteTruststore", contentPane.containerNode)[0];
                             connect.connect(registry.byNode(deleteTruststore), "onClick",
                                     function(evt){
-                                        util.deleteGridSelections(
-                                                that.brokerUpdater,
+                                        util.deleteSelectedObjects(
                                                 that.brokerUpdater.trustStoresGrid.grid,
-                                                "api/latest/truststore",
-                                                "Are you sure you want to delete trust store");
+                                                "Are you sure you want to delete trust store",
+                                                that.management,
+                                                {type: "truststore", parent:that.modelObj},
+                                                that.brokerUpdater);
                                 }
                             );
 
                             var addGroupProviderButton = query(".addGroupProvider", contentPane.containerNode)[0];
                             connect.connect(registry.byNode(addGroupProviderButton), "onClick",
-                                function(evt){addGroupProvider.show();});
+                                function(evt){addGroupProvider.show(that.controller.management, that.modelObj);});
 
                             var deleteGroupProvider = query(".deleteGroupProvider", contentPane.containerNode)[0];
                             connect.connect(registry.byNode(deleteGroupProvider), "onClick",
@@ -207,30 +210,32 @@ define(["dojo/_base/xhr",
                                           }
                                         }
 
-                                        util.deleteGridSelections(
-                                                that.brokerUpdater,
+                                        util.deleteSelectedObjects(
                                                 that.brokerUpdater.groupProvidersGrid.grid,
-                                                "api/latest/groupprovider",
-                                                warning + "Are you sure you want to delete group provider");
+                                                warning + "Are you sure you want to delete group provider",
+                                                that.management,
+                                                {type: "groupprovider", parent:that.modelObj},
+                                                that.brokerUpdater);
                                 }
                             );
 
                             var addAccessControlButton = query(".addAccessControlProvider", contentPane.containerNode)[0];
                             connect.connect(registry.byNode(addAccessControlButton), "onClick",
-                                function(evt){addAccessControlProvider.show();});
+                                function(evt){addAccessControlProvider.show(that.management, that.modelObj);});
 
                             var deleteAccessControlProviderButton = query(".deleteAccessControlProvider", contentPane.containerNode)[0];
                             connect.connect(registry.byNode(deleteAccessControlProviderButton), "onClick",
                                     function(evt){
-                                        util.deleteGridSelections(
-                                                that.brokerUpdater,
+                                        util.deleteSelectedObjects(
                                                 that.brokerUpdater.accessControlProvidersGrid.grid,
-                                                "api/latest/accesscontrolprovider",
-                                                "Are you sure you want to delete access control provider");
+                                                "Are you sure you want to delete access control provider",
+                                                that.management,
+                                                {type: "accesscontrolprovider", parent:that.modelObj},
+                                                that.brokerUpdater);
                                 }
                             );
                             });
-                        }});
+                        }
            };
 
            Broker.prototype.close = function() {
@@ -240,11 +245,12 @@ define(["dojo/_base/xhr",
            function BrokerUpdater(node, brokerObj, controller)
            {
                this.controller = controller;
-               this.query = "api/latest/broker?depth=2";
-               this.accessControlProvidersWarn = query(".broker-access-control-providers-warning", node)[0]
+               this.accessControlProvidersWarn = query(".broker-access-control-providers-warning", node)[0];
+               this.management = controller.management;
+               this.brokerObj = brokerObj;
                var that = this;
 
-               xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"})
+               this.management.load(brokerObj, {depth:2})
                    .then(function(data)
                          {
                              that.brokerData= data[0];
@@ -369,11 +375,12 @@ define(["dojo/_base/xhr",
 
                              deleteNodeItem.on("click",
                                      function(evt){
-                                         util.deleteGridSelections(
-                                                 that,
+                                         util.deleteSelectedObjects(
                                                  that.vhostsGrid.grid,
-                                                 "api/latest/virtualhostnode",
-                                                 "Deletion of virtual host node will delete both configuration and message data.\n\n Are you sure you want to delete virtual host node");
+                                                 "Deletion of virtual host node will delete both configuration and message data.\n\n Are you sure you want to delete virtual host node",
+                                                 that.management,
+                                                 {type: "virtualhostnode", parent:that.modelObj},
+                                                 that.brokerUpdater);
                                  }
                              );
 
@@ -384,9 +391,9 @@ define(["dojo/_base/xhr",
                                  if (data.length == 1)
                                  {
                                    var item = data[0];
-                                   util.sendRequest("api/latest/virtualhostnode/" + encodeURIComponent(item.name),
-                                           "PUT", {desiredState: "ACTIVE"});
-                                   that.vhostsGrid.grid.selection.clear();
+                                   that.management.update({type:"virtualhostnode", name:item.name, parent: that.modelObj},
+                                           {desiredState: "ACTIVE"},
+                                           function(data){that.vhostsGrid.grid.selection.clear();});
                                  }
                                });
 
@@ -401,9 +408,9 @@ define(["dojo/_base/xhr",
                                            + "Are you sure you want to stop virtual host node '"
                                            + entities.encode(String(item.name)) +"'?"))
                                    {
-                                       util.sendRequest("api/latest/virtualhostnode/" + encodeURIComponent(item.name),
-                                               "PUT", {desiredState: "STOPPED"});
-                                       that.vhostsGrid.grid.selection.clear();
+                                       that.management.update({type:"virtualhostnode", name:item.name, parent: that.modelObj},
+                                               {desiredState: "STOPPED"},
+                                               function(data){that.vhostsGrid.grid.selection.clear();});
                                    }
                                  }
                                });
@@ -415,9 +422,9 @@ define(["dojo/_base/xhr",
                                  {
                                    var item = data[0];
                                    var host = item.virtualhosts[0];
-                                   util.sendRequest("api/latest/virtualhost/" + encodeURIComponent(item.name) + "/" + encodeURIComponent(host.name),
-                                           "PUT", {desiredState: "ACTIVE"});
-                                   that.vhostsGrid.grid.selection.clear();
+                                   that.management.update({type:"virtualhost", name:item.name, parent: {type:"virtualhostnode", name: host.name, parent: that.modelObj}},
+                                            {desiredState: "ACTIVE"},
+                                            function(data){that.vhostsGrid.grid.selection.clear();});
                                  }
                                });
 
@@ -431,9 +438,9 @@ define(["dojo/_base/xhr",
                                    if (confirm("Are you sure you want to stop virtual host '"
                                            + entities.encode(String(host.name)) +"'?"))
                                    {
-                                       util.sendRequest("api/latest/virtualhost/" + encodeURIComponent(item.name) + "/" + encodeURIComponent(host.name),
-                                               "PUT", {desiredState: "STOPPED"});
-                                       that.vhostsGrid.grid.selection.clear();
+                                       that.management.update({type:"virtualhost", name:item.name, parent: {type:"virtualhostnode", name: host.name, parent: that.modelObj}},
+                                               {desiredState: "STOPPED"},
+                                               function(data){that.vhostsGrid.grid.selection.clear();});
                                    }
                                  }
                                });
@@ -472,7 +479,16 @@ define(["dojo/_base/xhr",
                                                      { name: "Type", field: "type", width: "20%"},
                                                      { name: "User Management", field: "type", width: "20%",
                                                              formatter: function(val){
-                                                                 return "<input type='radio' disabled='disabled' "+(util.isProviderManagingUsers(val)?"checked='checked'": "")+" />";
+                                                                 var isProviderManagingUsers = false;
+                                                                 try
+                                                                 {
+                                                                    isProviderManagingUsers = that.management.metadata.implementsManagedInterface("AuthenticationProvider", val, "PasswordCredentialManagingAuthenticationProvider");
+                                                                 }
+                                                                 catch(e)
+                                                                 {
+                                                                    console.error(e);
+                                                                 }
+                                                                 return "<input type='radio' disabled='disabled' "+(isProviderManagingUsers?"checked='checked'": "")+" />";
                                                              }
                                                      }
                                                  ], function(obj) {
@@ -635,7 +651,7 @@ define(["dojo/_base/xhr",
 
                var that = this;
 
-               xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}).then(function(data)
+               this.management.load(this.brokerObj, {depth:2}).then(function(data)
                    {
                        that.brokerData = data[0];
                        util.flattenStatistics( that.brokerData );

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Connection.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Connection.js?rev=1677590&r1=1677589&r2=1677590&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Connection.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Connection.js Mon May  4 12:17:23 2015
@@ -18,8 +18,7 @@
  * under the License.
  *
  */
-define(["dojo/_base/xhr",
-        "dojo/parser",
+define(["dojo/parser",
         "dojo/query",
         "dojo/_base/connect",
         "qpid/common/properties",
@@ -27,15 +26,16 @@ define(["dojo/_base/xhr",
         "qpid/common/util",
         "qpid/common/formatter",
         "qpid/common/UpdatableStore",
-        "qpid/management/UserPreferences",
         "dojox/html/entities",
+        "dojo/text!showConnection.html",
         "dojo/domReady!"],
-       function (xhr, parser, query, connect, properties, updater, util, formatter, UpdatableStore, UserPreferences, entities) {
+       function (parser, query, connect, properties, updater, util, formatter, UpdatableStore, entities, template) {
 
            function Connection(name, parent, controller) {
                this.name = name;
                this.controller = controller;
-               this.modelObj = { type: "exchange", name: name, parent: parent };
+               this.management = controller.management
+               this.modelObj = { type: "connection", name: name, parent: parent };
            }
 
            Connection.prototype.getTitle = function()
@@ -46,17 +46,13 @@ define(["dojo/_base/xhr",
            Connection.prototype.open = function(contentPane) {
                var that = this;
                this.contentPane = contentPane;
-               xhr.get({url: "showConnection.html",
-                        sync: true,
-                        load:  function(data) {
-                            contentPane.containerNode.innerHTML = data;
+
+                            contentPane.containerNode.innerHTML = template;
                             parser.parse(contentPane.containerNode).then(function(instances)
                             {
                                 that.connectionUpdater = new ConnectionUpdater(contentPane.containerNode, that.modelObj, that.controller);
-                                updater.add( that.connectionUpdater );
-                                that.connectionUpdater.update();
+                                that.connectionUpdater.update(function(){updater.add( that.connectionUpdater );});
                             });
-                        }});
            };
 
            Connection.prototype.close = function() {
@@ -66,6 +62,8 @@ define(["dojo/_base/xhr",
            function ConnectionUpdater(containerNode, connectionObj, controller)
            {
                var that = this;
+               this.management = controller.management;
+               this.modelObj = connectionObj;
 
                function findNode(name) {
                    return query("." + name, containerNode)[0];
@@ -95,18 +93,11 @@ define(["dojo/_base/xhr",
                            "bytesOutRateUnits"]);
 
 
+               var userPreferences = this.management.userPreferences;
 
-               this.query = "api/latest/connection/"+ encodeURIComponent(connectionObj.parent.parent.name)
-                               + "/" + encodeURIComponent(connectionObj.parent.name) + "/" + encodeURIComponent(connectionObj.name);
-
-               xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}).then(function(data)
-                               {
-                                   that.connectionData = data[0];
-
-                                   util.flattenStatistics( that.connectionData );
 
-                                   that.updateHeader();
-                                   that.sessionsGrid = new UpdatableStore(that.connectionData.sessions, findNode("sessions"),
+                                   that.connectionData = {};
+                                   that.sessionsGrid = new UpdatableStore([], findNode("sessions"),
                                                             [ { name: "Name", field: "name", width: "20%"},
                                                               { name: "Consumers", field: "consumerCount", width: "15%"},
                                                               { name: "Unacknowledged messages", field: "unacknowledgedMessages", width: "15%"},
@@ -115,7 +106,7 @@ define(["dojo/_base/xhr",
                                                                 {
                                                                     if (transactionStartTime > 0)
                                                                     {
-                                                                        return UserPreferences.formatDateTime(transactionStartTime, {selector: "time", addOffset: true, appendTimeZone: true});
+                                                                        return userPreferences.formatDateTime(transactionStartTime, {selector: "time", addOffset: true, appendTimeZone: true});
                                                                     }
                                                                     else
                                                                     {
@@ -128,7 +119,7 @@ define(["dojo/_base/xhr",
                                                                 {
                                                                     if (transactionUpdateTime > 0)
                                                                     {
-                                                                        return UserPreferences.formatDateTime(transactionUpdateTime, {selector: "time", addOffset: true, appendTimeZone: true});
+                                                                        return userPreferences.formatDateTime(transactionUpdateTime, {selector: "time", addOffset: true, appendTimeZone: true});
                                                                     }
                                                                     else
                                                                     {
@@ -139,8 +130,6 @@ define(["dojo/_base/xhr",
                                                             ]);
 
 
-                               });
-
            }
 
            ConnectionUpdater.prototype.updateHeader = function()
@@ -153,21 +142,27 @@ define(["dojo/_base/xhr",
               this.transport.innerHTML = entities.encode(String(this.connectionData[ "transport" ]));
               var remoteProcessPid = this.connectionData[ "remoteProcessPid" ];
               this.remoteProcessPid.innerHTML = entities.encode(String(remoteProcessPid ? remoteProcessPid : "N/A"));
-              this.createdTime.innerHTML = UserPreferences.formatDateTime(this.connectionData[ "createdTime" ], {addOffset: true, appendTimeZone: true});
-              this.lastIoTime.innerHTML = UserPreferences.formatDateTime(this.connectionData[ "lastIoTime" ], {addOffset: true, appendTimeZone: true});
+              var userPreferences = this.management.userPreferences;
+              this.createdTime.innerHTML = userPreferences.formatDateTime(this.connectionData[ "createdTime" ], {addOffset: true, appendTimeZone: true});
+              this.lastIoTime.innerHTML = userPreferences.formatDateTime(this.connectionData[ "lastIoTime" ], {addOffset: true, appendTimeZone: true});
            };
 
-           ConnectionUpdater.prototype.update = function()
+           ConnectionUpdater.prototype.update = function(callback)
            {
 
               var that = this;
 
-              xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}).then(function(data)
+              that.management.load(this.modelObj).then(function(data)
                    {
                        that.connectionData = data[0];
 
                        util.flattenStatistics( that.connectionData );
 
+                       if (callback)
+                       {
+                            callback();
+                       }
+
                        var sessions = that.connectionData[ "sessions" ];
 
                        that.updateHeader();

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js?rev=1677590&r1=1677589&r2=1677590&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Exchange.js Mon May  4 12:17:23 2015
@@ -31,12 +31,14 @@ define(["dojo/_base/xhr",
         "qpid/management/addBinding",
         "dojox/grid/EnhancedGrid",
         "dojox/html/entities",
+        "dojo/text!showExchange.html",
         "dojo/domReady!"],
-       function (xhr, parser, query, connect, registry, properties, updater, util, formatter, UpdatableStore, addBinding, EnhancedGrid, entities) {
+       function (xhr, parser, query, connect, registry, properties, updater, util, formatter, UpdatableStore, addBinding, EnhancedGrid, entities, template) {
 
            function Exchange(name, parent, controller) {
                this.name = name;
                this.controller = controller;
+               this.management = controller.management;
                this.modelObj = { type: "exchange", name: name, parent: parent};
            }
 
@@ -63,28 +65,18 @@ define(["dojo/_base/xhr",
            };
 
            Exchange.prototype.open = function(contentPane) {
-               var that = this;
-               this.contentPane = contentPane;
-               xhr.get({url: "showExchange.html",
-                        sync: true,
-                        load:  function(data) {
-                            contentPane.containerNode.innerHTML = data;
-                            parser.parse(contentPane.containerNode).then(function(instances)
-                            {
-
-                            that.exchangeUpdater = new ExchangeUpdater(contentPane.containerNode, that.modelObj, that.controller);
-
-                            updater.add( that.exchangeUpdater );
-
-                            that.exchangeUpdater.update();
+                var that = this;
+                this.contentPane = contentPane;
 
+                contentPane.containerNode.innerHTML = template;
+                parser.parse(contentPane.containerNode).then(function(instances)
+                {
 
+                            that.exchangeUpdater = new ExchangeUpdater(contentPane.containerNode, that.modelObj, that.controller);
                             var addBindingButton = query(".addBindingButton", contentPane.containerNode)[0];
                             connect.connect(registry.byNode(addBindingButton), "onClick",
                                             function(evt){
-                                                addBinding.show({ virtualhost: that.getVirtualHostName(),
-                                                                  virtualhostnode: that.getVirtualHostNodeName(),
-                                                                  exchange: that.getExchangeName()});
+                                                addBinding.show(that.management, that.modelObj);
                                             });
 
                             var deleteBindingButton = query(".deleteBindingButton", contentPane.containerNode)[0];
@@ -107,8 +99,9 @@ define(["dojo/_base/xhr",
                                             that.deleteExchange();
                                         });
                             }
-                            });
-                        }});
+
+                            that.exchangeUpdater.update( function(){updater.add( that.exchangeUpdater )});
+                });
            };
 
            Exchange.prototype.close = function() {
@@ -117,18 +110,21 @@ define(["dojo/_base/xhr",
 
            Exchange.prototype.deleteBindings = function()
            {
-               util.deleteGridSelections(
-                       this.exchangeUpdater,
-                       this.exchangeUpdater.bindingsGrid.grid,
-                       "api/latest/binding/" + encodeURIComponent(this.getVirtualHostNodeName())
-                           + "/" + encodeURIComponent(this.getVirtualHostName()) + "/" + encodeURIComponent(this.name),
-                       "Are you sure you want to delete binding for queue");
+               util.deleteSelectedObjects(
+                        this.exchangeUpdater.bindingsGrid.grid,
+                        "Are you sure you want to delete binding",
+                        this.management,
+                        {type: "binding", parent:that.modelObj},
+                        this.exchangeUpdater);
            }
 
            function ExchangeUpdater(containerNode, exchangeObj, controller)
            {
                var that = this;
 
+               this.management = controller.management;
+               this.modelObj = exchangeObj;
+
                function findNode(name) {
                    return query("." + name, containerNode)[0];
                }
@@ -161,18 +157,9 @@ define(["dojo/_base/xhr",
                            "bytesDropRate",
                            "bytesDropRateUnits"]);
 
+                                  that.exchangeData = {};
 
-
-               this.query = "api/latest/exchange/" + encodeURIComponent(exchangeObj.parent.parent.name)
-                               + "/" + encodeURIComponent(exchangeObj.parent.name) + "/" + encodeURIComponent(exchangeObj.name);
-
-               xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}).then(function(data)
-                               {
-                                  that.exchangeData = data[0];
-                                  util.flattenStatistics( that.exchangeData );
-
-                                  that.updateHeader();
-                                  that.bindingsGrid = new UpdatableStore(that.exchangeData.bindings, findNode("bindings"),
+                                  that.bindingsGrid = new UpdatableStore([], findNode("bindings"),
                                                            [ { name: "Queue",    field: "queue",      width: "40%"},
                                                              { name: "Binding Key", field: "name",          width: "30%"},
                                                              { name: "Arguments",   field: "argumentString",     width: "30%"}
@@ -191,9 +178,6 @@ define(["dojo/_base/xhr",
                                                                          indirectSelection: true
 
                                                                 }}, EnhancedGrid);
-
-                               });
-
            }
 
            ExchangeUpdater.prototype.updateHeader = function()
@@ -207,15 +191,20 @@ define(["dojo/_base/xhr",
 
            };
 
-           ExchangeUpdater.prototype.update = function()
+           ExchangeUpdater.prototype.update = function(callback)
            {
 
               var thisObj = this;
 
-              xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}).then(function(data)
+              this.management.load(this.modelObj).then(function(data)
                    {
                       thisObj.exchangeData = data[0];
 
+                      if (callback)
+                      {
+                        callback();
+                      }
+
                       util.flattenStatistics( thisObj.exchangeData );
 
                       var bindings = thisObj.exchangeData[ "bindings" ];
@@ -275,25 +264,18 @@ define(["dojo/_base/xhr",
                       // update bindings
                       thisObj.bindingsGrid.update(thisObj.exchangeData.bindings)
 
-                   });
+                   }, util.xhrErrorHandler);
            };
 
            Exchange.prototype.deleteExchange = function() {
                if(confirm("Are you sure you want to delete exchange '" +this.name+"'?")) {
-                   var query = "api/latest/exchange/" + encodeURIComponent(this.getVirtualHostNodeName())
-                                   + "/" + encodeURIComponent(this.getVirtualHostName()) +  "/" + encodeURIComponent(this.name);
-                   this.success = true
                    var that = this;
-                   xhr.del({url: query, sync: true, handleAs: "json"}).then(
-                       function(data) {
-                           that.contentPane.onClose()
-                           that.controller.tabContainer.removeChild(that.contentPane);
-                           that.contentPane.destroyRecursive();
-                       },
-                       function(error) {that.success = false; that.failureReason = error;});
-                   if(!this.success ) {
-                       util.xhrErrorHandler(this.failureReason);
-                   }
+                   this.management.remove(this.modelObj).then(
+                                       function(data) {
+                                           that.contentPane.onClose()
+                                           that.controller.tabContainer.removeChild(that.contentPane);
+                                           that.contentPane.destroyRecursive();
+                                       }, util.xhrErrorHandler);
                }
            }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message