From 966bfe35b2f85a9b6e72bd7c130fdc032adbbdc0 Mon Sep 17 00:00:00 2001 From: afitzek Date: Fri, 27 Jan 2012 14:30:22 +0000 Subject: + fixed statistic log entry to provide session-ERROR + fixed log entry order to provide statistic entry before error log entry git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@906 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../gv/egiz/pdfas/web/servlets/DataURLServlet.java | 72 +++++++++++++++------- .../gv/egiz/pdfas/web/servlets/VerifyServlet.java | 3 +- .../web/session/VerifySessionInformation.java | 5 ++ 3 files changed, 56 insertions(+), 24 deletions(-) diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java index b167541..a19b24a 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/DataURLServlet.java @@ -70,6 +70,7 @@ import at.gv.egiz.pdfas.web.session.VerifySessionInformation; import at.gv.egiz.pdfas.web.servlets.SignServlet; import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException; +import at.knowcenter.wag.egov.egiz.exceptions.SettingNotFoundException; import at.knowcenter.wag.egov.egiz.exceptions.SignatureException; /** @@ -146,9 +147,7 @@ public class DataURLServlet extends HttpServlet { log.debug("Data URL is accessed."); //$NON-NLS-1$ Object sessionObject = null; - Long startTime = Long.valueOf(0); try { - startTime = (Long) request.getAttribute("START_TIME_STAT"); sessionObject = SessionHelper.getSession(request); // obsolete since EncodingFilter is set in web.xml checkRequestCharacterEncoding(request); @@ -163,13 +162,7 @@ public class DataURLServlet extends HttpServlet { processVerify(request, response, si); } } catch (ExternalErrorException f) { - log.error(f.getMessage(), f); - HttpSession session = request.getSession(true); - session.setAttribute(SignServlet.ERROR_WITHIN_IFRAME, "false"); - log.debug("Attribute ERROR_WITHIN_IFRAME: " - + session.getAttribute(SignServlet.ERROR_WITHIN_IFRAME)); - SignServlet.prepareDispatchToErrorPage(f, request); - dispatch(request, response, "/jsp/error.jsp"); + if (statLog.isInfoEnabled()) { long endTime = System.currentTimeMillis(); // String toReport = "SIGN;" + si.mode + ";" + si.filename + @@ -184,21 +177,39 @@ public class DataURLServlet extends HttpServlet { + (endTime - si.startTime) + ";ERROR"; } else { VerifySessionInformation si = (VerifySessionInformation) sessionObject; - toReport = "VERIFY;" + si.mode + ";" + si.connector - + ";" + (endTime - si.startTime) + ";ERROR"; + try { + toReport = "VERIFY;"+ si.file_name + ";"+ 0 + ";" + (endTime - si.startTime) + ";" + VerifyServlet.debugVerifyResults(si.verifyResults) + ";ERROR"; + } catch (SettingNotFoundException e1) { + toReport = "VERIFY;"+ si.file_name + ";"+ 0 + ";" + (endTime - si.startTime) + ";ERROR-debug-verify" + ";ERROR"; + } } } - statLog.info(toReport); + if(toReport != null) + { + statLog.info(toReport); + } + else + { + statLog.info(";;;;;session-ERROR"); + } } - } catch (PdfAsException e) { - log.error(e.getMessage(), e); - SignServlet.prepareDispatchToErrorPage(e, request); + + log.error(f.getMessage(), f); + HttpSession session = request.getSession(true); + session.setAttribute(SignServlet.ERROR_WITHIN_IFRAME, "false"); + log.debug("Attribute ERROR_WITHIN_IFRAME: " + + session.getAttribute(SignServlet.ERROR_WITHIN_IFRAME)); + SignServlet.prepareDispatchToErrorPage(f, request); dispatch(request, response, "/jsp/error.jsp"); + + } catch (PdfAsException e) { + if (statLog.isInfoEnabled()) { long endTime = System.currentTimeMillis(); // String toReport = "SIGN;" + si.mode + ";" + si.filename + // ";"+ fileSize + ";" + + String toReport = null; if (sessionObject != null) { if (sessionObject instanceof SignSessionInformation) { @@ -208,13 +219,27 @@ public class DataURLServlet extends HttpServlet { + (endTime - si.startTime) + ";ERROR"; } else { VerifySessionInformation si = (VerifySessionInformation) sessionObject; - toReport = "VERIFY;" + si.mode + ";" + si.connector - + ";" + (endTime - si.startTime) + ";ERROR"; + try { + toReport = "VERIFY;"+ si.file_name + ";"+ 0 + ";" + (endTime - si.startTime) + ";" + VerifyServlet.debugVerifyResults(si.verifyResults) + ";ERROR"; + } catch (SettingNotFoundException e1) { + toReport = "VERIFY;"+ si.file_name + ";"+ 0 + ";" + (endTime - si.startTime) + ";ERROR-debug-verify" + ";ERROR"; + } } } - statLog.info(toReport); + if(toReport != null) + { + statLog.info(toReport); + } + else + { + statLog.info(";;;;;session-ERROR"); + } } + + log.error(e.getMessage(), e); + SignServlet.prepareDispatchToErrorPage(e, request); + dispatch(request, response, "/jsp/error.jsp"); } log.debug("DataURL access finished."); //$NON-NLS-1$ @@ -527,15 +552,16 @@ public class DataURLServlet extends HttpServlet { }; dispatchToResults(results, request, response, backToListURL); - Long startTime = Long.valueOf(0); - startTime = (Long) request.getAttribute("START_TIME_STAT"); - if (statLog.isInfoEnabled()) { long endTime = System.currentTimeMillis(); // String toReport = "SIGN;" + si.mode + ";" + si.filename + // ";"+ fileSize + ";" + - String toReport = "VERIFY;" + si.mode + ";" + si.connector - + ";" + (endTime - si.startTime) + ";OK"; + String toReport = null; + try { + toReport = "VERIFY;"+ si.file_name + ";"+ 0 + ";" + (endTime - si.startTime) + ";" + VerifyServlet.debugVerifyResults(si.verifyResults) + ";OK"; + } catch (SettingNotFoundException e1) { + toReport = "VERIFY;"+ si.file_name + ";"+ 0 + ";" + (endTime - si.startTime) + ";ERROR-debug-verify" + ";OK"; + } statLog.info(toReport); } diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java index ab3a24e..aef7f19 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/servlets/VerifyServlet.java @@ -125,6 +125,7 @@ public class VerifyServlet extends HttpServlet si.mode = null; si.inputDataSource = ud.dataSource; si.type = null; + si.file_name = ud.file_name; //afitzek si.startTime = startTime; @@ -355,7 +356,7 @@ public class VerifyServlet extends HttpServlet * @throws SettingNotFoundException * Forwarded exception. */ - protected static int debugVerifyResults(VerifyResults verifyResults) throws SettingNotFoundException + public static int debugVerifyResults(VerifyResults verifyResults) throws SettingNotFoundException { int toreturn = 0; Iterator it = verifyResults.getResults().iterator(); diff --git a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/VerifySessionInformation.java b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/VerifySessionInformation.java index 7cc3f4d..b3a75e9 100644 --- a/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/VerifySessionInformation.java +++ b/pdf-as-web/src/main/java/at/gv/egiz/pdfas/web/session/VerifySessionInformation.java @@ -117,6 +117,11 @@ public class VerifySessionInformation implements HttpSessionBindingListener, Ser */ public long startTime; + /** + * Save filename of file for statistic log (afitzek) + */ + public String file_name; + /** * @see javax.servlet.http.HttpSessionBindingListener#valueBound(javax.servlet.http.HttpSessionBindingEvent) */ -- cgit v1.2.3