Esempio n. 1
0
  // Process the request
  private String processRequest(HttpServletRequest request, HttpServletResponse response) {
    String command = request.getParameter("command");
    String id = request.getParameter("id");
    String description = request.getParameter("description");
    String status = request.getParameter("rstatus");
    status = (status != null && status.compareTo(" ") > 0) ? status : null;
    String outLine = "";
    // String nextScript = "home.jsp";
    String nextScript = request.getParameter("nextscript");
    OutputStream toClient;
    HttpSession session = request.getSession();
    boolean success = false;
    String userIDs = (String) session.getAttribute("user.id");
    long userID = Long.parseLong(userIDs);

    command = (command != null && command.compareTo(" ") > 0) ? command : "form";
    nextScript = (nextScript != null && nextScript.compareTo(" ") > 0) ? nextScript : "roles.jsp";

    //    inputstring = (inputstring != null && inputstring.compareTo(" ") > 0) ? inputstring : "";

    DbConn myConn = null;
    try {

      Context initCtx = new InitialContext();
      // String csiSchema = (String) initCtx.lookup("java:comp/env/csi-schema-path");
      String acronym = (String) initCtx.lookup("java:comp/env/SystemAcronym");
      myConn = new DbConn();
      String csiSchema = myConn.getSchemaPath();
      if (command.equals("add")) {
        Role item = new Role();
        item.setDescription(description);
        item.setStatus(status);
        getPermissions(request, item);
        getPositions(request, item);
        item.add(myConn, userID);
        GlobalMembership.refresh(myConn);
        success = true;
        outLine = "";

      } else if (command.equals("update")) {
        Role item = new Role(myConn, Long.parseLong(id));
        item.setDescription(description);
        item.setStatus(status);
        getPermissions(request, item);
        getPositions(request, item);
        item.save(myConn, userID);
        GlobalMembership.refresh(myConn);
        success = true;
        outLine = "";
      } else if (command.equals("drop")) {
        Role item = new Role(myConn, Long.parseLong(id));
        item.drop(myConn, userID);
        success = true;
        outLine = "Role " + item.getDescription() + " Removed";
      } else if (command.equals("test")) {
        outLine = "test";
      }

    } catch (IllegalArgumentException e) {
      outLine = outLine + "IllegalArgumentException caught: " + e.getMessage();
      ALog.logActivity(userID, "csi", 0, "Role error: '" + outLine + "'");
      // log(outLine);
    } catch (NullPointerException e) {
      outLine = outLine + "NullPointerException caught: " + e.getMessage();
      ALog.logActivity(userID, "csi", 0, "Role error: '" + outLine + "'");
      // log(outLine);
    }

    // catch (IOException e) {
    //    outLine = outLine + "IOException caught: " + e.getMessage();
    //    ALog.logActivity(userID, "csi", 0, "Role error: '" + outLine + "'");
    //    //log(outLine);
    // }

    catch (Exception e) {
      outLine = outLine + "Exception caught: " + e.getMessage();
      ALog.logActivity(userID, "csi", 0, "Role error: '" + outLine + "'");
      // log(outLine);
    } finally {
      try {
        generateResponse(outLine, command, nextScript, success, response);
      } catch (Exception i) {
      }

      myConn.release();
      // log("Test log message\n");
    }

    return outLine;
  }
Esempio n. 2
0
  // Process the request
  private String processRequest(HttpServletRequest request, HttpServletResponse response) {
    HttpSession session = request.getSession();
    String userIDs = (String) session.getAttribute("user.id");
    userIDs = (userIDs != null && userIDs.compareTo(" ") > 0) ? userIDs : "0";
    long userID = Long.parseLong(userIDs);
    String command = request.getParameter("command");
    String template = request.getParameter("template");
    String pageHash = request.getParameter("pagehash");
    String pageTitle = request.getParameter("pagetitle");
    String pageDescription = request.getParameter("pagedescription");

    String outLine = "";
    String nextScript = request.getParameter("nextscript");
    OutputStream toClient;
    boolean success = false;

    // System.out.println("userid=" + userID + ", id=" + id + ", command=" + command);

    command = (command != null && command.compareTo(" ") > 0) ? command : "form";
    nextScript = (nextScript != null && nextScript.compareTo(" ") > 0) ? nextScript : "simple1.jsp";

    //    inputstring = (inputstring != null && inputstring.compareTo(" ") > 0) ? inputstring : "";

    DbConn myConn = null;
    try {

      Context initCtx = new InitialContext();
      // String csiSchema = (String) initCtx.lookup("java:comp/env/csi-schema-path");
      // String acronym = (String) initCtx.lookup("java:comp/env/SystemAcronym");
      myConn = new DbConn();
      String csiSchema = myConn.getSchemaPath();
      if (userID != 0) {
        if (command.equals("add")) {
          outLine = "";
        } else if (command.equals("update")) {
          outLine = "";
        } else if (command.equals("updatepage")) {
          UHash uPage = new UHash(pageHash, myConn);
          // System.out.println("Got Here 1");
          if (template.equals("simple1")) {
            TextItem title = new TextItem(uPage.get("title"), myConn);
            title.setText(pageTitle);
            title.save(myConn);
            TextItem description = new TextItem(uPage.get("description"), myConn);
            description.setText(pageDescription);
            description.save(myConn);
          } else if (template.equals("simple2")) {
          }

        } else if (command.equals("test")) {
          outLine = "test";
        }
        success = true;
      }

    } catch (IllegalArgumentException e) {
      outLine = outLine + "IllegalArgumentException caught: " + e.getMessage();
      ALog.logActivity(userID, "csi", 0, pageHash + " error: '" + outLine + "'");
      // log(outLine);
    } catch (NullPointerException e) {
      outLine = outLine + "NullPointerException caught: " + e.getMessage();
      ALog.logActivity(userID, "csi", 0, pageHash + " error: '" + outLine + "'");
      // log(outLine);
    }

    // catch (IOException e) {
    //    outLine = outLine + "IOException caught: " + e.getMessage();
    //    ALog.logActivity(userID, "csi", 0, pageHash + " error: '" + outLine + "'");
    //    //log(outLine);
    // }

    catch (Exception e) {
      outLine = outLine + "Exception caught: " + e.getMessage();
      ALog.logActivity(userID, "csi", 0, pageHash + " error: '" + outLine + "'");
      // log(outLine);
    } finally {
      try {
        generateResponse(outLine, command, nextScript, success, response);
      } catch (Exception i) {
      }

      myConn.release();
      // log("Test log message\n");
    }

    return outLine;
  }
Esempio n. 3
0
  public void lookup(int orgid, int year, DbConn myConn) {
    String outLine = "";
    ResultSet rs = null;
    Statement stmt = null;
    // get *active* organizations
    // get organization name and acronym
    try {
      Connection conn = myConn.conn;
      stmt = conn.createStatement();
      String sqlcode = null;
      String wherestring = null;
      String orderby = " order by name ";
      if (orgid > 0) {
        wherestring = " where isactive = 'T' AND id=" + orgid;
        sqlcode =
            "SELECT id, name, acronym, isactive, porgid FROM "
                + SCHEMAPATH
                + ".ORGANIZATION "
                + wherestring;
      } else {
        wherestring = " where isactive = 'T'";
        sqlcode =
            "SELECT id, name, acronym, isactive, porgid FROM "
                + SCHEMAPATH
                + ".ORGANIZATION "
                + wherestring
                + orderby;
      }
      // System.out.println(sqlcode);
      rs = stmt.executeQuery(sqlcode);
      while (rs.next()) {
        System.out.println(
            "/************** "
                + rs.getString("name")
                + ", "
                + rs.getInt("id")
                + " **************/");
        SelfAssessment sa = new SelfAssessment();
        SelfAssessment[] item = sa.getSAList(myConn, "id", 0, orgid, year);
        for (int i = 0; i < item.length; i++) {
          System.out.println("/**************" + "**************/");
          sanumber = item[i].getSANumber(item[i].getOrgid(), item[i].getDivid(), myConn);
          System.out.println("sanumber: " + sanumber);
          teamleadid = Integer.valueOf(item[i].getTeamleadid());
          String teamleadname = null;
          teamleadname = item[i].getTeamleadname(teamleadid, myConn);
          System.out.println("teamleadname: " + teamleadname);
          title = item[i].getTitle();
          System.out.println("title: " + title);
          purpose = item[i].getPurpose();
          System.out.println("purpose: " + purpose);
          scheduleddate = item[i].getScheduleddate();
          System.out.println("scheduleddate: " + scheduleddate);
          rescheduleddate = item[i].getRescheduleddate();
          System.out.println("rescheduleddate: " + rescheduleddate);
          signeddate = item[i].getSigneddate();
          System.out.println("signeddate: " + signeddate);
          cancelleddate = item[i].getCancelleddate();
          System.out.println("cancelleddate: " + cancelleddate);
          cancelledrationale = item[i].getCancelledrationale();
          System.out.println("cancelledrationale: " + cancelledrationale);
          comments = item[i].getComments();
          System.out.println("comments: " + comments);
          hascirs = item[i].getHascirs();
          System.out.println("hascirs: " + hascirs);
          asstype = item[i].getAsstype();
          System.out.println("asstype: " + asstype);
          assobj = item[i].getAssobj();
          System.out.println("assobj: " + assobj);
          crlevels = item[i].getCrlevels();
          System.out.println("crlevels: " + crlevels);
          crnums = item[i].getCrnums();
          System.out.println("crnums: " + crnums);
          llnums = item[i].getLlnums();
          System.out.println("llnums: " + llnums);
        }
      }

    } catch (SQLException e) {
      outLine = outLine + "SQLException caught: " + e.getMessage();
      // log(outLine);
      // gov.ymp.csi.db.ALog.logError(myConn, 0,"N/A",0, outLine + " - SelfAssessment lookup");
    } catch (Exception e) {
      outLine = outLine + "Exception caught: " + e.getMessage();
      // log(outLine);
      // gov.ymp.csi.db.ALog.logError(myConn, 0,"N/A",0, outLine);
    } finally {
      if (rs != null)
        try {
          rs.close();
        } catch (Exception i) {
        }
      if (stmt != null)
        try {
          stmt.close();
        } catch (Exception i) {
        }
    }
  }