public static Map<String, Object> displayXaDebugInfo( DispatchContext dctx, Map<String, ?> context) { if (TransactionUtil.debugResources) { if (UtilValidate.isNotEmpty(TransactionUtil.debugResMap)) { TransactionUtil.logRunningTx(); } else { Debug.log("No running transaction to display.", module); } } else { Debug.log("Debug resources is disabled.", module); } return ServiceUtil.returnSuccess(); }
/** {@inheritDoc} */ public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponseWrapper response = new HttpServletResponseWrapper((HttpServletResponse) resp); String encoding = request.getHeader("Accept-Encoding"); boolean supportsGzip = false; // Now, check to see if the browser supports the GZIP compression if (encoding != null) { if (encoding.toLowerCase().indexOf("gzip") > -1) supportsGzip = true; } Debug.log( "supportsGzip : " + supportsGzip + ", encoding : " + encoding + ", requestURL : " + request.getRequestURL()); if (supportsGzip) { // add content encoding response.setHeader("Content-Encoding", "gzip"); GzipResponse compressionResponse = new GzipResponse(response); chain.doFilter(request, compressionResponse); compressionResponse.close(); } else { chain.doFilter(req, resp); } }
public static Map<String, Object> streamTest(DispatchContext dctx, Map<String, ?> context) { InputStream in = (InputStream) context.get("inputStream"); OutputStream out = (OutputStream) context.get("outputStream"); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); Writer writer = new OutputStreamWriter(out); String line; try { while ((line = reader.readLine()) != null) { Debug.log("Read line: " + line, module); writer.write(line); } } catch (IOException e) { Debug.logError(e, module); return ServiceUtil.returnError(e.getMessage()); } finally { try { writer.close(); } catch (Exception e) { Debug.logError(e, module); } } Map<String, Object> result = ServiceUtil.returnSuccess(); result.put("contentType", "text/plain"); return result; }
public static Map<String, Object> mcaTest(DispatchContext dctx, Map<String, ?> context) { MimeMessageWrapper wrapper = (MimeMessageWrapper) context.get("messageWrapper"); MimeMessage message = wrapper.getMessage(); try { if (message.getAllRecipients() != null) { Debug.log("To: " + UtilMisc.toListArray(message.getAllRecipients()), module); } if (message.getFrom() != null) { Debug.log("From: " + UtilMisc.toListArray(message.getFrom()), module); } Debug.log("Subject: " + message.getSubject(), module); if (message.getSentDate() != null) { Debug.log("Sent: " + message.getSentDate().toString(), module); } if (message.getReceivedDate() != null) { Debug.log("Received: " + message.getReceivedDate().toString(), module); } } catch (Exception e) { Debug.logError(e, module); } return ServiceUtil.returnSuccess(); }
public static Map<String, Object> simpleMapListTest( DispatchContext dctx, Map<String, ?> context) { List<String> listOfStrings = checkList(context.get("listOfStrings"), String.class); Map<String, String> mapOfStrings = checkMap(context.get("mapOfStrings"), String.class, String.class); for (String str : listOfStrings) { String v = mapOfStrings.get(str); Debug.log("SimpleMapListTest: " + str + " -> " + v, module); } return ServiceUtil.returnSuccess(); }
public void outputTraceMessage(MethodContext methodContext, String... messages) { String lineSep = System.getProperty("line.separator"); StringBuilder buf = new StringBuilder(getSimpleMethod().getFileName()); buf.append(", Line ") .append(getLineNumber()) .append(" <") .append(getTagName()) .append("> element: "); for (int i = 0; i < messages.length; i++) { buf.append(messages[i]); if (i < messages.length - 1 && messages.length > 1) { buf.append(lineSep); } } Debug.log(methodContext.getTraceLogLevel(), null, buf.toString(), module); }
public static Map<String, String> getResponseData(HttpResponse response) throws IOException { Map<String, String> responseData = new HashMap<String, String>(); HttpEntity httpEntity = response.getEntity(); if (httpEntity != null) { InputStream inputStream = httpEntity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); String data = null; while ((data = reader.readLine()) != null) { if (data.indexOf("=") != -1) { String name = data.substring(0, data.indexOf("=")); String value = data.substring(data.indexOf("=") + 1); responseData.put(name, value); } } } Debug.log("SagePay Response Data : " + responseData); return responseData; }
/** Test entity sorting */ public static Map<String, Object> entitySortTest(DispatchContext dctx, Map<String, ?> context) { Delegator delegator = dctx.getDelegator(); Set<ModelEntity> set = new TreeSet<ModelEntity>(); set.add(delegator.getModelEntity("Person")); set.add(delegator.getModelEntity("PartyRole")); set.add(delegator.getModelEntity("Party")); set.add(delegator.getModelEntity("ContactMech")); set.add(delegator.getModelEntity("PartyContactMech")); set.add(delegator.getModelEntity("OrderHeader")); set.add(delegator.getModelEntity("OrderItem")); set.add(delegator.getModelEntity("OrderContactMech")); set.add(delegator.getModelEntity("OrderRole")); set.add(delegator.getModelEntity("Product")); set.add(delegator.getModelEntity("RoleType")); for (ModelEntity modelEntity : set) { Debug.log(modelEntity.getEntityName(), module); } return ServiceUtil.returnSuccess(); }
public static HttpPost getHttpPost(String uri, Map<String, String> parameters) throws UnsupportedEncodingException { HttpPost httpPost = new HttpPost(uri); httpPost.addHeader("User-Agent", "HTTP Client"); httpPost.addHeader("Content-type", "application/x-www-form-urlencoded"); // postMethod.addHeader("Content-Length", "0"); HttpParams params = new BasicHttpParams(); httpPost.setParams(params); List<NameValuePair> postParameters = new ArrayList<NameValuePair>(); Set<String> keys = parameters.keySet(); for (String key : keys) { String value = parameters.get(key); postParameters.add(new BasicNameValuePair(key, value)); } Debug.log("SagePay PostParameters - " + postParameters); HttpEntity postEntity = new UrlEncodedFormEntity(postParameters); httpPost.setEntity(postEntity); return httpPost; }
public static void logFatal(Throwable t, String msg, String module) { log(Debug.FATAL, t, msg, module, emptyParams); }
public static void logFatal(String msg, String module) { log(Debug.FATAL, null, msg, module, emptyParams); }
public static void logError(Throwable t, String msg, String module) { log(Debug.ERROR, t, msg, module, emptyParams); }
public static void logError(String msg, String module) { log(Debug.ERROR, null, msg, module, emptyParams); }
public static void logWarning(Throwable t, String msg, String module) { log(Debug.WARNING, t, msg, module, emptyParams); }
public static void logWarning(String msg, String module) { log(Debug.WARNING, null, msg, module, emptyParams); }
public static void logImportant(Throwable t, String msg, String module) { log(Debug.IMPORTANT, t, msg, module, emptyParams); }
public static void logImportant(Throwable t, String msg, String module, Object... params) { log(Debug.IMPORTANT, t, msg, module, params); }
public static void logTiming(Throwable t, String msg, String module, Object... params) { log(Debug.TIMING, t, msg, module, params); }
public static void logWarning(String msg, String module, Object... params) { log(Debug.WARNING, null, msg, module, params); }
public static void logInfo(String msg, String module) { log(Debug.INFO, null, msg, module, emptyParams); }
public static void logWarning(Throwable t, String msg, String module, Object... params) { log(Debug.WARNING, t, msg, module, params); }
public static void logInfo(String msg, String module, Object... params) { log(Debug.INFO, null, msg, module, params); }
public static void logError(String msg, String module, Object... params) { log(Debug.ERROR, null, msg, module, params); }
public static void logInfo(Throwable t, String msg, String module) { log(Debug.INFO, t, msg, module, emptyParams); }
public static void logError(Throwable t, String msg, String module, Object... params) { log(Debug.ERROR, t, msg, module, params); }
public static void logInfo(Throwable t, String msg, String module, Object... params) { log(Debug.INFO, t, msg, module, params); }
public static void logFatal(String msg, String module, Object... params) { log(Debug.FATAL, null, msg, module, params); }
public static void logImportant(String msg, String module) { log(Debug.IMPORTANT, null, msg, module, emptyParams); }
public static void logFatal(Throwable t, String msg, String module, Object... params) { log(Debug.FATAL, t, msg, module, params); }
public static void logImportant(String msg, String module, Object... params) { log(Debug.IMPORTANT, null, msg, module, params); }