From db07194fdec1c2c27d9de2fdc881e5d8e7b3ead9 Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Sun, 7 Dec 2014 10:54:59 +0000 Subject: QPID-6263 : [Java Broker] Remove knowledge of BrokerOptions from SystemConfig and simply use attributes instead git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1643660 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/server/store/derby/DerbySystemConfigImpl.java | 7 ++++--- .../org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java | 7 ++++--- .../java/org/apache/qpid/server/store/MemorySystemConfigImpl.java | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'qpid/java/broker-plugins') diff --git a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfigImpl.java b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfigImpl.java index a8b9edaa12..0cc4f2b18c 100644 --- a/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfigImpl.java +++ b/qpid/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbySystemConfigImpl.java @@ -20,7 +20,8 @@ */ package org.apache.qpid.server.store.derby; -import org.apache.qpid.server.BrokerOptions; +import java.util.Map; + import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.LogRecorder; @@ -48,10 +49,10 @@ public class DerbySystemConfigImpl extends AbstractSystemConfig attributes, final BrokerShutdownProvider brokerShutdownProvider) { - super(taskExecutor, eventLogger, logRecorder, brokerOptions, brokerShutdownProvider); + super(taskExecutor, eventLogger, logRecorder, attributes, brokerShutdownProvider); } @Override diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java index a552b170a0..9c3d33fc04 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java @@ -20,7 +20,8 @@ */ package org.apache.qpid.server.store.jdbc; -import org.apache.qpid.server.BrokerOptions; +import java.util.Map; + import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.LogRecorder; @@ -50,10 +51,10 @@ public class JDBCSystemConfigImpl extends AbstractSystemConfig attributes, final BrokerShutdownProvider brokerShutdownProvider) { - super(taskExecutor, eventLogger, logRecorder, brokerOptions, brokerShutdownProvider); + super(taskExecutor, eventLogger, logRecorder, attributes, brokerShutdownProvider); } @Override diff --git a/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java b/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java index 3f5215219b..a15de21ce7 100644 --- a/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java +++ b/qpid/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemorySystemConfigImpl.java @@ -20,7 +20,8 @@ */ package org.apache.qpid.server.store; -import org.apache.qpid.server.BrokerOptions; +import java.util.Map; + import org.apache.qpid.server.configuration.updater.TaskExecutor; import org.apache.qpid.server.logging.EventLogger; import org.apache.qpid.server.logging.LogRecorder; @@ -40,10 +41,10 @@ public class MemorySystemConfigImpl extends AbstractSystemConfig attributes, final BrokerShutdownProvider brokerShutdownProvider) { - super(taskExecutor, eventLogger, logRecorder, brokerOptions, brokerShutdownProvider); + super(taskExecutor, eventLogger, logRecorder, attributes, brokerShutdownProvider); } @Override -- cgit v1.2.1 From 5b46665ddfa9875ab7b11c6a916b943d4fbcce75 Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Mon, 15 Dec 2014 13:03:19 +0000 Subject: QPID-6125: [Java Broker] Consistently quote queue/exchange names in error messages sent back over the wire git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1645645 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/server/protocol/v0_8/AMQChannel.java | 89 +++++++++++----------- 1 file changed, 43 insertions(+), 46 deletions(-) (limited to 'qpid/java/broker-plugins') diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java index 7604662980..2550221949 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java @@ -2113,32 +2113,32 @@ public class AMQChannel catch (AMQQueue.ExistingExclusiveConsumer e) { _connection.closeConnection(AMQConstant.ACCESS_REFUSED, - "Cannot subscribe to queue " + "Cannot subscribe to queue '" + queue1.getName() - + " as it already has an existing exclusive consumer", _channelId); + + "' as it already has an existing exclusive consumer", _channelId); } catch (AMQQueue.ExistingConsumerPreventsExclusive e) { _connection.closeConnection(AMQConstant.ACCESS_REFUSED, - "Cannot subscribe to queue " + "Cannot subscribe to queue '" + queue1.getName() - + " exclusively as it already has a consumer", _channelId); + + "' exclusively as it already has a consumer", _channelId); } catch (AccessControlException e) { - _connection.closeConnection(AMQConstant.ACCESS_REFUSED, "Cannot subscribe to queue " + _connection.closeConnection(AMQConstant.ACCESS_REFUSED, "Cannot subscribe to queue '" + queue1.getName() - + " permission denied", _channelId); + + "' permission denied", _channelId); } catch (MessageSource.ConsumerAccessRefused consumerAccessRefused) { _connection.closeConnection(AMQConstant.ACCESS_REFUSED, - "Cannot subscribe to queue " + "Cannot subscribe to queue '" + queue1.getName() - + " as it already has an incompatible exclusivity policy", _channelId); + + "' as it already has an incompatible exclusivity policy", _channelId); } @@ -2247,7 +2247,7 @@ public class AMQChannel // if the exchange does not exist we raise a channel exception if (destination == null) { - closeChannel(AMQConstant.NOT_FOUND, "Unknown exchange name: " + exchangeName); + closeChannel(AMQConstant.NOT_FOUND, "Unknown exchange name: '" + exchangeName + "'"); } else { @@ -2805,15 +2805,14 @@ public class AMQChannel exchange = virtualHost.getExchange(exchangeName.toString()); if (exchange == null) { - closeChannel(AMQConstant.NOT_FOUND, "Unknown exchange: " + exchangeName); + closeChannel(AMQConstant.NOT_FOUND, "Unknown exchange: '" + exchangeName + "'"); } else if (!(type == null || type.length() == 0) && !exchange.getType().equals(type.asString())) { - _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: " - + - exchangeName - + " of type " + _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: '" + + exchangeName + + "' of type " + exchange.getType() + " to " + type @@ -2840,7 +2839,6 @@ public class AMQChannel { attributes.putAll(FieldTable.convertToMap(arguments)); } - attributes.put(Exchange.ID, null); attributes.put(Exchange.NAME, name); attributes.put(Exchange.TYPE, typeString); attributes.put(Exchange.DURABLE, durable); @@ -2865,8 +2863,8 @@ public class AMQChannel catch (ReservedExchangeNameException e) { _connection.closeConnection(AMQConstant.NOT_ALLOWED, - "Attempt to declare exchange: " + exchangeName + - " which begins with reserved prefix.", getChannelId()); + "Attempt to declare exchange: '" + exchangeName + + "' which begins with reserved prefix.", getChannelId()); } @@ -2875,8 +2873,8 @@ public class AMQChannel exchange = e.getExistingExchange(); if (!new AMQShortString(exchange.getType()).equals(type)) { - _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: " - + exchangeName + " of type " + _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Attempt to redeclare exchange: '" + + exchangeName + "' of type " + exchange.getType() + " to " + type + ".", getChannelId()); @@ -2912,7 +2910,7 @@ public class AMQChannel // note - since 0-8/9/9-1 can't set the alt. exchange this exception should never occur final String message = "Unknown alternate exchange " + (e.getName() != null - ? "name: \"" + e.getName() + "\"" + ? "name: '" + e.getName() + "'" : "id: " + e.getId()); _connection.closeConnection(AMQConstant.NOT_FOUND, message, getChannelId()); @@ -2958,7 +2956,7 @@ public class AMQChannel final ExchangeImpl exchange = virtualHost.getExchange(exchangeName); if (exchange == null) { - closeChannel(AMQConstant.NOT_FOUND, "No such exchange: " + exchangeStr); + closeChannel(AMQConstant.NOT_FOUND, "No such exchange: '" + exchangeStr + "'"); } else { @@ -3035,7 +3033,7 @@ public class AMQChannel else if (isDefaultExchange(exchange)) { _connection.closeConnection(AMQConstant.NOT_ALLOWED, - "Cannot bind the queue " + queueName + " to the default exchange", getChannelId()); + "Cannot bind the queue '" + queueName + "' to the default exchange", getChannelId()); } else @@ -3047,7 +3045,7 @@ public class AMQChannel if (exch == null) { closeChannel(AMQConstant.NOT_FOUND, - "Exchange " + exchangeName + " does not exist."); + "Exchange '" + exchangeName + "' does not exist."); } else { @@ -3138,19 +3136,19 @@ public class AMQChannel if (queue == null) { closeChannel(AMQConstant.NOT_FOUND, - "Queue: " + "Queue: '" + queueName - + " not found on VirtualHost(" - + virtualHost - + ")."); + + "' not found on VirtualHost '" + + virtualHost.getName() + + "'."); } else { if (!queue.verifySessionAccess(this)) { - _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Queue " + _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Queue '" + queue.getName() - + " is exclusive, but not created on this Connection.", getChannelId()); + + "' is exclusive, but not created on this Connection.", getChannelId()); } else { @@ -3180,7 +3178,6 @@ public class AMQChannel QueueArgumentsConverter.convertWireArgsToModel(FieldTable.convertToMap(arguments)); final String queueNameString = AMQShortString.toString(queueName); attributes.put(Queue.NAME, queueNameString); - attributes.put(Queue.ID, UUID.randomUUID()); attributes.put(Queue.DURABLE, durable); LifetimePolicy lifetimePolicy; @@ -3227,9 +3224,9 @@ public class AMQChannel if (!queue.verifySessionAccess(this)) { - _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Queue " + _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Queue '" + queue.getName() - + " is exclusive, but not created on this Connection.", getChannelId()); + + "' is exclusive, but not created on this Connection.", getChannelId()); } else if (queue.isExclusive() != exclusive) @@ -3323,27 +3320,27 @@ public class AMQChannel if (queue == null) { - closeChannel(AMQConstant.NOT_FOUND, "Queue " + queueName + " does not exist."); + closeChannel(AMQConstant.NOT_FOUND, "Queue '" + queueName + "' does not exist."); } else { if (ifEmpty && !queue.isEmpty()) { - closeChannel(AMQConstant.IN_USE, "Queue: " + queueName + " is not empty."); + closeChannel(AMQConstant.IN_USE, "Queue: '" + queueName + "' is not empty."); } else if (ifUnused && !queue.isUnused()) { // TODO - Error code - closeChannel(AMQConstant.IN_USE, "Queue: " + queueName + " is still used."); + closeChannel(AMQConstant.IN_USE, "Queue: '" + queueName + "' is still used."); } else { if (!queue.verifySessionAccess(this)) { - _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Queue " + _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Queue '" + queue.getName() - + " is exclusive, but not created on this Connection.", getChannelId()); + + "' is exclusive, but not created on this Connection.", getChannelId()); } else @@ -3383,7 +3380,7 @@ public class AMQChannel } else if ((queueName != null) && (queue = virtualHost.getQueue(queueName.toString())) == null) { - closeChannel(AMQConstant.NOT_FOUND, "Queue " + queueName + " does not exist."); + closeChannel(AMQConstant.NOT_FOUND, "Queue '" + queueName + "' does not exist."); } else if (!queue.verifySessionAccess(this)) { @@ -3416,14 +3413,14 @@ public class AMQChannel @Override public void receiveQueueUnbind(final AMQShortString queueName, final AMQShortString exchange, - final AMQShortString routingKey, + final AMQShortString bindingKey, final FieldTable arguments) { if(_logger.isDebugEnabled()) { _logger.debug("RECV[" + _channelId + "] QueueUnbind[" +" queue: " + queueName + " exchange: " + exchange + - " bindingKey: " + routingKey + + " bindingKey: " + bindingKey + " arguments: " + arguments + " ]"); } @@ -3440,14 +3437,14 @@ public class AMQChannel { String message = useDefaultQueue ? "No default queue defined on channel and queue was null" - : "Queue " + queueName + " does not exist."; + : "Queue '" + queueName + "' does not exist."; closeChannel(AMQConstant.NOT_FOUND, message); } else if (isDefaultExchange(exchange)) { - _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Cannot unbind the queue " + _connection.closeConnection(AMQConstant.NOT_ALLOWED, "Cannot unbind the queue '" + queue.getName() - + " from the default exchange", getChannelId()); + + "' from the default exchange", getChannelId()); } else @@ -3457,9 +3454,9 @@ public class AMQChannel if (exch == null) { - closeChannel(AMQConstant.NOT_FOUND, "Exchange " + exchange + " does not exist."); + closeChannel(AMQConstant.NOT_FOUND, "Exchange '" + exchange + "' does not exist."); } - else if (!exch.hasBinding(String.valueOf(routingKey), queue)) + else if (!exch.hasBinding(String.valueOf(bindingKey), queue)) { closeChannel(AMQConstant.NOT_FOUND, "No such binding"); } @@ -3467,7 +3464,7 @@ public class AMQChannel { try { - exch.deleteBinding(String.valueOf(routingKey), queue); + exch.deleteBinding(String.valueOf(bindingKey), queue); final AMQMethodBody responseBody = _connection.getMethodRegistry().createQueueUnbindOkBody(); sync(); -- cgit v1.2.1 From 77dbff8daed044b9c95ef0c210b5fe69ff9bbc2c Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Tue, 16 Dec 2014 08:55:22 +0000 Subject: QPID-6272: [Java Broker] Null reference to AMQChannel#defaultQueue once the queue is deleted git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1645880 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/server/protocol/v0_8/AMQChannel.java | 50 ++++++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'qpid/java/broker-plugins') diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java index 2550221949..5461b47eb4 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java @@ -124,6 +124,8 @@ public class AMQChannel public static final int DEFAULT_PREFETCH = 4096; private static final Logger _logger = Logger.getLogger(AMQChannel.class); + private final DefaultQueueAssociationClearingTask + _defaultQueueAssociationClearingTask = new DefaultQueueAssociationClearingTask(); //TODO use Broker property to configure message authorization requirements private boolean _messageAuthorizationRequired = Boolean.getBoolean(BrokerProperties.PROPERTY_MSG_AUTH); @@ -140,7 +142,7 @@ public class AMQChannel private long _deliveryTag = 0; /** A channel has a default queue (the last declared) that is used when no queue name is explicitly set */ - private AMQQueue _defaultQueue; + private volatile AMQQueue _defaultQueue; /** This tag is unique per subscription to a queue. The server returns this in response to a basic.consume request. */ private int _consumerTag; @@ -181,11 +183,9 @@ public class AMQChannel private LogSubject _logSubject; private volatile boolean _rollingBack; - private static final Runnable NULL_TASK = new Runnable() { public void run() {} }; private List _resendList = new ArrayList(); private static final AMQShortString IMMEDIATE_DELIVERY_REPLY_TEXT = new AMQShortString("Immediate delivery is not possible."); - private long _createTime = System.currentTimeMillis(); private final ClientDeliveryMethod _clientDeliveryMethod; @@ -1289,17 +1289,6 @@ public class AMQChannel return "("+ _suspended.get() + ", " + _closing.get() + ", " + _connection.isClosing() + ") "+"["+ _connection.toString()+":"+_channelId+"]"; } - public void setDefaultQueue(AMQQueue queue) - { - _defaultQueue = queue; - } - - public AMQQueue getDefaultQueue() - { - return _defaultQueue; - } - - public boolean isClosing() { return _closing.get(); @@ -3585,4 +3574,37 @@ public class AMQChannel return exchangeName == null || AMQShortString.EMPTY_STRING.equals(exchangeName); } + private void setDefaultQueue(AMQQueue queue) + { + AMQQueue currentDefaultQueue = _defaultQueue; + if (queue != currentDefaultQueue) + { + if (currentDefaultQueue != null) + { + currentDefaultQueue.removeDeleteTask(_defaultQueueAssociationClearingTask); + } + if (queue != null) + { + queue.addDeleteTask(_defaultQueueAssociationClearingTask); + } + } + _defaultQueue = queue; + } + + private AMQQueue getDefaultQueue() + { + return _defaultQueue; + } + + private class DefaultQueueAssociationClearingTask implements Action + { + @Override + public void performAction(final AMQQueue queue) + { + if ( queue == _defaultQueue) + { + _defaultQueue = null; + } + } + } } -- cgit v1.2.1 From 87b282857f59a43fa77ab65a06ea55cd14de0e05 Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Wed, 17 Dec 2014 00:22:01 +0000 Subject: QPID-6272 : [Java Broker] clear queue delete task on default queue before closing session git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1646118 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'qpid/java/broker-plugins') diff --git a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java index 5461b47eb4..d52fb735a2 100644 --- a/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java +++ b/qpid/java/broker-plugins/amqp-0-8-protocol/src/main/java/org/apache/qpid/server/protocol/v0_8/AMQChannel.java @@ -142,7 +142,7 @@ public class AMQChannel private long _deliveryTag = 0; /** A channel has a default queue (the last declared) that is used when no queue name is explicitly set */ - private volatile AMQQueue _defaultQueue; + private volatile AMQQueue _defaultQueue; /** This tag is unique per subscription to a queue. The server returns this in response to a basic.consume request. */ private int _consumerTag; @@ -827,7 +827,7 @@ public class AMQChannel getVirtualHost().getEventLogger().message(_logSubject, operationalLogMessage); unsubscribeAllConsumers(); - + setDefaultQueue(null); for (Action task : _taskList) { task.performAction(this); @@ -3114,7 +3114,7 @@ public class AMQChannel queueName = queueStr.intern(); } - AMQQueue queue; + AMQQueue queue; //TODO: do we need to check that the queue already exists with exactly the same "configuration"? @@ -3574,9 +3574,9 @@ public class AMQChannel return exchangeName == null || AMQShortString.EMPTY_STRING.equals(exchangeName); } - private void setDefaultQueue(AMQQueue queue) + private void setDefaultQueue(AMQQueue queue) { - AMQQueue currentDefaultQueue = _defaultQueue; + AMQQueue currentDefaultQueue = _defaultQueue; if (queue != currentDefaultQueue) { if (currentDefaultQueue != null) -- cgit v1.2.1 From aa516ab4d908927a95b20275fc7daaa7bb9420a9 Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Fri, 19 Dec 2014 19:13:50 +0000 Subject: QPID-6276: [Java Broker] Enhance the virtualhost UI to support upload/download of virtualhost config expressed as JSON. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1646829 13f79535-47bb-0310-9956-ffa450edef68 --- .../plugin/servlet/rest/RestServlet.java | 44 +++++- .../addVirtualHostNodeAndVirtualHost.html | 28 ++++ .../src/main/java/resources/css/common.css | 16 +++ .../src/main/java/resources/index.html | 1 + .../resources/js/qpid/management/VirtualHost.js | 14 ++ .../management/addVirtualHostNodeAndVirtualHost.js | 156 +++++++++++++++------ .../src/main/java/resources/showVirtualHost.html | 1 + 7 files changed, 213 insertions(+), 47 deletions(-) (limited to 'qpid/java/broker-plugins') 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 0bc0a4514f..52c9b10e59 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 @@ -62,13 +62,20 @@ public class RestServlet extends AbstractServlet public static final String INHERITED_ACTUALS_PARAM = "inheritedActuals"; public static final String EXTRACT_INITIAL_CONFIG_PARAM = "extractInitialConfig"; + /** + * Signifies that the agent wishes the servlet to set the Content-Disposition on the + * response with the value attachment. This filename will be derived from the parameter value. + */ + public static final String CONTENT_DISPOSITION_ATTACHMENT_FILENAME_PARAM = "contentDispositionAttachmentFilename"; + public static final Set RESERVED_PARAMS = new HashSet<>(Arrays.asList(DEPTH_PARAM, SORT_PARAM, ACTUALS_PARAM, INCLUDE_SYS_CONTEXT_PARAM, EXTRACT_INITIAL_CONFIG_PARAM, - INHERITED_ACTUALS_PARAM)); + INHERITED_ACTUALS_PARAM, + CONTENT_DISPOSITION_ATTACHMENT_FILENAME_PARAM)); private Class[] _hierarchy; @@ -316,19 +323,23 @@ public class RestServlet extends AbstractServlet @Override protected void doGetWithSubjectAndActor(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + // TODO - sort special params, everything else should act as a filter + String attachmentFilename = request.getParameter(CONTENT_DISPOSITION_ATTACHMENT_FILENAME_PARAM); + boolean extractInitialConfig = getBooleanParameterFromRequest(request, EXTRACT_INITIAL_CONFIG_PARAM); + response.setContentType("application/json"); response.setStatus(HttpServletResponse.SC_OK); setCachingHeadersOnResponse(response); + setContentDispositionHeaderIfNecessary(response, attachmentFilename); Collection> allObjects = getObjects(request); - // TODO - sort special params, everything else should act as a filter - boolean extractInitialConfig = getBooleanParameterFromRequest(request, EXTRACT_INITIAL_CONFIG_PARAM); int depth; boolean actuals; boolean includeSystemContext; boolean inheritedActuals; + if(extractInitialConfig) { depth = Integer.MAX_VALUE; @@ -344,20 +355,35 @@ public class RestServlet extends AbstractServlet inheritedActuals = getBooleanParameterFromRequest(request, INHERITED_ACTUALS_PARAM); } - List> output = new ArrayList>(); + List> output = new ArrayList<>(); for(ConfiguredObject configuredObject : allObjects) { output.add(_objectConverter.convertObjectToMap(configuredObject, getConfiguredClass(), depth, actuals, inheritedActuals, includeSystemContext, extractInitialConfig)); } + Writer writer = getOutputWriter(request, response); ObjectMapper mapper = new ObjectMapper(); mapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true); mapper.writeValue(writer, extractInitialConfig && output.size() == 1 ? output.get(0) : output); + } - response.setContentType("application/json"); - response.setStatus(HttpServletResponse.SC_OK); + private void setContentDispositionHeaderIfNecessary(final HttpServletResponse response, + final String attachmentFilename) + { + if (attachmentFilename != null) + { + String filenameRfc2183 = ensureFilenameIsRfc2183(attachmentFilename); + if (filenameRfc2183.length() > 0) + { + response.setHeader("Content-disposition", String.format("attachment; filename=\"%s\"", filenameRfc2183)); + } + else + { + response.setHeader("Content-disposition", String.format("attachment")); // Agent will allow user to choose a name + } + } } private Class getConfiguredClass() @@ -671,4 +697,10 @@ public class RestServlet extends AbstractServlet return Boolean.parseBoolean(request.getParameter(paramName)); } + private String ensureFilenameIsRfc2183(final String requestedFilename) + { + String fileNameRfc2183 = requestedFilename.replaceAll("[\\P{InBasic_Latin}\\\\:/]", ""); + return fileNameRfc2183; + } + } 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 3e3e931829..383c782d60 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 @@ -59,6 +59,34 @@
+
+
+ +
+
+ +
+
+
+ +
+
+ + + +
+
+
+ +
+
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 d04117b266..e6a0ce467f 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 @@ -215,6 +215,22 @@ div .messages { height: 16px; } +.loadingIcon +{ + background: url("../dojo/dojox/image/resources/images/loading.gif") no-repeat; + width: 25px; + height: 25px; + display: inline-block; +} + +.loadedIcon +{ + background: url("../dojo/dojox/mobile/themes/common/domButtons/compat/mblDomButtonDarkBlueCheck.png") no-repeat; + width: 25px; + height: 25px; + display: inline-block; +} + .infoMessage { padding: 5px; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html index eb742bbfa0..379a25bbcd 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/index.html @@ -25,6 +25,7 @@ +