Search in sources :

Example 1 with Service

use of org.opennms.web.element.Service in project opennms by OpenNMS.

the class DeleteServiceServlet method doPost.

/*
     * (non-Javadoc)
     * 
     * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest,
     *      javax.servlet.http.HttpServletResponse)
     */
/**
 * {@inheritDoc}
 */
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    checkParameters(request);
    int nodeId = WebSecurityUtils.safeParseInt(request.getParameter("node"));
    String ipAddr = request.getParameter("intf");
    int serviceId = WebSecurityUtils.safeParseInt(request.getParameter("service"));
    Service service_db = NetworkElementFactory.getInstance(getServletContext()).getService(nodeId, ipAddr, serviceId);
    if (service_db == null) {
        // handle this WAY better, very awful
        throw new ServletException("No such service in database");
    }
    Event e = EventUtils.createDeleteServiceEvent("OpenNMS.WebUI", nodeId, ipAddr, service_db.getServiceName(), -1L);
    sendEvent(e);
    // forward the request for proper display
    RequestDispatcher dispatcher = this.getServletContext().getRequestDispatcher("/admin/serviceDeleted.jsp");
    dispatcher.forward(request, response);
}
Also used : ServletException(javax.servlet.ServletException) Service(org.opennms.web.element.Service) Event(org.opennms.netmgt.xml.event.Event) RequestDispatcher(javax.servlet.RequestDispatcher)

Example 2 with Service

use of org.opennms.web.element.Service in project opennms by OpenNMS.

the class ServiceApplicationBoxController method handleRequestInternal.

/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Service service = ElementUtil.getServiceByParams(request, getServletContext());
    List<OnmsApplication> applications = m_adminApplicationService.findByMonitoredService(service.getId());
    ModelAndView modelAndView = new ModelAndView("/includes/serviceApplication-box", "applications", applications);
    modelAndView.addObject("service", service);
    if (request.isUserInRole(Authentication.ROLE_ADMIN)) {
        modelAndView.addObject("isAdmin", "true");
    }
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) Service(org.opennms.web.element.Service) AdminApplicationService(org.opennms.web.svclayer.AdminApplicationService) OnmsApplication(org.opennms.netmgt.model.OnmsApplication)

Example 3 with Service

use of org.opennms.web.element.Service in project opennms by OpenNMS.

the class ServiceOutagesController method handleRequestInternal.

/**
 * {@inheritDoc}
 */
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Service service = ElementUtil.getServiceByParams(request, getServletContext());
    Outage[] outages = new Outage[0];
    if (service.getNodeId() > 0 && service.getIpAddress() != null && service.getServiceId() > 0) {
        List<Filter> filters = new ArrayList<>();
        filters.add(new InterfaceFilter(service.getIpAddress()));
        filters.add(new NodeFilter(service.getNodeId(), getServletContext()));
        filters.add(new ServiceFilter(service.getServiceId(), getServletContext()));
        filters.add(new RecentOutagesFilter());
        OutageCriteria criteria = new OutageCriteria(filters.toArray(new Filter[0]), SortStyle.ID, null, -1, -1);
        outages = m_webOutageRepository.getMatchingOutages(criteria);
    }
    ModelAndView modelAndView = new ModelAndView(getSuccessView());
    modelAndView.addObject("serviceId", service.getServiceId());
    modelAndView.addObject("outages", outages);
    return modelAndView;
}
Also used : ServiceFilter(org.opennms.web.outage.filter.ServiceFilter) InterfaceFilter(org.opennms.web.outage.filter.InterfaceFilter) Outage(org.opennms.web.outage.Outage) Filter(org.opennms.web.filter.Filter) RecentOutagesFilter(org.opennms.web.outage.filter.RecentOutagesFilter) ServiceFilter(org.opennms.web.outage.filter.ServiceFilter) NodeFilter(org.opennms.web.outage.filter.NodeFilter) InterfaceFilter(org.opennms.web.outage.filter.InterfaceFilter) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) Service(org.opennms.web.element.Service) OutageCriteria(org.opennms.web.outage.filter.OutageCriteria) RecentOutagesFilter(org.opennms.web.outage.filter.RecentOutagesFilter) NodeFilter(org.opennms.web.outage.filter.NodeFilter)

Aggregations

Service (org.opennms.web.element.Service)3 ModelAndView (org.springframework.web.servlet.ModelAndView)2 ArrayList (java.util.ArrayList)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 ServletException (javax.servlet.ServletException)1 OnmsApplication (org.opennms.netmgt.model.OnmsApplication)1 Event (org.opennms.netmgt.xml.event.Event)1 Filter (org.opennms.web.filter.Filter)1 Outage (org.opennms.web.outage.Outage)1 InterfaceFilter (org.opennms.web.outage.filter.InterfaceFilter)1 NodeFilter (org.opennms.web.outage.filter.NodeFilter)1 OutageCriteria (org.opennms.web.outage.filter.OutageCriteria)1 RecentOutagesFilter (org.opennms.web.outage.filter.RecentOutagesFilter)1 ServiceFilter (org.opennms.web.outage.filter.ServiceFilter)1 AdminApplicationService (org.opennms.web.svclayer.AdminApplicationService)1