// 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; }
// 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; }
private void init() { DbConn tempDB = new DbConn("dummy"); SCHEMA = "sat"; SCHEMAPATH = "sat"; DBTYPE = tempDB.getDBType(); }