You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2018/02/23 14:16:33 UTC

qpid-broker-j git commit: QPID-8102: [Broker-J] Address review comments

Repository: qpid-broker-j
Updated Branches:
  refs/heads/master 38819bcac -> 0a26d40f3


QPID-8102: [Broker-J] Address review comments


Project: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/commit/0a26d40f
Tree: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/tree/0a26d40f
Diff: http://git-wip-us.apache.org/repos/asf/qpid-broker-j/diff/0a26d40f

Branch: refs/heads/master
Commit: 0a26d40f3b65421bfd354ae09fac51b56b0ce949
Parents: 38819bc
Author: Alex Rudyy <or...@apache.org>
Authored: Fri Feb 23 14:15:09 2018 +0000
Committer: Alex Rudyy <or...@apache.org>
Committed: Fri Feb 23 14:15:58 2018 +0000

----------------------------------------------------------------------
 .../server/virtualhost/AbstractVirtualHost.java | 12 ++--
 .../resources/js/qpid/management/VirtualHost.js | 25 ++++++---
 .../js/qpid/management/editVirtualHost.js       | 58 ++++++++++++++------
 .../virtualhost/NodeAutoCreationPolicyForm.js   | 38 ++++++-------
 .../virtualhost/NodeAutoCreationPolicyForm.html | 13 +++--
 5 files changed, 93 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0a26d40f/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
----------------------------------------------------------------------
diff --git a/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java b/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
index 44ebe3f..3e64deb 100644
--- a/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
+++ b/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java
@@ -464,7 +464,7 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte
         String pattern = policy.getPattern();
         if(pattern == null)
         {
-            throw new IllegalArgumentException("The 'pattern' attribute of a NodeAutoCreationPattern MUST be supplied: " + policy);
+            throw new IllegalArgumentException("The 'pattern' attribute of a NodeAutoCreationPolicy MUST be supplied: " + policy);
         }
 
         try
@@ -473,7 +473,7 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte
         }
         catch (PatternSyntaxException e)
         {
-            throw new IllegalArgumentException("The 'pattern' attribute of a NodeAutoCreationPattern MUST be a valid "
+            throw new IllegalArgumentException("The 'pattern' attribute of a NodeAutoCreationPolicy MUST be a valid "
                                                + "Java Regular Expression Pattern, the value '" + pattern + "' is not: " + policy);
 
         }
@@ -490,23 +490,23 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte
         }
         if(sourceClass == null)
         {
-            throw new IllegalArgumentException("The node type of a NodeAutoCreationPattern must be a valid child type "
+            throw new IllegalArgumentException("The node type of a NodeAutoCreationPolicy must be a valid child type "
                                                + "of a VirtualHost, '" + nodeType + "' is not.");
         }
         if(policy.isCreatedOnConsume() && !MessageSource.class.isAssignableFrom(sourceClass))
         {
-            throw new IllegalArgumentException("A NodeAutoCreationPattern which creates nodes on consume must have a "
+            throw new IllegalArgumentException("A NodeAutoCreationPolicy which creates nodes on consume must have a "
                                                + "nodeType which implements MessageSource, '" + nodeType + "' does not.");
         }
 
         if(policy.isCreatedOnPublish() && !MessageDestination.class.isAssignableFrom(sourceClass))
         {
-            throw new IllegalArgumentException("A NodeAutoCreationPattern which creates nodes on publish must have a "
+            throw new IllegalArgumentException("A NodeAutoCreationPolicy which creates nodes on publish must have a "
                                                + "nodeType which implements MessageDestination, '" + nodeType + "' does not.");
         }
         if(!(policy.isCreatedOnConsume() || policy.isCreatedOnPublish()))
         {
-            throw new IllegalArgumentException("A NodeAutoCreationPattern must create on consume, create on publish or both.");
+            throw new IllegalArgumentException("A NodeAutoCreationPolicy must create on consume, create on publish or both.");
         }
 
     }

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0a26d40f/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHost.js
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHost.js b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHost.js
index 6df7870..7a96baa 100644
--- a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHost.js
+++ b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHost.js
@@ -513,7 +513,8 @@ define(["dojo/parser",
                                 markup = "<div class='keyValuePair'>";
                                 for(var key in value)
                                 {
-                                    markup += "<div>" + key + "=" + value[key] + "</div>";
+                                    markup += "<div>" + entities.encode(String(key)) + "="
+                                              + entities.encode(String(value[key])) + "</div>";
                                 }
                                 markup += "</div>"
                             }
@@ -709,23 +710,31 @@ define(["dojo/parser",
             {
                 for (var i = 0; i < data.length; i++)
                 {
-                    dstore.put(data[i]);
+                    dstore.putSync(data[i]);
                 }
             }
-            dstore.fetch()
+            var objectsToRemove = [];
+            dstore.fetchSync()
                 .forEach(function (object) {
-                    if (data)
+                    if (object)
                     {
-                        for (var i = 0; i < data.length; i++)
+                        if (data)
                         {
-                            if (data[i][idProperty] === object[idProperty])
+                            for (var i = 0; i < data.length; i++)
                             {
-                                return;
+                                if (data[i][idProperty] === object[idProperty])
+                                {
+                                    return;
+                                }
                             }
                         }
+                        objectsToRemove.push(object[idProperty]);
                     }
-                    dstore.remove(object[idProperty]);
                 });
+            for (var i = 0 ; i < objectsToRemove.length; i++)
+            {
+                dstore.removeSync(objectsToRemove[i]);
+            }
         };
 
         return VirtualHost;

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0a26d40f/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js
index 01dc072..fd0c577 100644
--- a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js
+++ b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js
@@ -258,7 +258,7 @@ define(["dojox/html/entities",
                     }
                 });
 
-                this._initNodeAutoCreationPolicies(data);
+                this._initNodeAutoCreationPolicies(data.actual && data.actual.nodeAutoCreationPolicies ? data.actual.nodeAutoCreationPolicies : []);
                 this.dialog.startup();
                 this.dialog.show();
                 if (!this.resizeEventRegistered)
@@ -302,7 +302,7 @@ define(["dojox/html/entities",
                             label: 'All',
                             selector: 'checkbox'
                         },
-                        nodeType: {
+                        type: {
                             label: "Node Type"
                         },
                         pattern: {
@@ -317,17 +317,17 @@ define(["dojox/html/entities",
                         attributes: {
                             label: "Attributes",
                             sortable: false,
-                            formatter: function(value, object)
-                            {
+                            formatter: function (value, object) {
                                 var markup = "";
                                 if (value)
                                 {
                                     markup = "<div class='keyValuePair'>";
-                                    for(var key in value)
+                                    for (var key in value)
                                     {
-                                        markup += "<div>" + key + "=" + value[key] + "</div>";
+                                        markup += "<div>" + entities.encode(String(key)) + "="
+                                                  + entities.encode(String(value[key])) + "</div>";
                                     }
-                                    markup +="</div>"
+                                    markup += "</div>"
                                 }
                                 return markup;
                             }
@@ -346,9 +346,22 @@ define(["dojox/html/entities",
                 this._policyGrid.on('dgrid-deselect', lang.hitch(this, this._policySelectionChanged));
 
             },
-            _initNodeAutoCreationPolicies: function (data) {
-                this._policies =
-                    data.actual && data.actual.nodeAutoCreationPolicies ? data.actual.nodeAutoCreationPolicies : [];
+            _toDgridFriendlyNodeAutoCreationPolicyObject: function (policy) {
+                return { pattern: policy.pattern,
+                         type: policy.nodeType,
+                         attributes: policy.attributes,
+                         createdOnPublish: policy.createdOnPublish,
+                         createdOnConsume: policy.createdOnConsume};
+            },
+            _initNodeAutoCreationPolicies: function (policies) {
+
+                var dgridFriendlyPolicies = [];
+                for (var i = 0; i < policies.length; i++)
+                {
+                    dgridFriendlyPolicies.push(this._toDgridFriendlyNodeAutoCreationPolicyObject(policies[i]));
+                }
+
+                this._policies = dgridFriendlyPolicies;
                 var Store = MemoryStore.createSubclass(TrackableStore);
                 this._policyStore = new Store({
                     data: this._policies,
@@ -373,7 +386,11 @@ define(["dojox/html/entities",
                             this.nodeAutoCreationPolicyForm.on("create", lang.hitch(this, function (e) {
                                 try
                                 {
-                                    this._policyStore.putSync(e.data);
+                                    this._policyStore.putSync(this._toDgridFriendlyNodeAutoCreationPolicyObject(e.data));
+                                    if (e.oldData && e.oldData.pattern !== e.data.pattern)
+                                    {
+                                        this._policyStore.removeSync(e.oldData.pattern);
+                                    }
                                 }
                                 catch (e)
                                 {
@@ -387,7 +404,7 @@ define(["dojox/html/entities",
             },
             _policySelected: function (event) {
                 var row = this._policyGrid.row(event);
-                this._showNodeAutoCreationPolicyForm(row.data);
+                this._showNodeAutoCreationPolicyForm(this._toNodeAutoCreationPolicyObject(row.data));
             },
             _deleteNodeAutoCreationPolicy: function () {
                 var selected = this._getSelectedPolicies();
@@ -418,11 +435,20 @@ define(["dojox/html/entities",
             },
             _getNodeAutoCreationPolicies: function () {
                 var policies = [];
-                this._policyStore.fetchSync().forEach(function (policy) {
-                    policies.push(policy);
-                });
+                this._policyStore.fetchSync().forEach(lang.hitch(this, function (policy) {
+                    policies.push(this._toNodeAutoCreationPolicyObject(policy));
+                }));
                 return policies;
-            }
+            },
+            _toNodeAutoCreationPolicyObject: function (policy) {
+                return {
+                    pattern: policy.pattern,
+                    nodeType: policy.type,
+                    attributes: policy.attributes,
+                    createdOnPublish: policy.createdOnPublish,
+                    createdOnConsume: policy.createdOnConsume
+                };
+            },
         };
 
         virtualHostEditor.init();

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0a26d40f/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/NodeAutoCreationPolicyForm.js
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/NodeAutoCreationPolicyForm.js b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/NodeAutoCreationPolicyForm.js
index c250063..bfa0d74 100644
--- a/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/NodeAutoCreationPolicyForm.js
+++ b/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/NodeAutoCreationPolicyForm.js
@@ -171,7 +171,7 @@ define(["dojo/_base/declare",
                                         createdOnConsume: this.createdOnConsume.checked,
                                         attributes: this._getObjectAttributes()
                                     };
-                                    this.emit("create", {data: data});
+                                    this.emit("create", {data: data, oldData: this._policy});
                                     this.nodeAutoCreationPolicyDialog.hide();
                                 }
                                 else
@@ -198,8 +198,8 @@ define(["dojo/_base/declare",
                 _addAttribute: function () {
                     var id = (++this._id);
                     var item = {
-                        name: "<new>",
-                        value: "<new>",
+                        name: "",
+                        value: "",
                         id: id
                     };
                     this.addAttributeButton.set("disabled", true);
@@ -212,10 +212,10 @@ define(["dojo/_base/declare",
                     {
                         console.error("failure to add new attribute:" + e);
                     }
+                    this._onChange();
                 },
                 _deleteAttribute: function () {
                     var selected = this._getSelectedAttributes();
-                    var newDeleted = false;
                     if (selected.length > 0)
                     {
                         for (var s in selected)
@@ -226,20 +226,14 @@ define(["dojo/_base/declare",
                                 var item =  this._store.getSync(id);
                                 if (item)
                                 {
-                                    if (item.name === "<new>")
-                                    {
-                                        newDeleted = true;
-                                    }
                                     this._store.removeSync(selected[s]);
                                 }
                             }
                         }
                         this._attributesGrid.clearSelection();
                     }
-                    if (newDeleted)
-                    {
-                        this.addAttributeButton.set("disabled", false);
-                    }
+                    this.addAttributeButton.set("disabled", this._emptyPatternFound());
+                    this._onChange();
                 },
                 _getSelectedAttributes: function () {
                     var selected = [];
@@ -254,13 +248,8 @@ define(["dojo/_base/declare",
                     return selected;
                 },
                 _onGridEdit: function (e) {
-                        if (e.value !== "<new>")
-                        {
-                            if (e.cell.column.field==="name" && e.oldValue === "<new>" && e.value !== "<new>")
-                            {
-                                this.addAttributeButton.set("disabled", false);
-                            }
-                        }
+                    this.addAttributeButton.set("disabled", this._emptyPatternFound());
+                    this._onChange();
                 },
                 _gridSelectionChanged: function () {
                     var selected = this._getSelectedAttributes();
@@ -350,6 +339,17 @@ define(["dojo/_base/declare",
                         }), true);
                         this._attributesGrid.startup();
                     }
+                },
+                _emptyPatternFound: function () {
+                    var emptyPatternDetected = false;
+                    this._store.fetchSync()
+                        .forEach(function (value) {
+                            if (value && value.pattern === "")
+                            {
+                                emptyPatternDetected = true;
+                            }
+                        });
+                    return emptyPatternDetected;
                 }
             });
     });

http://git-wip-us.apache.org/repos/asf/qpid-broker-j/blob/0a26d40f/broker-plugins/management-http/src/main/java/resources/virtualhost/NodeAutoCreationPolicyForm.html
----------------------------------------------------------------------
diff --git a/broker-plugins/management-http/src/main/java/resources/virtualhost/NodeAutoCreationPolicyForm.html b/broker-plugins/management-http/src/main/java/resources/virtualhost/NodeAutoCreationPolicyForm.html
index bef23eb..ed8e861 100644
--- a/broker-plugins/management-http/src/main/java/resources/virtualhost/NodeAutoCreationPolicyForm.html
+++ b/broker-plugins/management-http/src/main/java/resources/virtualhost/NodeAutoCreationPolicyForm.html
@@ -37,8 +37,9 @@
                                data-dojo-props="name: 'pattern',
                         required: true,
                         intermediateChanges: true,
-                        placeHolder: 'Name matching regular expression',
-                        title: 'Enter name matching regular expression'"/>
+                        placeHolder: 'regular expression',
+                        title: 'Policy will apply to requests for new nodes with names matching this pattern',
+                        promptMessage: 'Policy will apply to requests for new nodes with names matching this pattern'"/>
                     </div>
                     <div class="clear">
                         <label class="formLabel-labelCell tableContainer-labelCell" for="${id}_nodeType"
@@ -50,8 +51,8 @@
                                           placeHolder: 'Type of Node',
                                           required: true,
                                           value: 'Queue',
-                                          title: 'Type of node to create.',
-                                          promptMessage: 'Select type of node to create.',
+                                          title: 'Select type of node created by this policy',
+                                          promptMessage: 'Type of the automatically created node.',
                                           intermediateChanges: true">
                             <option value="Queue" selected="true">Queue</option>
                             <option value="Exchange">Exchange</option>
@@ -95,6 +96,10 @@
                             <legend>Attributes:</legend>
                             <div data-dojo-attach-point="attributes" id="${id}_attributes"
                                  class="nodeAutoCreationPolicyAttributes"></div>
+                            <div data-dojo-type="dijit/Tooltip"
+                                 data-dojo-props="connectId: ['${id}_attributes'],
+                              label: 'Attributes applied to the automatically created node'">
+                            </div>
                             <div>
                                 <button data-dojo-type="dijit/form/Button"
                                         id="${id}_addAttributeButton"


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