Search in sources :

Example 16 with VirtualHost

use of org.apache.qpid.server.model.VirtualHost in project qpid-broker-j by apache.

the class QueueReportServlet method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response, final ConfiguredObject<?> managedObject) throws IOException, ServletException {
    List<String> pathInfoElements = HttpManagementUtil.getPathInfoElements(request.getServletPath(), request.getPathInfo());
    Queue<?> queue;
    String reportName;
    if (managedObject instanceof Broker && pathInfoElements.size() == 3) {
        queue = getQueueFromRequest(pathInfoElements);
        reportName = pathInfoElements.get(2);
    } else if (managedObject instanceof VirtualHost && pathInfoElements.size() == 2) {
        queue = getQueueFromVirtualHost(pathInfoElements.get(0), (VirtualHost<?>) managedObject);
        reportName = pathInfoElements.get(1);
    } else {
        queue = null;
        reportName = null;
    }
    if (queue != null) {
        ReportRunner<?> reportRunner = ReportRunner.createRunner(reportName, 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");
    }
}
Also used : Broker(org.apache.qpid.server.model.Broker) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) VirtualHost(org.apache.qpid.server.model.VirtualHost)

Aggregations

VirtualHost (org.apache.qpid.server.model.VirtualHost)16 Broker (org.apache.qpid.server.model.Broker)5 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)5 Test (org.junit.Test)4 Exchange (org.apache.qpid.server.model.Exchange)3 Queue (org.apache.qpid.server.model.Queue)3 HashMap (java.util.HashMap)2 QmfAgentData (org.apache.qpid.qmf2.agent.QmfAgentData)2 AbstractConfigurationChangeListener (org.apache.qpid.server.model.AbstractConfigurationChangeListener)2 Binding (org.apache.qpid.server.model.Binding)2 TrustStore (org.apache.qpid.server.model.TrustStore)2 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)2 ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)2 MessageStore (org.apache.qpid.server.store.MessageStore)2 TestMemoryMessageStore (org.apache.qpid.server.store.TestMemoryMessageStore)2 Before (org.junit.Before)2 Cache (com.google.common.cache.Cache)1 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1