public String buildInterfaceTable(String rule, String[] serviceList) throws FilterParseException {
    StringBuffer buffer = new StringBuffer();
    Filter filter = new Filter();
    Map interfaces = filter.getIPServiceMap(rule);

    Iterator i = interfaces.keySet().iterator();
    while (i.hasNext()) {
      String key = (String) i.next();
      buffer.append("<tr><td valign=\"top\">").append(key).append("</td>");
      buffer.append("<td>");

      if (serviceList != null && serviceList.length != 0) {
        Map services = (Map) interfaces.get(key);
        Iterator j = services.keySet().iterator();
        while (j.hasNext()) {
          String svc = (String) j.next();
          for (int idx = 0; idx < serviceList.length; idx++) {
            if (svc.equals(serviceList[idx])) {
              buffer.append(svc).append("<br>");
            }
          }
        }
      } else {
        buffer.append("All services");
      }
      buffer.append("</td>");

      buffer.append("</tr>");
    }

    return buffer.toString();
  }
Exemplo n.º 2
0
  protected String createEndTagBody() {

    StringBuffer results = new StringBuffer("");
    String forInclude = getStringForInclude(endTag_xslt);
    if (forInclude != null) results.append(forInclude);
    return results.toString();
  }
  private String getLink(
      final String event,
      final String label,
      final String css,
      String defaultValue,
      String selectedValue,
      String tooltip) {
    String status = Utilities.escapeHTML(Utilities.filterOutHTMLTags(tooltip));

    StringBuffer link = new StringBuffer();
    defaultValue = defaultValue == null ? AbstractChip.FALSE : defaultValue;
    selectedValue = selectedValue == null ? AbstractChip.TRUE : selectedValue;
    link.append("<input type=\"hidden\" name=\"" + event + "\" value=\"" + defaultValue + "\" />");
    link.append(
        "<a href=\"#\" onMouseover=\"window.status='"
            + status
            + "'; return true;\" onMouseout=\"window.status=''; return true;\" ");
    if (css != null) {
      link.append("class=\"" + css + "\" ");
    }
    link.append("hidefocus=\"true\" ");
    link.append(
        "onclick=\"document.editorForm.elements['"
            + event
            + "'].value='"
            + selectedValue
            + "';setScrollAndSubmit();return false;\">");
    link.append(label);
    link.append("</a>");
    return link.toString();
  }
Exemplo n.º 4
0
  public int doEndTag() throws JspException {
    StringBuffer buf = new StringBuffer();

    try {
      pageContext.getOut().print(buf.toString());
    } catch (IOException e) {
      throw new JspTagException(
          (new StringBuilder("Select Tag ERROR:")).append(e.getMessage()).toString());
    }
    return 6;
  }
Exemplo n.º 5
0
 public int doStartTag() throws JspException {
   StringBuffer results = new StringBuffer();
   results.append(this.createStartTagBody());
   JspWriter writer = pageContext.getOut();
   try {
     writer.print(results.toString());
   } catch (IOException e) {
     throw new JspException(e.toString());
   }
   return (EVAL_BODY_INCLUDE);
 }
Exemplo n.º 6
0
 public int doStartTag() throws JspException {
   StringBuffer buf = new StringBuffer();
   buf.append(
       "<style type=\"text/css\">.loadingdiv{position: absolute; left: 0; top: 0; background: #F1F1F1;display:none;filter: alpha(opacity=35);opacity: 0.5;font-weight: bold;     color: Red;width: 100%;height: 4000px;z-index: 3333;font-size: 14px;}.loadingdiv .child{position: absolute; visibility:visible;z-index:3332;width:100%;text-align:center;margin-top:250px;</style>");
   buf.append("<div id=\"loadingdiv\" class=\"loadingdiv\">\n");
   buf.append("<center>\n");
   buf.append("<div class=\"child\">\n");
   buf.append("<img src=\"./images/loading.gif\" style=\"width:160px\" />\n");
   buf.append("</div>\n");
   buf.append("</center>\n");
   buf.append("</div>\n");
   try {
     pageContext.getOut().print(buf.toString());
   } catch (IOException e) {
     throw new JspTagException(
         (new StringBuilder("Select Tag ERROR:")).append(e.getMessage()).toString());
   }
   return 1;
 }
Exemplo n.º 7
0
 private static String parseDate(String input) {
   if (input == null || "".equals(input)) {
     return input;
   }
   if (input.length() < 19) {
     return input;
   }
   String d = input.substring(0, 19);
   // try to parse it
   try {
     StringBuffer buf = new StringBuffer(input.length());
     synchronized (formatter) {
       Date date = formatter.parse(d);
       buf.append("<span class=\"date\" title=\"").append(formatter.format(date)).append("\">");
     }
     buf.append(d).append("</span>");
     buf.append(input.substring(19, input.length()));
     return buf.toString();
   } catch (ParseException pe) {
     return input;
   }
 }
  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();
  }
 private String getExternalLink(final String url, final String label, final String css) {
   StringBuffer link = new StringBuffer();
   link.append("<a href=\"" + url + "\" ");
   if (css != null) {
     link.append("class=\"" + css + "\" ");
   }
   link.append(">");
   link.append(label);
   link.append("</a>");
   return link.toString();
 }
  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 buildPathSelect(String currentPath) throws ServletException {
    StringBuffer buffer = new StringBuffer("<select NAME=\"path\">");

    Map pathsMap = null;

    try {
      pathsMap = new TreeMap(DestinationPathFactory.getInstance().getPaths());
      Iterator iterator = pathsMap.keySet().iterator();
      while (iterator.hasNext()) {
        String key = (String) iterator.next();
        if (key.equals(currentPath)) {
          buffer.append("<option SELECTED VALUE=" + key + ">" + key + "</option>");
        } else {
          buffer.append("<option VALUE=" + key + ">" + key + "</option>");
        }
      }
    } catch (Exception e) {
      throw new ServletException("couldn't get destination path list.", e);
    }
    buffer.append("</select>");

    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();
  }
Exemplo n.º 14
0
 private static String hilite(String input) {
   if (input == null || "".equals(input)) {
     return input;
   }
   if (input.indexOf("org.jivesoftware.") > -1) {
     StringBuffer buf = new StringBuffer();
     buf.append("<span class=\"hilite\">").append(input).append("</span>");
     return buf.toString();
   } else if (input.trim().startsWith("---") && input.trim().endsWith("---")) {
     StringBuffer buf = new StringBuffer();
     buf.append("<span class=\"hilite-marker\">").append(input).append("</span>");
     return buf.toString();
   }
   return input;
 }
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      /*
       * Copyright 2006 Pentaho Corporation.  All rights reserved.
       * This software was developed by Pentaho Corporation and is provided under the terms
       * of the Mozilla Public License, Version 1.1, or any later version. You may not use
       * this file except in compliance with the license. If you need a copy of the license,
       * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
       * BI Platform.  The Initial Developer is Pentaho Corporation.
       *
       * Software distributed under the Mozilla Public License is distributed on an "AS IS"
       * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
       * the license for the specific language governing your rights and limitations.
       *
       * Created Feb 16, 2006
       * @author James Dixon  modified by Kurtis Cruzada
       */

      /*
       * This JSP is an example of how to use Pentaho components to build a dashboard.
       * The script in this file controls the layout and content generation of the dashboard.
       * See the document 'Dashboard Builder Guide' for more details
       */

      // set the character encoding e.g. UFT-8
      response.setCharacterEncoding(LocaleHelper.getSystemEncoding());

      // create a new Pentaho session
      IPentahoSession userSession = PentahoHttpSessionHelper.getPentahoSession(request);

      out.write("\t\r\n");
      out.write("\t");

      // See if we have a 'territory' parameter
      String territory = request.getParameter("territory");
      // See if we have a 'productline' parameter
      String productline = request.getParameter("productline");

      // Create the title for the top of the page
      String title = "Revenue Analysis";
      if (productline != null) {
        title = "Sales for " + territory + ", " + productline;
      } else if (territory != null) {
        title = "Sales for " + territory;
      }

      out.write("\r\n");
      out.write("\t<html>\n");
      out.write("\t<head>\r\n");
      out.write("\t\t<title>Steel Wheels - Revenue Analysis</title>\r\n");
      out.write("\t</head>\r\n");
      out.write("\t<body>\r\n");
      out.write("  \t<table  background=\"/sw-style/active/logo_backup.png\">\n");
      out.write("  \t\t<tr>\r\n");
      out.write(
          "  \t\t\t<td width=\"750\" height=\"40\" align=\"right\" valign=\"middle\" style=\"font-family:Arial;font-weight:bold\" border=\"0\"/>");
      out.print(title);
      out.write("</td>\n");
      out.write("  \t\t</tr>\t\t\n");
      out.write("  \t</table>\t\r\n");
      out.write(
          "  \t<table class=\"homeDashboard\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" >\r\n");
      out.write("\t<tr>\r\n");
      out.write("\t\t<td valign=\"top\" align=\"center\">\r\n");
      out.write("\t");

      // Make a pie chart showing the territories
      // create the parameres for the pie chart
      SimpleParameterProvider parameters = new SimpleParameterProvider();
      // define the click url template
      parameters.setParameter("drill-url", "SWDashboard?territory={TERRITORY}");
      // define the slices of the pie chart
      parameters.setParameter("inner-param", "TERRITORY"); // $NON-NLS-1$ //$NON-NLS-2$
      // set the width and the height
      parameters.setParameter("image-width", "350"); // $NON-NLS-1$ //$NON-NLS-2$
      parameters.setParameter("image-height", "200"); // $NON-NLS-1$ //$NON-NLS-2$
      StringBuffer content = new StringBuffer();
      ArrayList messages = new ArrayList();
      // call the chart helper to generate the pie chart image and to get the HTML content
      // use the chart definition in 'steel-wheels/dashboard/territory.widget.xml'
      ChartHelper.doPieChart(
          "steel-wheels",
          "dashboards",
          "territory.widget.xml",
          parameters,
          content,
          userSession,
          messages,
          null);

      out.write("\r\n");
      out.write("\t\t");
      out.print(content.toString());
      out.write("\r\n");
      out.write("\t\t</td>\t\t\t\r\n");
      out.write("\t\t<td valign=\"top\" align=\"center\">\r\n");
      out.write("\t");

      if (territory == null) {
        // if the user has clicked on a slice of the pie chart we should have a territory to work
        // with

        out.write("\t\t\t\r\n");
        out.write("\t");

        // Make a bar chart showing the department
        // create the parameres for the bar chart
        parameters = new SimpleParameterProvider();
        // define the click url template
        parameters.setParameter(
            "drill-url", "SWDashboard?territory=" + territory + "&amp;productline={SERIES}");
        parameters.setParameter("TERRITORY", territory);
        parameters.setParameter("outer-params", "TERRITORY");
        // define the category axis of the bar chart
        parameters.setParameter("inner-param", "TERRITORY"); // $NON-NLS-1$ //$NON-NLS-2$
        parameters.setParameter("inner-param", "PRODUCTLINE"); // $NON-NLS-1$ //$NON-NLS-2$
        // set the width and the height
        parameters.setParameter("image-width", "400"); // $NON-NLS-1$ //$NON-NLS-2$
        parameters.setParameter("image-height", "200"); // $NON-NLS-1$ //$NON-NLS-2$
        content = new StringBuffer();
        messages = new ArrayList();
        // call the chart helper to generate the pie chart image and to get the HTML content
        // use the chart definition in 'steel-wheels/dashboard/productline.widget.xml'
        ChartHelper.doChart(
            "steel-wheels",
            "dashboards",
            "productline_all.widget.xml",
            parameters,
            content,
            userSession,
            messages,
            null);

        out.write("\t\t\r\n");
        out.write("\t\t");
        out.print(content.toString());
        out.write("\r\n");
        out.write("\t\t");
      }

      out.write('\r');
      out.write('\n');
      out.write('	');

      if (territory != null) {
        // if the user has clicked on a slice of the pie chart we should have a territory to work
        // with

        out.write("\t\t\t\r\n");
        out.write("\t");

        // Make a bar chart showing the department
        // create the parameres for the bar chart
        parameters = new SimpleParameterProvider();
        // define the click url template
        parameters.setParameter(
            "drill-url", "SWDashboard?territory=" + territory + "&amp;productline={SERIES}");
        parameters.setParameter("TERRITORY", territory);
        parameters.setParameter("outer-params", "TERRITORY");
        // define the category axis of the bar chart
        parameters.setParameter("inner-param", "TERRITORY"); // $NON-NLS-1$ //$NON-NLS-2$
        parameters.setParameter("inner-param", "PRODUCTLINE"); // $NON-NLS-1$ //$NON-NLS-2$
        // set the width and the height
        parameters.setParameter("image-width", "400"); // $NON-NLS-1$ //$NON-NLS-2$
        parameters.setParameter("image-height", "200"); // $NON-NLS-1$ //$NON-NLS-2$
        content = new StringBuffer();
        messages = new ArrayList();
        // call the chart helper to generate the pie chart image and to get the HTML content
        // use the chart definition in 'steel-wheels/dashboard/productline.widget.xml'
        ChartHelper.doChart(
            "steel-wheels",
            "dashboards",
            "productline.widget.xml",
            parameters,
            content,
            userSession,
            messages,
            null);

        out.write("\r\n");
        out.write("\t\t\t");
        out.print(content.toString());
        out.write('\r');
        out.write('\n');
        out.write('	');
      }

      out.write("\r\n");
      out.write("\t\t</td>\r\n");
      out.write("\t</tr> \t\r\n");
      out.write("    </table>\n");
      out.write(
          "  \t<table class=\"homeDashboard\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" >\n");
      out.write("  \t<tr>\r\n");
      out.write("  \t\t<td valign=\"top\" align=\"center\"> \t  \t\t\t\t\r\n");
      out.write("  \t");

      if (productline != null) {

        // if the user has clicked on a bar of the bar chart we should have a territory and
        // productline to work with

        // create a dial and supply a value we create from the current time
        // create the parameters for the line chart
        parameters = new SimpleParameterProvider();
        parameters.setParameter("TERRITORY", territory);
        parameters.setParameter("outer-params", "TERRITORY");
        parameters.setParameter("PRODUCTLINE", productline);
        parameters.setParameter("outer-params", "PRODUCTLINE");
        // define the category axis of the bar chart
        parameters.setParameter("inner-param", "PRODUCTLINE"); // $NON-NLS-1$ //$NON-NLS-2$
        // set the width and the height
        parameters.setParameter("image-width", "750"); // $NON-NLS-1$ //$NON-NLS-2$
        parameters.setParameter("image-height", "200"); // $NON-NLS-1$ //$NON-NLS-2$
        content = new StringBuffer();
        messages = new ArrayList();
        // call the chart helper to generate the pie chart image and to get the HTML content
        // use the chart definition in 'steel-wheels/dashboard/regions.widget.xml'
        ChartHelper.doChart(
            "steel-wheels",
            "dashboards",
            "SalesOvertime.widget.xml",
            parameters,
            content,
            userSession,
            messages,
            null);

        out.write("\r\n");
        out.write("  \t");
        out.print(content.toString());
        out.write("\r\n");
        out.write("  \t");
      }

      out.write("\r\n");
      out.write(" \t");

      if (productline == null) {
        // if the user has clicked on a bar of the bar chart we should have a territory and
        // productline to work with
        // create a dial and supply a value we create from the current time
        // create the parameters for the line chart
        parameters = new SimpleParameterProvider();
        parameters.setParameter("TERRITORY", territory);
        parameters.setParameter("outer-params", "TERRITORY");
        // define the category axis of the bar chart
        parameters.setParameter("inner-param", "PRODUCTLINE"); // $NON-NLS-1$ //$NON-NLS-2$
        // set the width and the height
        parameters.setParameter("image-width", "750"); // $NON-NLS-1$ //$NON-NLS-2$
        parameters.setParameter("image-height", "200"); // $NON-NLS-1$ //$NON-NLS-2$
        content = new StringBuffer();
        messages = new ArrayList();
        // call the chart helper to generate the pie chart image and to get the HTML content
        // use the chart definition in 'steel-wheels/dashboard/regions.widget.xml'
        ChartHelper.doChart(
            "steel-wheels",
            "dashboards",
            "SalesOvertime_All.widget.xml",
            parameters,
            content,
            userSession,
            messages,
            null);

        out.write("  \t\t\r\n");
        out.write("  \t\t");
        out.print(content.toString());
        out.write("\r\n");
        out.write("  \t");
      }

      out.write("\t\r\n");
      out.write("  \t\t</td>\r\n");
      out.write("  \t</tr>\r\n");
      out.write("  </table>\r\n");
      out.write("</body>\r\n");
      out.write("</html>\r\n");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
Exemplo n.º 16
0
  public String buildHtml() {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
    CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
    StringBuffer html = new StringBuffer(512);
    String fileName = null;
    boolean showWeekday = true;
    try {
      if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(getCssFile())) {
        String cssfile = cms.getRequestContext().removeSiteRoot(getCssFile());
        CmsObject cmso = cms.getCmsObject();
        Locale locale = cms.getRequestContext().getLocale();
        CmsFile configFile = cmso.readFile(cssfile, CmsResourceFilter.IGNORE_EXPIRATION);
        CmsXmlContent configuration = CmsXmlContentFactory.unmarshal(cmso, configFile);
        showWeekday =
            Boolean.parseBoolean(configuration.getStringValue(cmso, "showweekday", locale));
        fileName = configFile.getName();
        html.append("<style type=\"text/css\">\n");
        html.append("<!--");
        html.append(buildCSS(cms, cssfile));
        html.append("-->");
        html.append("</style>\n");
      }
      html.append(
          "<div"
              + (CmsStringUtil.isEmpty(fileName) ? "" : (" class=\"topTime" + fileName + "\""))
              + ">\n");
      html.append("<SCRIPT language=\"JavaScript\">\n");
      html.append("dayObj=new Date();\n");
      html.append("monthStr=dayObj.getMonth()+1;\n");
      html.append("year=dayObj.getFullYear();\n");
      html.append(
          "document.write(year+\""
              + cms.label(Messages.YEAR)
              + "\"+monthStr+\""
              + cms.label(Messages.MONTH)
              + "\"+dayObj.getDate()+\""
              + cms.label(Messages.DAY)
              + "\"+\" \"); \n");
      if (showWeekday) {
        html.append("document.write(\"&nbsp;\");\n");
        html.append(
            "if(dayObj.getDay()==1) document.write(\"" + cms.label(Messages.XQYI) + "\");\n");
        html.append(
            "if(dayObj.getDay()==2) document.write(\"" + cms.label(Messages.XQER) + "\");\n");
        html.append(
            "if(dayObj.getDay()==3) document.write(\"" + cms.label(Messages.XQSAN) + "\");\n");
        html.append(
            "if(dayObj.getDay()==4) document.write(\"" + cms.label(Messages.XQSI) + "\");\n");
        html.append(
            "if(dayObj.getDay()==5) document.write(\"" + cms.label(Messages.XQWU) + "\");\n");
        html.append(
            "if(dayObj.getDay()==6) document.write(\"" + cms.label(Messages.XQLIU) + "\");\n");
        html.append(
            "if(dayObj.getDay()==0) document.write(\"" + cms.label(Messages.XQRI) + "\");\n");
      }
      html.append("</SCRIPT>");
      html.append("</div>\n");
    } catch (Exception e) {
      LOG.debug(e);
    }

    return html.toString();
  }
  private String getSimpleImageConfirmLink(
      final String event,
      final String label,
      final String image,
      String imageOver,
      String javascript) {
    String status = Utilities.escapeHTML(Utilities.filterOutHTMLTags(label));

    if ((imageOver == null) || imageOver.equals("")) {
      imageOver = image;
    }

    if ((javascript == null) || javascript.equals("")) {
      javascript = "true";
    }

    final String imageID = event + "_img";

    StringBuffer link = new StringBuffer();

    link.append("<input type=\"hidden\" name=\"")
        .append(event)
        .append("\" value=\"")
        .append(AbstractChip.FALSE)
        .append("\" />");
    link.append("<a href=\"#\" hidefocus=\"true\" style=\"text-decoration:none; \" alt=\"")
        .append(status)
        .append("\" title=\"")
        .append(status)
        .append("\"");
    link.append("onMouseover=\"window.status='")
        .append(status)
        .append("'; swapImage('")
        .append(imageID)
        .append("', '")
        .append(imageOver)
        .append("'); return true;\" ");
    link.append("onMouseout=\"window.status=''; swapImage('")
        .append(imageID)
        .append("', '")
        .append(image)
        .append("'); return true;\" ");
    link.append("onFocus=\"swapImage('")
        .append(imageID)
        .append("', '")
        .append(imageOver)
        .append("'); return true;\" ");
    link.append("onBlur=\"swapImage('")
        .append(imageID)
        .append("', '")
        .append(image)
        .append("'); return true;\" ");
    link.append("onclick=\"document.editorForm.elements['")
        .append(event)
        .append("'].value = ")
        .append(javascript)
        .append("; setScrollAndSubmit(); return false;\">");
    link.append("<img id=\"")
        .append(imageID)
        .append("\" src=\"")
        .append(image)
        .append("\" alt=\"")
        .append(status)
        .append("\">");
    link.append("</a>");

    return link.toString();
  }
  private String getFooterButton(
      final String event,
      final String label,
      final String tooltip,
      final String image,
      String javascript,
      boolean showLabel,
      boolean isEnabled) {
    if ((javascript == null) || javascript.equals("")) {
      javascript = "true";
    }

    final String imageID = event + "_img";

    StringBuffer link = new StringBuffer();
    final String color = isEnabled ? "#333333" : "#999999";

    if (isEnabled) {
      link.append(
          "<input type=\"hidden\" name=\"" + event + "\" value=\"" + AbstractChip.FALSE + "\" />");
      link.append(
          "<a href=\"#\" hidefocus=\"true\" style=\"text-decoration:none; \" alt=\""
              + tooltip
              + "\" ");
      link.append(
          "onMouseover=\"window.status='"
              + tooltip
              + "'; "
              + " document.getElementById('"
              + imageID
              + "_bg_left').style.backgroundImage = 'url(images/icons/footer_background_hover_l.gif)'; "
              + " document.getElementById('"
              + imageID
              + "_bg_middle').style.backgroundImage = 'url(images/icons/footer_background_hover_m.gif)'; "
              + " document.getElementById('"
              + imageID
              + "_bg_right').style.backgroundImage = 'url(images/icons/footer_background_hover_r.gif)'; "
              + " return true;\" ");
      link.append(
          "onMouseout=\"window.status='';"
              + " document.getElementById('"
              + imageID
              + "_bg_left').style.backgroundImage = 'url(images/icons/footer_background_l.gif)'; "
              + " document.getElementById('"
              + imageID
              + "_bg_middle').style.backgroundImage = 'url(images/icons/footer_background_m.gif)'; "
              + " document.getElementById('"
              + imageID
              + "_bg_right').style.backgroundImage = 'url(images/icons/footer_background_r.gif)'; "
              + " return true;\" ");
      link.append(
          "onFocus=\"window.status='"
              + tooltip
              + "'; "
              + " document.getElementById('"
              + imageID
              + "_bg_left').style.backgroundImage = 'url(images/icons/footer_background_hover_l.gif)'; "
              + " document.getElementById('"
              + imageID
              + "_bg_middle').style.backgroundImage = 'url(images/icons/footer_background_hover_m.gif)'; "
              + " document.getElementById('"
              + imageID
              + "_bg_right').style.backgroundImage = 'url(images/icons/footer_background_hover_r.gif)'; "
              + " return true;\" ");
      link.append(
          "onBlur=\"window.status='';"
              + " document.getElementById('"
              + imageID
              + "_bg_left').style.backgroundImage = 'url(images/icons/footer_background_l.gif)'; "
              + " document.getElementById('"
              + imageID
              + "_bg_middle').style.backgroundImage = 'url(images/icons/footer_background_m.gif)'; "
              + " document.getElementById('"
              + imageID
              + "_bg_right').style.backgroundImage = 'url(images/icons/footer_background_r.gif)'; "
              + " return true;\" ");
      link.append(
          "onclick=\"document.editorForm.elements['"
              + event
              + "'].value = "
              + javascript
              + "; setScrollAndSubmit(); return false;\">");
    }

    link.append(
        "<table title=\""
            + tooltip
            + "\" style=\"vertical-align:middle; width:100%; height:23px;\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
    link.append("<tr>");
    link.append(
        "<td id=\""
            + imageID
            + "_bg_left\" style=\"width:3px;\" background=\"images/icons/footer_background_l.gif\">&nbsp;</td>");
    link.append(
        "<td id=\""
            + imageID
            + "_bg_middle\" style=\"white-space:nowrap;vertical-align:middle;text-align:center;\" background=\"images/icons/footer_background_m.gif\">");

    link.append(
        "<img id=\"" + imageID + "\" style=\"vertical-align:middle\" src=\"" + image + "\">");
    if (showLabel) {
      link.append("<span style=\"padding-left:5px; color:" + color + "\">" + label + "</span>");
    }

    link.append("</td>");
    link.append(
        "<td id=\""
            + imageID
            + "_bg_right\" style=\"width:3px;\" background=\"images/icons/footer_background_r.gif\">&nbsp;</td>");
    link.append("</tr>");
    link.append("</table>");

    if (isEnabled) {
      link.append("</a>");
    }

    return link.toString();
  }
  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/html;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");

      response.setContentType("text/xml");

      int mapId = -1;

      TopologyMap map = (TopologyMap) request.getAttribute("map");

      String isRcad = "false";

      if (map == null) {
        String strMapId = request.getParameter("mapId");
        if (strMapId != null) {
          mapId = Integer.parseInt(request.getParameter("mapId"));
        }
      }
      if (map == null && mapId != 99999) {
        map = TopologyMap.getMapById(mapId);
      }
      if (map != null) {
        List centities = map.getCentityMaps();
        List connections = map.getConnections();
        List bgimages = map.getMapBgimages();

        if (WTAccountCredentials.current() == null) {
          System.out.println("NullPointerException: WTAccountCredentials.current() is null");
          return;
        }

        String user = WTAccountCredentials.current().getUserName();
        boolean admin = false;
        WTRole role = WTAccountCredentials.current().getMostPrivilegedRole();
        admin = role.isOrgAdmin() || role.isSiteAdmin();

        if (user == null) {

          out.write("<topology-map />");

          return;
        }
        boolean readOnly = !user.equals(map.getCreator());

        Integer groupId = map.getGroupId();
        String groupAttrs = "";
        if (groupId != null) {
          WTGroupManager groupMan = ManagersImpl.GroupManager;
          WTGroup group = (WTGroup) groupMan.getObject(groupId.intValue());
          groupMan.resolveReferences(group);
          groupAttrs =
              "groupName=\""
                  + URLEncoder.encode(group.getOrg().getName() + " - " + group.getName(), "UTF-8")
                  + "\" groupId=\""
                  + groupId.intValue()
                  + "\"";
        }

        isRcad = String.valueOf(map.isRca());

        out.write("\n\t");
        out.write("<topology-map mapId=\"");
        out.print(map.getMapId());
        out.write("\" name=\"");
        out.print(map.getName());
        out.write("\" mapTypeId=\"");
        out.print(map.getTypeId());
        out.write("\" \n\t zoomLevel=\"");
        out.print(map.getZoom());
        out.write("\" paneScrollX=\"");
        out.print(map.getScrollX());
        out.write("\" paneScrollY=\"");
        out.print(map.getScrollY());
        out.write("\"\n\t shared=\"");
        out.print(map.isShared());
        out.write("\" creator=\"");
        out.print(map.getCreator());
        out.write("\" iconSize=\"");
        out.print(map.getIconSize());
        out.write("\"\n\t labelsAlwaysOn=\"");
        out.print(map.isLabelsAlwaysOn());
        out.write("\" readOnly=\"");
        out.print(readOnly);
        out.write("\" ");
        out.print(groupAttrs);
        out.write(" admin=\"");
        out.print(admin);
        out.write("\" isRcad=\"");
        out.print(isRcad);
        out.write("\">\n\t\n\t\t");
        out.write("<entities>\n\t");

        for (Iterator it = centities.iterator(); it.hasNext(); ) {
          CentityMap centityMap = (CentityMap) it.next();
          StringBuffer hierarchyBuffer = new StringBuffer();
          if (centityMap.getType().equals("category")) {
            WTCategory cat =
                (WTCategory)
                    ManagersImpl.CategoryManager.getObject(
                        Integer.valueOf(centityMap.getIdForType()));
            List sectionList = ManagersImpl.CategoryManager.getAllParentSections(cat);

            for (Iterator sectionIt = sectionList.iterator(); sectionIt.hasNext(); ) {
              WTSection section = (WTSection) sectionIt.next();
              hierarchyBuffer.append(section.getName() + " / ");
            }
          }

          out.write("\n\t    ");
          out.write("<entity centityId=\"");
          out.print(centityMap.getCentityId());
          out.write("\" type=\"");
          out.print(centityMap.getType());
          out.write("\" id=\"");
          out.print(centityMap.getXmlId());
          out.write("\"\n\t     icon=\"");
          out.print(centityMap.getIcon());
          out.write("\" label=\"");
          out.print(centityMap.getLabel());
          out.write("\" hierarchy=\"");
          out.print(hierarchyBuffer.toString());
          out.write("\"\n\t      x=\"");
          out.print(centityMap.getXPlacement());
          out.write("\" y=\"");
          out.print(centityMap.getYPlacement());
          out.write("\"/>\n\t    ");
        }

        out.write("\n\t\t");
        out.write("</entities>\n\t\t");
        out.write("<connections>\n\t");

        for (Iterator it = connections.iterator(); it.hasNext(); ) {
          CentityConnection cc = (CentityConnection) it.next();
          String startType = null;
          String endType = null;
          int startId = -1;
          int endId = -1;
          if (cc.getParentNodeid() != null) {
            startType = "node";
            startId = cc.getParentNodeid();
          } else if (cc.getParentCategoryId() != null) {
            startType = "category";
            startId = cc.getParentCategoryId();
          }
          if (cc.getNodeid() != null) {
            endType = "node";
            endId = cc.getNodeid();
          } else if (cc.getCategoryId() != null) {
            endType = "category";
            endId = cc.getCategoryId();
          }

          out.write("\n\t\t\t");
          out.write("<connection startType=\"");
          out.print(startType);
          out.write("\" startId=\"");
          out.print(startId);
          out.write("\" endType=\"");
          out.print(endType);
          out.write("\" endId=\"");
          out.print(endId);
          out.write("\" />\n\t");
        }

        out.write("\n\t\t");
        out.write("</connections>\n\t\t");
        out.write("<bgimages>\n\t");

        for (Iterator it = bgimages.iterator(); it.hasNext(); ) {
          MapBgimage bgimage = (MapBgimage) it.next();

          out.write("\n\t\t\t\t");
          out.write("<bgimage mapBgimageId=\"");
          out.print(bgimage.getMapBgimageId());
          out.write("\" bgimageId=\"");
          out.print(bgimage.getBgimageId());
          out.write("\"\n\t\t\t\t creator=\"");
          out.print(bgimage.getCreator());
          out.write("\" src=\"");
          out.print(bgimage.getSrc());
          out.write("\" x=\"");
          out.print(bgimage.getXPlacement());
          out.write("\"\n\t\t\t\t  y=\"");
          out.print(bgimage.getYPlacement());
          out.write("\" zindex=\"");
          out.print(bgimage.getZIndex());
          out.write("\" xscale=\"");
          out.print(bgimage.getXScale());
          out.write("\"\n\t\t\t\t   yscale=\"");
          out.print(bgimage.getYScale());
          out.write("\" />\n\t");
        }

        out.write("\n\t\t");
        out.write("</bgimages>\n\t\t\n\t");
        out.write("</topology-map>\n");

      } else {
        out.write("\n");
        out.write(
            "<topology-map mapId=\"99999\" name=\"Topology Sample\" zoomLevel=\"10\" paneScrollX=\"0\" paneScrollY=\"0\" shared=\"true\" creator=\"admin\" iconSize=\"32\" labelsAlwaysOn=\"true\" type=\"topology\">\n\t");
        out.write("<entities>\n\t\t");
        out.write(
            "<entity centityId=\"-90\" type=\"node\" id=\"node_603\" icon=\"OS_Win2003.swf\" label=\"CARROT\" x=\"300\" y=\"200\"/>\n\t\t");
        out.write(
            "<entity centityId=\"-91\" type=\"node\" id=\"node_653\" icon=\"OS_Win2000.swf\" label=\"RAISIN\" x=\"200\" y=\"200\"/>\n\t\t");
        out.write(
            "<entity centityId=\"-92\" type=\"node\" id=\"node_615\" icon=\"OS_Win2003.swf\" label=\"10.100.100.88\" x=\"300\" y=\"100\"/>\n\t\t");
        out.write(
            "<entity centityId=\"-93\" type=\"node\" id=\"node_616\" icon=\"OS_WinXP.swf\" label=\"10.100.100.241\" x=\"100\" y=\"100\"/>\n\t\t");
        out.write(
            "<entity centityId=\"-94\" type=\"node\" id=\"node_613\" icon=\"OS_FoundryIronWare.swf\" label=\"Foundry\" x=\"200\" y=\"125\"/>\n\t\t");
        out.write(
            "<entity centityId=\"-95\" type=\"node\" id=\"node_656\" icon=\"OS_WinXP.swf\" label=\"10.100.100.239\" x=\"225\" y=\"70\"/>\n\t\t");
        out.write(
            "<entity centityId=\"-96\" type=\"node\" id=\"node_610\" icon=\"OS_CiscoIOS.swf\" label=\"Cittio-2621\" x=\"125\" y=\"150\"/>\n\t\t");
        out.write(
            "<entity centityId=\"-97\" type=\"node\" id=\"node_614\" icon=\"OS_Linux.swf\" label=\"Mango\" x=\"100\" y=\"200\"/>\n\n\t");
        out.write("</entities>\n\t");
        out.write("<connections>\n\t\t");
        out.write(
            "<connection startType=\"node\" startId=\"603\" endType=\"node\" endId=\"613\"/>\n\t\t");
        out.write(
            "<connection startType=\"node\" startId=\"653\" endType=\"node\" endId=\"613\"/>\n\t\t");
        out.write(
            "<connection startType=\"node\" startId=\"615\" endType=\"node\" endId=\"613\"/>\n\t\t");
        out.write(
            "<connection startType=\"node\" startId=\"616\" endType=\"node\" endId=\"613\"/>\n\t\t");
        out.write(
            "<connection startType=\"node\" startId=\"656\" endType=\"node\" endId=\"613\"/>\n\t\t");
        out.write(
            "<connection startType=\"node\" startId=\"610\" endType=\"node\" endId=\"613\"/>\n\t\t");
        out.write(
            "<connection startType=\"node\" startId=\"614\" endType=\"node\" endId=\"610\"/>\n\t");
        out.write("</connections>\n\t");
        out.write("<bgimages />\n");
        out.write("</topology-map>\n");
      }

      out.write("\n\n\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);
    }
  }
Exemplo n.º 20
0
  public String buildHtml() {
    StringBuffer html = new StringBuffer(512);
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();
    CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
    CmsJspXmlContentBean cmsx = new CmsJspXmlContentBean(pageContext, request, response);
    Locale locale = cms.getRequestContext().getLocale();
    String folderpath1 = "";
    String folderpath2 = "";
    int mwidth = 0;
    int iwidth = 0;
    int fwidth = 0;
    int twidth = 0;
    int fs = 0;
    int zf = 0;
    boolean have = false;
    try {
      String cssfile = cms.getRequestContext().removeSiteRoot(getCssFile());
      String linkpath = cms.getRequestContext().removeSiteRoot(getLinkFile());
      CmsObject obj = cms.getCmsObject();
      CmsFile config = obj.readFile(cssfile, CmsResourceFilter.IGNORE_EXPIRATION);
      CmsXmlContent configuration = CmsXmlContentFactory.unmarshal(obj, config);
      String mainwidth = configuration.getStringValue(obj, "main.width", locale);
      String imgwidth = configuration.getStringValue(obj, "img.width", locale);
      String trmargin = configuration.getStringValue(obj, "tr.margin", locale);
      String fontsize = configuration.getStringValue(obj, "font.size", locale);

      String imguprowbgimage = configuration.getStringValue(obj, "img.uprow.bgimage", locale);
      String imgdownrowbgimage = configuration.getStringValue(obj, "img.downrow.bgimage", locale);
      List lt = new ArrayList();

      I_CmsXmlContentContainer container;

      container = cmsx.contentload("singleFile", linkpath, true);

      while (container.hasMoreResources()) {

        I_CmsXmlContentContainer container1 = cmsx.contentloop(container, "ProgramLink");

        for (int number = 0; container1.hasMoreResources() && number < 2; number++) {

          if (number == 0) {
            folderpath1 = cmsx.contentshow(container1, "ProgramLink");
          } else {
            folderpath2 = cmsx.contentshow(container1, "ProgramLink");
          }
        }
      }

      String fileName = config.getName();
      if (CmsStringUtil.isEmpty(getCssIndicator())) {
        html.append("<style type=\"text/css\">\n");
        html.append("<!--");
        html.append(buildCSS(cms, cssfile));
        html.append("-->");
        html.append("</style>\n");
      }
      if (CmsStringUtil.isNotEmpty(getCssIndicator())
          && A_LanghuaTag.CSS_INDICATOR_NOSTYLE.equals(getCssIndicator())) {

        html.append(buildCSS(cms, cssfile));
      }
      if (CmsStringUtil.isEmpty(getCssIndicator())
          || A_LanghuaTag.CSS_INDICATOR_CUSTOMIZED.equals(getCssIndicator())) {
        html.append("<div align=\"center\">\n");
        html.append("<div class=\"content" + fileName + "\">\n");
        html.append("<div class=\"img" + fileName + "\">");
        html.append("</div>");
        if (CmsStringUtil.isNotEmpty(mainwidth) && CmsStringUtil.isNotEmpty(imgwidth)) {
          mwidth = Integer.parseInt(mainwidth);
          iwidth = Integer.parseInt(imgwidth);
          fwidth = mwidth - iwidth;
        }
        if (CmsStringUtil.isNotEmpty(trmargin)) {
          twidth = Integer.parseInt(trmargin);
        }
        if (CmsStringUtil.isNotEmpty(fontsize)) {
          fs = Integer.parseInt(fontsize);
        }
        if (CmsStringUtil.isEmpty(imguprowbgimage)) {
          html.append("<div class=\"uprow" + fileName + "\" >");
        } else {
          String uprowuri = cms.link(imguprowbgimage);
          html.append(
              "<div class=\"uprow" + fileName + "\" style=\"background:url(" + uprowuri + ");\">");
        }
        if (CmsStringUtil.isNotEmpty(folderpath1)) {

          List<CmsJspNavElement> list =
              new CmsJspNavBuilder(cms.getCmsObject()).getNavigationForFolder(folderpath1);
          for (int j = 0; j < list.size(); j++) {
            CmsJspNavElement nav = (CmsJspNavElement) list.get(j);
            String ntitle = nav.getNavText();
            String npath = cms.link(nav.getResourceName());
            int nl = ntitle.length();
            nl = nl * fs;
            zf = zf + twidth + nl;
            if (zf > fwidth && (fwidth != 0)) {
              have = true;
            }
            if (have) {
              TitleFont titfont = new TitleFont();
              titfont.setTitlefont(ntitle);
              titfont.setPath(npath);
              lt.add(titfont);

            } else {
              html.append("<div class=\"tr" + fileName + "\">");
              html.append("<a href=\"" + npath + "\"  class=\"uplink" + fileName + "\">");
              html.append(ntitle);
              html.append("</a>");
              html.append("</div>");
            }
          }
        }

        I_CmsXmlContentContainer container0;

        container0 = cmsx.contentload("singleFile", linkpath, true);

        while (container0.hasMoreResources()) {

          I_CmsXmlContentContainer container1 = cmsx.contentloop(container0, "SuperLink");

          while (container1.hasMoreResources()) {
            String description = cmsx.contentshow(container1, "Description");
            String uri = cmsx.contentshow(container1, "SuperLink");
            uri = cms.getRequestContext().removeSiteRoot(uri);
            String id = cmsx.contentshow(container1, "ID");
            if ("1".equals(id)) {
              html.append("<div class=\"tr" + fileName + "\">");
              html.append("<a href=\"" + uri + "\" class=\"uplink" + fileName + "\">\n");
              html.append(description);
              html.append("</a>\n");
              html.append("</div>");
            }
          }
        }
        html.append("</div>");
        if (CmsStringUtil.isEmpty(imgdownrowbgimage)) {
          html.append("<div class=\"downrow" + fileName + "\" >");
        } else {
          String downrowuri = cms.link(imgdownrowbgimage);
          html.append(
              "<div class=\"downrow"
                  + fileName
                  + "\" style=\"background:url("
                  + downrowuri
                  + ");\">");
        }
        ListIterator iterator = lt.listIterator();
        if (have) {
          while (iterator.hasNext()) {
            TitleFont titfont = new TitleFont();
            titfont = (TitleFont) iterator.next();

            html.append("<div class=\"tr" + fileName + "\">");
            html.append(
                "<a href=\"" + titfont.getPath() + "\"  class=\"downlink" + fileName + "\">");
            html.append(titfont.getTitlefont());
            html.append("</a>");
            html.append("</div>");
          }
        }
        if (CmsStringUtil.isNotEmpty(folderpath2)) {
          List<CmsJspNavElement> list =
              new CmsJspNavBuilder(cms.getCmsObject()).getNavigationForFolder(folderpath2);
          for (int j = 0; j < list.size(); j++) {
            CmsJspNavElement nav = (CmsJspNavElement) list.get(j);
            html.append("<div class=\"tr" + fileName + "\">");
            html.append(
                "<a href=\""
                    + cms.link(nav.getResourceName())
                    + "\"  class=\"downlink"
                    + fileName
                    + "\">");
            html.append(nav.getNavText());
            html.append("</a>");
            html.append("</div>");
          }
        }
        I_CmsXmlContentContainer container3;

        container3 = cmsx.contentload("singleFile", linkpath, true);

        while (container3.hasMoreResources()) {

          I_CmsXmlContentContainer container1 = cmsx.contentloop(container3, "SuperLink");

          while (container1.hasMoreResources()) {
            String description = cmsx.contentshow(container1, "Description");
            String uri = cmsx.contentshow(container1, "SuperLink");
            String id = cmsx.contentshow(container1, "ID");
            if ("2".equals(id)) {
              html.append("<div class=\"tr" + fileName + "\">");
              html.append("<a href=\"" + uri + "\" class=\"downlink" + fileName + "\">\n");
              html.append(description);
              html.append("</a>\n");
              html.append("</div>");
            }
          }
        }

        html.append("</div>");
        html.append("</div>");

        html.append("</div>");
      }
    } catch (Exception e1) {

      if (LOG.isDebugEnabled()) {
        LOG.debug(e1);
      }
    }

    return html.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();
  }
Exemplo n.º 22
0
  // createPageString -
  // Create list of pages for search results
  private String createPageString(
      int numberOfItems, int itemsPerPage, int currentPage, String baseUrl) {
    StringBuffer pageString = new StringBuffer();

    // Calculate the total number of pages
    int totalPages = 1;
    if (numberOfItems > itemsPerPage) {
      double pages = Math.ceil(numberOfItems / (double) itemsPerPage);
      totalPages = (int) Math.ceil(pages);
    }

    //
    if (totalPages > 1) {
      for (int i = 1; i <= totalPages; i++) {
        if (i == currentPage) {
          pageString.append(i);
        } else {
          pageString.append("<a href=\"" + baseUrl + i + "\" title=\"" + i + "\">" + i + "</a>");
        }

        if (i != totalPages) pageString.append(" ");
      }
    } else {
      pageString.append("1");
    }

    return pageString.toString();
  }
Exemplo n.º 23
0
  public void getEnv(VariableTable vt) {
    Enumeration e = null;
    HttpServletRequest request = (HttpServletRequest) (pageContext.getRequest());
    HttpSession session = request.getSession(false);

    String db_charset = "gb2312";
    String url_charset = null;

    vt.remove("SESSION.LOGINID");
    vt.remove("SESSION.LOGINNAME");
    vt.remove("SESSION.LOGINROLE");

    if (vt.exists("WEBCHART.DB_CHARSET")) {
      db_charset = vt.getString("WEBCHART.DB_CHARSET");
    }

    if (vt.exists("WEBCHART.URL_CHARSET")) {
      url_charset = vt.getString("WEBCHART.URL_CHARSET");
    }

    if (session != null) {
      e = session.getAttributeNames();
      while (e.hasMoreElements()) {
        String name = (String) e.nextElement();
        Object value = session.getAttribute(name);
        vt.add(name, java.sql.Types.VARCHAR);
        if (value != null) vt.setValue(name, value.toString());
      }
      vt.add("SESSION.ID", java.sql.Types.VARCHAR);
      vt.setValue("SESSION.ID", session.getId());
      vt.add("SESSION.CREATE", java.sql.Types.VARCHAR);
      vt.setValue(
          "SESSION.CREATE",
          DBOperation.toString(
              new java.util.Date(session.getCreationTime()), "yyyy-MM-dd HH:mm:ss"));
      vt.add("SESSION.ACCESS", java.sql.Types.VARCHAR);
      vt.setValue(
          "SESSION.ACCESS",
          DBOperation.toString(
              new java.util.Date(session.getLastAccessedTime()), "yyyy-MM-dd HH:mm:ss"));
    }
    e = request.getParameterNames();
    while (e.hasMoreElements()) {
      String name = (String) e.nextElement();
      String value = request.getParameter(name);
      ;
      String par_values[] = request.getParameterValues(name);
      name = name.toUpperCase();
      if (name.equalsIgnoreCase("WEBCHART.SECURITY")
          || name.equalsIgnoreCase("WEBCHART.DEFAULTACCESS")
          || name.equalsIgnoreCase("WEBCHART.ALLOW")
          || name.equalsIgnoreCase("WEBCHART.DENY")
          || name.equalsIgnoreCase("WEBCHART.IPSECURITY")
          || name.equalsIgnoreCase("WEBCHART.IPACCESS")
          || name.equalsIgnoreCase("WEBCHART.IPALLOW")
          || name.equalsIgnoreCase("WEBCHART.IPDENY")
          || name.equalsIgnoreCase("WEBCHART.XSLDOC")
          || name.equalsIgnoreCase("WEBCHART.IMAGEONLY")
          || name.equalsIgnoreCase("WEBCHART.XMLDATA")
          || name.equalsIgnoreCase("WEBCHART.LOGSQL")
          || name.equalsIgnoreCase("WEBCHART.DATATYPE")
          || name.equalsIgnoreCase("WEBCHART.URLS")
          || name.equalsIgnoreCase("WEBCHART.TOPURLS")
          || name.equalsIgnoreCase("WEBCHART.TOPCURR")
          || name.equalsIgnoreCase("WEBCHART.LEFTURLS")
          || name.equalsIgnoreCase("WEBCHART.LEFTCURR")
          || name.equalsIgnoreCase("WEBCHART.INPUTS")
          || name.equalsIgnoreCase("WEBCHART.CACHE")
          || name.equalsIgnoreCase("WEBCHART.DATA")
          || name.equalsIgnoreCase("WEBCHART.CSS")
          || name.equalsIgnoreCase("WEBCHART.RELOAD")
          || name.equalsIgnoreCase("WEBCHART.EXPIRE")
          || name.equalsIgnoreCase("WEBCHART.DMLKEY")
          || name.equalsIgnoreCase("WEBCHART.ENGINE")
          || name.equalsIgnoreCase("WEBCHART.EXCELURL")
          || name.equalsIgnoreCase("WEBCHART.DBID")
          || name.equalsIgnoreCase("WEBCHART.DBIDSEED")
          || name.equalsIgnoreCase("WEBCHART.SECUREFIELDS")
          || name.equalsIgnoreCase("WEBCHART.KEEP_CACHE_IMAGE")
          || name.equalsIgnoreCase("WEBCHART.KEEP_CACHE_TIME")
          || name.startsWith("WEBCHART.SECUREMEMO")
          || name.startsWith("WEBCHART.QUERY_")
          || name.startsWith("WEBCHART.HEADHTML_")
          || name.startsWith("WEBCHART.DATAHTML_")
          || name.startsWith("WEBCHART.VARLIST_")
          || name.startsWith("WEBCHART.FORALL_")
          || name.startsWith("WEBCHART.XMLDATA_")
          || name.startsWith("WEBCHART.TABLE_")
          || name.startsWith("WEBCHART.COLUMN_")
          || name.startsWith("SESSION.")) continue;
      if (name.startsWith("WEBCHART.") && !name.equals("WEBCHART.DOCTYPE")) continue;
      vt.add(name, java.sql.Types.VARCHAR);

      if (par_values != null && par_values.length > 1) {
        StringBuffer temp = new StringBuffer();
        for (int i = 0; i < par_values.length; i++) {
          if (par_values[i] != null && par_values[i].trim().length() > 0) {
            if (temp.length() > 0) {
              temp.append(",");
            }
            temp.append(par_values[i]);
          }
        }
        value = temp.toString();
      }
      if (url_charset != null) {
        try {
          value = new String(value.getBytes(url_charset), db_charset);
        } catch (java.io.UnsupportedEncodingException uee) {
        }
        ;
      }
      vt.setValue(name, value);
    }
    vt.add("REQUEST.REMOTEADDR", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.REMOTEADDR", getClientIPAddr());
    vt.add("REQUEST.REMOTEHOST", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.REMOTEHOST", request.getRemoteAddr());
    vt.add("REQUEST.REFERER", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.REFERER", request.getHeader("Referer"));
    vt.add("REQUEST.QUERYSTRING", java.sql.Types.VARCHAR);
    vt.setValue("REQUEST.QUERYSTRING", request.getQueryString());
  }