You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by lq...@apache.org on 2016/05/02 17:57:54 UTC

svn commit: r1741993 [11/29] - in /qpid/java/trunk: bdbstore/src/main/java/resources/js/qpid/management/virtualhost/bdb/ bdbstore/src/main/java/resources/js/qpid/management/virtualhost/bdb_ha/ bdbstore/src/main/java/resources/js/qpid/management/virtual...

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js?rev=1741993&r1=1741992&r2=1741993&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Management.js Mon May  2 15:57:52 2016
@@ -29,592 +29,594 @@ define(["dojo/_base/lang",
         "qpid/common/metadata",
         "qpid/common/timezone",
         "qpid/management/UserPreferences"],
-       function (lang, array, xhr, ioQuery, json, Promise, Deferred, sasl, Metadata, Timezone, UserPreferences)
-       {
+    function (lang, array, xhr, ioQuery, json, Promise, Deferred, sasl, Metadata, Timezone, UserPreferences)
+    {
 
-           function shallowCopy(source, target, excludes)
-           {
-               if (source)
-               {
-                   for (var fieldName in source)
-                   {
-                       if (source.hasOwnProperty(fieldName))
-                       {
-                           if (excludes && array.indexOf(excludes, fieldName) != -1)
-                           {
-                               continue;
-                           }
-
-                           target[fieldName] = source[fieldName];
-                       }
-                   }
-               }
-               return target;
-           }
-
-           function merge(data1, data2)
-           {
-               var result = {};
-               shallowCopy(data1, result);
-               shallowCopy(data2, result);
-               return result;
-           }
-
-           // summary:
-           // This is a facade for sending management requests to broker at given brokerURL specifying schema, host and port.
-           // Optional errorHandler method can be set and invoked on error responses.
-           function Management(brokerURL, errorHandler)
-           {
-               this.brokerURL = brokerURL;
-               this.errorHandler = errorHandler || function (error)
-                   {
-                       console.error(error);
-                   };
-           }
-
-           // summary:
-           // Submits HTTP request to broker using dojo.request.xhr
-           // request: Object?
-           //        request object can have the same fields as dojo.request.xhr options and  additional 'url' field:
-           //          data: String|Object|FormData?
-           //                Data to transfer. This is ignored for GET and DELETE requests.
-           //          headers: Object?
-           //              Headers to use for the request.
-           //          user: String?
-           //                Username to use during the request.
-           //          password: String?
-           //                Password to use during the request.
-           //          withCredentials: Boolean?
-           //                For cross-site requests, whether to send credentials or not.
-           //          query: Object?
-           //              the query parameters to add to the request url
-           //          handleAs: String
-           //                Indicates how the response will be handled.
-           //          url: String?
-           //              relative URL to broker REST API
-           //
-           // returns: promise of type dojo.promise.Promise
-           //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
-           Management.prototype.submit = function (request)
-           {
-               var requestOptions = {
-                   sync: false,
-                   handleAs: "json",
-                   withCredentials: true,
-                   headers: {"Content-Type": "application/json"}
-               };
-
-               if (request)
-               {
-                   shallowCopy(request, requestOptions, ["url"]);
-                   if (requestOptions.data && requestOptions.headers && requestOptions.headers["Content-Type"]
-                       && requestOptions.headers["Content-Type"] == "application/json" && typeof requestOptions.data
-                                                                                          != "string")
-                   {
-                       requestOptions.data = json.stringify(request.data);
-                   }
-               }
-
-               if (!requestOptions.method)
-               {
-                   requestOptions.method = "GET";
-               }
-
-               var url = this.getFullUrl(request.url);
-               var promise = xhr(url, requestOptions);
-               var errorHandler = this.errorHandler;
-
-               // decorate promise in order to use a default error handler when 'then' method is invoked without providing error handler
-               return lang.mixin(new Promise(), {
-                   then: function (callback, errback, progback)
-                   {
-                       return promise.then(callback, errback || errorHandler, progback);
-                   },
-                   cancel: function (reason, strict)
-                   {
-                       return promise.cancel(reason, strict);
-                   },
-                   isResolved: function ()
-                   {
-                       return promise.isResolved();
-                   },
-                   isRejected: function ()
-                   {
-                       return promise.isRejected();
-                   },
-                   isFulfilled: function ()
-                   {
-                       return promise.isFulfilled();
-                   },
-                   isCanceled: function ()
-                   {
-                       return promise.isCanceled();
-                   },
-                   always: function (callbackOrErrback)
-                   {
-                       return promise.always(callbackOrErrback);
-                   },
-                   otherwise: function (errback)
-                   {
-                       return promise.otherwise(errback);
-                   },
-                   trace: function ()
-                   {
-                       return promise.trace();
-                   },
-                   traceRejected: function ()
-                   {
-                       return promise.traceRejected();
-                   },
-                   toString: function ()
-                   {
-                       return promise.toString();
-                   },
-                   response: promise.response
-               });
-           };
-
-           Management.prototype.get = function (request)
-           {
-               var requestOptions = merge(request, {method: "GET"});
-               return this.submit(requestOptions);
-           };
-
-           Management.prototype.post = function (request, data)
-           {
-               var requestOptions = merge(request,
-                                          {
-                                              method: "POST",
-                                              data: data
-                                          });
-               return this.submit(requestOptions);
-           };
-
-           Management.prototype.del = function (request)
-           {
-               var requestOptions = merge(request, {method: "DELETE"});
-               return this.submit(requestOptions);
-           };
-
-           // summary:
-           //  Loads object data specified as modelObj argument
-           //   modelObj: Object?
-           //             is a JSON object specifying the hierarchy
-           //             It can have the following fields:
-           //               name: String?
-           //                     name of the object
-           //               type: String?
-           //                     category of the object
-           //               parent: Object?
-           //                     parent of the object in the same format, having fields name, type, parent
-           //
-           //   parameters: Object?
-           //               is optional JSON to pass additional request parameters which will be added into query of REST url
-           //
-           // returns: promise of type dojo.promise.Promise
-           //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
-           Management.prototype.load = function (modelObj, parameters, requestOptions)
-           {
-               var url = this.objectToURL(modelObj);
-               var request = {url: url};
-
-               if (requestOptions)
-               {
-                   lang.mixin(request, requestOptions);
-               }
-
-               if (parameters)
-               {
-                   request.query = parameters;
-               }
-               return this.get(request);
-           };
-
-           // summary:
-           //  Creates object as specified in data parameter with given category and with given parent parentModelObject
-           //   category: String?
-           //             Object category
-           //
-           //   parentModelObject: Object?
-           //              Parent object hierarchy
-           //              It can have the following fields:
-           //               name: String?
-           //                     name of the object
-           //               type: String?
-           //                     category of the object
-           //               parent: Object?
-           //                     parent of the object in the same format, having fields name, type, parent
-           //   data; Object?
-           //              Object structure
-           //
-           // returns: promise of type dojo.promise.Promise
-           //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
-           Management.prototype.create = function (category, parentModelObject, data)
-           {
-               var newObjectModel = {
-                   type: category.toLowerCase(),
-                   parent: parentModelObject
-               };
-               var url = this.objectToURL(newObjectModel);
-               var request = {url: url};
-               return this.post(request, data);
-           };
-
-           // summary:
-           //  Updates object (which can be located using modelObj parameter) attributes to the values set in data parameter
-           //
-           //   modelObj: Object?
-           //              Object specifying hierarchy
-           //              It can have the following fields:
-           //               name: String?
-           //                     name of the object
-           //               type: String?
-           //                     category of the object
-           //               parent: Object?
-           //                     parent of the object in the same format, having fields name, type, parent
-           //   data; Object?
-           //              New attributes
-           //
-           // returns: promise of type dojo.promise.Promise
-           //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
-           Management.prototype.update = function (modelObj, data)
-           {
-               var url = this.objectToURL(modelObj);
-               var request = {url: url};
-               return this.post(request, data);
-           };
-
-           // summary:
-           //  Removes object specified as modelObj argument
-           //   modelObj: Object?
-           //             hierarchy object
-           //             It can have the following fields:
-           //               name: String?
-           //                     name of the object
-           //               type: String?
-           //                     category of the object
-           //               parent: Object?
-           //                     parent of the object in the same format, having fields name, type, parent
-           //   parameters: Object?
-           //               is optional JSON object to pass additional request parameters which will be added into query of REST url
-           //
-           // returns: promise of type dojo.promise.Promise
-           //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
-           Management.prototype.remove = function (modelObj, parameters)
-           {
-               var url = this.objectToURL(modelObj);
-               var request = {url: url};
-               if (parameters)
-               {
-                   request.query = parameters;
-               }
-               return this.del(request);
-           };
-
-           // summary:
-           //  Downloads current JSON for object specified as modelObj argument
-           //
-           //   modelObj: Object?
-           //             hierarchy object
-           //             It can have the following fields:
-           //               name: String?
-           //                     name of the object
-           //               type: String?
-           //                     category of the object
-           //               parent: Object?
-           //                     parent of the object in the same format, having fields name, type, parent
-           //   parameters: Object?
-           //               is optional JSON object to pass additional request parameters  which will be added into query of REST url
-           //
-           Management.prototype.download = function (modelObj, parameters)
-           {
-               var url = this.buildObjectURL(modelObj, parameters);
-               setTimeout(function ()
-                          {
-                              window.location = url;
-                          }, 100);
-           }
-
-           // summary:
-           //  Downloads current JSON for object specified as modelObj argument into iframe
-           Management.prototype.downloadIntoFrame = function (modelObj, parameters)
-           {
-               var url = this.buildObjectURL(modelObj, parameters);
-               var iframe = document.createElement('iframe');
-               iframe.id = "downloader_" + modelObj.name;
-               document.body.appendChild(iframe);
-               iframe.src = url;
-               // It seems there is no way to remove this iframe in a manner that is cross browser compatible.
-           }
-
-           // summary:
-           //  Builds relative REST url (excluding schema, host and port) for the object representing CO hierarchy
-           //   modelObj: Object?
-           //             hierarchy object
-           //             It can have the following fields:
-           //               name: String?
-           //                     name of the object
-           //               type: String?
-           //                     category of the object
-           //               parent: Object?
-           //                     parent of the object in the same format, having fields name, type, parent
-           //   parameters: Object?
-           //             is optional JSON object to pass additional request parameters  which will be added into query of REST url
-           //
-           // returns: relative REST url for the hierarchy object
-           //
-           Management.prototype.objectToURL = function (modelObj)
-           {
-               var url = null;
-               if (modelObj.type == "broker")
-               {
-                   url = "broker"
-               }
-               else
-               {
-                   url = encodeURIComponent(modelObj.type);
-                   var parentPath = this.objectToPath(modelObj);
-                   if (parentPath)
-                   {
-                       url = url + "/" + parentPath;
-                   }
-
-                   if (modelObj.name)
-                   {
-                       if (url.substring(url.length - 1) != "/")
-                       {
-                           url = url + "/";
-                       }
-                       // Double encode the object name in case it contains slashes
-                       url = url + encodeURIComponent(encodeURIComponent(modelObj.name))
-                   }
-               }
-               return "api/latest/" + url;
-           };
-
-           // summary:
-           //  Builds a servlet path of REST url for the object representing CO hierarchy
-           //   modelObj: Object?
-           //             hierarchy object
-           //             It can have the following fields:
-           //               name: String?
-           //                     name of the object
-           //               type: String?
-           //                     category of the object
-           //               parent: Object?
-           //                     parent of the object in the same format, having fields name, type, parent
-           //   parameters: Object?
-           //             is optional JSON object to pass additional request parameters  which will be added into query of REST url
-           //
-           // returns: relative REST servlet path for the hierarchy object
-           //
-           Management.prototype.objectToPath = function (modelObj)
-           {
-               var path = "";
-               var parent = modelObj.parent;
-               while (parent && parent.type != "broker")
-               {
-                   if (path)
-                   {
-                       path = encodeURIComponent(encodeURIComponent(parent.name)) + "/" + path;
-                   }
-                   else
-                   {
-                       path = encodeURIComponent(encodeURIComponent(parent.name));
-                   }
-                   parent = parent.parent;
-               }
-               return path;
-           };
-
-           // summary:
-           //  Builds full REST url for the object representing CO hierarchy
-           //   modelObj: Object?
-           //             hierarchy object
-           //             It can have the following fields:
-           //               name: String?
-           //                     name of the object
-           //               type: String?
-           //                     category of the object
-           //               parent: Object?
-           //                     parent of the object in the same format, having fields name, type, parent
-           //   parameters: Object?
-           //             is optional JSON object to pass additional request parameters  which will be added into query of REST url
-           //
-           // returns: full REST url for the hierarchy object
-           //
-           Management.prototype.buildObjectURL = function (modelObj, parameters)
-           {
-               var url = this.objectToURL(modelObj);
-               if (parameters)
-               {
-                   url = url + "?" + ioQuery.objectToQuery(parameters);
-               }
-               return this.getFullUrl(url);
-           }
-
-           // summary:
-           //  Returns full REST url for the relative REST url
-           //
-           // returns: full urk for the given relative URL
-           //
-           Management.prototype.getFullUrl = function (url)
-           {
-               var baseUrl = this.brokerURL || "";
-               if (baseUrl != "")
-               {
-                   baseUrl = baseUrl + "/";
-               }
-               return baseUrl + url;
-           }
-
-           // summary:
-           //  Loads meta data, time zones, user preferences and invokes callback functions after loading user preferences
-           //
-           Management.prototype.init = function (callback)
-           {
-               var that = this;
-               this.loadMetadata(function ()
-                                 {
-                                     that.loadTimezones(function ()
-                                                        {
-                                                            that.loadUserPreferences(callback)
-                                                        });
-                                 });
-           };
-
-           // summary:
-           //  Loads meta data and store it under 'metadata' field as object of type qpid.common.metadata object.
-           //  When meta data are loaded successfully a callback function is executed, otherwise default error handler is invoked
-           //
-           Management.prototype.loadMetadata = function (callback)
-           {
-               var that = this;
-               this.get({url: "service/metadata"}).then(function (data)
-                                                        {
-                                                            that.metadata = new Metadata(data);
-                                                            if (callback)
-                                                            {
-                                                                callback();
-                                                            }
-                                                        });
-           };
-
-           // summary:
-           //  Loads timezones and store them under 'timezone' field as  object of type qpid.common.timezone object
-           //  When timezones are loaded successfully a callback function is executed, otherwise default error handler is invoked
-           //
-           Management.prototype.loadTimezones = function (callback)
-           {
-               var that = this;
-               that.get({url: "service/timezones"}).then(function (timezones)
-                                                         {
-                                                             that.timezone = new Timezone(timezones);
-                                                             if (callback)
-                                                             {
-                                                                 callback();
-                                                             }
-                                                         });
-           };
-
-           // summary:
-           //  Loads user preferences and store them under 'userPreferences' field as object of type qpid.management.UserPreferences
-           //  Callback is invoked on both successful and unsuccessful preferences request
-           //
-           Management.prototype.loadUserPreferences = function (callback)
-           {
-               this.userPreferences = new UserPreferences(this);
-               this.userPreferences.load(callback, callback);
-           };
-
-           var saslServiceUrl = "service/sasl";
-
-           Management.prototype.getSaslStatus = function ()
-           {
-               return this.get({url: saslServiceUrl});
-           }
-
-           Management.prototype.sendSaslResponse = function (response)
-           {
-               return this.submit({
-                                      url: saslServiceUrl,
-                                      data: response,
-                                      headers: {},
-                                      method: "POST"
-                                  });
-           };
-
-           Management.prototype.authenticate = function (forceAuthentication)
-           {
-               var that = this;
-               var deferred = new Deferred();
-               var successCallback = function (data)
-               {
-                   that.getSaslStatus().then(function (saslData)
-                                             {
-                                                 if (saslData.user)
-                                                 {
-                                                     deferred.resolve(saslData);
-                                                 }
-                                                 else
-                                                 {
-                                                     deferred.reject({
-                                                                         message: "User identifier is not found!"
-                                                                                  + " Authentication failed!"
-                                                                     });
-                                                 }
-                                             }, failureCallback);
-               };
-               var failureCallback = function (data)
-               {
-                   deferred.reject(data);
-               };
-               this.getSaslStatus().then(function (data)
-                                         {
-                                             if (data.user && !forceAuthentication)
-                                             {
-                                                 deferred.resolve(data);
-                                             }
-                                             else
-                                             {
-                                                 sasl.authenticate(data.mechanisms, that)
-                                                     .then(successCallback, failureCallback);
-                                             }
-                                         }, failureCallback);
-               return deferred.promise;
-           };
-
-           // summary:
-           //   Sends query request
-           //   query: query Object?
-           //             is a JSON object specifying the hierarchy
-           //             It can have the following fields:
-           //               where: String?
-           //                     sql like expression containing 'where' conditions
-           //               select: String?
-           //                     coma separated list of fields to select
-           //               category: String?
-           //                     category of the object
-           //               parent: Object?
-           //                     hierarchy object defining query scope,
-           //                     if not set queries will be executed against broker.
-           //                     Virtual host query scope can be defined by setting parent
-           //                     into corresponding object representing a virtual host hierarchy
-           //
-           // returns: promise of type dojo.promise.Promise
-           //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
-           Management.prototype.query = function (query)
-           {
-               var url = "api/latest/" + (query.parent && query.parent.type === "virtualhost" ? "queryvhost/"
-                         + this.objectToPath({parent: query.parent}) : "querybroker") + (query.category ? "/"
-                         + query.category : "");
-               var request = {
-                   url: this.getFullUrl(url),
-                   query: {}
-               };
-               shallowCopy(query, request.query, ["parent", "category"]);
-               return this.get(request);
-           };
+        function shallowCopy(source, target, excludes)
+        {
+            if (source)
+            {
+                for (var fieldName in source)
+                {
+                    if (source.hasOwnProperty(fieldName))
+                    {
+                        if (excludes && array.indexOf(excludes, fieldName) != -1)
+                        {
+                            continue;
+                        }
+
+                        target[fieldName] = source[fieldName];
+                    }
+                }
+            }
+            return target;
+        }
+
+        function merge(data1, data2)
+        {
+            var result = {};
+            shallowCopy(data1, result);
+            shallowCopy(data2, result);
+            return result;
+        }
+
+        // summary:
+        // This is a facade for sending management requests to broker at given brokerURL specifying schema, host and port.
+        // Optional errorHandler method can be set and invoked on error responses.
+        function Management(brokerURL, errorHandler)
+        {
+            this.brokerURL = brokerURL;
+            this.errorHandler = errorHandler || function (error)
+                {
+                    console.error(error);
+                };
+        }
+
+        // summary:
+        // Submits HTTP request to broker using dojo.request.xhr
+        // request: Object?
+        //        request object can have the same fields as dojo.request.xhr options and  additional 'url' field:
+        //          data: String|Object|FormData?
+        //                Data to transfer. This is ignored for GET and DELETE requests.
+        //          headers: Object?
+        //              Headers to use for the request.
+        //          user: String?
+        //                Username to use during the request.
+        //          password: String?
+        //                Password to use during the request.
+        //          withCredentials: Boolean?
+        //                For cross-site requests, whether to send credentials or not.
+        //          query: Object?
+        //              the query parameters to add to the request url
+        //          handleAs: String
+        //                Indicates how the response will be handled.
+        //          url: String?
+        //              relative URL to broker REST API
+        //
+        // returns: promise of type dojo.promise.Promise
+        //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
+        Management.prototype.submit = function (request)
+        {
+            var requestOptions = {
+                sync: false,
+                handleAs: "json",
+                withCredentials: true,
+                headers: {"Content-Type": "application/json"}
+            };
+
+            if (request)
+            {
+                shallowCopy(request, requestOptions, ["url"]);
+                if (requestOptions.data && requestOptions.headers && requestOptions.headers["Content-Type"]
+                    && requestOptions.headers["Content-Type"] == "application/json" && typeof requestOptions.data
+                                                                                       != "string")
+                {
+                    requestOptions.data = json.stringify(request.data);
+                }
+            }
+
+            if (!requestOptions.method)
+            {
+                requestOptions.method = "GET";
+            }
+
+            var url = this.getFullUrl(request.url);
+            var promise = xhr(url, requestOptions);
+            var errorHandler = this.errorHandler;
+
+            // decorate promise in order to use a default error handler when 'then' method is invoked without providing error handler
+            return lang.mixin(new Promise(), {
+                then: function (callback, errback, progback)
+                {
+                    return promise.then(callback, errback || errorHandler, progback);
+                },
+                cancel: function (reason, strict)
+                {
+                    return promise.cancel(reason, strict);
+                },
+                isResolved: function ()
+                {
+                    return promise.isResolved();
+                },
+                isRejected: function ()
+                {
+                    return promise.isRejected();
+                },
+                isFulfilled: function ()
+                {
+                    return promise.isFulfilled();
+                },
+                isCanceled: function ()
+                {
+                    return promise.isCanceled();
+                },
+                always: function (callbackOrErrback)
+                {
+                    return promise.always(callbackOrErrback);
+                },
+                otherwise: function (errback)
+                {
+                    return promise.otherwise(errback);
+                },
+                trace: function ()
+                {
+                    return promise.trace();
+                },
+                traceRejected: function ()
+                {
+                    return promise.traceRejected();
+                },
+                toString: function ()
+                {
+                    return promise.toString();
+                },
+                response: promise.response
+            });
+        };
+
+        Management.prototype.get = function (request)
+        {
+            var requestOptions = merge(request, {method: "GET"});
+            return this.submit(requestOptions);
+        };
+
+        Management.prototype.post = function (request, data)
+        {
+            var requestOptions = merge(request, {
+                method: "POST",
+                data: data
+            });
+            return this.submit(requestOptions);
+        };
+
+        Management.prototype.del = function (request)
+        {
+            var requestOptions = merge(request, {method: "DELETE"});
+            return this.submit(requestOptions);
+        };
+
+        // summary:
+        //  Loads object data specified as modelObj argument
+        //   modelObj: Object?
+        //             is a JSON object specifying the hierarchy
+        //             It can have the following fields:
+        //               name: String?
+        //                     name of the object
+        //               type: String?
+        //                     category of the object
+        //               parent: Object?
+        //                     parent of the object in the same format, having fields name, type, parent
+        //
+        //   parameters: Object?
+        //               is optional JSON to pass additional request parameters which will be added into query of REST url
+        //
+        // returns: promise of type dojo.promise.Promise
+        //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
+        Management.prototype.load = function (modelObj, parameters, requestOptions)
+        {
+            var url = this.objectToURL(modelObj);
+            var request = {url: url};
+
+            if (requestOptions)
+            {
+                lang.mixin(request, requestOptions);
+            }
+
+            if (parameters)
+            {
+                request.query = parameters;
+            }
+            return this.get(request);
+        };
+
+        // summary:
+        //  Creates object as specified in data parameter with given category and with given parent parentModelObject
+        //   category: String?
+        //             Object category
+        //
+        //   parentModelObject: Object?
+        //              Parent object hierarchy
+        //              It can have the following fields:
+        //               name: String?
+        //                     name of the object
+        //               type: String?
+        //                     category of the object
+        //               parent: Object?
+        //                     parent of the object in the same format, having fields name, type, parent
+        //   data; Object?
+        //              Object structure
+        //
+        // returns: promise of type dojo.promise.Promise
+        //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
+        Management.prototype.create = function (category, parentModelObject, data)
+        {
+            var newObjectModel = {
+                type: category.toLowerCase(),
+                parent: parentModelObject
+            };
+            var url = this.objectToURL(newObjectModel);
+            var request = {url: url};
+            return this.post(request, data);
+        };
+
+        // summary:
+        //  Updates object (which can be located using modelObj parameter) attributes to the values set in data parameter
+        //
+        //   modelObj: Object?
+        //              Object specifying hierarchy
+        //              It can have the following fields:
+        //               name: String?
+        //                     name of the object
+        //               type: String?
+        //                     category of the object
+        //               parent: Object?
+        //                     parent of the object in the same format, having fields name, type, parent
+        //   data; Object?
+        //              New attributes
+        //
+        // returns: promise of type dojo.promise.Promise
+        //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
+        Management.prototype.update = function (modelObj, data)
+        {
+            var url = this.objectToURL(modelObj);
+            var request = {url: url};
+            return this.post(request, data);
+        };
+
+        // summary:
+        //  Removes object specified as modelObj argument
+        //   modelObj: Object?
+        //             hierarchy object
+        //             It can have the following fields:
+        //               name: String?
+        //                     name of the object
+        //               type: String?
+        //                     category of the object
+        //               parent: Object?
+        //                     parent of the object in the same format, having fields name, type, parent
+        //   parameters: Object?
+        //               is optional JSON object to pass additional request parameters which will be added into query of REST url
+        //
+        // returns: promise of type dojo.promise.Promise
+        //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
+        Management.prototype.remove = function (modelObj, parameters)
+        {
+            var url = this.objectToURL(modelObj);
+            var request = {url: url};
+            if (parameters)
+            {
+                request.query = parameters;
+            }
+            return this.del(request);
+        };
+
+        // summary:
+        //  Downloads current JSON for object specified as modelObj argument
+        //
+        //   modelObj: Object?
+        //             hierarchy object
+        //             It can have the following fields:
+        //               name: String?
+        //                     name of the object
+        //               type: String?
+        //                     category of the object
+        //               parent: Object?
+        //                     parent of the object in the same format, having fields name, type, parent
+        //   parameters: Object?
+        //               is optional JSON object to pass additional request parameters  which will be added into query of REST url
+        //
+        Management.prototype.download = function (modelObj, parameters)
+        {
+            var url = this.buildObjectURL(modelObj, parameters);
+            setTimeout(function ()
+            {
+                window.location = url;
+            }, 100);
+        }
+
+        // summary:
+        //  Downloads current JSON for object specified as modelObj argument into iframe
+        Management.prototype.downloadIntoFrame = function (modelObj, parameters)
+        {
+            var url = this.buildObjectURL(modelObj, parameters);
+            var iframe = document.createElement('iframe');
+            iframe.id = "downloader_" + modelObj.name;
+            document.body.appendChild(iframe);
+            iframe.src = url;
+            // It seems there is no way to remove this iframe in a manner that is cross browser compatible.
+        }
+
+        // summary:
+        //  Builds relative REST url (excluding schema, host and port) for the object representing CO hierarchy
+        //   modelObj: Object?
+        //             hierarchy object
+        //             It can have the following fields:
+        //               name: String?
+        //                     name of the object
+        //               type: String?
+        //                     category of the object
+        //               parent: Object?
+        //                     parent of the object in the same format, having fields name, type, parent
+        //   parameters: Object?
+        //             is optional JSON object to pass additional request parameters  which will be added into query of REST url
+        //
+        // returns: relative REST url for the hierarchy object
+        //
+        Management.prototype.objectToURL = function (modelObj)
+        {
+            var url = null;
+            if (modelObj.type == "broker")
+            {
+                url = "broker"
+            }
+            else
+            {
+                url = encodeURIComponent(modelObj.type);
+                var parentPath = this.objectToPath(modelObj);
+                if (parentPath)
+                {
+                    url = url + "/" + parentPath;
+                }
+
+                if (modelObj.name)
+                {
+                    if (url.substring(url.length - 1) != "/")
+                    {
+                        url = url + "/";
+                    }
+                    // Double encode the object name in case it contains slashes
+                    url = url + encodeURIComponent(encodeURIComponent(modelObj.name))
+                }
+            }
+            return "api/latest/" + url;
+        };
+
+        // summary:
+        //  Builds a servlet path of REST url for the object representing CO hierarchy
+        //   modelObj: Object?
+        //             hierarchy object
+        //             It can have the following fields:
+        //               name: String?
+        //                     name of the object
+        //               type: String?
+        //                     category of the object
+        //               parent: Object?
+        //                     parent of the object in the same format, having fields name, type, parent
+        //   parameters: Object?
+        //             is optional JSON object to pass additional request parameters  which will be added into query of REST url
+        //
+        // returns: relative REST servlet path for the hierarchy object
+        //
+        Management.prototype.objectToPath = function (modelObj)
+        {
+            var path = "";
+            var parent = modelObj.parent;
+            while (parent && parent.type != "broker")
+            {
+                if (path)
+                {
+                    path = encodeURIComponent(encodeURIComponent(parent.name)) + "/" + path;
+                }
+                else
+                {
+                    path = encodeURIComponent(encodeURIComponent(parent.name));
+                }
+                parent = parent.parent;
+            }
+            return path;
+        };
+
+        // summary:
+        //  Builds full REST url for the object representing CO hierarchy
+        //   modelObj: Object?
+        //             hierarchy object
+        //             It can have the following fields:
+        //               name: String?
+        //                     name of the object
+        //               type: String?
+        //                     category of the object
+        //               parent: Object?
+        //                     parent of the object in the same format, having fields name, type, parent
+        //   parameters: Object?
+        //             is optional JSON object to pass additional request parameters  which will be added into query of REST url
+        //
+        // returns: full REST url for the hierarchy object
+        //
+        Management.prototype.buildObjectURL = function (modelObj, parameters)
+        {
+            var url = this.objectToURL(modelObj);
+            if (parameters)
+            {
+                url = url + "?" + ioQuery.objectToQuery(parameters);
+            }
+            return this.getFullUrl(url);
+        }
+
+        // summary:
+        //  Returns full REST url for the relative REST url
+        //
+        // returns: full urk for the given relative URL
+        //
+        Management.prototype.getFullUrl = function (url)
+        {
+            var baseUrl = this.brokerURL || "";
+            if (baseUrl != "")
+            {
+                baseUrl = baseUrl + "/";
+            }
+            return baseUrl + url;
+        }
+
+        // summary:
+        //  Loads meta data, time zones, user preferences and invokes callback functions after loading user preferences
+        //
+        Management.prototype.init = function (callback)
+        {
+            var that = this;
+            this.loadMetadata(function ()
+            {
+                that.loadTimezones(function ()
+                {
+                    that.loadUserPreferences(callback)
+                });
+            });
+        };
+
+        // summary:
+        //  Loads meta data and store it under 'metadata' field as object of type qpid.common.metadata object.
+        //  When meta data are loaded successfully a callback function is executed, otherwise default error handler is invoked
+        //
+        Management.prototype.loadMetadata = function (callback)
+        {
+            var that = this;
+            this.get({url: "service/metadata"})
+                .then(function (data)
+                {
+                    that.metadata = new Metadata(data);
+                    if (callback)
+                    {
+                        callback();
+                    }
+                });
+        };
+
+        // summary:
+        //  Loads timezones and store them under 'timezone' field as  object of type qpid.common.timezone object
+        //  When timezones are loaded successfully a callback function is executed, otherwise default error handler is invoked
+        //
+        Management.prototype.loadTimezones = function (callback)
+        {
+            var that = this;
+            that.get({url: "service/timezones"})
+                .then(function (timezones)
+                {
+                    that.timezone = new Timezone(timezones);
+                    if (callback)
+                    {
+                        callback();
+                    }
+                });
+        };
+
+        // summary:
+        //  Loads user preferences and store them under 'userPreferences' field as object of type qpid.management.UserPreferences
+        //  Callback is invoked on both successful and unsuccessful preferences request
+        //
+        Management.prototype.loadUserPreferences = function (callback)
+        {
+            this.userPreferences = new UserPreferences(this);
+            this.userPreferences.load(callback, callback);
+        };
+
+        var saslServiceUrl = "service/sasl";
+
+        Management.prototype.getSaslStatus = function ()
+        {
+            return this.get({url: saslServiceUrl});
+        }
+
+        Management.prototype.sendSaslResponse = function (response)
+        {
+            return this.submit({
+                url: saslServiceUrl,
+                data: response,
+                headers: {},
+                method: "POST"
+            });
+        };
+
+        Management.prototype.authenticate = function (forceAuthentication)
+        {
+            var that = this;
+            var deferred = new Deferred();
+            var successCallback = function (data)
+            {
+                that.getSaslStatus()
+                    .then(function (saslData)
+                    {
+                        if (saslData.user)
+                        {
+                            deferred.resolve(saslData);
+                        }
+                        else
+                        {
+                            deferred.reject({
+                                message: "User identifier is not found!" + " Authentication failed!"
+                            });
+                        }
+                    }, failureCallback);
+            };
+            var failureCallback = function (data)
+            {
+                deferred.reject(data);
+            };
+            this.getSaslStatus()
+                .then(function (data)
+                {
+                    if (data.user && !forceAuthentication)
+                    {
+                        deferred.resolve(data);
+                    }
+                    else
+                    {
+                        sasl.authenticate(data.mechanisms, that)
+                            .then(successCallback, failureCallback);
+                    }
+                }, failureCallback);
+            return deferred.promise;
+        };
+
+        // summary:
+        //   Sends query request
+        //   query: query Object?
+        //             is a JSON object specifying the hierarchy
+        //             It can have the following fields:
+        //               where: String?
+        //                     sql like expression containing 'where' conditions
+        //               select: String?
+        //                     coma separated list of fields to select
+        //               category: String?
+        //                     category of the object
+        //               parent: Object?
+        //                     hierarchy object defining query scope,
+        //                     if not set queries will be executed against broker.
+        //                     Virtual host query scope can be defined by setting parent
+        //                     into corresponding object representing a virtual host hierarchy
+        //
+        // returns: promise of type dojo.promise.Promise
+        //      Promise returned by dojo.request.xhr with modified then method allowing to use default error handler if none is specified.
+        Management.prototype.query = function (query)
+        {
+            var url = "api/latest/" + (query.parent && query.parent.type === "virtualhost" ? "queryvhost/"
+                      + this.objectToPath({parent: query.parent}) : "querybroker") + (query.category ? "/"
+                      + query.category : "");
+            var request = {
+                url: this.getFullUrl(url),
+                query: {}
+            };
+            shallowCopy(query, request.query, ["parent", "category"]);
+            return this.get(request);
+        };
 
-           return Management;
-       });
+        return Management;
+    });

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Plugin.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Plugin.js?rev=1741993&r1=1741992&r2=1741993&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Plugin.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Plugin.js Mon May  2 15:57:52 2016
@@ -29,77 +29,77 @@ define(["dojo/parser",
         "dojox/html/entities",
         "dojo/text!showPlugin.html",
         "dojo/domReady!"],
-       function (parser, query, connect, properties, updater, util, registry, event, entities, template)
-       {
+    function (parser, query, connect, properties, updater, util, registry, event, entities, template)
+    {
 
-           function Plugin(name, parent, controller)
-           {
-               this.name = name;
-               this.controller = controller;
-               this.management = controller.management;
-               this.modelObj = {
-                   type: "plugin",
-                   name: name,
-                   parent: parent
-               };
-           }
-
-           Plugin.prototype.getTitle = function ()
-           {
-               return "Plugin: " + this.name;
-           };
-
-           Plugin.prototype.open = function (contentPane)
-           {
-               var that = this;
-               this.contentPane = contentPane;
-               contentPane.containerNode.innerHTML = template;
-               parser.parse(contentPane.containerNode).then(function (instances)
-                                                            {
-                                                                that.pluginUpdater =
-                                                                    new PluginUpdater(contentPane, that.modelObj, that.controller);
-                                                            });
-           };
-
-           Plugin.prototype.close = function ()
-           {
-               updater.remove(this.pluginUpdater);
-           };
-
-           function PluginUpdater(contentPane, pluginObject, controller)
-           {
-               this.controller = controller;
-               this.modelObj = pluginObject;
-               this.management = controller.management;
-               var node = contentPane.containerNode;
-               this.name = query(".name", node)[0];
-               this.type = query(".type", node)[0];
-
-               var that = this;
-
-               this.management.load(that.modelObj)
-                   .then(function (data)
-                         {
-                             that.pluginData = data[0];
-
-                             that.updateHeader();
-
-                             require(["qpid/management/plugin/" + that.pluginData.type.toLowerCase().replace('-', '')],
-                                     function (SpecificPlugin)
-                                     {
-                                         that.details = new SpecificPlugin(query(".pluginDetails",
-                                                                                 node)[0], pluginObject, controller, contentPane);
-                                     });
-
-                         }, util.xhrErrorHandler);
-
-           }
-
-           PluginUpdater.prototype.updateHeader = function ()
-           {
-               this.name.innerHTML = entities.encode(String(this.pluginData["name"]));
-               this.type.innerHTML = entities.encode(String(this.pluginData["type"]));
-           };
+        function Plugin(name, parent, controller)
+        {
+            this.name = name;
+            this.controller = controller;
+            this.management = controller.management;
+            this.modelObj = {
+                type: "plugin",
+                name: name,
+                parent: parent
+            };
+        }
+
+        Plugin.prototype.getTitle = function ()
+        {
+            return "Plugin: " + this.name;
+        };
+
+        Plugin.prototype.open = function (contentPane)
+        {
+            var that = this;
+            this.contentPane = contentPane;
+            contentPane.containerNode.innerHTML = template;
+            parser.parse(contentPane.containerNode)
+                .then(function (instances)
+                {
+                    that.pluginUpdater = new PluginUpdater(contentPane, that.modelObj, that.controller);
+                });
+        };
+
+        Plugin.prototype.close = function ()
+        {
+            updater.remove(this.pluginUpdater);
+        };
+
+        function PluginUpdater(contentPane, pluginObject, controller)
+        {
+            this.controller = controller;
+            this.modelObj = pluginObject;
+            this.management = controller.management;
+            var node = contentPane.containerNode;
+            this.name = query(".name", node)[0];
+            this.type = query(".type", node)[0];
+
+            var that = this;
+
+            this.management.load(that.modelObj)
+                .then(function (data)
+                {
+                    that.pluginData = data[0];
+
+                    that.updateHeader();
+
+                    require(["qpid/management/plugin/" + that.pluginData.type.toLowerCase()
+                        .replace('-', '')], function (SpecificPlugin)
+                    {
+                        that.details =
+                            new SpecificPlugin(query(".pluginDetails", node)[0], pluginObject, controller, contentPane);
+                    });
+
+                }, util.xhrErrorHandler);
+
+        }
+
+        PluginUpdater.prototype.updateHeader = function ()
+        {
+            this.name.innerHTML = entities.encode(String(this.pluginData["name"]));
+            this.type.innerHTML = entities.encode(String(this.pluginData["type"]));
+        };
 
-           return Plugin;
-       });
+        return Plugin;
+    });

Modified: qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js?rev=1741993&r1=1741992&r2=1741993&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js (original)
+++ qpid/java/trunk/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Port.js Mon May  2 15:57:52 2016
@@ -31,273 +31,270 @@ define(["dojo/dom",
         "qpid/management/addPort",
         "dojo/text!showPort.html",
         "dojo/domReady!"],
-       function (dom, parser, query, connect, registry, entities, properties, updater, util, formatter, addPort, template)
-       {
+    function (dom, parser, query, connect, registry, entities, properties, updater, util, formatter, addPort, template)
+    {
 
-           function Port(name, parent, controller)
-           {
-               this.name = name;
-               this.controller = controller;
-               this.management = controller.management;
-               this.modelObj = {
-                   type: "port",
-                   name: name,
-                   parent: parent
-               };
-           }
-
-           Port.prototype.getTitle = function ()
-           {
-               return "Port: " + this.name;
-           };
-
-           Port.prototype.open = function (contentPane)
-           {
-               var that = this;
-               this.contentPane = contentPane;
-
-               contentPane.containerNode.innerHTML = template;
-               parser.parse(contentPane.containerNode).then(function (instances)
-                                                            {
-                                                                that.portUpdater = new PortUpdater(that);
-
-                                                                var deletePortButton = query(".deletePortButton",
-                                                                                             contentPane.containerNode)[0];
-                                                                var node = registry.byNode(deletePortButton);
-                                                                connect.connect(node, "onClick", function (evt)
-                                                                {
-                                                                    that.deletePort();
-                                                                });
-
-                                                                var editPortButton = query(".editPortButton",
-                                                                                           contentPane.containerNode)[0];
-                                                                var node = registry.byNode(editPortButton);
-                                                                connect.connect(node, "onClick", function (evt)
-                                                                {
-                                                                    that.showEditDialog();
-                                                                });
-
-                                                                that.portUpdater.update(function ()
-                                                                                        {
-                                                                                            updater.add(that.portUpdater);
-                                                                                        });
-                                                            });
-           };
-
-           Port.prototype.close = function ()
-           {
-               updater.remove(this.portUpdater);
-           };
-
-           Port.prototype.deletePort = function ()
-           {
-               if (confirm("Are you sure you want to delete port '" + entities.encode(this.name) + "'?"))
-               {
-                   var that = this;
-                   this.management.remove(this.modelObj).then(function (data)
-                                                              {
-                                                                  that.contentPane.onClose()
-                                                                  that.controller.tabContainer.removeChild(that.contentPane);
-                                                                  that.contentPane.destroyRecursive();
-                                                                  that.close();
-                                                              }, util.xhrErrorHandler);
-               }
-           }
-
-           Port.prototype.showEditDialog = function ()
-           {
-               var that = this;
-               this.management.load(that.modelObj.parent)
-                   .then(function (data)
-                         {
-                             var brokerData = data[0];
-                             addPort.show(that.management,
-                                          that.modelObj,
-                                          that.portUpdater.portData.type,
-                                          brokerData.authenticationproviders,
-                                          brokerData.keystores,
-                                          brokerData.truststores);
-                         }, util.xhrErrorHandler);
-           }
-
-           function PortUpdater(portTab)
-           {
-               var that = this;
-               this.tabObject = portTab;
-               this.management = portTab.controller.management;
-               this.modelObj = portTab.modelObj;
-               var containerNode = portTab.contentPane.containerNode;
-
-               function findNode(name)
-               {
-                   return query("." + name, containerNode)[0];
-               }
-
-               function storeNodes(names)
-               {
-                   for (var i = 0; i < names.length; i++)
-                   {
-                       that[names[i]] = findNode(names[i]);
-                   }
-               }
-
-               storeNodes(["nameValue",
-                           "stateValue",
-                           "typeValue",
-                           "portValue",
-                           "authenticationProviderValue",
-                           "protocolsValue",
-                           "transportsValue",
-                           "bindingAddressValue",
-                           "keyStoreValue",
-                           "needClientAuthValue",
-                           "wantClientAuthValue",
-                           "trustStoresValue",
-                           "connectionCountValue",
-                           "maxOpenConnectionsValue",
-                           "authenticationProvider",
-                           "bindingAddress",
-                           "keyStore",
-                           "needClientAuth",
-                           "wantClientAuth",
-                           "clientCertRecorderValue",
-                           "trustStores",
-                           "maxOpenConnections",
-                           "threadPoolMinimum",
-                           "threadPoolMaximum",
-                           "threadPoolSize",
-                           "threadPoolMinimumValue",
-                           "threadPoolMaximumValue",
-                           "threadPoolSizeValue",
-                           "portTypeSpecificDetails",
-                           "portAttributes"]);
-           }
-
-           PortUpdater.prototype.updateHeader = function ()
-           {
-               function printArray(fieldName, object)
-               {
-                   var array = object[fieldName];
-                   var data = "<div>";
-                   if (array)
-                   {
-                       for (var i = 0; i < array.length; i++)
-                       {
-                           data += "<div>" + entities.encode(array[i]) + "</div>";
-                       }
-                   }
-                   return data + "</div>";
-               }
-
-               this.nameValue.innerHTML = entities.encode(String(this.portData["name"]));
-               this.stateValue.innerHTML = entities.encode(String(this.portData["state"]));
-               this.typeValue.innerHTML = entities.encode(String(this.portData["type"]));
-               this.portValue.innerHTML = entities.encode(String(this.portData["port"]));
-               this.authenticationProviderValue.innerHTML = this.portData["authenticationProvider"]
-                   ? entities.encode(String(this.portData["authenticationProvider"]))
-                   : "";
-               this.protocolsValue.innerHTML = printArray("protocols", this.portData);
-               this.transportsValue.innerHTML = printArray("transports", this.portData);
-               this.bindingAddressValue.innerHTML =
-                   this.portData["bindingAddress"] ? entities.encode(String(this.portData["bindingAddress"])) : "";
-               this.connectionCountValue.innerHTML =
-                   this.portData["connectionCount"] ? entities.encode(String(this.portData["connectionCount"])) : "0";
-               this.maxOpenConnectionsValue.innerHTML =
-                   (this.portData["maxOpenConnections"] && this.portData["maxOpenConnections"] >= 0) ? entities.encode(
-                       String(this.portData["maxOpenConnections"])) : "(no limit)";
-               this.threadPoolMinimumValue.innerHTML =
-                   entities.encode(String(this.portData["threadPoolMinimum"] || ""));
-               this.threadPoolMaximumValue.innerHTML =
-                   entities.encode(String(this.portData["threadPoolMaximum"] || ""));
-               this.threadPoolSizeValue.innerHTML = entities.encode(String(this.portData["threadPoolSize"] || ""));
-
-               this.keyStoreValue.innerHTML =
-                   this.portData["keyStore"] ? entities.encode(String(this.portData["keyStore"])) : "";
-               this.needClientAuthValue.innerHTML =
-                   "<input type='checkbox' disabled='disabled' " + (this.portData["needClientAuth"]
-                       ? "checked='checked'"
-                       : "") + " />";
-               this.wantClientAuthValue.innerHTML =
-                   "<input type='checkbox' disabled='disabled' " + (this.portData["wantClientAuth"]
-                       ? "checked='checked'"
-                       : "") + " />";
-               this.trustStoresValue.innerHTML = printArray("trustStores", this.portData);
-               this.clientCertRecorderValue.innerHTML = this.portData["clientCertRecorder"]
-                   ? entities.encode(String(this.portData["clientCertRecorder"]))
-                   : "";
-
-               var typeMetaData = this.management.metadata.getMetaData("Port", this.portData["type"]);
-
-               this.authenticationProvider.style.display =
-                   "authenticationProvider" in typeMetaData.attributes ? "block" : "none";
-               this.bindingAddress.style.display = "bindingAddress" in typeMetaData.attributes ? "block" : "none";
-               this.keyStore.style.display = "keyStore" in typeMetaData.attributes ? "block" : "none";
-               this.needClientAuth.style.display = "needClientAuth" in typeMetaData.attributes ? "block" : "none";
-               this.wantClientAuth.style.display = "wantClientAuth" in typeMetaData.attributes ? "block" : "none";
-               this.trustStores.style.display = "trustStores" in typeMetaData.attributes ? "block" : "none";
-
-               var hasThreadPoolMinMaxSettings = "threadPoolMaximum" in typeMetaData.attributes;
-               this.threadPoolMinimum.style.display = hasThreadPoolMinMaxSettings ? "block" : "none";
-               this.threadPoolMaximum.style.display = hasThreadPoolMinMaxSettings ? "block" : "none";
-
-               var hasThreadPoolSizeSettings = "threadPoolSize" in typeMetaData.attributes;
-               this.threadPoolSize.style.display = hasThreadPoolSizeSettings ? "block" : "none";
-
-               this.maxOpenConnections.style.display =
-                   "maxOpenConnections" in typeMetaData.attributes ? "block" : "none";
-
-           };
-
-           PortUpdater.prototype.update = function (callback)
-           {
-
-               var thisObj = this;
-
-               this.management.load(this.modelObj).then(function (data)
-                                                        {
-                                                            thisObj.portData = data[0] || {};
-                                                            thisObj.updateUI(thisObj.portData);
-                                                            util.flattenStatistics(thisObj.portData);
-                                                            if (callback)
-                                                            {
-                                                                callback();
-                                                            }
-                                                            thisObj.updateHeader();
-                                                        }, function (error)
-                                                        {
-                                                            util.tabErrorHandler(error, {
-                                                                updater: thisObj,
-                                                                contentPane: thisObj.tabObject.contentPane,
-                                                                tabContainer: thisObj.tabObject.controller.tabContainer,
-                                                                name: thisObj.modelObj.name,
-                                                                category: "Port"
-                                                            });
-                                                        });
-           };
-
-           PortUpdater.prototype.updateUI = function (data)
-           {
-               if (!this.details)
-               {
-                   var that = this;
-                   require(["qpid/management/port/" + data.type.toLowerCase() + "/show"], function (Details)
-                   {
-                       that.details = new Details({
-                           containerNode: that.portAttributes,
-                           typeSpecificDetailsNode: that.portTypeSpecificDetails,
-                           metadata: that.tabObject.management.metadata,
-                           data: data,
-                           management: that.tabObject.management,
-                           modelObj: that.tabObject.modelObj,
-                           portUpdater: that.portUpdater
-                       });
-                   });
-               }
-               else
-               {
-                   this.details.update(data);
-               }
-           }
+        function Port(name, parent, controller)
+        {
+            this.name = name;
+            this.controller = controller;
+            this.management = controller.management;
+            this.modelObj = {
+                type: "port",
+                name: name,
+                parent: parent
+            };
+        }
+
+        Port.prototype.getTitle = function ()
+        {
+            return "Port: " + this.name;
+        };
+
+        Port.prototype.open = function (contentPane)
+        {
+            var that = this;
+            this.contentPane = contentPane;
+
+            contentPane.containerNode.innerHTML = template;
+            parser.parse(contentPane.containerNode)
+                .then(function (instances)
+                {
+                    that.portUpdater = new PortUpdater(that);
+
+                    var deletePortButton = query(".deletePortButton", contentPane.containerNode)[0];
+                    var node = registry.byNode(deletePortButton);
+                    connect.connect(node, "onClick", function (evt)
+                    {
+                        that.deletePort();
+                    });
+
+                    var editPortButton = query(".editPortButton", contentPane.containerNode)[0];
+                    var node = registry.byNode(editPortButton);
+                    connect.connect(node, "onClick", function (evt)
+                    {
+                        that.showEditDialog();
+                    });
+
+                    that.portUpdater.update(function ()
+                    {
+                        updater.add(that.portUpdater);
+                    });
+                });
+        };
+
+        Port.prototype.close = function ()
+        {
+            updater.remove(this.portUpdater);
+        };
+
+        Port.prototype.deletePort = function ()
+        {
+            if (confirm("Are you sure you want to delete port '" + entities.encode(this.name) + "'?"))
+            {
+                var that = this;
+                this.management.remove(this.modelObj)
+                    .then(function (data)
+                    {
+                        that.contentPane.onClose()
+                        that.controller.tabContainer.removeChild(that.contentPane);
+                        that.contentPane.destroyRecursive();
+                        that.close();
+                    }, util.xhrErrorHandler);
+            }
+        }
+
+        Port.prototype.showEditDialog = function ()
+        {
+            var that = this;
+            this.management.load(that.modelObj.parent)
+                .then(function (data)
+                {
+                    var brokerData = data[0];
+                    addPort.show(that.management,
+                        that.modelObj,
+                        that.portUpdater.portData.type,
+                        brokerData.authenticationproviders,
+                        brokerData.keystores,
+                        brokerData.truststores);
+                }, util.xhrErrorHandler);
+        }
+
+        function PortUpdater(portTab)
+        {
+            var that = this;
+            this.tabObject = portTab;
+            this.management = portTab.controller.management;
+            this.modelObj = portTab.modelObj;
+            var containerNode = portTab.contentPane.containerNode;
+
+            function findNode(name)
+            {
+                return query("." + name, containerNode)[0];
+            }
+
+            function storeNodes(names)
+            {
+                for (var i = 0; i < names.length; i++)
+                {
+                    that[names[i]] = findNode(names[i]);
+                }
+            }
+
+            storeNodes(["nameValue",
+                        "stateValue",
+                        "typeValue",
+                        "portValue",
+                        "authenticationProviderValue",
+                        "protocolsValue",
+                        "transportsValue",
+                        "bindingAddressValue",
+                        "keyStoreValue",
+                        "needClientAuthValue",
+                        "wantClientAuthValue",
+                        "trustStoresValue",
+                        "connectionCountValue",
+                        "maxOpenConnectionsValue",
+                        "authenticationProvider",
+                        "bindingAddress",
+                        "keyStore",
+                        "needClientAuth",
+                        "wantClientAuth",
+                        "clientCertRecorderValue",
+                        "trustStores",
+                        "maxOpenConnections",
+                        "threadPoolMinimum",
+                        "threadPoolMaximum",
+                        "threadPoolSize",
+                        "threadPoolMinimumValue",
+                        "threadPoolMaximumValue",
+                        "threadPoolSizeValue",
+                        "portTypeSpecificDetails",
+                        "portAttributes"]);
+        }
+
+        PortUpdater.prototype.updateHeader = function ()
+        {
+            function printArray(fieldName, object)
+            {
+                var array = object[fieldName];
+                var data = "<div>";
+                if (array)
+                {
+                    for (var i = 0; i < array.length; i++)
+                    {
+                        data += "<div>" + entities.encode(array[i]) + "</div>";
+                    }
+                }
+                return data + "</div>";
+            }
+
+            this.nameValue.innerHTML = entities.encode(String(this.portData["name"]));
+            this.stateValue.innerHTML = entities.encode(String(this.portData["state"]));
+            this.typeValue.innerHTML = entities.encode(String(this.portData["type"]));
+            this.portValue.innerHTML = entities.encode(String(this.portData["port"]));
+            this.authenticationProviderValue.innerHTML = this.portData["authenticationProvider"]
+                ? entities.encode(String(this.portData["authenticationProvider"]))
+                : "";
+            this.protocolsValue.innerHTML = printArray("protocols", this.portData);
+            this.transportsValue.innerHTML = printArray("transports", this.portData);
+            this.bindingAddressValue.innerHTML =
+                this.portData["bindingAddress"] ? entities.encode(String(this.portData["bindingAddress"])) : "";
+            this.connectionCountValue.innerHTML =
+                this.portData["connectionCount"] ? entities.encode(String(this.portData["connectionCount"])) : "0";
+            this.maxOpenConnectionsValue.innerHTML =
+                (this.portData["maxOpenConnections"] && this.portData["maxOpenConnections"] >= 0) ? entities.encode(
+                    String(this.portData["maxOpenConnections"])) : "(no limit)";
+            this.threadPoolMinimumValue.innerHTML = entities.encode(String(this.portData["threadPoolMinimum"] || ""));
+            this.threadPoolMaximumValue.innerHTML = entities.encode(String(this.portData["threadPoolMaximum"] || ""));
+            this.threadPoolSizeValue.innerHTML = entities.encode(String(this.portData["threadPoolSize"] || ""));
+
+            this.keyStoreValue.innerHTML =
+                this.portData["keyStore"] ? entities.encode(String(this.portData["keyStore"])) : "";
+            this.needClientAuthValue.innerHTML =
+                "<input type='checkbox' disabled='disabled' " + (this.portData["needClientAuth"]
+                    ? "checked='checked'"
+                    : "") + " />";
+            this.wantClientAuthValue.innerHTML =
+                "<input type='checkbox' disabled='disabled' " + (this.portData["wantClientAuth"]
+                    ? "checked='checked'"
+                    : "") + " />";
+            this.trustStoresValue.innerHTML = printArray("trustStores", this.portData);
+            this.clientCertRecorderValue.innerHTML =
+                this.portData["clientCertRecorder"] ? entities.encode(String(this.portData["clientCertRecorder"])) : "";
+
+            var typeMetaData = this.management.metadata.getMetaData("Port", this.portData["type"]);
+
+            this.authenticationProvider.style.display =
+                "authenticationProvider" in typeMetaData.attributes ? "block" : "none";
+            this.bindingAddress.style.display = "bindingAddress" in typeMetaData.attributes ? "block" : "none";
+            this.keyStore.style.display = "keyStore" in typeMetaData.attributes ? "block" : "none";
+            this.needClientAuth.style.display = "needClientAuth" in typeMetaData.attributes ? "block" : "none";
+            this.wantClientAuth.style.display = "wantClientAuth" in typeMetaData.attributes ? "block" : "none";
+            this.trustStores.style.display = "trustStores" in typeMetaData.attributes ? "block" : "none";
+
+            var hasThreadPoolMinMaxSettings = "threadPoolMaximum" in typeMetaData.attributes;
+            this.threadPoolMinimum.style.display = hasThreadPoolMinMaxSettings ? "block" : "none";
+            this.threadPoolMaximum.style.display = hasThreadPoolMinMaxSettings ? "block" : "none";
+
+            var hasThreadPoolSizeSettings = "threadPoolSize" in typeMetaData.attributes;
+            this.threadPoolSize.style.display = hasThreadPoolSizeSettings ? "block" : "none";
+
+            this.maxOpenConnections.style.display = "maxOpenConnections" in typeMetaData.attributes ? "block" : "none";
+
+        };
+
+        PortUpdater.prototype.update = function (callback)
+        {
+
+            var thisObj = this;
+
+            this.management.load(this.modelObj)
+                .then(function (data)
+                {
+                    thisObj.portData = data[0] || {};
+                    thisObj.updateUI(thisObj.portData);
+                    util.flattenStatistics(thisObj.portData);
+                    if (callback)
+                    {
+                        callback();
+                    }
+                    thisObj.updateHeader();
+                }, function (error)
+                {
+                    util.tabErrorHandler(error, {
+                        updater: thisObj,
+                        contentPane: thisObj.tabObject.contentPane,
+                        tabContainer: thisObj.tabObject.controller.tabContainer,
+                        name: thisObj.modelObj.name,
+                        category: "Port"
+                    });
+                });
+        };
+
+        PortUpdater.prototype.updateUI = function (data)
+        {
+            if (!this.details)
+            {
+                var that = this;
+                require(["qpid/management/port/" + data.type.toLowerCase() + "/show"], function (Details)
+                {
+                    that.details = new Details({
+                        containerNode: that.portAttributes,
+                        typeSpecificDetailsNode: that.portTypeSpecificDetails,
+                        metadata: that.tabObject.management.metadata,
+                        data: data,
+                        management: that.tabObject.management,
+                        modelObj: that.tabObject.modelObj,
+                        portUpdater: that.portUpdater
+                    });
+                });
+            }
+            else
+            {
+                this.details.update(data);
+            }
+        }
 
-           return Port;
-       });
+        return Port;
+    });



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