Search in sources :

Example 1 with SystemReportFormatter

use of org.opennms.systemreport.SystemReportFormatter in project opennms by OpenNMS.

the class SystemReportController method handleRequestInternal.

/** {@inheritDoc} */
@Override
protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    String operation = request.getParameter("operation");
    if (!StringUtils.hasText(operation)) {
        operation = "list";
    }
    LOG.debug("Calling operation {} in SystemReportController", operation);
    if ("run".equalsIgnoreCase(operation)) {
        SystemReportFormatter formatter = null;
        final String formatterName = request.getParameter("formatter");
        for (final SystemReportFormatter f : m_systemReport.getFormatters()) {
            if (f.getName().equals(formatterName)) {
                formatter = f;
                break;
            }
        }
        if (formatter == null) {
            throw new FormatterNotFoundException("Unable to locate formatter plugin for format type '" + formatterName + "'");
        }
        final List<String> selectedPlugins = Arrays.asList(request.getParameterValues("plugins"));
        final List<SystemReportPlugin> plugins = new ArrayList<SystemReportPlugin>();
        for (final SystemReportPlugin plugin : m_systemReport.getPlugins()) {
            if (selectedPlugins.contains(plugin.getName())) {
                plugins.add(plugin);
            }
        }
        return new ModelAndView(new FormatterView(formatter), "report", new SystemReportInfo(Arrays.asList(formatter), plugins));
    } else {
        return new ModelAndView("redirect:/admin/support/systemReportList.htm");
    }
}
Also used : SystemReportPlugin(org.opennms.systemreport.SystemReportPlugin) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) SystemReportFormatter(org.opennms.systemreport.SystemReportFormatter)

Aggregations

ArrayList (java.util.ArrayList)1 SystemReportFormatter (org.opennms.systemreport.SystemReportFormatter)1 SystemReportPlugin (org.opennms.systemreport.SystemReportPlugin)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1