Search in sources :

Example 1 with EditModel

use of org.opennms.web.svclayer.support.DefaultAdminApplicationService.EditModel in project opennms by OpenNMS.

the class ApplicationController method handleRequestInternal.

/** {@inheritDoc} */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String removeApplicationIdString = getNonEmptyParameter(request, "removeApplicationId");
    String newApplicationName = getNonEmptyParameter(request, "newApplicationName");
    String applicationIdString = getNonEmptyParameter(request, "applicationid");
    String editString = getNonEmptyParameter(request, "edit");
    String ifServiceIdString = getNonEmptyParameter(request, "ifserviceid");
    if (removeApplicationIdString != null) {
        m_adminApplicationService.removeApplication(removeApplicationIdString);
        return new ModelAndView(new RedirectView("/admin/applications.htm", true));
    }
    if (newApplicationName != null) {
        m_adminApplicationService.addNewApplication(newApplicationName);
        /*
             * We could be smart and take the user straight to the edit page
             * for this new application, which would be great, however it's
             * not so great if the site has a huge number of available
             * applications and they need to edit application member services
             * from the service pages.  So, we don't do it.
             */
        return new ModelAndView(new RedirectView("/admin/applications.htm", true));
    }
    if (applicationIdString != null && editString != null) {
        String editAction = getNonEmptyParameter(request, "action");
        if (editAction != null) {
            String[] toAdd = request.getParameterValues("toAdd");
            String[] toDelete = request.getParameterValues("toDelete");
            m_adminApplicationService.performEdit(applicationIdString, editAction, toAdd, toDelete);
            ModelAndView modelAndView = new ModelAndView(new RedirectView("/admin/applications.htm", true));
            modelAndView.addObject("applicationid", applicationIdString);
            modelAndView.addObject("edit", "edit");
            return modelAndView;
        }
        EditModel model = m_adminApplicationService.findApplicationAndAllMonitoredServices(applicationIdString);
        return new ModelAndView("/admin/editApplication", "model", model);
    }
    if (applicationIdString != null) {
        return new ModelAndView("/admin/showApplication", "model", m_adminApplicationService.getApplication(applicationIdString));
    }
    if (ifServiceIdString != null && editString != null) {
        String editAction = getNonEmptyParameter(request, "action");
        if (editAction != null) {
            String[] toAdd = request.getParameterValues("toAdd");
            String[] toDelete = request.getParameterValues("toDelete");
            m_adminApplicationService.performServiceEdit(ifServiceIdString, editAction, toAdd, toDelete);
            ModelAndView modelAndView = new ModelAndView(new RedirectView("/admin/applications.htm", true));
            modelAndView.addObject("ifserviceid", ifServiceIdString);
            modelAndView.addObject("edit", "edit");
            return modelAndView;
        }
        ServiceEditModel model = m_adminApplicationService.findServiceApplications(ifServiceIdString);
        return new ModelAndView("/admin/editServiceApplications", "model", model);
    }
    List<OnmsApplication> sortedApplications = m_adminApplicationService.findAllApplications();
    return new ModelAndView("/admin/applications", "applications", sortedApplications);
}
Also used : EditModel(org.opennms.web.svclayer.support.DefaultAdminApplicationService.EditModel) ServiceEditModel(org.opennms.web.svclayer.support.DefaultAdminApplicationService.ServiceEditModel) ModelAndView(org.springframework.web.servlet.ModelAndView) RedirectView(org.springframework.web.servlet.view.RedirectView) OnmsApplication(org.opennms.netmgt.model.OnmsApplication) ServiceEditModel(org.opennms.web.svclayer.support.DefaultAdminApplicationService.ServiceEditModel)

Aggregations

OnmsApplication (org.opennms.netmgt.model.OnmsApplication)1 EditModel (org.opennms.web.svclayer.support.DefaultAdminApplicationService.EditModel)1 ServiceEditModel (org.opennms.web.svclayer.support.DefaultAdminApplicationService.ServiceEditModel)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1 RedirectView (org.springframework.web.servlet.view.RedirectView)1