public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; javax.servlet.jsp.PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/xml;charset=ISO-8859-1"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\n"); out.write("\n"); HttpSession user = request.getSession(true); Notification newNotice = (Notification) user.getAttribute("newNotice"); List exclude = new ArrayList(); exclude.add(NotificationWizardServlet.WT_VENDOR_NAME); // Exclude WebTelemetry out.print(buildTree(newNotice, exclude)); out.write("\n"); } catch (Throwable t) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (pageContext != null) pageContext.handlePageException(t); } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(pageContext); } }
public String buildServiceList(String rule) throws SQLException { if (rule == null) { return ""; } List services = NotificationFactory.getInstance().getServiceNames(); Collections.sort( services, new Comparator() { public int compare(Object o1, Object o2) { return ((String) o1).compareToIgnoreCase((String) o2); } }); StringBuffer buffer = new StringBuffer(); for (int i = 0; i < services.size(); i++) { if (rule.indexOf((String) services.get(i)) > 0) { buffer.append(services.get(i)).append("</br>"); } } return buffer.toString(); }
/** * Build a commonly used event list where each event's uei is separated by a </br> tag. * * @param notice the notification that contains the ueis * @return a String representation for the UI */ public String buildEventList(Notification notice) { if (notice == null) { return ""; } StringBuffer buffer = new StringBuffer(); for (Iterator iter = notice.getEventInfoCollection().iterator(); iter.hasNext(); ) { // create temp event object and use get() // NOTE: cannot do this until we also fill in the snmp data /*org.opennms.netmgt.xml.event.Event e = EventConfigurationManager.makeEvent( (org.opennms.netmgt.config.notifications.EventInfo)iter.next()); List events = EventConfigurationManager.get(e); */ List events = EventConfigurationManager.getByEventInfo( (org.opennms.netmgt.config.notifications.EventInfo) iter.next()); for (Iterator iter2 = events.iterator(); iter2.hasNext(); ) { buffer.append(((Event) iter2.next()).getEventLabel()).append("</br>"); } } return buffer.toString(); }
public String buildEventSelect(Notification notice) throws IOException, FileNotFoundException { // The list of events needs to be transposed to (label, uei) in // order to sort it by label for display. List eventVendors = EventConfigurationManager.getEventsByVendor(NotificationWizardServlet.WT_VENDOR_NAME); StringBuffer buffer = new StringBuffer(); SortedMap sortedEvents = (SortedMap) new TreeMap(); List excludeList = NotificationWizardServlet.getExcludeList(); for (Iterator iter = eventVendors.iterator(); iter.hasNext(); ) { com.jjlabs.model.EventVendor e = (com.jjlabs.model.EventVendor) iter.next(); sortedEvents.put(e.getLabel(), e); } Iterator j = sortedEvents.keySet().iterator(); while (j.hasNext()) { String label = (String) j.next(); com.jjlabs.model.EventVendor e = (com.jjlabs.model.EventVendor) sortedEvents.get(label); String uei = e.getUei(); String trimmedUei = NotificationWizardServlet.stripUei(uei); if (!excludeList.contains(trimmedUei)) { boolean foundUei = NotificationWizardServlet.isEventInNotification(notice, e); int id = e.getId(); if (foundUei) { buffer.append("<option selected VALUE=\"" + id + "\">" + label + "</option>"); } else { buffer.append("<option value=\"" + id + "\">" + label + "</option>"); } } } return buffer.toString(); }
public String buildServiceOptions(String rule) throws SQLException { List services = NotificationFactory.getInstance().getServiceNames(); Collections.sort( services, new Comparator() { public int compare(Object o1, Object o2) { return ((String) o1).compareToIgnoreCase((String) o2); } }); StringBuffer buffer = new StringBuffer(); for (int i = 0; i < services.size(); i++) { if (rule != null && rule.indexOf((String) services.get(i)) > 0) { buffer.append( "<option selected VALUE='" + services.get(i) + "'>" + services.get(i) + "</option>"); } else { buffer.append("<option VALUE='" + services.get(i) + "'>" + services.get(i) + "</option>"); } } return buffer.toString(); }
/** * Builds the vendor events tree. * * @param notice the selected notification so that events that match this notification can be * preselected * @param vendorExcludeList a list of vendors to exclude from the result * @return an xml tree of vendors and their events */ public String buildTree(Notification notice, List vendorExcludeList) throws IOException, FileNotFoundException { StringBuffer buffer = new StringBuffer(); String itemPrefix = "i_"; String sectionPrefix = "s_"; int sid = 1, iid = 1; List ueiExcludeList = NotificationWizardServlet.getExcludeList(); buffer .append("<xTree>") .append("<item id=\"") .append(sectionPrefix) .append(sid) .append("\">") .append("<itemPrimaryData><![CDATA[System Monitoring Events]]></itemPrimaryData>") .append("<subitems>"); List vendors = EventConfigurationManager.getVendorNames(); for (Iterator iter = vendors.iterator(); iter.hasNext(); ) { String vendor = (String) iter.next(); // Don't show any excluded vendors if (vendorExcludeList != null && vendorExcludeList.contains(vendor)) { continue; } sid++; buffer .append("<item id=\"") .append(sectionPrefix) .append(sid) .append("\">") .append("<itemPrimaryData><![CDATA[<input type=\"checkbox\" id=\"c_") .append(sectionPrefix) .append(sid) .append("\" onClick=\"tcs('") .append(sectionPrefix) .append(sid) .append("');us()\">"); // Write the vendor name buffer.append(vendor); buffer.append("]]></itemPrimaryData>").append("<subitems>"); // Now write all the events for the vendor. List eventVendors = EventConfigurationManager.getEventsByVendor(vendor); SortedMap sortedEvents = (SortedMap) new TreeMap(); for (Iterator iter2 = eventVendors.iterator(); iter2.hasNext(); ) { com.jjlabs.model.EventVendor e = (com.jjlabs.model.EventVendor) iter2.next(); sortedEvents.put(e.getLabel(), e); } for (Iterator iter2 = sortedEvents.entrySet().iterator(); iter2.hasNext(); ) { Map.Entry entry = (Map.Entry) iter2.next(); com.jjlabs.model.EventVendor e = (com.jjlabs.model.EventVendor) entry.getValue(); String uei = e.getUei(); if (!ueiExcludeList.contains(NotificationWizardServlet.stripUei(uei))) { iid++; boolean inNotification = NotificationWizardServlet.isEventInNotification(notice, e); buffer .append("<item id=\"") .append(itemPrefix) .append(iid) .append("\">") .append( "<itemPrimaryData><![CDATA[<input type=\"checkbox\" name=\"tree_check\" id=\"c_") .append(itemPrefix) .append(iid) .append("\" value=\"") .append(e.getId()) .append("\" onClick=\"us()\"") .append((inNotification ? " checked" : "")) .append(">"); // Write the event info buffer.append(e.getLabel()); buffer.append("]]></itemPrimaryData>").append("</item>"); } } buffer.append("</subitems></item>"); } buffer.append("</subitems></item></xTree>"); return buffer.toString(); }