Thread: [Aimmath-commit] AIM/WEB-INF/java Alice.java,1.8,1.9
Brought to you by:
gustav_delius,
npstrick
From: Neil S. <nps...@us...> - 2005-04-28 21:44:30
|
Update of /cvsroot/aimmath/AIM/WEB-INF/java In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6090/WEB-INF/java Modified Files: Alice.java Log Message: Set the ProcessID variable in each Maple process. Also, most \n's replaced using println() etc, to make line endings work better on different platforms. Index: Alice.java =================================================================== RCS file: /cvsroot/aimmath/AIM/WEB-INF/java/Alice.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Alice.java 5 Sep 2003 09:57:07 -0000 1.8 --- Alice.java 28 Apr 2005 21:44:21 -0000 1.9 *************** *** 219,223 **** if (configError == null) { ! writeLog("Alice servlet initialized\n" + ParamReport() + "\n"); // Start the Maple process pool --- 219,223 ---- if (configError == null) { ! writeLog("Alice servlet initialized", ParamReport()); // Start the Maple process pool *************** *** 229,238 **** maplePool.logFile = LogFile; ! writeLog("Maple process pool started\n"); } } else { ! writeLog("Alice servlet not initialized because of " + ! "configuration problems: \n\n " + ! configError + "\n\n"); } } --- 229,240 ---- maplePool.logFile = LogFile; ! writeLog("Maple process pool started"); } } else { ! try { ! writeLog("Alice servlet not initialized because of configuration problems: ", ! "", ! configError); ! } catch(Exception e) {;} } } *************** *** 452,455 **** --- 454,458 ---- "See the AIM installation documentation for more details. \n" + "</p>\n"; + } } *************** *** 483,487 **** } } else { ! s = "The parent directory does not exist."; } } --- 486,499 ---- } } else { ! try { ! d.mkdir(); ! if (d.canWrite()) { ! // OK ! } else { ! s = "The containing directory has been created, but it is not writeable"; ! } ! } catch (Exception e) { ! s = "The containing directory does not exist, and could not be created"; ! } } } *************** *** 490,495 **** } if (s.length() > 0) { ! p.println(n + " was set to '" + LogFile + "'"); ! p.print("<br />\n" + s + "\n<br />\n"); } } --- 502,509 ---- } if (s.length() > 0) { ! p.println(n + " was set to '" + l + "'"); ! p.println("<br />"); ! p.println(s); ! p.println("<br />"); } } *************** *** 556,568 **** msg = new PrintWriter(msg_); ! msg.write("Fatal error getting new Maple process:\n" + ! "Exception message:\n" + e.getMessage() + "\n\n" + ! "Stack trace:\n"); ! e.printStackTrace(msg); ! ! msg.write("\n\n"); ! throw(new UnavailableException(msg_.toString())); } --- 570,581 ---- msg = new PrintWriter(msg_); ! msg.println("Fatal error getting new Maple process:"); ! msg.println("Exception message:"); ! msg.println(e.getMessage()); ! msg.println("Stack trace:"); e.printStackTrace(msg); ! msg.println(); ! throw(new ServletException(msg_.toString())); } *************** *** 577,582 **** initMaple(maple); ! writeLog("Command sent to maple process " + ! maple.id + ":\n" + "`aim/Main`(" + commandargs + "):\n\n"); if (LastRequestFile != null) { --- 590,595 ---- initMaple(maple); ! writeLog("Command sent to maple process " + maple.id + ":", ! "`aim/Main`(" + commandargs + "):",""); if (LastRequestFile != null) { *************** *** 588,592 **** logWriter.close(); } catch( Exception e ) { ! throw new ServletException("Could not write last request file\n",e); } } --- 601,605 ---- logWriter.close(); } catch( Exception e ) { ! throw new ServletException("Could not write last request file",e); } } *************** *** 616,620 **** } ! maple.exec("`aim/Main`(" + commandargs + "):\n", webOutput, alicereq.mathdisplay, tthOpt); } catch(Exception e) { logentry.close("ERROR"); --- 629,633 ---- } ! maple.exec("`aim/Main`(" + commandargs + "):", webOutput, alicereq.mathdisplay, tthOpt); } catch(Exception e) { logentry.close("ERROR"); *************** *** 625,633 **** msg = new PrintWriter(msg_); ! msg.write("Error while executing Maple command:\n" + ! "`aim/Main`(" + commandargs + "):\n-----------------\n" + ! "Exception message:\n" + e.getMessage() + "\n\n" + ! "Stack trace:\n"); ! e.printStackTrace(msg); --- 638,648 ---- msg = new PrintWriter(msg_); ! msg.println("Error while executing Maple command:"); ! msg.println("`aim/Main`(" + commandargs + "):"); ! msg.println("-----------------"); ! msg.println("Exception message:"); ! msg.println(e.getMessage()); ! msg.println(); ! msg.println("Stack trace:"); e.printStackTrace(msg); *************** *** 683,693 **** Enumeration names; String name; ! StringWriter rlog; String[] values; String value; if (LogFile != null) { ! rlog = new StringWriter(); ! rlog.write("Request parameters:\n"); names = alicereq.getParameterNames(); while(names.hasMoreElements()) { --- 698,711 ---- Enumeration names; String name; ! StringWriter rlog_; ! BufferedWriter rlog; String[] values; String value; if (LogFile != null) { ! rlog_ = new StringWriter(); ! rlog = new BufferedWriter(rlog_); ! rlog.write("Request parameters:"); ! rlog.newLine(); names = alicereq.getParameterNames(); while(names.hasMoreElements()) { *************** *** 695,707 **** values = alicereq.getParameterValues(name); ! rlog.write(name + ": " + values.length + " value(s)\n"); for (int i = 0; i < values.length; i++) { value = values[i]; ! rlog.write("> " + Maple.quote(value) + " (" + value.length() + ")\n"); } } ! rlog.write("\n\n"); ! writeLog(rlog.toString()); } } --- 713,728 ---- values = alicereq.getParameterValues(name); ! rlog.write(name + ": " + values.length + " value(s)"); ! rlog.newLine(); for (int i = 0; i < values.length; i++) { value = values[i]; ! rlog.write("> " + Maple.quote(value) + " (" + value.length() + ")"); ! rlog.newLine(); } } ! rlog.newLine(); ! rlog.newLine(); ! writeLog(rlog_.toString()); } } *************** *** 781,787 **** String s; if (p == null) { ! return("<tr>\n<td>" + n + "</td>\n<td>(missing)</td>\n</tr>\n"); } else { ! return("<tr>\n<td>" + n + "</td>\n<td>" + p + "</td>\n</tr>\n"); } } --- 802,808 ---- String s; if (p == null) { ! return("<tr><td>" + n + "</td><td>(missing)</td></tr>"); } else { ! return("<tr><td>" + n + "</td><td>" + p + "</td></tr>"); } } *************** *** 797,801 **** logWriter.close(); } catch (Exception e) { ! throw new ServletException("Could not write log file\n",e); } } --- 818,855 ---- logWriter.close(); } catch (Exception e) { ! throw new ServletException("Could not write log file",e); ! } ! } ! } ! ! private void writeLog(String s1,String s2) ! throws ServletException { ! if (LogFile != null) { ! try { ! PrintWriter logWriter = new PrintWriter(new FileWriter(LogFile,true)); ! DateFormat df = DateFormat.getDateTimeInstance(); ! logWriter.println(df.format(new Date())); ! logWriter.println(s1); ! logWriter.println(s2); ! logWriter.close(); ! } catch (Exception e) { ! throw new ServletException("Could not write log file",e); ! } ! } ! } ! ! private void writeLog(String s1,String s2,String s3) ! throws ServletException { ! if (LogFile != null) { ! try { ! PrintWriter logWriter = new PrintWriter(new FileWriter(LogFile,true)); ! DateFormat df = DateFormat.getDateTimeInstance(); ! logWriter.println(df.format(new Date())); ! logWriter.println(s1); ! logWriter.println(s2); ! logWriter.println(s3); ! logWriter.close(); ! } catch (Exception e) { ! throw new ServletException("Could not write log file",e); } } *************** *** 803,847 **** private String ParamReport() { ! StringBuffer s = new StringBuffer(); ! s.append("Alice initialization parameters:\n"); ! s.append("AliceMapleDir=" + AliceMapleDir + "\n"); if (MapleProgram == null) { ! s.append("MapleProgram=null\n"); } else { ! s.append("MapleProgram=" + MapleProgram + "\n"); } if (MapleInitOptions == null) { ! s.append("MapleInitOptions=null\n"); } else { ! s.append("MapleInitOptions=" + MapleInitOptions + "\n"); } if (LogFile == null) { ! s.append("LogFile=null\n"); } else { ! s.append("LogFile=" + LogFile + "\n"); } if (LastRequestFile == null) { ! s.append("LastRequestFile=null\n"); } else { ! s.append("LastRequestFile=" + LastRequestFile + "\n"); } if (TtHProgram == null) { ! s.append("TtHProgram=null\n"); } else { ! s.append("TtHProgram=" + TtHProgram + "\n"); } if (TtHLogFile == null) { ! s.append("TtHLogFile=null\n"); } else { ! s.append("TtHLogFile=" + TtHLogFile + "\n"); } ! return( s.toString() ); } --- 857,902 ---- private String ParamReport() { ! StringWriter s_ = new StringWriter(); ! PrintWriter s = new PrintWriter(s_); ! s.println("Alice initialization parameters:"); ! s.println("AliceMapleDir=" + AliceMapleDir); if (MapleProgram == null) { ! s.println("MapleProgram=null"); } else { ! s.println("MapleProgram=" + MapleProgram); } if (MapleInitOptions == null) { ! s.println("MapleInitOptions=null"); } else { ! s.println("MapleInitOptions=" + MapleInitOptions); } if (LogFile == null) { ! s.println("LogFile=null"); } else { ! s.println("LogFile=" + LogFile); } if (LastRequestFile == null) { ! s.println("LastRequestFile=null"); } else { ! s.println("LastRequestFile=" + LastRequestFile); } if (TtHProgram == null) { ! s.println("TtHProgram=null"); } else { ! s.println("TtHProgram=" + TtHProgram); } if (TtHLogFile == null) { ! s.println("TtHLogFile=null"); } else { ! s.println("TtHLogFile=" + TtHLogFile); } ! return( s_.toString() ); } *************** *** 857,869 **** try { trapOutput_ = new StringWriter(); ! trapOutput = new PrintWriter(trapOutput_); ! initcommand = "currentdir(\"" + AliceMapleDir + "\"):\n"; maple.exec(initcommand,trapOutput); } catch (Exception ex) { - //TODO: check that these \n's are OK in Windows msg_ = new StringWriter(); ! msg = new PrintWriter(msg_); ! msg.write("Exception while starting new Maple process:\n" + ! ex.getMessage() + "\n"); ex.printStackTrace(msg); --- 912,923 ---- try { trapOutput_ = new StringWriter(); ! trapOutput = new PrintWriter(trapOutput_,true); ! initcommand = "currentdir(\"" + AliceMapleDir + "\"):"; maple.exec(initcommand,trapOutput); } catch (Exception ex) { msg_ = new StringWriter(); ! msg = new PrintWriter(msg_,true); ! msg.println("Exception while starting new Maple process:"); ! msg.println(ex.getMessage()); ex.printStackTrace(msg); *************** *** 876,880 **** if (trapOutput_.toString().trim().length() > 0) { String err = "Unexpected output while starting new " + ! "Maple process:\n" + trapOutput_.toString() + "\n"; maplePool.discardMaple(maple); throw(new ServletException(err)); --- 930,934 ---- if (trapOutput_.toString().trim().length() > 0) { String err = "Unexpected output while starting new " + ! "Maple process:" + trapOutput_.toString(); maplePool.discardMaple(maple); throw(new ServletException(err)); *************** *** 893,896 **** --- 947,951 ---- try { + maple.exec("ProcessID:=" + maple.id + ":"); maple.exec("read \"AliceServer.mpl\":", trapOutput); } catch(Exception ex) { *************** *** 898,904 **** msg_ = new StringWriter(); ! msg = new PrintWriter(msg_); ! msg.write("Error while reading AliceServer.mpl:\n" + ! ex.getMessage() + "\n"); ex.printStackTrace(msg); throw(new ServletException(msg_.toString())); --- 953,959 ---- msg_ = new StringWriter(); ! msg = new PrintWriter(msg_,true); ! msg.println("Error while reading AliceServer.mpl:"); ! msg.println(ex.getMessage()); ex.printStackTrace(msg); throw(new ServletException(msg_.toString())); *************** *** 909,913 **** String err = "Unexpected output while initializing new " + ! "Aim process:\n" + trapOutput_.toString() + "\n"; throw(new ServletException(err)); } --- 964,968 ---- String err = "Unexpected output while initializing new " + ! "Aim process:" + trapOutput_.toString(); throw(new ServletException(err)); } *************** *** 921,925 **** // close all Maple processes try { ! writeLog("Closing down servlet\n"); maplePool.drain(); } catch (Exception ex) {} --- 976,980 ---- // close all Maple processes try { ! writeLog("Closing down servlet"); maplePool.drain(); } catch (Exception ex) {} *************** *** 1223,1236 **** } ! return("<tr>\n" + ! "<td>" + id + "</td>\n" + ! "<td>" + st + "</td>\n" + ! "<td>" + tt + "</td>\n" + ! "<td>" + studentID + "</td>\n" + ! "<td>" + command + "</td>\n" + ! "<td>" + subject + "</td>\n" + ! "<td>" + quiz + "</td>\n" + ! "<td>" + status + "</td>\n" + ! "</tr>\n"); } } --- 1278,1295 ---- } ! StringWriter s_ = new StringWriter(); ! PrintWriter s = new PrintWriter(s_); ! s.println("<tr>"); ! s.println("<td>" + id + "</td>"); ! s.println("<td>" + st + "</td>"); ! s.println("<td>" + tt + "</td>"); ! s.println("<td>" + studentID + "</td>"); ! s.println("<td>" + command + "</td>"); ! s.println("<td>" + subject + "</td>"); ! s.println("<td>" + quiz + "</td>"); ! s.println("<td>" + status + "</td>"); ! s.println("</tr>"); ! ! return(s_.toString()); } } *************** *** 1270,1275 **** s = ! "<table border width='100%'>\n" + ! "<tr>\n" + "<th>Process</th>" + "<th>Start time</th>" + --- 1329,1334 ---- s = ! "<table border width='100%'>" + ! "<tr>" + "<th>Process</th>" + "<th>Start time</th>" + *************** *** 1282,1286 **** "</tr>" + s + ! "</table>\n"; return(s); --- 1341,1345 ---- "</tr>" + s + ! "</table>"; return(s); |