public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PortalTransaction trans = new PortalTransaction(); try { populateTransaction(trans, request, response); logRequestStart(trans); doService(trans); } catch (Throwable th) { reportError(th, trans.requestNumber, trans.logger); trans.reply = createErrorReply(th); } trans.endTime = Calendar.getInstance(); logPerformance(trans); try { response.setContentType(CONTENT_TYPE); PrintWriter out = response.getWriter(); out.print(trans.reply); out.close(); } catch (Exception e) { /** Not much we can do here but log the error. */ reportError(e, trans.requestNumber, trans.logger); } logRequestEnd(trans); }
public void doService(PortalTransaction trans) { if (processAdminCommand(trans)) return; String xmlRequestStr = getXMLRequest(trans.request); if (xmlRequestStr == null) { throw new IllegalArgumentException("No request XML in HTTP request"); } processSetupRequest(trans); trans.portalRequest = new PayorPortalRequest( trans.requestNumber, getXMLRequest(trans.request), HttpUtils.getRequestURL(trans.request).toString()); trans.portalRequest.processRequest(); trans.reply = trans.portalRequest.getResponse(); }
private void populateTransaction( PortalTransaction trans, HttpServletRequest request, HttpServletResponse response) { trans.logger = new Logger(); trans.request = request; trans.response = response; trans.reply = null; trans.requestNumber = nextRequestNumber(); trans.beginTime = Calendar.getInstance(); trans.endTime = null; trans.logger.setRequestID(Integer.toString(trans.requestNumber)); }
private boolean processAdminCommand(PortalTransaction trans) { String adminCommand = trans.request.getParameter(ADMIN_COMMAND); /** Allow old-style command for report_version */ if (trans.request.getParameter(REPORT_VERSION) != null) adminCommand = REPORT_VERSION; if (adminCommand == null) return false; if (REPORT_VERSION.equals(adminCommand)) { reportVersion(trans); return true; } else if (CLEAR_CACHE.equals(adminCommand)) { clearCache(trans); return true; } else if (GET_CACHE_STATISTICS.equals(adminCommand)) { getCacheStatistics(trans); return true; } else { trans.reply = "Unintelligib le admin_command '" + adminCommand + "'."; return true; } }
private void getCacheStatistics(PortalTransaction trans) { trans.reply = PayorPortalCache.getAllStatistics(); }
private void clearCache(PortalTransaction trans) { PayorPortalCache.clearAll(); trans.reply = "<ClearCache>All caches cleared.</ClearCache>"; }
private void reportVersion(PortalTransaction trans) { trans.reply = "<Version>" + Version.get() + "</Version>"; }