diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2013-06-19 15:51:30 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2013-06-19 15:51:30 +0000 |
| commit | 706675d432369def04b47ab935a17adec390e202 (patch) | |
| tree | b4c85415ad3a305e47d4d8af51a43b39bcd5a106 /qpid/java/broker-plugins | |
| parent | 0c801f4ef8be29a0a756bce67651cac7f583a525 (diff) | |
| download | qpid-python-706675d432369def04b47ab935a17adec390e202.tar.gz | |
QPID-4937 : [Java Broker] separate virtualhosts into different types
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1494667 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins')
7 files changed, 153 insertions, 66 deletions
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java index a7066c73d8..8692ecc88c 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java @@ -33,8 +33,9 @@ import javax.servlet.http.HttpServletResponse; import org.apache.qpid.server.management.plugin.servlet.rest.action.ListAccessControlProviderAttributes; import org.apache.qpid.server.management.plugin.servlet.rest.action.ListAuthenticationProviderAttributes; +import org.apache.qpid.server.management.plugin.servlet.rest.action.ListBrokerAttribute; import org.apache.qpid.server.management.plugin.servlet.rest.action.ListGroupProviderAttributes; -import org.apache.qpid.server.management.plugin.servlet.rest.action.ListMessageStoreTypes; +import org.apache.qpid.server.model.Broker; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; @@ -52,8 +53,10 @@ public class HelperServlet extends AbstractServlet _actions = new HashMap<String, Action>(); Action listProviderAttributes = new ListAuthenticationProviderAttributes(); _actions.put(listProviderAttributes.getName(), listProviderAttributes); - Action listMessageStoreTypes = new ListMessageStoreTypes(); + Action listMessageStoreTypes = new ListBrokerAttribute(Broker.SUPPORTED_VIRTUALHOST_STORE_TYPES, "ListMessageStoreTypes"); _actions.put(listMessageStoreTypes.getName(), listMessageStoreTypes); + Action listVirtualHostTypes = new ListBrokerAttribute(Broker.SUPPORTED_VIRTUALHOST_TYPES, "ListVirtualHostTypes"); + _actions.put(listVirtualHostTypes.getName(), listVirtualHostTypes); Action groupProviderAttributes = new ListGroupProviderAttributes(); _actions.put(groupProviderAttributes.getName(), groupProviderAttributes); Action aclProviderAttributes = new ListAccessControlProviderAttributes(); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListMessageStoreTypes.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListBrokerAttribute.java index c0a5d78753..dc414e6a64 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListMessageStoreTypes.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/action/ListBrokerAttribute.java @@ -25,19 +25,28 @@ import java.util.Map; import org.apache.qpid.server.management.plugin.servlet.rest.Action; import org.apache.qpid.server.model.Broker; -public class ListMessageStoreTypes implements Action +public class ListBrokerAttribute implements Action { + private final String _attributeName; + private final String _name; + + public ListBrokerAttribute(String attributeName, String name) + { + _attributeName = attributeName; + _name = name; + } + @Override public String getName() { - return ListMessageStoreTypes.class.getSimpleName(); + return _name; } @Override public Object perform(Map<String, Object> request, Broker broker) { - return broker.getAttribute(Broker.SUPPORTED_VIRTUALHOST_STORE_TYPES); + return broker.getAttribute(_attributeName); } } diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHost.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHost.html index 43281f600d..282f4ab8f6 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHost.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addVirtualHost.html @@ -48,17 +48,12 @@ <div id="addVirtualHost.attributesDiv"> <table class="tableContainer-table tableContainer-table-horiz"> <tr> - <td class="tableContainer-labelCell" style="width: 300px;"><strong>Store Type*: </strong></td> - <td class="tableContainer-valueCell" ><div id="addVirtualHost.selectStoreType"></div></td> - </tr> - <tr> - <td class="tableContainer-labelCell" style="width: 300px;"><strong>Path to store location*: </strong></td> - <td class="tableContainer-valueCell"> - <input dojoType="dijit.form.ValidationTextBox" id="formAddVirtualHost.storePath" - name="storePath" placeholder="/path/to/message/store" /> - </td> + <td class="tableContainer-labelCell" style="width: 300px;"><strong>Type*: </strong></td> + <td class="tableContainer-valueCell" ><div id="addVirtualHost.selectType"></div></td> </tr> </table> + <div id="addVirtualHost.typeSpecificDiv"> + </div> </div> </div> diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js index 0343d3393a..18abfa443f 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addPort.js @@ -60,7 +60,7 @@ define(["dojo/_base/xhr", var node = construct.create("div", null, win.body(), "last"); - var convertToPort = function convertToPort(formValues) + var convertToPort = function convertToPort(formValues) { var newPort = {}; newPort.name = dijit.byId("formAddPort.name").value; @@ -478,4 +478,4 @@ define(["dojo/_base/xhr", }; return addPort; - });
\ No newline at end of file + }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHost.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHost.js index 9c04c3014f..330c6ed40b 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHost.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/addVirtualHost.js @@ -92,7 +92,7 @@ define(["dojo/_base/xhr", }, "addVirtualHost.configPathDiv"); var attributesPane = new dijit.layout.AccordionPane({ - title: "Store Attributes", + title: "Virtual Host Attributes", selected: true }, "addVirtualHost.attributesDiv"); @@ -112,14 +112,14 @@ define(["dojo/_base/xhr", if(theForm.validate()){ var formValues = theForm.getValues(); - if (formValues.configPath == "" && formValues.storeType == "") + if (formValues.configPath == "" && formValues["type"] == "") { - alert("Please specify either configuration or store type for the virtual host"); + alert("Please specify either configuration file or type for the virtual host"); return false; } - if (formValues.configPath != "" && formValues.storeType != "") + if (formValues.configPath != "" && formValues["type"] != "") { - alert("Either configuration or store type with path have to be specified!"); + alert("Either configuration file or type have to be specified!"); return false; } var newVirtualHost = convertToVirtualHost(formValues); @@ -149,63 +149,51 @@ define(["dojo/_base/xhr", }}); } - addVirtualHost.show = function(virtualHostName) { + addVirtualHost.selectVhostType = function(type) { + if(type && String(type).trim() != "") { + require(["qpid/management/virtualhost/"+type.toLowerCase()+"/addVirtualHost"], + function(vhostType) + { + vhostType.show(); + }); + } + } + + addVirtualHost.show = function() { var that = this; + dom.byId("addVirtualHost.typeSpecificDiv").innerHTML = ""; registry.byId("formAddVirtualHost").reset(); dojo.byId("formAddVirtualHost.id").value=""; - if (!that.hasOwnProperty("storeTypeChooser")) + + if (!that.hasOwnProperty("typeChooser")) { xhr.get({ sync: true, - url: "rest/helper?action=ListMessageStoreTypes", + url: "rest/helper?action=ListVirtualHostTypes", handleAs: "json" }).then( function(data) { - var storeTypes = data; - var storeTypesData = []; - for (var i =0 ; i < storeTypes.length; i++) + var vhostTypes = data; + var vhostTypesData = []; + for (var i =0 ; i < vhostTypes.length; i++) { - storeTypesData[i]= {id: storeTypes[i], name: storeTypes[i]}; + vhostTypesData[i]= {id: vhostTypes[i], name: vhostTypes[i]}; } - var storeTypesStore = new Memory({ data: storeTypesData }); - var storeTypesDiv = dom.byId("addVirtualHost.selectStoreType"); - var input = construct.create("input", {id: "addStoreType", required: false}, storeTypesDiv); - that.storeTypeChooser = new FilteringSelect({ id: "addVirtualHost.storeType", - name: "storeType", - store: storeTypesStore, - searchAttr: "name", required: false}, input); + var typesStore = new Memory({ data: vhostTypesData }); + var typesDiv = dom.byId("addVirtualHost.selectType"); + var input = construct.create("input", {id: "addType", required: false}, typesDiv); + that.typeChooser = new FilteringSelect({ id: "addVirtualHost.type", + name: "type", + store: typesStore, + searchAttr: "name", + required: false, + onChange: that.selectVhostType }, input); }); } - if (virtualHostName) - { - xhr.get({ - url: "rest/virtualhost/" + encodeURIComponent(virtualHostName), - handleAs: "json" - }).then( - function(data) { - var host = data[0]; - var nameField = dijit.byId("formAddVirtualHost.name"); - nameField.set("value", host.name); - dojo.byId("formAddVirtualHost.id").value=host.id; - var configPath = host.configPath; - if (configPath) - { - var configPathField = dijit.byId("formAddVirtualHost.configPath"); - configPathField.set("value", host.configPath); - } - else - { - that.storeTypeChooser.set("value", host.storeType.toLowerCase()); - var storePathField = dijit.byId("formAddVirtualHost.storePath"); - storePathField.set("value", host.storePath); - } - registry.byId("addVirtualHost").show(); - }); - } - else - { - registry.byId("addVirtualHost").show(); - } + + + registry.byId("addVirtualHost").show(); + } return addVirtualHost; - });
\ No newline at end of file + }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/standard/addVirtualHost.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/standard/addVirtualHost.js new file mode 100644 index 0000000000..cd56ca9cba --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/standard/addVirtualHost.js @@ -0,0 +1,79 @@ +/* + * + * 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", + "dojo/dom", + "dojo/dom-construct", + "dojo/_base/window", + "dijit/registry", + "dojo/parser", + "dojo/_base/array", + "dojo/_base/event", + 'dojo/_base/json', + "dojo/store/Memory", + "dijit/form/FilteringSelect", + "dojo/domReady!"], + function (xhr, dom, construct, win, registry, parser, array, event, json, Memory, FilteringSelect) { + return { + show: function() { + var node = dom.byId("addVirtualHost.typeSpecificDiv"); + var that = this; + + array.forEach(registry.toArray(), + function(item) { + if(item.id.substr(0,27) == "formAddVirtualHost.specific") { + item.destroyRecursive(); + } + }); + + xhr.get({url: "virtualhost/standard/add.html", + sync: true, + load: function(data) { + node.innerHTML = data; + parser.parse(node); + if (that.hasOwnProperty("storeTypeChooser")) + { + that.storeTypeChooser.destroy(); + } + xhr.get({ + sync: true, + url: "rest/helper?action=ListMessageStoreTypes", + handleAs: "json" + }).then( + function(data) { + var storeTypes = data; + var storeTypesData = []; + for (var i =0 ; i < storeTypes.length; i++) + { + storeTypesData[i]= {id: storeTypes[i], name: storeTypes[i]}; + } + var storeTypesStore = new Memory({ data: storeTypesData }); + var storeTypesDiv = dom.byId("addVirtualHost.specific.selectStoreType"); + var input = construct.create("input", {id: "addStoreType", required: false}, storeTypesDiv); + that.storeTypeChooser = new FilteringSelect({ id: "addVirtualHost.specific.storeType", + name: "storeType", + store: storeTypesStore, + searchAttr: "name", required: false}, input); + }); + + }}); + } + }; + }); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/standard/add.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/standard/add.html new file mode 100644 index 0000000000..9596ef4175 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/virtualhost/standard/add.html @@ -0,0 +1,13 @@ +<table class="tableContainer-table tableContainer-table-horiz"> + <tr> + <td class="tableContainer-labelCell" style="width: 300px;"><strong>Store Type*: </strong></td> + <td class="tableContainer-valueCell" ><div id="addVirtualHost.specific.selectStoreType"></div></td> + </tr> + <tr> + <td class="tableContainer-labelCell" style="width: 300px;"><strong>Path to store location*: </strong></td> + <td class="tableContainer-valueCell"> + <input dojoType="dijit/form/ValidationTextBox" required="true" id="formAddVirtualHost.specific.storePath" + name="storePath" placeholder="/path/to/message/store" /> + </td> + </tr> +</table> |
