details: /erp/devel/pi/rev/910d90095076
changeset: 6486:910d90095076
user: Antonio Moreno <antonio.moreno <at> openbravo.com>
date: Wed Feb 24 18:56:14 2010 +0100
summary: Fixed issue 12462. Errors which happened in a task which doesn't use
log4j will now always be shown both in the rebuild window and in the log file.
diffstat:
src/org/openbravo/erpCommon/ad_process/ApplyModules.html | 3 +-
src/org/openbravo/erpCommon/ad_process/ApplyModulesCallServlet.java | 69
++++++++-
src/org/openbravo/erpCommon/utility/AntExecutor.java | 4 +-
3 files changed, 67 insertions(+), 9 deletions(-)
diffs (158 lines):
diff -r 8925b5958741 -r 910d90095076
src/org/openbravo/erpCommon/ad_process/ApplyModules.html
--- a/src/org/openbravo/erpCommon/ad_process/ApplyModules.html Wed Feb 24
19:00:37 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/ApplyModules.html Wed Feb 24
18:56:14 2010 +0100
@@ -132,7 +132,6 @@
}
var charn= document.getElementById('warningsAndErrors').innerHTML.length;
if(charn>2000){
- stopAddingWarns=true;
document.getElementById('warningsAndErrors').innerHTML += "<p
class='CL_RSW_ta_line'>" + "and more..." + "</p>";
}
else{
@@ -236,6 +235,8 @@
progList_changeNode(node, 'Error');
progList_changeIcon(node, 'Error');
}
+ //Make a final call to requesterrorstate, to get the last
errors/warnings, if they were any
+ submitXmlHttpRequest(askForErrorStatus, null,
"REQUESTLASTERRORSTATE", "ApplyModulesCallServlet.html", false, null, null);
}
}
return true;
diff -r 8925b5958741 -r 910d90095076
src/org/openbravo/erpCommon/ad_process/ApplyModulesCallServlet.java
--- a/src/org/openbravo/erpCommon/ad_process/ApplyModulesCallServlet.java
Wed Feb 24 19:00:37 2010 +0100
+++ b/src/org/openbravo/erpCommon/ad_process/ApplyModulesCallServlet.java
Wed Feb 24 18:56:14 2010 +0100
@@ -51,7 +51,9 @@
if (vars.commandIn("UPDATESTATUS")) {
update(response, vars);
} else if (vars.commandIn("REQUESTERRORSTATE")) {
- requesterrorstate(response, vars);
+ requesterrorstate(response, vars, false);
+ } else if (vars.commandIn("REQUESTLASTERRORSTATE")) {
+ requesterrorstate(response, vars, true);
} else if (vars.commandIn("GETERR")) {
getError(response, vars);
}
@@ -145,6 +147,52 @@
return resp;
}
+ private ApplyModulesResponse fillErrorResponse(VariablesSecureApp vars,
String state,
+ String defaultState) {
+
+ ApplyModulesResponse resp = new ApplyModulesResponse();
+ resp.setState(Integer.parseInt(state.replace("RB", "")));
+ PreparedStatement ps2 = null;
+ PreparedStatement ps3 = null;
+ boolean warning = false;
+ boolean error = false;
+ try {
+ ps2 = getPreparedStatement("SELECT MESSAGE, LINE_NUMBER FROM
AD_ERROR_LOG WHERE ERROR_LEVEL='ERROR' ORDER BY CREATED DESC");
+ ps2.executeQuery();
+ ResultSet rs2 = ps2.getResultSet();
+ ArrayList<String> errors = new ArrayList<String>();
+ if (rs2.next()) {
+ error = true; // there is at least an error in this state
+ errors.add(rs2.getString(1));
+ }
+ resp.setErrors(errors.toArray(new String[0]));
+
+ ps3 = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG ORDER BY
CREATED DESC");
+ ps3.executeQuery();
+ ResultSet rs3 = ps3.getResultSet();
+ if (rs3.next()) {
+ resp.setLastmessage(rs3.getString(1));
+ } else {
+ resp.setLastmessage("");
+ }
+
+ if (error)
+ resp.setStatusofstate("Error");
+ else if (warning)
+ resp.setStatusofstate("Warning");
+ else
+ resp.setStatusofstate(defaultState);
+ } catch (Exception e) {
+ } finally {
+ try {
+ releasePreparedStatement(ps3);
+ releasePreparedStatement(ps2);
+ } catch (SQLException e2) {
+ }
+ }
+ return resp;
+ }
+
/**
* This method is called via AJAX through a timer in the rebuild window. It
returns the current
* status of the system (and warnings/errors that happened in the current
state)
@@ -185,13 +233,19 @@
* state. This method will be called when the Rebuild Window notices that
one or more steps were
* not updated and the build process already finished them
*/
- private void requesterrorstate(HttpServletResponse response,
VariablesSecureApp vars) {
+ private void requesterrorstate(HttpServletResponse response,
VariablesSecureApp vars,
+ boolean lastError) {
String ln = vars.getSessionValue("ApplyModules|Last_Line_Number_Log");
if (ln == null || ln.equals("")) {
return;
}
String state = vars.getStringParameter("reqStatus");
- ApplyModulesResponse resp = fillResponse(vars, state, "Success");
+ ApplyModulesResponse resp;
+ if (lastError) {
+ resp = fillErrorResponse(vars, state, "Success");
+ } else {
+ resp = fillResponse(vars, state, "Success");
+ }
response.setContentType("text/plain; charset=UTF-8");
try {
final PrintWriter out = response.getWriter();
@@ -219,15 +273,16 @@
PreparedStatement ps;
PreparedStatement ps2;
try {
- ps = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG WHERE
ERROR_LEVEL='ERROR'");
+ ps = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG WHERE
ERROR_LEVEL='ERROR' ORDER BY CREATED DESC");
ps.executeQuery();
ResultSet rs = ps.getResultSet();
if (rs.next()) {
error.setType("Error");
error.setTitle(Utility.messageBD(myPool, "Error", vars.getLanguage()));
- error.setMessage(Utility.messageBD(myPool, "BuildError",
vars.getLanguage())
- + "<a href=\"http://wiki.openbravo.com/wiki/ERP/2.50/Update_Tips\"
target=\"_blank\" class=\"MessageBox_TextLink\">"
- + Utility.messageBD(myPool, "ThisLink", vars.getLanguage()) +
"</a>");
+ error
+ .setMessage(Utility.messageBD(myPool, "BuildError",
vars.getLanguage())
+ + "<a
href=\"http://wiki.openbravo.com/wiki/ERP/2.50/Update_Tips\" target=\"_blank\"
class=\"MessageBox_TextLink\">"
+ + Utility.messageBD(myPool, "ThisLink", vars.getLanguage()) +
"</a>");
} else {
ps2 = getPreparedStatement("SELECT MESSAGE FROM AD_ERROR_LOG WHERE
ERROR_LEVEL='WARN'");
diff -r 8925b5958741 -r 910d90095076
src/org/openbravo/erpCommon/utility/AntExecutor.java
--- a/src/org/openbravo/erpCommon/utility/AntExecutor.java Wed Feb 24
19:00:37 2010 +0100
+++ b/src/org/openbravo/erpCommon/utility/AntExecutor.java Wed Feb 24
18:56:14 2010 +0100
@@ -49,6 +49,7 @@
private PrintWriter out;
private FileOutputStream logFile;
+ private PrintStream ps;
/**
* Initializes a newly created AntExecutor object assigning it the build.xml
file to execute tasks
@@ -146,7 +147,7 @@
final DefaultLogger logger1 = new DefaultLogger();
try {
logFile = new FileOutputStream(file);
- PrintStream ps = new PrintStream(logFile);
+ ps = new PrintStream(logFile);
logger1.setOutputPrintStream(ps);
logger1.setErrorPrintStream(ps);
logger1.setMessageOutputLevel(Project.MSG_INFO);
@@ -300,6 +301,7 @@
public void closeLogFile() {
try {
if (logFile != null) {
+ ps.flush();
logFile.close();
}
} catch (IOException e) {
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits