From 9dc57fe738f366d875c2319dafdfa2c50ce2f20b Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Tue, 3 Mar 2015 14:56:40 +0000 Subject: merge from trunk git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/QPID-6262-JavaBrokerNIO@1663717 13f79535-47bb-0310-9956-ffa450edef68 --- .../server/management/plugin/HttpManagement.java | 3 + .../plugin/report/QueueBinaryReport.java | 28 ++ .../management/plugin/report/QueueReport.java | 161 ++++++++ .../management/plugin/report/QueueTextReport.java | 28 ++ .../management/plugin/report/ReportRunner.java | 408 +++++++++++++++++++++ .../plugin/report/ReportableMessage.java | 42 +++ .../plugin/report/ReportableMessageHeader.java | 58 +++ .../rest/ConfiguredObjectToMapConverter.java | 4 +- .../plugin/servlet/rest/QueueReportServlet.java | 103 ++++++ .../src/main/java/resources/addPort.html | 17 + .../main/java/resources/editVirtualHostNode.html | 33 +- .../resources/js/qpid/common/ResourceWidget.js | 38 +- .../js/qpid/common/grid/ColumnDefDialog.js | 11 +- .../js/qpid/common/grid/RowNumberLimitDialog.js | 14 +- .../src/main/java/resources/js/qpid/common/util.js | 52 +-- .../js/qpid/management/AccessControlProvider.js | 12 +- .../js/qpid/management/AuthenticationProvider.js | 4 +- .../java/resources/js/qpid/management/Broker.js | 12 +- .../resources/js/qpid/management/Connection.js | 14 +- .../java/resources/js/qpid/management/Exchange.js | 5 +- .../resources/js/qpid/management/GroupProvider.js | 7 +- .../java/resources/js/qpid/management/KeyStore.js | 4 +- .../java/resources/js/qpid/management/Plugin.js | 7 +- .../main/java/resources/js/qpid/management/Port.js | 18 +- .../resources/js/qpid/management/Preferences.js | 11 +- .../js/qpid/management/PreferencesProvider.js | 5 +- .../java/resources/js/qpid/management/Queue.js | 5 +- .../resources/js/qpid/management/TrustStore.js | 4 +- .../resources/js/qpid/management/VirtualHost.js | 5 +- .../js/qpid/management/VirtualHostNode.js | 6 +- .../management/accesscontrolprovider/AclFile.js | 6 +- .../accesscontrolprovider/aclfile/add.js | 7 +- .../js/qpid/management/addAccessControlProvider.js | 7 +- .../qpid/management/addAuthenticationProvider.js | 7 +- .../js/qpid/management/addGroupProvider.js | 7 +- .../java/resources/js/qpid/management/addPort.js | 15 +- .../js/qpid/management/addPreferencesProvider.js | 7 +- .../java/resources/js/qpid/management/addStore.js | 14 +- .../management/addVirtualHostNodeAndVirtualHost.js | 7 +- .../PrincipalDatabaseAuthenticationManager.js | 6 +- .../base64md5passwordfile/add.js | 13 +- .../authenticationprovider/external/add.js | 13 +- .../plainpasswordfile/add.js | 13 +- .../authenticationprovider/simpleldap/add.js | 7 +- .../resources/js/qpid/management/editBroker.js | 7 +- .../java/resources/js/qpid/management/editQueue.js | 6 +- .../js/qpid/management/editVirtualHost.js | 6 +- .../js/qpid/management/editVirtualHostNode.js | 9 +- .../resources/js/qpid/management/group/Group.js | 5 +- .../groupprovider/GroupManagingGroupProvider.js | 15 +- .../qpid/management/groupprovider/groupfile/add.js | 13 +- .../qpid/management/logs/LogFileDownloadDialog.js | 8 +- .../resources/js/qpid/management/logs/LogViewer.js | 8 +- .../js/qpid/management/plugin/managementhttp.js | 5 +- .../js/qpid/management/plugin/managementjmx.js | 5 +- .../filesystempreferences/add.js | 13 +- .../filesystempreferences/show.js | 6 +- .../js/qpid/management/store/filekeystore/add.js | 79 ++-- .../js/qpid/management/store/filetruststore/add.js | 74 ++-- .../qpid/management/store/nonjavakeystore/add.js | 93 +++-- .../qpid/management/store/nonjavatruststore/add.js | 85 +++-- .../management/store/nonjavatruststore/show.js | 11 +- .../management/virtualhost/providedstore/add.js | 8 +- .../management/virtualhost/providedstore/edit.js | 11 +- .../qpid/management/virtualhostnode/json/edit.js | 7 +- .../src/main/java/resources/showPort.html | 81 ++-- .../src/main/java/resources/showQueue.html | 2 +- 67 files changed, 1450 insertions(+), 355 deletions(-) create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueBinaryReport.java create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueReport.java create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueTextReport.java create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportRunner.java create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportableMessage.java create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportableMessageHeader.java create mode 100644 qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/QueueReportServlet.java (limited to 'qpid/java/broker-plugins/management-http/src/main') diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java index 4e340c7b72..69920ff488 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/HttpManagement.java @@ -69,6 +69,7 @@ import org.apache.qpid.server.management.plugin.servlet.rest.LogoutServlet; import org.apache.qpid.server.management.plugin.servlet.rest.MessageContentServlet; import org.apache.qpid.server.management.plugin.servlet.rest.MessageServlet; import org.apache.qpid.server.management.plugin.servlet.rest.MetaDataServlet; +import org.apache.qpid.server.management.plugin.servlet.rest.QueueReportServlet; import org.apache.qpid.server.management.plugin.servlet.rest.RestServlet; import org.apache.qpid.server.management.plugin.servlet.rest.SaslServlet; import org.apache.qpid.server.management.plugin.servlet.rest.StructureServlet; @@ -304,6 +305,8 @@ public class HttpManagement extends AbstractPluginAdapter implem root.addServlet(new ServletHolder(new StructureServlet()), "/service/structure"); root.addServlet(new ServletHolder(new MessageServlet()), "/service/message/*"); root.addServlet(new ServletHolder(new MessageContentServlet()), "/service/message-content/*"); + root.addServlet(new ServletHolder(new QueueReportServlet()), "/service/queuereport/*"); + root.addServlet(new ServletHolder(new LogRecordsServlet()), "/service/logrecords"); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueBinaryReport.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueBinaryReport.java new file mode 100644 index 0000000000..d842de3f1b --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueBinaryReport.java @@ -0,0 +1,28 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.management.plugin.report; + +public abstract class QueueBinaryReport extends QueueReport +{ + public QueueBinaryReport() + { + } +} diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueReport.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueReport.java new file mode 100644 index 0000000000..23b24aaf8d --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueReport.java @@ -0,0 +1,161 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.management.plugin.report; + +import org.apache.qpid.server.model.Queue; +import org.apache.qpid.server.model.VirtualHost; + +/** + *

+ * The QueueReport class provides an extension point for installations to provide custom management reporting on + * queues through the REST API. + *

+ * + *

+ * A custom QueueReport must extend either {@link org.apache.qpid.server.management.plugin.report.QueueTextReport} + * or {@link org.apache.qpid.server.management.plugin.report.QueueBinaryReport}. The report implementation must + * define a {@link #getName() name} which is unique amongst all installed reports. The report class must be present + * in the classpath of the broker, and a provider-configuration file named + * org.apache.qpid.server.management.plugin.report.QueueReport must be added in the resource directory + * META-INF/services directory with the binary name of the implementation (as described in + * {@link java.util.ServiceLoader ServiceLoader}). + *

+ * + *

Running reports

+ *

+ * The report can be run using the URL: + * {@code http:///service/queuereport///[?param1=x¶m2=y...]} + *

+ * + *

Report Parameters

+ * + *

+ * Reports can take parameters from the query string of the HTTP request. For every parameter in the query string + * the system will look for a setter on the report object with either a String or String[] parameter. Thus if + * the query string contains {@code foo=bar}, then the system will look for a setter {@code setFoo(String value)} or + * {@code setFoo(String[] value)}. If the same parameter occurs multiple times in the query string then only the + * array variant of the setter will be called. + *

+ *

+ * Setters for the parameters are guaranteed to be called before the first message is added to the report. + *

+ * + *

+ * NOTE: In order to comply with the requirements of the {@link java.util.ServiceLoader ServiceLoader} api, all + * implementations of QueueReport MUST provide a public no-args constructor. + *

+ * @param + */ +public abstract class QueueReport +{ + private Queue _queue; + + QueueReport() + { + + } + + /** + * Gets the name of the report. + *

+ * The name of the report must be unique amongst all installed implementations. The name of the report + * is examined by the Qpid immediately upon construction. The name should not change during + * the lifetime of the object (the value is only meaningful to the system at the time of initial construction) + * and all instances of the same concrete implementation should have the same name. + *

+ * @return the name of the report + */ + public abstract String getName(); + + /** + * Get the name of the queue against which the report is being run. + * + * @return the name of the queue + */ + public final String getQueueName() + { + return _queue.getName(); + } + + final void setQueue(final Queue queue) + { + _queue = queue; + } + + /** + * Get the name of the virtual host against which the report is being run. + * + * @return the name of the virtual host + */ + public final String getVirtualHostName() + { + return _queue.getParent(VirtualHost.class).getName(); + } + + /** + * + * The value returned by getContentType() will be used to set the Content-Type HTTP header field + * + * @return the value to use for the content-type HTTP header field + */ + public abstract String getContentType(); + + /** + * Called by the system to add a message to the report. + * + *

+ * The method is called by the system for every message on the queue, or until {@link #isComplete()} returns true. + *

+ * @param reportableMessage the message to add to the report + */ + public abstract void addMessage(final ReportableMessage reportableMessage); + + /** + * Informs the system if the report is complete (i.e. does not need to report on any more messages). + * + *

+ * This method will be called by the system after each message is {@link #addMessage(ReportableMessage) added} + * to the report. If a report is only interested in some messages, and can determine that the addition of more + * messages will not vary the content of the report, then it can return true. + *

+ *

+ * If this method always returns false, then all messages from the queue will be added to the report. + *

+ *

+ * NOTE: Retrieving content or properties of the message may require it to be reloaded from disk, and so care + * should be taken by reports to only access properties/content of the message if it is going to be required + * for the report production. + *

+ * + * @return true if the report does not want to report on any more messages in the queue + */ + public abstract boolean isComplete(); + + /** + * Called by the system to get the content of the report to retrun to the user. + *

+ * The system guarantees to only call this method once + *

+ * @return the report content. + */ + public abstract T getReport(); + +} diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueTextReport.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueTextReport.java new file mode 100644 index 0000000000..09bc5c4229 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/QueueTextReport.java @@ -0,0 +1,28 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.management.plugin.report; + +public abstract class QueueTextReport extends QueueReport +{ + public QueueTextReport() + { + } +} diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportRunner.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportRunner.java new file mode 100644 index 0000000000..2a05cfc9a1 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportRunner.java @@ -0,0 +1,408 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.management.plugin.report; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.ServiceLoader; +import java.util.Set; +import java.util.UUID; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.qpid.server.message.AMQMessageHeader; +import org.apache.qpid.server.message.ServerMessage; +import org.apache.qpid.server.model.Queue; +import org.apache.qpid.server.queue.QueueEntry; +import org.apache.qpid.server.queue.QueueEntryVisitor; + +public class ReportRunner +{ + private static final Logger LOGGER = LoggerFactory.getLogger(ReportRunner.class); + + private static final Set IMMUTABLE_CLASSES = new HashSet<>(Arrays.asList( + Boolean.class, + Byte.class, + Short.class, + Character.class, + Integer.class, + Long.class, + Float.class, + Double.class, + UUID.class, + Date.class, + String.class + )); + + private ReportRunner(final QueueReport report) + { + _report = report; + } + + public boolean isBinaryReport() + { + return _report instanceof QueueBinaryReport; + } + + public static ReportRunner createRunner(final String reportName, final Map parameterMap) + { + QueueReport report = getReport(reportName); + setReportParameters(report, parameterMap); + return new ReportRunner<>(report); + } + + private static void setReportParameters(final QueueReport report, final Map parameterMap) + { + if(parameterMap != null && !parameterMap.isEmpty()) + { + Class clazz = report.getClass(); + for(Map.Entry entry : parameterMap.entrySet()) + { + String key = entry.getKey(); + String[] value = entry.getValue(); + if(isValidName(key)) + { + + StringBuilder setterName = new StringBuilder("set"); + setterName.append(key.substring(0,1).toUpperCase()); + if(key.length()>1) + { + setterName.append(key.substring(1)); + } + Method method = null; + try + { + + if (value == null || value.length == 0 || value.length == 1) + { + try + { + method = clazz.getMethod(setterName.toString(), String.class); + method.invoke(report, value == null || value.length == 0 ? null : value[0]); + } + catch (NoSuchMethodException | IllegalAccessException e) + { + method = null; + } + } + if (method == null) + { + try + { + method = clazz.getMethod(setterName.toString(), String[].class); + method.invoke(report, new Object[] { value }); + } + catch (NoSuchMethodException | IllegalAccessException e) + { + LOGGER.info("Unknown parameter '" + + key + + "' (no setter) for report " + + report.getName()); + } + } + } + catch (InvocationTargetException e) + { + LOGGER.info("Error setting parameter '" + key + "' for report " + report.getName(), e); + } + } + else + { + LOGGER.info("Invalid parameter name '" + key + "' running report " + report.getName()); + } + } + } + } + + private static boolean isValidName(final String key) + { + if(key != null && key.length() != 0) + { + if(Character.isJavaIdentifierStart(key.charAt(0))) + { + for(int i = 1; i < key.length(); i++) + { + if(!Character.isJavaIdentifierPart(key.charAt(i))) + { + return false; + } + } + return true; + } + + } + return false; + + } + + private static QueueReport getReport(final String reportName) + { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + for (final QueueReport report : ServiceLoader.load(QueueReport.class, classLoader)) + { + if (report.getName().equals(reportName)) + { + try + { + return report.getClass().newInstance(); + } + catch (InstantiationException | IllegalAccessException e) + { + // can't happen as by definition must have public noargs constructor + } + } + } + throw new IllegalArgumentException("Unknown report: " + reportName); + } + + public String getContentType() + { + return _report.getContentType(); + } + + + private static class ReportVisitor implements QueueEntryVisitor + { + + private final QueueReport _report; + + public ReportVisitor(final QueueReport report) + { + _report = report; + } + + @Override + public boolean visit(final QueueEntry entry) + { + _report.addMessage(convertMessage(entry.getMessage())); + return _report.isComplete(); + } + + + } + + + private static ReportableMessage convertMessage(final ServerMessage message) + { + return new ReportableMessage() + { + @Override + public String getInitialRoutingAddress() + { + return message.getInitialRoutingAddress(); + } + + @Override + public ReportableMessageHeader getMessageHeader() + { + return convertMessageHeader(message.getMessageHeader()); + } + + @Override + public ByteBuffer getContent() + { + ByteBuffer content = message.getContent(0, (int) getSize()); + + return content.asReadOnlyBuffer(); + } + + @Override + public boolean isPersistent() + { + return message.isPersistent(); + } + + @Override + public long getSize() + { + return message.getSize(); + } + + @Override + public long getExpiration() + { + return message.getExpiration(); + } + + @Override + public long getMessageNumber() + { + return message.getMessageNumber(); + } + + @Override + public long getArrivalTime() + { + return message.getArrivalTime(); + } + }; + } + + private static ReportableMessageHeader convertMessageHeader(final AMQMessageHeader messageHeader) + { + return new ReportableMessageHeader() + { + @Override + public String getCorrelationId() + { + return messageHeader.getCorrelationId(); + } + + @Override + public long getExpiration() + { + return messageHeader.getExpiration(); + } + + @Override + public String getUserId() + { + return messageHeader.getUserId(); + } + + @Override + public String getAppId() + { + return messageHeader.getAppId(); + } + + @Override + public String getMessageId() + { + return messageHeader.getMessageId(); + } + + @Override + public String getMimeType() + { + return messageHeader.getMimeType(); + } + + @Override + public String getEncoding() + { + return messageHeader.getEncoding(); + } + + @Override + public byte getPriority() + { + return messageHeader.getPriority(); + } + + @Override + public long getTimestamp() + { + return messageHeader.getTimestamp(); + } + + @Override + public String getType() + { + return messageHeader.getType(); + } + + @Override + public String getReplyTo() + { + return messageHeader.getReplyTo(); + } + + @Override + public Object getHeader(final String name) + { + return makeImmutable(messageHeader.getHeader(name)); + } + + @Override + public boolean containsHeaders(final Set names) + { + return messageHeader.containsHeaders(names); + } + + @Override + public boolean containsHeader(final String name) + { + return messageHeader.containsHeader(name); + } + + @Override + public Collection getHeaderNames() + { + return Collections.unmodifiableCollection(messageHeader.getHeaderNames()); + } + }; + } + + private static Object makeImmutable(final Object value) + { + if(value == null || IMMUTABLE_CLASSES.contains(value.getClass())) + { + return value; + } + else if(value instanceof byte[]) + { + return ByteBuffer.wrap((byte[])value).asReadOnlyBuffer(); + } + else if(value instanceof List) + { + List orig = (List) value; + List copy = new ArrayList<>(orig.size()); + for(Object element : orig) + { + copy.add(makeImmutable(element)); + } + return copy; + } + else if(value instanceof Map) + { + Map orig = (Map) value; + LinkedHashMap copy = new LinkedHashMap<>(); + for(Map.Entry entry : orig.entrySet()) + { + copy.put(makeImmutable(entry.getKey()),makeImmutable(entry.getValue())); + } + return copy; + } + else return null; + } + + private final QueueReport _report; + + public final T runReport(Queue queue) + { + _report.setQueue(queue); + ReportVisitor visitor = new ReportVisitor(_report); + queue.visit(visitor); + return _report.getReport(); + } +} diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportableMessage.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportableMessage.java new file mode 100644 index 0000000000..00b6c4abeb --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportableMessage.java @@ -0,0 +1,42 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.management.plugin.report; + +import java.nio.ByteBuffer; + +public interface ReportableMessage +{ + String getInitialRoutingAddress(); + + ReportableMessageHeader getMessageHeader(); + + public ByteBuffer getContent(); + + boolean isPersistent(); + + long getSize(); + + long getExpiration(); + + long getMessageNumber(); + + long getArrivalTime(); +} diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportableMessageHeader.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportableMessageHeader.java new file mode 100644 index 0000000000..e78415f8d0 --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/report/ReportableMessageHeader.java @@ -0,0 +1,58 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.management.plugin.report; + +import java.util.Collection; +import java.util.Set; + +public interface ReportableMessageHeader +{ + String getCorrelationId(); + + long getExpiration(); + + String getUserId(); + + String getAppId(); + + String getMessageId(); + + String getMimeType(); + + String getEncoding(); + + byte getPriority(); + + long getTimestamp(); + + String getType(); + + String getReplyTo(); + + Object getHeader(String name); + + boolean containsHeaders(Set names); + + boolean containsHeader(String name); + + Collection getHeaderNames(); + +} 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 331b50ea7c..0f1b7d03e9 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 @@ -162,14 +162,14 @@ public class ConfiguredObjectToMapConverter .getAttributeTypes(confObject.getClass()) .get(name); - if (attribute.isSecure() && !(isSecureTransport && extractAsConfig)) + if (attribute.isSecureValue(value) && !(isSecureTransport && extractAsConfig)) { // do not expose actual secure attribute value // getAttribute() returns encoded value value = confObject.getAttribute(name); } - if(attribute.isOversized() && !extractAsConfig) + if(attribute.isOversized() && !extractAsConfig && !useActualValues) { String valueString = String.valueOf(value); if(valueString.length() > oversizeThreshold) diff --git a/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/QueueReportServlet.java b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/QueueReportServlet.java new file mode 100644 index 0000000000..2b3def2dab --- /dev/null +++ b/qpid/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/QueueReportServlet.java @@ -0,0 +1,103 @@ +/* + * + * 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. + * + */ +package org.apache.qpid.server.management.plugin.servlet.rest; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.qpid.server.management.plugin.report.ReportRunner; +import org.apache.qpid.server.model.Queue; +import org.apache.qpid.server.model.VirtualHost; + +public class QueueReportServlet extends AbstractServlet +{ + @Override + protected void doGetWithSubjectAndActor(HttpServletRequest request, HttpServletResponse response) throws + IOException, + ServletException + { + String[] pathInfoElements = getPathInfoElements(request); + if(pathInfoElements != null && pathInfoElements.length == 3) + { + Queue queue = getQueueFromRequest(request); + ReportRunner reportRunner = ReportRunner.createRunner(pathInfoElements[2],request.getParameterMap()); + Object output = reportRunner.runReport(queue); + response.setContentType(reportRunner.getContentType()); + if(reportRunner.isBinaryReport()) + { + response.getOutputStream().write((byte[])output); + } + else + { + response.getWriter().write((String)output); + } + } + else + { + throw new IllegalArgumentException("Invalid path is specified"); + } + + } + + private Queue getQueueFromRequest(HttpServletRequest request) + { + String[] pathInfoElements = getPathInfoElements(request); + if(pathInfoElements == null || pathInfoElements.length < 2) + { + throw new IllegalArgumentException("Invalid path is specified"); + } + String vhostName = pathInfoElements[0]; + String queueName = pathInfoElements[1]; + + VirtualHost vhost = getBroker().findVirtualHostByName(vhostName); + if (vhost == null) + { + throw new IllegalArgumentException("Could not find virtual host with name '" + vhostName + "'"); + } + + Queue queueFromVirtualHost = getQueueFromVirtualHost(queueName, vhost); + if (queueFromVirtualHost == null) + { + throw new IllegalArgumentException("Could not find queue with name '" + queueName + "' on virtual host '" + vhost.getName() + "'"); + } + return queueFromVirtualHost; + } + + private Queue getQueueFromVirtualHost(String queueName, VirtualHost vhost) + { + Queue queue = null; + + for(Queue q : vhost.getQueues()) + { + + if(q.getName().equals(queueName)) + { + queue = q; + break; + } + } + return queue; + } + +} diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html index b787e701ec..10b79987a5 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/addPort.html @@ -159,6 +159,23 @@ +
+
+
+ +
+
+ +
+
+
+
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 cee18f7185..59597845a2 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 @@ -19,31 +19,34 @@
-
-
NOTE: All changes will only take effect after Virtual Host Node restart.
-
-
Name*:
-
- +
+
NOTE: All changes will only take effect after Virtual Host Node restart.
+
+
Name*:
+
+ -
-
+
+
-
+
-
+
-
-
+
+
+
+
-
+
diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js index f603c96ff3..bee38149da 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/ResourceWidget.js @@ -44,6 +44,7 @@ function (declare, array, lang, util, _WidgetBase, _TemplatedMixin, _WidgetsInTe fileReaderSupported: window.FileReader ? true : false, displayWarningWhenFileReaderUnsupported: false, isDebug: false, + uploaded: false, buildRendering: function() { @@ -74,7 +75,7 @@ function (declare, array, lang, util, _WidgetBase, _TemplatedMixin, _WidgetsInTe { // Fall back for IE8/9 which do not support FileReader this.uploadFields.style.display = "none"; - if (displayWarningWhenFileReaderUnsupported) + if (this.displayWarningWhenFileReaderUnsupported) { this.unsupportedWarning.className = this.unsupportedWarning.className.replace("hidden", ""); } @@ -127,6 +128,7 @@ function (declare, array, lang, util, _WidgetBase, _TemplatedMixin, _WidgetsInTe }, _fileClearButtonClicked: function(event) { + this.uploaded = false; this.uploader.reset(); this.set("value", this._resetValue); }, @@ -134,20 +136,17 @@ function (declare, array, lang, util, _WidgetBase, _TemplatedMixin, _WidgetsInTe { var serverPathValue = this.resourceLocation.get("value") || this._resetValue; this.set("value", serverPathValue); + if (this.uploaded ) + { + this.uploaded = !serverPathValue; + } }, _setValueAttr: function(newValue, priorityChange) { - var isDataUrl = newValue && newValue.indexOf("data:") == 0; + var isDataUrl = this.uploaded || ( newValue && newValue.indexOf("data:") == 0 ); if (isDataUrl) { - this.uploadData.style.display = "block"; - this.selectedFileStatus.className = "loadedIcon"; - this.selectedFile.innerHTML = this.selectedFileName || "uploaded data"; - this.resourceLocation.set("value", ""); - this.resourceLocation.setDisabled(true); - this.resourceLocation.set("required", false); - this.clearButton.setDisabled(false); - this.selectedFileStatus.className = "loadedIcon"; + this._initUploaded(true); } else { @@ -172,6 +171,25 @@ function (declare, array, lang, util, _WidgetBase, _TemplatedMixin, _WidgetsInTe _setPlaceHolderAttr: function(newValue) { this.resourceLocation.set("placeHolder", newValue); + }, + _setUploadedAttr: function(uploaded) + { + this.uploaded = uploaded; + this._initUploaded(uploaded); + }, + _initUploaded: function(uploaded) + { + if (uploaded) + { + this.uploadData.style.display = "block"; + this.selectedFileStatus.className = "loadedIcon"; + this.selectedFile.innerHTML = this.selectedFileName || "uploaded data"; + this.resourceLocation.set("value", ""); + this.resourceLocation.setDisabled(true); + this.resourceLocation.set("required", false); + this.clearButton.setDisabled(false); + this.selectedFileStatus.className = "loadedIcon"; + } } } ); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/ColumnDefDialog.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/ColumnDefDialog.js index d285dfaad6..a0b62082cb 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/ColumnDefDialog.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/ColumnDefDialog.js @@ -45,10 +45,15 @@ return declare("qpid.common.grid.ColumnDefDialog", null, { constructor: function(args){ var grid = this.grid = args.grid; - + var that = this; this.containerNode = dom.create("div", {innerHTML: template}); - parser.parse(this.containerNode); - + parser.parse(this.containerNode).then(function(instances) + { + that._postParse(); + }); + }, + _postParse: function() + { var submitButton = registry.byNode(query(".displayButton", this.containerNode)[0]); this.closeButton = registry.byNode(query(".cancelButton", this.containerNode)[0]); var columnsContainer = query(".columnList", this.containerNode)[0]; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/RowNumberLimitDialog.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/RowNumberLimitDialog.js index db3ae5a2ea..e78670bf57 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/RowNumberLimitDialog.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/grid/RowNumberLimitDialog.js @@ -41,11 +41,17 @@ return declare("qpid.management.logs.RowNumberLimitDialog", null, { grid: null, dialog: null, - constructor: function(domNode, limitChangedCallback){ - + constructor: function(domNode, limitChangedCallback) + { + var that = this; this.containerNode = dom.create("div", {innerHTML: template}); - parser.parse(this.containerNode); - + parser.parse(this.containerNode).then(function(instances) + { + that._postParse(domNode, limitChangedCallback); + }); + }, + _postParse: function(domNode, limitChangedCallback) + { this.rowNumberLimit = registry.byNode(query(".rowNumberLimit", this.containerNode)[0]) this.submitButton = registry.byNode(query(".submitButton", this.containerNode)[0]); this.closeButton = registry.byNode(query(".cancelButton", this.containerNode)[0]); diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js index 60be40b62b..746eb4bbbc 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/common/util.js @@ -528,40 +528,41 @@ define(["dojo/_base/xhr", return object1 === object2; } - util.parseHtmlIntoDiv = function(containerNode, htmlTemplateLocation) + util.parseHtmlIntoDiv = function(containerNode, htmlTemplateLocation, postParseCallback) { xhr.get({url: htmlTemplateLocation, sync: true, load: function(template) { containerNode.innerHTML = template; - parser.parse(containerNode); + parser.parse(containerNode).then(function(instances) + { + if (postParseCallback && typeof postParseCallback == "function") + { + postParseCallback(); + } + }); }}); } - util.buildUI = function(containerNode, parent, htmlTemplateLocation, fieldNames, obj) + util.buildUI = function(containerNode, parent, htmlTemplateLocation, fieldNames, obj, postParseCallback) { - this.parseHtmlIntoDiv(containerNode, htmlTemplateLocation); - if (fieldNames && obj) - { - for(var i=0; i= 0) ? entities.encode(String(this.portData[ "maxOpenConnections" ])) : "(no limit)" ; + this.keyStoreValue.innerHTML = this.portData[ "keyStore" ] ? entities.encode(String(this.portData[ "keyStore" ])) : ""; this.needClientAuthValue.innerHTML = "" ; this.wantClientAuthValue.innerHTML = "" ; @@ -190,6 +198,9 @@ define(["dojo/dom", this.needClientAuth.style.display = "needClientAuth" in typeMetaData.attributes ? "block" : "none"; this.wantClientAuth.style.display = "wantClientAuth" in typeMetaData.attributes ? "block" : "none"; this.trustStores.style.display = "trustStores" in typeMetaData.attributes ? "block" : "none"; + + this.maxOpenConnections.style.display = "maxOpenConnections" in typeMetaData.attributes ? "block" : "none"; + }; PortUpdater.prototype.update = function() @@ -200,6 +211,7 @@ define(["dojo/dom", xhr.get({url: this.query, sync: properties.useSyncGet, handleAs: "json"}).then(function(data) { thisObj.portData = data[0]; + util.flattenStatistics( thisObj.portData ); thisObj.updateHeader(); }); }; diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js index f9982a1699..c8e1d17e06 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/Preferences.js @@ -65,8 +65,15 @@ function (declare, xhr, event, connect, dom, domConstruct, parser, json, Memory, this.userPreferences = {}; this.domNode = domConstruct.create("div", {innerHTML: markup}); - this.preferencesDialog = parser.parse(this.domNode)[0]; - + parser.parse(this.domNode).then(function(instances) + { + that._postParse(); + }); + }, + _postParse: function() + { + var that = this; + this.preferencesDialog = registry.byId("preferences.preferencesDialog"); for(var i=0; iName:
- -
-
Port Type:
-
+
+
+
+
Port Type:
+
+
+
+
+
Open connections (current/maximum):
+
+ / +
+
+
-
+
State:
-
-
+
+
-
+
Port Number:
-
-
+
+
-
+
Protocols:
-
-
+
+
-
Authentication Provider:
-
+
Authentication Provider:
+
-
Binding address:
-
+
Binding address:
+
Transports:
-
-
+
+
-
-
Key Store:
-
-
+
+
Key Store:
+
+
-
-
Need SSL Client Certificate:
-
-
+
+
Need SSL Client Certificate:
+
+
-
-
Want SSL Client Certificate:
-
-
+
+
Want SSL Client Certificate:
+
+
+ +
+
Trust Stores:
+
+
-
-
Trust Stores:
-
-

diff --git a/qpid/java/broker-plugins/management-http/src/main/java/resources/showQueue.html b/qpid/java/broker-plugins/management-http/src/main/java/resources/showQueue.html index a068868e7f..7132dd8105 100644 --- a/qpid/java/broker-plugins/management-http/src/main/java/resources/showQueue.html +++ b/qpid/java/broker-plugins/management-http/src/main/java/resources/showQueue.html @@ -25,7 +25,7 @@
Name:
-
+
Type:
-- cgit v1.2.1