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");
}
}
Aggregations