コード例 #1
0
  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\n");

      // Get the current user's ac
      WTAccountCredentials ac = WTAccountCredentials.current();
      SecureInfoManagerImpl sim = new SecureInfoManagerImpl();

      // Setup for permission checking
      boolean editInterfaces = false;
      if (sim.canEditEntity(ProtectedResourceConstants.PR_INTERFACES, ac)) editInterfaces = true;
      pageContext.setAttribute("editInterfaces", new Boolean(editInterfaces));

      out.write("  \n");

      String hostIP = null;
      try {
        hostIP = InetAddress.getLocalHost().getHostAddress();
        //    out.print(hostIP);

      } catch (UnknownHostException ex) {
        throw new Exception("Could not determine the local host address", ex);
      }

      out.write("\n\nvar javaScriptVar=\"");
      out.print(hostIP);
      out.write("\";\nvar javaScriptVar2=\"");
      out.print(editInterfaces);
      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);
    }
  }
コード例 #2
0
  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\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n\n");

      // This JSP handles cross context communications from wt-monitor
      // to wt-core for use in accessing wt-core functionality that is
      // needed in WTnav-tree.jsp.

      // Assign a pooled DB connection handle
      Context ctx = new InitialContext();
      DataSource ds = (DataSource) ctx.lookup(WTConstants.WATCHTOWERDB_CONN);
      int iIndex = 6100;
      GraphViewManager graphman = new GraphViewManager(ds);
      // Vector views = graphman.getViews();

      Vector views = new Vector();
      WTOrganization[] orgs = null;

      WTAccountCredentials ac =
          (WTAccountCredentials)
              request.getSession().getAttribute(WTAccountCredentials.SESSION_ATTRIBUTE_AC);
      if (ac != null) {
        // WTOrganization[] orgs = null;
        int selectedOrg = ac.getCurrentManagedId();

        boolean siteUser = ac.getIsSiteUser();
        int userId = ac.getUserId();

        // Get list of organizations for the current user
        if (siteUser) {
          try {
            orgs = DAOImpl.OrgDAO.getWTOrganization();
          } catch (Exception e) {
            e.printStackTrace();
          }
        } else {
          if (!(userId < 0)) {
            try {
              orgs = DAOImpl.OrgDAO.getWTOrganizationsByUser(userId);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        }

        // Get the list of actively managed nodes
        if (selectedOrg == WTAccountCredentials.ALL_ORGS) {
          if (siteUser) {
            views = graphman.getViews();
          } else {
            if (orgs != null) {
              int[] orgsIds = new int[orgs.length];
              for (int i = 0; i < orgs.length; i++) {
                orgsIds[i] = orgs[i].getID();
              }
              views = graphman.getViews(orgsIds);
            }
          }
        } else {
          views = graphman.getViews(selectedOrg);
        }
      }

      // My Graph Views is an experimental feature and is commented out until all kinks are worked
      // out. LS

      String strOutput = null;
      // 	if( views.size()==0 ) {
      //		strOutput = "nav.add(6100, 6000, 'My Graph Views', '/wt-monitor/report/index.jsp', 'My
      // Customized Graph Views', 'mainContentsFrame', icon16_basedir + 'bs_chart.gif',
      // icon16_basedir + 'bs_chart.gif', '');\r\n";
      //	} else {
      //		strOutput = "nav.add(6100, 6000, 'My Graph Views', '', 'My Customized Graph Views',
      // 'mainContentsFrame', icon16_basedir + 'bs_chart.gif', icon16_basedir + 'bs_chart.gif',
      // '');\r\n";
      //	}
      //	for (int i=0; i<views.size(); i++)
      //	{
      //		iIndex++;
      //		String strViewName = ((GraphViewJB)views.elementAt(i)).getName();
      //		int strOrgId = ((GraphViewJB)views.elementAt(i)).getOrgId();
      //		String orgName = null;
      //       for(int j=0;j<orgs.length;j++){
      //	        if(orgs[j].getID() != -1 && orgs[j].getID() == strOrgId){
      //	        	orgName = orgs[j].getName();
      //	        }
      //		}
      //
      //		strOutput +="nav.add(" + iIndex +
      //		            ", 6100, '" + strViewName +
      //		            "', 'javascript:
      // PopupCenteredWindow(\\'/wt-core/jsp/sysmon/graphview/GraphView.jsp?view=" + strViewName +
      // "&orgname="+orgName +"&start=01&end=02" + "\\', \\'graphview\\', \\'yes\\', \\'yes\\',
      // \\'yes\\', \\'900\\', \\'1010\\'); location.href=\\'/wt-monitor/wt-jsp/WTnav-tree.jsp\\';',
      // 'Open " + strViewName + " Graph View', '', icon16_basedir + 'bs_chart.gif', icon16_basedir
      // + 'bs_chart.gif', '');\r\n";
      // }

      out.write("\n\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n\n");
      out.print(strOutput);
      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);
    }
  }