diff options
| author | Alex Rudyy <orudyy@apache.org> | 2014-09-11 17:37:32 +0000 |
|---|---|---|
| committer | Alex Rudyy <orudyy@apache.org> | 2014-09-11 17:37:32 +0000 |
| commit | 4b4d4ce4f3f1c401903411d43b91a700c6a8fb8b (patch) | |
| tree | 892486528c980be64fae5ae7b23aa689971409cf /qpid/java | |
| parent | ddeca4d5acc43889e39253d16323c198475b6f66 (diff) | |
| download | qpid-python-4b4d4ce4f3f1c401903411d43b91a700c6a8fb8b.tar.gz | |
QPID-6093: Add UI to set context variables
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1624345 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java')
28 files changed, 1113 insertions, 320 deletions
diff --git a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/add.js b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/add.js index db3bf8f57b..0ec991ea16 100644 --- a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/add.js +++ b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/add.js @@ -32,34 +32,13 @@ define(["dojo/_base/xhr", "dijit/form/FilteringSelect", "dojo/domReady!"], function (xhr, dom, construct, win, registry, parser, array, event, json, string, Memory, FilteringSelect) { - var fieldNames = ["maxConnectionsPerPartition", "minConnectionsPerPartition", "partitionCount"]; return { - show: function(poolSpecificDivId, formFieldPrefix, htmlUrl) { - var node = dom.byId(poolSpecificDivId); - var that = this; - - array.forEach(registry.toArray(), - function(item) { - if(item.id.substr(0,formFieldPrefix.length) == formFieldPrefix) { - item.destroyRecursive(); - } - }); - - xhr.get({url: htmlUrl, - sync: true, - load: function(data) { - - node.innerHTML = data; - parser.parse(node); - - for ( var i = 0 ; i < fieldNames.length; i++ ) - { - var widgetName = fieldNames[i]; - var widget = registry.byId(formFieldPrefix + widgetName); - widget.set("regExpGen", util.numericOrContextVarRegexp); - } - - }}); + show: function(data) { + data.context.addInheritedContext({ + "qpid.jdbcstore.bonecp.partitionCount": "4", + "qpid.jdbcstore.bonecp.minConnectionsPerPartition": "5", + "qpid.jdbcstore.bonecp.maxConnectionsPerPartition": "10" + }); } }; }); diff --git a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/edit.js b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/edit.js index 0179f38d07..6876e3850b 100644 --- a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/edit.js +++ b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/edit.js @@ -27,32 +27,7 @@ define(["dojo/_base/xhr", "qpid/common/util", "dojo/domReady!"], function (xhr, dom, construct, win, registry, parser, util) { - var fieldNames = ["maxConnectionsPerPartition", "minConnectionsPerPartition", "partitionCount"]; return { - show: function(data) { - var that = this; - xhr.get({url: "virtualhost/store/pool/bonecp/add.html", - sync: true, - load: function(template) { - for ( var i = 0 ; i < fieldNames.length; i++ ) - { - var widgetName = fieldNames[i]; - var widget = registry.byId("formAddVirtualHost.qpid.jdbcstore.bonecp." + widgetName); - if (widget) - { - widget.destroyRecursive(); - } - } - data.containerNode.innerHTML = template; - parser.parse(data.containerNode); - for ( var i = 0 ; i < fieldNames.length; i++ ) - { - var widgetName = fieldNames[i]; - var widget = registry.byId("formAddVirtualHost.qpid.jdbcstore.bonecp." + widgetName); - widget.set("value", data.data.context["qpid.jdbcstore.bonecp." + widgetName]); - widget.set("regExpGen", util.numericOrContextVarRegexp); - } - }}); - } + show: function(data) { } }; }); diff --git a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/show.js b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/show.js index c0556c28fd..31e5db5035 100644 --- a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/show.js +++ b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/js/qpid/management/store/pool/bonecp/show.js @@ -51,10 +51,11 @@ define(["dojo/_base/xhr", BoneCP.prototype.update=function(data) { + for(var i=0; i<fieldNames.length;i++) { var fieldName = fieldNames[i]; - var value = data.context["qpid.jdbcstore.bonecp."+fieldName]; + var value = data && data.context ? data.context["qpid.jdbcstore.bonecp."+fieldName] : ""; this[fieldName].innerHTML= value?entities.encode(String(value)):""; } }; diff --git a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/virtualhost/store/pool/bonecp/add.html b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/virtualhost/store/pool/bonecp/add.html deleted file mode 100644 index dc2450a532..0000000000 --- a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/virtualhost/store/pool/bonecp/add.html +++ /dev/null @@ -1,55 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to You under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<div class="clear formBox"> -<fieldset> -<legend>BoneCP Settings</legend> -<table class="tableContainer-table tableContainer-table-horiz"> - - <tr> - <td class="tableContainer-labelCell"><strong>Partition Count: </strong></td> - <td class="tableContainer-valueCell"> - <input data-dojo-type="dijit/form/ValidationTextBox" - id="formAddVirtualHost.qpid.jdbcstore.bonecp.partitionCount" - name="qpid.jdbcstore.bonecp.partitionCount" - value="4" - contextvar="true"/> - </td> - </tr> - <tr> - <td class="tableContainer-labelCell"><strong>Minimum connections per Partition:</strong></td> - <td class="tableContainer-valueCell"> - <input dojoType="dijit/form/ValidationTextBox" - id="formAddVirtualHost.qpid.jdbcstore.bonecp.minConnectionsPerPartition" - name="qpid.jdbcstore.bonecp.minConnectionsPerPartition" - value="5" - contextvar="true"/> - </td> - </tr> - <tr> - <td class="tableContainer-labelCell"><strong>Maximum connections per Partition: </strong></td> - <td class="tableContainer-valueCell"> - <input dojoType="dijit/form/ValidationTextBox" - id="formAddVirtualHost.qpid.jdbcstore.bonecp.maxConnectionsPerPartition" - name="qpid.jdbcstore.bonecp.maxConnectionsPerPartition" - value="10" - contextvar="true"/> - </td> - </tr> - -</table> -</fieldset> -</div> diff --git a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/virtualhostnode/store/pool/bonecp/add.html b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/virtualhostnode/store/pool/bonecp/add.html deleted file mode 100644 index 810a232091..0000000000 --- a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/resources/virtualhostnode/store/pool/bonecp/add.html +++ /dev/null @@ -1,55 +0,0 @@ -<!-- - ~ Licensed to the Apache Software Foundation (ASF) under one or more - ~ contributor license agreements. See the NOTICE file distributed with - ~ this work for additional information regarding copyright ownership. - ~ The ASF licenses this file to You under the Apache License, Version 2.0 - ~ (the "License"); you may not use this file except in compliance with - ~ the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, software - ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - ~ See the License for the specific language governing permissions and - ~ limitations under the License. - --> -<div class="clear formBox"> -<fieldset> -<legend>BoneCP Settings</legend> -<table class="tableContainer-table tableContainer-table-horiz"> - - <tr> - <td class="tableContainer-labelCell"><strong>Partition Count: </strong></td> - <td class="tableContainer-valueCell"> - <input data-dojo-type="dijit/form/ValidationTextBox" - id="formAddVirtualHostNode.qpid.jdbcstore.bonecp.partitionCount" - name="qpid.jdbcstore.bonecp.partitionCount" - value="4" - contextvar="true"/> - </td> - </tr> - <tr> - <td class="tableContainer-labelCell"><strong>Minimum connections per Partition:</strong></td> - <td class="tableContainer-valueCell"> - <input dojoType="dijit/form/ValidationTextBox" - id="formAddVirtualHostNode.qpid.jdbcstore.bonecp.minConnectionsPerPartition" - name="qpid.jdbcstore.bonecp.minConnectionsPerPartition" - value="5" - contextvar="true"/> - </td> - </tr> - <tr> - <td class="tableContainer-labelCell"><strong>Maximum connections per Partition: </strong></td> - <td class="tableContainer-valueCell"> - <input dojoType="dijit/form/ValidationTextBox" - id="formAddVirtualHostNode.qpid.jdbcstore.bonecp.maxConnectionsPerPartition" - name="qpid.jdbcstore.bonecp.maxConnectionsPerPartition" - value="10" - contextvar="true"/> - </td> - </tr> - -</table> -</fieldset> -</div> diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/add.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/add.js index ccdcf643fb..44405c610b 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/add.js +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/store/pool/none/add.js @@ -33,24 +33,9 @@ define(["dojo/_base/xhr", "dojo/domReady!"], function (xhr, dom, construct, win, registry, parser, array, event, json, string, Memory, FilteringSelect) { return { - show: function(poolSpecificDivId, formFieldPrefix, htmlUrl) { - var node = dom.byId(poolSpecificDivId); - var that = this; - - array.forEach(registry.toArray(), - function(item) { - if(item.id.substr(0,formFieldPrefix.length) == formFieldPrefix) { - item.destroyRecursive(); - } - }); - - xhr.get({url: htmlUrl, - sync: true, - load: function(data) { - node.innerHTML = data; - parser.parse(node); - - }}); + show: function(data) + { + data.context.removeDynamicallyAddedInheritedContext(); } }; }); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/add.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/add.js index 88b338750d..beb298e988 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/add.js +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/add.js @@ -65,7 +65,7 @@ define(["dojo/_base/xhr", require(["qpid/management/store/pool/"+type.toLowerCase()+"/add"], function(poolType) { - poolType.show("addVirtualHost.poolSpecificDiv", "formAddVirtualHost.qpid.jdbcstore.bonecp", "virtualhost/store/pool/"+type.toLowerCase()+"/add.html"); + poolType.show({containerNode:poolTypeFieldsDiv, context: data.parent.virtualHostContext}); }); } } diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/edit.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/edit.js index 665f560290..90fc246276 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/edit.js +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/edit.js @@ -68,7 +68,7 @@ define(["qpid/common/util", require(["qpid/management/store/pool/"+type.toLowerCase()+"/edit"], function(poolType) { - poolType.show({containerNode:poolTypeFieldsDiv, data: data.data}) + poolType.show({containerNode:poolTypeFieldsDiv, data: data.data, context: data.parent.context}) }); } } diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/show.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/show.js index edca323926..d3fdf50769 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/show.js +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhost/jdbc/show.js @@ -35,7 +35,7 @@ define(["qpid/common/util", "dojo/query", "dojo/_base/array", "dojo/dom-construc var previousConnectionPoolType = this.connectionPoolType ? this.connectionPoolType.innerHTML : null; util.updateUI(data, fieldNames, this); this.usernameAttributeContainer.style.display = data.username ? "block" : "none"; - if (!this.poolDetails || previousConnectionPoolType != data.connectionPoolType) + if (data.connectionPoolType && (!this.poolDetails || previousConnectionPoolType != data.connectionPoolType)) { var that = this; require(["qpid/management/store/pool/" + data.connectionPoolType.toLowerCase() + "/show"], diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/add.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/add.js index a285733f0e..d5a7b43aae 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/add.js +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/add.js @@ -67,7 +67,7 @@ define(["dojo/_base/xhr", require(["qpid/management/store/pool/"+type.toLowerCase()+"/add"], function(poolType) { - poolType.show("addVirtualHostNode.poolSpecificDiv", "formAddVirtualHostNode.qpid.jdbcstore.bonecp", "virtualhostnode/store/pool/" + type.toLowerCase() + "/add.html"); + poolType.show({containerNode:poolTypeFieldsDiv, context: data.parent.virtualHostNodeContext}); }); } } diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/edit.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/edit.js index 69fa01871b..828369cae0 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/edit.js +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/edit.js @@ -67,7 +67,7 @@ define(["qpid/common/util", require(["qpid/management/store/pool/"+type.toLowerCase()+"/edit"], function(poolType) { - poolType.show({containerNode:poolTypeFieldsDiv, data: data.data}) + poolType.show({containerNode:poolTypeFieldsDiv, data: data.data, context: data.parent.context}) if (!(data.data.state == "STOPPED" || data.data.state == "ERRORED")) { diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/show.js b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/show.js index b41fe32010..15c237d0a2 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/show.js +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/resources/js/qpid/management/virtualhostnode/jdbc/show.js @@ -40,7 +40,7 @@ define(["qpid/common/util", "dojo/query", "dojo/_base/array", "dojo/dom-construc util.updateUI(data, fieldNames, this); this.usernameAttributeContainer.style.display = data.username ? "block" : "none"; - if (!this.poolDetails || previousConnectionPoolType != data.connectionPoolType) + if (data.connectionPoolType && (!this.poolDetails || previousConnectionPoolType != data.connectionPoolType)) { var that = this; require(["qpid/management/store/pool/" + data.connectionPoolType.toLowerCase() + "/show"], diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java index 7769263e5a..7bde933bb9 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverter.java @@ -35,6 +35,7 @@ import java.util.TreeMap; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.ConfiguredObjectAttribute; +import org.apache.qpid.server.model.Model; public class ConfiguredObjectToMapConverter { @@ -56,9 +57,20 @@ public class ConfiguredObjectToMapConverter final boolean includeSystemContext, final boolean extractAsConfig) { + return convertObjectToMap(confObject, clazz, depth, useActualValues, false, includeSystemContext, extractAsConfig); + } + + public Map<String, Object> convertObjectToMap(final ConfiguredObject<?> confObject, + Class<? extends ConfiguredObject> clazz, + int depth, + final boolean useActualValues, + final boolean inheritedActuals, + final boolean includeSystemContext, + final boolean extractAsConfig) + { Map<String, Object> object = new LinkedHashMap<>(); - incorporateAttributesIntoMap(confObject, object, useActualValues, includeSystemContext, extractAsConfig); + incorporateAttributesIntoMap(confObject, object, useActualValues, inheritedActuals, includeSystemContext, extractAsConfig); if(!extractAsConfig) { incorporateStatisticsIntoMap(confObject, object); @@ -66,7 +78,7 @@ public class ConfiguredObjectToMapConverter if(depth > 0) { - incorporateChildrenIntoMap(confObject, clazz, depth, object, useActualValues, includeSystemContext, extractAsConfig); + incorporateChildrenIntoMap(confObject, clazz, depth, object, useActualValues, inheritedActuals, includeSystemContext, extractAsConfig); } return object; } @@ -76,6 +88,7 @@ public class ConfiguredObjectToMapConverter final ConfiguredObject<?> confObject, Map<String, Object> object, final boolean useActualValues, + final boolean inheritedActuals, final boolean includeSystemContext, final boolean extractAsConfig) { @@ -115,7 +128,7 @@ public class ConfiguredObjectToMapConverter Map<String, Object> contextValues = new HashMap<>(); if (useActualValues) { - contextValues.putAll(confObject.getContext()); + collectContext(contextValues, confObject.getModel(), confObject, inheritedActuals); } else { @@ -165,6 +178,27 @@ public class ConfiguredObjectToMapConverter } } + private void collectContext(Map<String, Object> contextValues, Model model, ConfiguredObject<?> confObject, boolean inheritedContext) + { + Object value = confObject.getActualAttributes().get(ConfiguredObject.CONTEXT); + if (inheritedContext) + { + Collection<Class<? extends ConfiguredObject>> parents = model.getParentTypes(confObject.getCategoryClass()); + if(parents != null && !parents.isEmpty()) + { + ConfiguredObject parent = confObject.getParent(parents.iterator().next()); + if(parent != null) + { + collectContext(contextValues, model, parent, inheritedContext); + } + } + } + if (value instanceof Map) + { + contextValues.putAll((Map<String,String>)value); + } + } + private void incorporateStatisticsIntoMap( final ConfiguredObject<?> confObject, Map<String, Object> object) { @@ -184,6 +218,7 @@ public class ConfiguredObjectToMapConverter int depth, Map<String, Object> object, final boolean useActualValues, + final boolean inheritedActuals, final boolean includeSystemContext, final boolean extractAsConfig) { @@ -225,6 +260,7 @@ public class ConfiguredObjectToMapConverter childClass, depth - 1, useActualValues, + inheritedActuals, includeSystemContext, extractAsConfig)); } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java index efe644ca43..0bc0a4514f 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/RestServlet.java @@ -59,6 +59,7 @@ public class RestServlet extends AbstractServlet public static final String ACTUALS_PARAM = "actuals"; public static final String SORT_PARAM = "sort"; public static final String INCLUDE_SYS_CONTEXT_PARAM = "includeSysContext"; + public static final String INHERITED_ACTUALS_PARAM = "inheritedActuals"; public static final String EXTRACT_INITIAL_CONFIG_PARAM = "extractInitialConfig"; public static final Set<String> RESERVED_PARAMS = @@ -66,7 +67,8 @@ public class RestServlet extends AbstractServlet SORT_PARAM, ACTUALS_PARAM, INCLUDE_SYS_CONTEXT_PARAM, - EXTRACT_INITIAL_CONFIG_PARAM)); + EXTRACT_INITIAL_CONFIG_PARAM, + INHERITED_ACTUALS_PARAM)); private Class<? extends ConfiguredObject>[] _hierarchy; @@ -326,25 +328,27 @@ public class RestServlet extends AbstractServlet int depth; boolean actuals; boolean includeSystemContext; - + boolean inheritedActuals; if(extractInitialConfig) { depth = Integer.MAX_VALUE; actuals = true; includeSystemContext = false; + inheritedActuals = false; } else { depth = getDepthParameterFromRequest(request); actuals = getBooleanParameterFromRequest(request, ACTUALS_PARAM); includeSystemContext = getBooleanParameterFromRequest(request, INCLUDE_SYS_CONTEXT_PARAM); + inheritedActuals = getBooleanParameterFromRequest(request, INHERITED_ACTUALS_PARAM); } List<Map<String, Object>> output = new ArrayList<Map<String, Object>>(); for(ConfiguredObject configuredObject : allObjects) { output.add(_objectConverter.convertObjectToMap(configuredObject, getConfiguredClass(), - depth, actuals, includeSystemContext, extractInitialConfig)); + depth, actuals, inheritedActuals, includeSystemContext, extractInitialConfig)); } Writer writer = getOutputWriter(request, response); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHostNodeAndVirtualHost.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHostNodeAndVirtualHost.html index 738af25332..685b3bced4 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHostNodeAndVirtualHost.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHostNodeAndVirtualHost.html @@ -58,6 +58,12 @@ <div class="clear"></div> <div id="addVirtualHostNode.typeFields"></div> + + <div data-dojo-type="dijit/TitlePane" data-dojo-props="title: 'Context variables', open: false"> + <div id="addVirtualHostNode.context"></div> + </div> + + </fieldset> </div> </form> @@ -85,6 +91,11 @@ <div class="clear"></div> <div id="addVirtualHost.typeFields"></div> + + <div data-dojo-type="dijit/TitlePane" data-dojo-props="title: 'Context variables', open: false"> + <div id="addVirtualHost.context"></div> + </div> + </fieldset> </div> </form> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/common/ContextVariablesEditor.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/common/ContextVariablesEditor.html new file mode 100644 index 0000000000..60fc0843eb --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/common/ContextVariablesEditor.html @@ -0,0 +1,35 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<div class="contextEditor"> + <div class="contextGrid"> + <div class="grid"></div> + </div> + <div> + <button data-dojo-type="dijit/form/Button" class="addButton" type="button" data-dojo-props="title:'Add new entry'">+</button> + <button data-dojo-type="dijit/form/Button" class="deleteButton" type="button" data-dojo-props="title:'Remove selected entry'">-</button> + <span class="dijit dijitReset dijitInline"> + <label>Show</label> + <select class="filter" name="filter" data-dojo-type="dijit/form/Select"> + <option value="*" selected="selected">All</option> + <option value="false">Local</option> + <option value="true" >Inherited</option> + </select> + </span> + </div> +</div>
\ No newline at end of file diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css b/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css index 7076f08b0b..7c8ca2e644 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/css/common.css @@ -283,3 +283,26 @@ div .messages { .dijitMultiSelect { width : 14.75em; } + +.highlightedText +{ + font-weight: bold; +} + +.normalText +{ + font-weight: normal; +} + +.contextEditor +{ + margin-left:5px; + margin-right:5px; +} + +.contextGrid +{ + width:100%; + max-height: 140px; + overflow: auto; +}
\ No newline at end of file diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/editBroker.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/editBroker.html new file mode 100644 index 0000000000..2516396d4d --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/editBroker.html @@ -0,0 +1,118 @@ +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<div class="dijitHidden"> + <div data-dojo-type="dijit/Dialog" data-dojo-props="title:'Edit Broker'" id="editBrokerDialog"> + <form id="editBrokerForm" method="post" data-dojo-type="dijit/form/Form"> + <div id="editBroker.allFields"> + <div class="clear"> + <div class="formLabel-labelCell tableContainer-labelCell">Name*:</div> + <div class="formLabel-controlCell tableContainer-valueCell"> + <input type="text" id="editBroker.name" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props=" + name: 'name', + placeHolder: 'name', + required: true, + disabled: false, + trim: true, + promptMessage: 'Identifies the broker instance.', + title: 'Enter broker name'" /> + </div> + </div> + <div class="clear"> + <div class="formLabel-labelCell tableContainer-labelCell">Default Virtual Host*:</div> + <div class="formLabel-controlCell tableContainer-valueCell"> + <input type="text" id="editBroker.defaultVirtualHost" + data-dojo-type="dijit/form/FilteringSelect" + data-dojo-props=" + name: 'defaultVirtualHost', + required: true, + promptMessage: 'Default virtual host used for clients that do not specify one when connecting.', + title: 'Select default virtual host' " /> + </div> + </div> + <div class="clear"> + <div class="formLabel-labelCell tableContainer-labelCell">Statistics reporting period (ms):</div> + <div class="formLabel-controlCell tableContainer-valueCell"> + <input type="text" id="editBroker.statisticsReportingPeriod" + data-dojo-type="dijit/form/ValidationTextBox" + data-dojo-props=" + name: 'statisticsReportingPeriod', + trim: true, + placeholder: 'Time in ms', + label: 'Statistics reporting period (ms):', + promptMessage: 'Frequency with which statistics are reported to broker log.'" /> + </div> + </div> + <div class="clear"> + <div class="formLabel-labelCell tableContainer-labelCell">Statistics reporting period enabled:</div> + <div class="formLabel-controlCell tableContainer-valueCell"> + <input type="text" id="editBroker.statisticsReportingResetEnabled" + data-dojo-type="dijit/form/CheckBox" + data-dojo-props=" name: 'statisticsReportingResetEnabled' " /> + </div> + </div> + + <div class="clear formBox"> + <fieldset> + <legend>Global Connection Defaults</legend> + <div class="clear"> + <div class="formLabel-labelCell tableContainer-labelCell">Maximum number of sessions:</div> + <div class="tableContainer-valueCell formLabel-controlCell"> + <input data-dojo-type="dijit/form/ValidationTextBox" + id="editBroker.connection.sessionCountLimit" + data-dojo-props=" + name: 'connection.sessionCountLimit', + placeHolder: 'Number of sessions', + trim: true, + promptMessage: 'Maximum number of sessions per connection' "/> + </div> + </div> + <div class="clear"> + <div class="formLabel-labelCell tableContainer-labelCell">Heart beat delay (ms)::</div> + <div class="tableContainer-valueCell formLabel-controlCell"> + <input data-dojo-type="dijit/form/ValidationTextBox" + id="editBroker.connection.heartBeatDelay" + data-dojo-props=" + name: 'connection.heartBeatDelay', + trim: true, + invalidMessage: 'Invalid value', + placeHolder: 'Time in ms', + promptMessage: 'Interval between heart beat messages exchanged between broker and clients'"/> + </div> + </div> + </fieldset> + </div> + + <div data-dojo-type="dijit/TitlePane" data-dojo-props="title: 'Context variables', open: false"> + <div id="editBroker.context" + data-dojo-type="qpid/common/ContextVariablesEditor" + data-dojo-props="name: 'context', title: 'Context variables'" ></div> + </div> + + <div class="clear"></div> + + <div class="dijitDialogPaneActionBar"> + <button data-dojo-type="dijit/form/Button" id="editBroker.saveButton" data-dojo-props="label: 'Save'">Save</button> + <button data-dojo-type="dijit/form/Button" id="editBroker.cancelButton" data-dojo-props="label: 'Cancel'" ></button> + </div> + </div> + </form> + </div> +</div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHost.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHost.html index 9b981b055e..29229137bb 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHost.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHost.html @@ -119,8 +119,13 @@ </input> </div> </div> + <div class="clear"></div> + <div data-dojo-type="dijit/TitlePane" data-dojo-props="title: 'Context variables', open: false"> + <div id="editVirtualHost.context" ></div> + </div> + <div class="dijitDialogPaneActionBar"> <button data-dojo-type="dijit/form/Button" id="editVirtualHost.saveButton" data-dojo-props="label: 'Save'">Save</button> <button data-dojo-type="dijit/form/Button" id="editVirtualHost.cancelButton" data-dojo-props="label: 'Cancel'" ></button> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHostNode.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHostNode.html index 4caf718f20..8c2c82fdbd 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHostNode.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/editVirtualHostNode.html @@ -39,6 +39,10 @@ <div class="clear"></div> + <div data-dojo-type="dijit/TitlePane" data-dojo-props="title: 'Context variables', open: false"> + <div id="editVirtualHostNode.context" ></div> + </div> + <div class="dijitDialogPaneActionBar"> <button data-dojo-type="dijit/form/Button" id="editVirtualHostNode.saveButton" data-dojo-props="label: 'Save'">Save</button> <button data-dojo-type="dijit/form/Button" id="editVirtualHostNode.cancelButton" data-dojo-props="label: 'Cancel'" ></button> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ContextVariablesEditor.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ContextVariablesEditor.js new file mode 100644 index 0000000000..4f384315ac --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ContextVariablesEditor.js @@ -0,0 +1,526 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +define([ + "qpid/common/util", + "dojo/_base/xhr", + "dojo/_base/declare", + "dojo/_base/array", + "dojo/_base/connect", + "dojo/_base/lang", + "dojo/dom-construct", + "dojo/parser", + "dojo/query", + "dojo/store/Memory", + "dojo/data/ObjectStore", + "dijit/_WidgetBase", + "dijit/registry", + "dojo/text!common/ContextVariablesEditor.html", + "dijit/form/Button", + "dojox/grid/EnhancedGrid", + "dojox/grid/enhanced/_Plugin", + "dijit/form/Select", + "dojox/validate/us", + "dojox/validate/web", + "dojo/domReady!"], +function (util, xhr, declare, array, connect, lang, domConstruct, parser, query, Memory, ObjectStore, _WidgetBase, registry, template) + { + + return declare("qpid.common.ContextVariablesEditor", [_WidgetBase], { + + value: null, + effectiveValues: null, + inheritedActualValues: null, + domNode: null, + _grid: null, + _addButton: null, + _deleteButton: null, + _filterBox: null, + _nextGridItemId: 0, + _dynamicInheritedContext: {}, + + constructor: function(args) + { + this._args = args; + }, + + buildRendering: function() + { + this.domNode = domConstruct.create("div", {innerHTML: template}); + parser.parse(this.domNode); + }, + + postCreate: function() + { + this.inherited(arguments); + var that = this; + var gridNode = query(".grid", this.domNode)[0]; + var addButtonNode = query(".addButton", this.domNode)[0]; + var deleteButtonNode = query(".deleteButton", this.domNode)[0]; + var addButton = registry.byNode(addButtonNode); + var deleteButton = registry.byNode(deleteButtonNode); + var layout = [[ + { name: "Name", field: "name", width: "40%", editable: true }, + { name: 'Actual Value', field: 'actualValue', width: '30%', editable: true}, + { name: 'Effective Value', field: 'effectiveValue', width: '30%', editable: false} + ]]; + var data = []; + var objectStore = new dojo.data.ObjectStore({objectStore: new Memory({data:data, idProperty: "id"})}); + var grid = new dojox.grid.EnhancedGrid({ + selectionMode: "multiple", + store: objectStore, + singleClickEdit: true, + structure: layout, + autoHeight: true, + sortFields: [{attribute: 'name', descending: false}], + plugins: {indirectSelection: true} + }, gridNode); + grid.canEdit = function(inCell, inRowIndex) + { + var item = grid.getItem(inRowIndex); + return inCell.field == "actualValue" || (inCell.field=="name" && item && item["inherited"] == false); + }; + + this._grid = grid; + this._deleteButton = deleteButton; + this._addButtonNode = addButtonNode; + + var toggleGridButtons = function(index) + { + var data = grid.selection.getSelected(); + deleteButton.set("disabled", !data || data.length==0); + }; + + connect.connect(grid.selection, 'onSelected', toggleGridButtons); + connect.connect(grid.selection, 'onDeselected', toggleGridButtons); + connect.connect(grid, 'onStyleRow' , this, function(row) { that._onStyleRow(row); }); + + deleteButton.set("disabled", true); + addButton.on("click", function(event) { that._newItem(); }); + deleteButton.on("click", function(event) { that._deleteSelected(); }); + grid.on("applyEdit", function(inRowIndex) { that._onEdit(inRowIndex); }); + grid.startup(); + this._filterBox = registry.byNode(query(".filter", this.domNode)[0]); + this._filterBox.on("change", function(value) { if (value) { that._filter(value); } }); + }, + resize: function() + { + this._grid.render(); + }, + load: function(restUrl, data) + { + data = data || {}; + var actualValues = data.actualValues; + var allEffectiveValues = data.effectiveValues; + var inheritedActualValues = data.inheritedActualValues; + if (!actualValues) + { + xhr.get( + { + url: restUrl, + sync: true, + content: { actuals: true }, + handleAs: "json", + load: function(data) + { + actualValues = data[0].context; + } + } + ); + } + if (!allEffectiveValues) + { + xhr.get( + { + url: restUrl, + sync: true, + content: { actuals: false }, + handleAs: "json", + load: function(data) + { + allEffectiveValues = data[0].context; + } + } + ); + } + if (!inheritedActualValues) + { + xhr.get( + { + url: restUrl, + sync: true, + content: { actuals: true, inheritedActuals: true}, + handleAs: "json", + load: function(data) + { + inheritedActualValues = data[0].context; + } + } + ); + } + this.setData(actualValues, allEffectiveValues, inheritedActualValues); + }, + setData: function(actualValues, allEffectiveValues, inheritedActualValues) + { + this.value = actualValues; + this.effectiveValues = allEffectiveValues; + this.inheritedActualValues = inheritedActualValues; + + var values = this._mergeValues(actualValues, allEffectiveValues, inheritedActualValues); + this._originalValues = values; + + var grid = this._grid; + if (grid) + { + // delete previous store data + grid.store.fetch({ + onComplete:function(items,request) + { + if(items.length) + { + array.forEach(items, function(item) + { + grid.store.deleteItem(item); + }); + } + } + }); + + // add new data into grid store + this._nextGridItemId = 0; + for(var i=0; i<values.length; i++) + { + var item = values[i]; + var storeItem = { + id: this._nextId(), + name: item.name, + actualValue: item.actualValue, + effectiveValue: item.effectiveValue, + "inherited": item["inherited"], + changed: false + }; + grid.store.newItem(storeItem); + } + grid.store.save(); + } + this._filter(this._filterBox.value); + this._handleOnChange(actualValues); + }, + addInheritedContext: function(object) + { + if (object) + { + var grid = this._grid; + for(key in object) + { + for(var i=0;i< this._originalValues.length;i++) + { + var varExists = false; + if (this._originalValues[i].name == key) + { + varExists = true; + break; + } + } + if (!varExists && !(key in this._dynamicInheritedContext)) + { + this._dynamicInheritedContext[key] = object[key]; + var storeItem = { + id: this._nextId(), + name: key, + actualValue: object[key], + effectiveValue: "", + "inherited": true, + changed: false + }; + grid.store.newItem(storeItem); + this._originalValues.push({name: key, + actualValue: object[key], + effectiveValue: "", + "inherited": true, + changed: false}); + } + } + grid.store.save(); + this._filter(this._filterBox.value); + } + }, + removeDynamicallyAddedInheritedContext: function() + { + if (this._dynamicInheritedContext) + { + var that = this; + var grid = this._grid; + grid.store.fetch({ + onComplete:function(items,request) + { + if(items.length) + { + for(key in that._dynamicInheritedContext) + { + var item = null; + for(var i=0;i<items.length;i++) + { + if (items[i].name == key) + { + item = items[i]; + break; + } + } + if (item && !item.changed) + { + grid.store.deleteItem(item); + that._deleteOriginalItem(item); + } + } + grid.store.save(); + that._dynamicInheritedContext = {}; + } + } + }); + } + }, + destroy: function() + { + if (this.domNode) + { + this.domNode.destroy(); + this.domNode = null; + } + if (this._grid != null) + { + this._grid.destroyRecursively(); + this._grid = null; + } + if (this._addButton != null) + { + this._addButton.destroyRecursively(); + this._addButton = null; + } + if (this._deleteButton != null) + { + this._deleteButton.destroyRecursively(); + this._deleteButton = null; + } + }, + onChange: function(newValue){}, + _newItem: function() + { + var newItem = { id: this._nextId(), name: "", actualValue: "", effectiveValue: "", "inherited": false, changed: true}; + var grid = this._grid; + grid.store.newItem(newItem); + grid.store.save(); + grid.store.fetch( + { + onComplete:function(items,request) + { + var rowIndex = items.length - 1; + window.setTimeout(function() + { + grid.focus.setFocusIndex(rowIndex, 1 ); + },10); + } + }); + }, + _deleteSelected: function() + { + var that = this; + var grid = this._grid; + var data = grid.selection.getSelected(); + if(data.length > 0) + { + array.forEach(data, function(selectedItem) { + if (selectedItem !== null && !selectedItem["inherited"]) + { + grid.store.deleteItem(selectedItem); + that._deleteOriginalItem(selectedItem.name); + } + }); + grid.store.save(); + grid.selection.deselectAll(); + this._valueChanged(); + } + }, + _deleteOriginalItem: function(key) + { + for(var i=0;i< this._originalValues.length;i++) + { + if (this._originalValues[i].name == key) + { + this._originalValues = this._originalValues.splice(i, 1); + break; + } + } + }, + _onEdit:function(inRowIndex) + { + var grid = this._grid; + var item = grid.getItem(inRowIndex); + var previousItems = this._originalValues; + var previousItemActualValue = null; + for(var i=0;i<previousItems.length;i++) + { + if (previousItems[i].name == item.name) + { + previousItemActualValue = previousItems[i].actualValue; + break; + } + } + + if (item.actualValue != previousItemActualValue) + { + if (!item.changed) + { + grid.store.setValue(item, "changed", true); + grid.store.save(); + } + } + else + { + if (item["inherited"]== true && item.changed) + { + grid.store.setValue(item, "changed", false); + grid.store.save(); + } + } + this._valueChanged(); + }, + _onStyleRow: function(row) + { + var grid = this._grid; + var inRowIndex = row.index; + var item = grid.getItem(inRowIndex); + if (item && (item["inherited"] == false || item.changed)) + { + row.customClasses += " highlightedText"; + } + else + { + row.customClasses += " normalText"; + } + grid.focus.styleRow(row); + grid.edit.styleRow(row); + }, + _filter: function(value) + { + this._grid.filter({"inherited": value}); + }, + _nextId: function() + { + this._nextGridItemId = this._nextGridItemId + 1; + return this._nextGridItemId; + }, + _valueChanged: function() + { + if (this._grid) + { + var value ={}; + var grid = this._grid; + grid.store.fetch({ + onComplete:function(items,request) + { + if(items.length > 0) + { + array.forEach(items, function(item) + { + if (item !== null && item.name && ((item["inherited"] && item.changed) || !item["inherited"])) + { + value[item.name]=item.actualValue; + } + }); + } + } + }); + if (!util.equals(this.value, value)) + { + this.value = value; + this._handleOnChange(value); + } + } + }, + _setValueAttr: function(actualValues) + { + this.value = actualValues; + if (this.inheritedActualValues!=null && this.effectiveValues != null) + { + this.setData(this.value, this.effectiveValues, this.inheritedActualValues); + } + }, + _setEffectiveValuesAttr: function(effectiveValues) + { + this.effectiveValues = effectiveValues; + if (this.value != null && this.inheritedActualValues !=null) + { + this.setData(this.value, this.effectiveValues, this.inheritedActualValues); + } + }, + _setInheritedActualValues: function(inheritedActualValues) + { + this.inheritedActualValues = inheritedActualValues; + if (this.value!= null && this.effectiveValues != null) + { + this.setData(this.value, this.effectiveValues, this.inheritedActualValues); + } + }, + _mergeValues: function(actualValues, allEffectiveValues, inheritedActualValues) + { + var fields = []; + + if (allEffectiveValues) + { + for(var key in allEffectiveValues) + { + if (!actualValues || !(key in actualValues)) + { + var actualValue = inheritedActualValues && key in inheritedActualValues ? inheritedActualValues[key] : allEffectiveValues[key]; + fields.push({name: key, actualValue: actualValue, effectiveValue: allEffectiveValues[key], "inherited": true}); + } + } + } + + if (actualValues) + { + for(var key in actualValues) + { + var effectiveValue = allEffectiveValues && key in allEffectiveValues ? allEffectiveValues[key]: actualValues[key]; + fields.push({name: key, actualValue: actualValues[key], effectiveValue: effectiveValue, "inherited": false}); + } + } + return fields; + }, + _handleOnChange: function(newValue) + { + if (!util.equals(this._lastValueReported, newValue)) + { + this._lastValueReported = newValue; + if(this._onChangeHandle) + { + this._onChangeHandle.remove(); + } + this._onChangeHandle = this.defer(function() + { + this._onChangeHandle = null; + this.onChange(newValue); + }); + } + } + + }); +});
\ No newline at end of file diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js index 81a21cf736..fb91a95de9 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Broker.js @@ -36,6 +36,7 @@ define(["dojo/_base/xhr", "qpid/management/addKeystore", "qpid/management/addGroupProvider", "qpid/management/addAccessControlProvider", + "qpid/management/editBroker", "dojox/grid/enhanced/plugins/Pagination", "dojox/grid/enhanced/plugins/IndirectSelection", "dijit/layout/AccordionContainer", @@ -49,7 +50,8 @@ define(["dojo/_base/xhr", "dijit/Menu", "dijit/MenuItem", "dojo/domReady!"], - function (xhr, parser, query, json, connect, properties, updater, util, UpdatableStore, EnhancedGrid, registry, entities, addAuthenticationProvider, addVirtualHostNodeAndVirtualHost, addPort, addKeystore, addGroupProvider, addAccessControlProvider) { + function (xhr, parser, query, json, connect, properties, updater, util, UpdatableStore, EnhancedGrid, registry, entities, + addAuthenticationProvider, addVirtualHostNodeAndVirtualHost, addPort, addKeystore, addGroupProvider, addAccessControlProvider, editBroker) { function Broker(name, parent, controller) { this.name = name; @@ -60,95 +62,6 @@ define(["dojo/_base/xhr", this.modelObj.parent = {}; this.modelObj.parent[ parent.type] = parent; } - this.attributeWidgetFactories = [{ - name: "name", - createWidget: function(brokerData) { - return new dijit.form.ValidationTextBox({ - required: true, - trim: true, - regExpGen: util.nameOrContextVarRegexp, - value: brokerData.name, - label: "Name*:", - name: "name", - promptMessage: "Identifies the broker instance."}) - } - }, { - name: "defaultVirtualHost", - createWidget: function(brokerData) { - var nodes = brokerData.virtualhostnodes; - var data = []; - if (nodes) { - for (var i=0; i< nodes.length; i++) { - if (nodes[i].virtualhosts) - { - data.push({id: nodes[i].virtualhosts[0].name, name: nodes[i].virtualhosts[0].name}); - } - } - } - var hostsStore = new dojo.store.Memory({ data: data }); - return new dijit.form.FilteringSelect({ - required: true, store: hostsStore, - value: brokerData.defaultVirtualHost, - label: "Default Virtual Host*:", - name: "defaultVirtualHost", - promptMessage: "Default virtual host used for clients that don't specify one when connecting."}) - } - }, { - name: "statisticsReportingPeriod", - createWidget: function(brokerData) { - return new dijit.form.ValidationTextBox({ - trim: "true", - regExpGen: util.numericOrContextVarRegexp, - required: false, - value: brokerData.statisticsReportingPeriod, - placeholder: "Time in ms", - label: "Statistics reporting period (ms):", - name: "statisticsReportingPeriod", - promptMessage: "Frequency with which statistics are reported to broker log." - }); - } - }, { - name: "statisticsReportingResetEnabled", - createWidget: function(brokerData) - { - return new dijit.form.CheckBox({ - required: false, checked: brokerData.statisticsReportingResetEnabled, value: "true", - label: "Statistics reporting period enabled:", - name: "statisticsReportingResetEnabled" - }); - } - }, { - name: "connection.sessionCountLimit", - groupName: "Global Connection Defaults", - createWidget: function(brokerData) - { - return new dijit.form.ValidationTextBox({ - trim: "true", - regExpGen: util.numericOrContextVarRegexp, - required: false, - value: brokerData["connection.sessionCountLimit"], - placeholder: "Number of sessions", - label: "Maximum number of sessions:", - name: "connection.sessionCountLimit", - promptMessage: "Maximum number of sessions per connection" - }); - } - }, { - name: "connection.heartBeatDelay", - createWidget: function(brokerData) { - return new dijit.form.ValidationTextBox({ - trim: "true", - regExpGen: util.numericOrContextVarRegexp, - invalidMessage: "Invalid value", - required: false, - value: brokerData["connection.heartBeatDelay"], - placeholder: "Time in ms", - label: "Heart beat delay (ms):", - name: "connection.heartBeatDelay", - promptMessage: "Interval between heart beat messages exchanged between broker and clients" - }); - } - } ]; } Broker.prototype.getTitle = function() @@ -227,20 +140,9 @@ define(["dojo/_base/xhr", var editButton = query(".editBroker", contentPane.containerNode)[0]; connect.connect(registry.byNode(editButton), "onClick", - function(evt){ - var query = "api/latest/broker"; - - xhr.get({url: query, sync: properties.useSyncGet, handleAs: "json", content: { actuals: true, depth: 2 }}) - .then(function(data) - { - var brokerData = data[0]; - - util.showSetAttributesDialog( - that.attributeWidgetFactories, - brokerData, - query, - "Set broker attributes", "Broker", "broker"); - }); + function(evt) + { + editBroker.show(that.brokerUpdater.brokerData); } ); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js index 455cfbb410..76eaadad18 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/VirtualHostNode.js @@ -107,7 +107,7 @@ define(["dojo/_base/xhr", this.editNodeButton.on("click", function(event) { - editVirtualHostNode.show(that.name); + editVirtualHostNode.show(that.vhostNodeUpdater.nodeData); } ); @@ -179,6 +179,7 @@ define(["dojo/_base/xhr", xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}).then( function(data) { + that.nodeData = data[0]; that.updateUI(data[0]); } ); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js index 02eb8cd2b6..96da8dc5fa 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHostNodeAndVirtualHost.js @@ -36,6 +36,9 @@ define(["dojo/_base/xhr", "qpid/common/util", "qpid/common/metadata", "dojo/text!addVirtualHostNodeAndVirtualHost.html", + "qpid/common/ContextVariablesEditor", + "dijit/TitlePane", + "dijit/layout/ContentPane", "dijit/form/Form", "dijit/form/CheckBox", "dijit/form/RadioButton", @@ -100,7 +103,65 @@ define(["dojo/_base/xhr", this.virtualHostForm.reset(); this.virtualHostType.set("value", null); + if (!this.virtualHostNodeContext) + { + this.virtualHostNodeContext = new qpid.common.ContextVariablesEditor({name: 'context', title: 'Context variables'}); + this.virtualHostNodeContext.placeAt(dom.byId("addVirtualHostNode.context")); + var that = this; + this.virtualHostNodeContext.on("change", function(value){ + var inherited = that.virtualHostContext.inheritedActualValues; + var effective = that.virtualHostContext.effectiveValues; + var actuals = that.virtualHostContext.value; + for(var key in value) + { + var val = value[key]; + if (!(key in actuals)) + { + inherited[key] = val; + if (!(key in effective)) + { + effective[key] = val.indexOf("${") == -1 ? val : ""; + } + } + } + that.virtualHostContext.setData(that.virtualHostContext.value,effective,inherited); + }); + } + if (!this.virtualHostContext) + { + this.virtualHostContext = new qpid.common.ContextVariablesEditor({name: 'context', title: 'Context variables'}); + this.virtualHostContext.placeAt(dom.byId("addVirtualHost.context")); + + } + var inheritedActualValues = null; + xhr.get( + { + url: "api/latest/broker", + sync: true, + content: { actuals: true, inheritedActuals: true}, + handleAs: "json", + load: function(data) + { + inheritedActualValues = data[0].context; + } + } + ); + var effectiveValues = null; + xhr.get( + { + url: "api/latest/broker", + sync: true, + handleAs: "json", + load: function(data) + { + effectiveValues = data[0].context; + } + } + ); + + this.virtualHostNodeContext.setData({},effectiveValues,inheritedActualValues); + this.virtualHostContext.setData({},effectiveValues,inheritedActualValues); this.dialog.show(); }, destroy: function() @@ -133,7 +194,14 @@ define(["dojo/_base/xhr", var widgets = registry.findWidgets(typeFieldsContainer); array.forEach(widgets, function(item) { item.destroyRecursive();}); domConstruct.empty(typeFieldsContainer); - + if (category) + { + var context = this["v" + category.substring(1) + "Context"]; + if (context) + { + context.removeDynamicallyAddedInheritedContext(); + } + } if (type) { var that = this; @@ -214,7 +282,17 @@ define(["dojo/_base/xhr", var success = false,failureReason=null; var virtualHostNodeData = this._getValues(this.virtualHostNodeForm); + var virtualHostNodeContext = this.virtualHostNodeContext.get("value"); + if (virtualHostNodeContext) + { + virtualHostNodeData["context"] = virtualHostNodeContext; + } var virtualHostData = this._getValues(this.virtualHostForm); + var virtualHostContext = this.virtualHostContext.get("value"); + if (virtualHostContext) + { + virtualHostData["context"] = virtualHostContext; + } //Default the VH name to be the same as the VHN name. virtualHostData["name"] = virtualHostNodeData["name"]; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editBroker.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editBroker.js new file mode 100644 index 0000000000..d83db74b65 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editBroker.js @@ -0,0 +1,196 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +define(["dojo/_base/xhr", + "dojox/html/entities", + "dojo/_base/array", + "dojo/_base/event", + "dojo/_base/lang", + "dojo/_base/window", + "dojo/dom", + "dojo/dom-construct", + "dijit/registry", + "dojo/parser", + 'dojo/json', + "dojo/query", + "dojo/store/Memory", + "dojo/data/ObjectStore", + "qpid/common/util", + "dojo/text!editBroker.html", + "qpid/common/ContextVariablesEditor", + "dijit/Dialog", + "dijit/form/CheckBox", + "dijit/form/FilteringSelect", + "dijit/form/ValidationTextBox", + "dijit/form/Button", + "dijit/form/Form", + "dojox/validate/us", + "dojox/validate/web", + "dojo/domReady!"], + function (xhr, entities, array, event, lang, win, dom, domConstruct, registry, parser, json, query, Memory, ObjectStore, util, template) + { + var fields = [ "name", "defaultVirtualHost", "statisticsReportingPeriod", "statisticsReportingResetEnabled", "connection.sessionCountLimit", "connection.heartBeatDelay"]; + var numericFieldNames = ["statisticsReportingPeriod", "connection.sessionCountLimit", "connection.heartBeatDelay"]; + + var brokerEditor = + { + init: function() + { + var that=this; + this.containerNode = domConstruct.create("div", {innerHTML: template}); + parser.parse(this.containerNode); + + this.dialog = registry.byId("editBrokerDialog"); + this.saveButton = registry.byId("editBroker.saveButton"); + this.cancelButton = registry.byId("editBroker.cancelButton"); + this.cancelButton.on("click", function(e){that._cancel(e);}); + this.saveButton.on("click", function(e){that._save(e);}); + for(var i = 0; i < fields.length; i++) + { + var fieldName = fields[i]; + this[fieldName] = registry.byId("editBroker." + fieldName); + } + this.form = registry.byId("editBrokerForm"); + this.context = registry.byId("editBroker.context"); + util.applyMetadataToWidgets(this.containerNode, "Broker", "broker"); + + for(var i = 0; i < numericFieldNames.length; i++) + { + this[numericFieldNames[i]].set("regExpGen", util.numericOrContextVarRegexp); + } + }, + show: function(brokerData) + { + var that=this; + this.query = "api/latest/broker"; + this.dialog.set("title", "Edit Broker - " + entities.encode(String(brokerData.name))); + xhr.get( + { + url: this.query, + sync: true, + content: { actuals: true }, + handleAs: "json", + load: function(data) + { + that._show(data[0], brokerData); + } + } + ); + }, + destroy: function() + { + if (this.dialog) + { + this.dialog.destroyRecursive(); + this.dialog = null; + } + + if (this.containerNode) + { + domConstruct.destroy(this.containerNode); + this.containerNode = null; + } + }, + _cancel: function(e) + { + this.dialog.hide(); + }, + _save: function(e) + { + event.stop(e); + if(this.form.validate()) + { + var data = util.getFormWidgetValues(this.form, this.initialData); + var context = this.context.get("value"); + if (context && !util.equals(context, this.initialData.context)) + { + data["context"] = context; + } + + var success = false,failureReason=null; + xhr.put({ + url: this.query, + sync: true, + handleAs: "json", + headers: { "Content-Type": "application/json"}, + putData: json.stringify(data), + load: function(x) {success = true; }, + error: function(error) {success = false; failureReason = error;} + }); + + if(success === true) + { + this.dialog.hide(); + } + else + { + util.xhrErrorHandler(failureReason); + } + } + else + { + alert('Form contains invalid data. Please correct first'); + } + }, + _show:function(actualData, effectiveData) + { + this.initialData = actualData; + var nodes = effectiveData.virtualhostnodes + var data = []; + if (nodes) + { + for (var i=0; i< nodes.length; i++) + { + if (nodes[i].virtualhosts) + { + data.push({id: nodes[i].virtualhosts[0].name, name: nodes[i].virtualhosts[0].name}); + } + } + } + var hostsStore = new dojo.store.Memory({ data: data }); + this["defaultVirtualHost"].set("store", hostsStore); + + + for(var i = 0; i < fields.length; i++) + { + var fieldName = fields[i]; + var widget = this[fieldName]; + widget.reset(); + + if (widget instanceof dijit.form.CheckBox) + { + widget.set("checked", actualData[fieldName]); + } + else + { + widget.set("value", actualData[fieldName]); + } + } + this.context.load(this.query, {actualValues: actualData.context, effectiveValues: effectiveData.context}); + this.dialog.startup(); + this.dialog.show(); + } + }; + + brokerEditor.init(); + + return brokerEditor; + } +); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js index f25be2d57e..7ba86e5d03 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHost.js @@ -34,6 +34,7 @@ define(["dojo/_base/xhr", "dojo/data/ObjectStore", "qpid/common/util", "dojo/text!editVirtualHost.html", + "qpid/common/ContextVariablesEditor", "dijit/Dialog", "dijit/form/CheckBox", "dijit/form/FilteringSelect", @@ -73,6 +74,11 @@ define(["dojo/_base/xhr", show: function(hostData) { var that=this; + if (!this.context) + { + this.context = new qpid.common.ContextVariablesEditor({name: 'context', title: 'Context variables'}); + this.context.placeAt(dom.byId("editVirtualHost.context")); + } this.query = "api/latest/virtualhost/" + encodeURIComponent(hostData.nodeName) + "/" + encodeURIComponent(hostData.hostName); this.dialog.set("title", "Edit Virtual Host - " + entities.encode(String(hostData.hostName))); xhr.get( @@ -83,7 +89,7 @@ define(["dojo/_base/xhr", handleAs: "json", load: function(data) { - that._show(data[0]); + that._show(data[0], hostData); } } ); @@ -112,7 +118,11 @@ define(["dojo/_base/xhr", if(this.form.validate()) { var data = util.getFormWidgetValues(this.form, this.initialData); - + var context = this.context.get("value"); + if (context && !util.equals(context, this.initialData.context)) + { + data["context"] = context; + } var success = false,failureReason=null; xhr.put({ url: this.query, @@ -138,10 +148,10 @@ define(["dojo/_base/xhr", alert('Form contains invalid data. Please correct first'); } }, - _show:function(virtualHostData) + _show:function(actualData, effectiveData) { - this.initialData = virtualHostData; + this.initialData = actualData; for(var i = 0; i < fields.length; i++) { var fieldName = fields[i]; @@ -150,14 +160,16 @@ define(["dojo/_base/xhr", if (widget instanceof dijit.form.CheckBox) { - widget.set("checked", virtualHostData[fieldName]); + widget.set("checked", actualData[fieldName]); } else { - widget.set("value", virtualHostData[fieldName]); + widget.set("value", actualData[fieldName]); } } + this.context.load(this.query, {actualValues:actualData.context, effectiveValues:effectiveData.context}); + // Add regexp to the numeric fields for(var i = 0; i < numericFieldNames.length; i++) { @@ -170,15 +182,15 @@ define(["dojo/_base/xhr", array.forEach(widgets, function(item) { item.destroyRecursive();}); domConstruct.empty(this.typeFieldsContainer); - require(["qpid/management/virtualhost/" + virtualHostData.type.toLowerCase() + "/edit"], + require(["qpid/management/virtualhost/" + actualData.type.toLowerCase() + "/edit"], function(TypeUI) { try { - TypeUI.show({containerNode:that.typeFieldsContainer, parent: that, data: virtualHostData}); + TypeUI.show({containerNode:that.typeFieldsContainer, parent: that, data: actualData}); that.form.connectChildren(); - util.applyMetadataToWidgets(that.allFieldsContainer, "VirtualHost", virtualHostData.type); + util.applyMetadataToWidgets(that.allFieldsContainer, "VirtualHost", actualData.type); } catch(e) { diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js index 545be75fff..ca619f10f5 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/editVirtualHostNode.js @@ -34,6 +34,7 @@ define(["dojo/_base/xhr", "dojo/data/ObjectStore", "qpid/common/util", "dojo/text!editVirtualHostNode.html", + "qpid/common/ContextVariablesEditor", "dijit/Dialog", "dijit/form/CheckBox", "dijit/form/FilteringSelect", @@ -61,11 +62,16 @@ define(["dojo/_base/xhr", this.name = registry.byId("editVirtualHostNode.name"); this.form = registry.byId("editVirtualHostNodeForm"); }, - show: function(nodeName) + show: function(effectiveData) { var that=this; - this.query = "api/latest/virtualhostnode/" + encodeURIComponent(nodeName); - this.dialog.set("title", "Edit Virtual Host Node - " + entities.encode(String(nodeName))); + if (!this.context) + { + this.context = new qpid.common.ContextVariablesEditor({name: 'context', title: 'Context variables'}); + this.context.placeAt(dom.byId("editVirtualHostNode.context")); + } + this.query = "api/latest/virtualhostnode/" + encodeURIComponent(effectiveData.name); + this.dialog.set("title", "Edit Virtual Host Node - " + entities.encode(String(effectiveData.name))); xhr.get( { url: this.query, @@ -74,7 +80,7 @@ define(["dojo/_base/xhr", handleAs: "json", load: function(data) { - that._show(data[0]); + that._show(data[0], effectiveData); } } ); @@ -103,7 +109,11 @@ define(["dojo/_base/xhr", if(this.form.validate()) { var data = util.getFormWidgetValues(this.form, this.initialData); - + var context = this.context.get("value"); + if (context && !util.equals(context, this.initialData.context)) + { + data["context"] = context; + } var success = false,failureReason=null; xhr.put({ url: this.query, @@ -129,10 +139,11 @@ define(["dojo/_base/xhr", alert('Form contains invalid data. Please correct first'); } }, - _show:function(nodeData) + _show:function(actualData, effectiveData) { - this.initialData = nodeData; - this.name.set("value", nodeData.name); + this.initialData = actualData; + this.name.set("value", actualData.name); + this.context.load( this.query, {actualValues: actualData.context, effectiveValues: effectiveData.context}); var that = this; @@ -140,15 +151,15 @@ define(["dojo/_base/xhr", array.forEach(widgets, function(item) { item.destroyRecursive();}); domConstruct.empty(this.typeFieldsContainer); - require(["qpid/management/virtualhostnode/" + nodeData.type.toLowerCase() + "/edit"], + require(["qpid/management/virtualhostnode/" + actualData.type.toLowerCase() + "/edit"], function(TypeUI) { try { - TypeUI.show({containerNode:that.typeFieldsContainer, parent: that, data: nodeData}); + TypeUI.show({containerNode:that.typeFieldsContainer, parent: that, data: actualData}); that.form.connectChildren(); - util.applyMetadataToWidgets(that.allFieldsContainer, "VirtualHostNode", nodeData.type); + util.applyMetadataToWidgets(that.allFieldsContainer, "VirtualHostNode", actualData.type); } catch(e) { diff --git a/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java index 15102c8ce4..ac595154bb 100644 --- a/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java +++ b/qpid/java/broker-plugins/management-http/src/test/java/org/apache/qpid/server/management/plugin/servlet/rest/ConfiguredObjectToMapConverterTest.java @@ -139,6 +139,7 @@ public class ConfiguredObjectToMapConverterTest extends TestCase when(_configuredObject.getContextValue(eq(String.class),eq("inheritedkey"))).thenReturn("foo"); when(_configuredObject.getContextKeys(anyBoolean())).thenReturn(inheritedKeys); when(_configuredObject.getContext()).thenReturn(actualContext); + when(_configuredObject.getActualAttributes()).thenReturn(Collections.singletonMap(ConfiguredObject.CONTEXT, actualContext)); when(mockChild.getAttributeNames()).thenReturn(Arrays.asList(childAttributeName, ConfiguredObject.CONTEXT)); when(mockChild.getAttribute(childAttributeName)).thenReturn(childAttributeValue); when(mockChild.getActualAttributes()).thenReturn(Collections.singletonMap(childAttributeName, childActualAttributeValue)); |
