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