protected ExceptionInfo createExceptionInfo(Throwable rootCause) throws IOException { ExceptionInfo info = new ExceptionInfo(); info.setException(rootCause); info.setMessage(rootCause.getMessage()); info.setStackTrace(rootCause.getStackTrace()); info.setTimestamp(new Date()); info.setType(rootCause.getClass().getName()); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); rootCause.printStackTrace(pw); info.setFormattedStackTrace(ComponentUtils.escapeXml(sw.toString()).replaceAll("(\r\n|\n)", "<br/>")); pw.close(); sw.close(); SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT_PATTERN); info.setFormattedTimestamp(format.format(info.getTimestamp())); return info; }
public void encodeJSONValue(String paramName, Object paramValue) throws IOException, JSONException { String json = new JSONObject().put(paramName, paramValue).toString(); json = ComponentUtils.escapeXml(json); getWrapped().write(json.substring(1, json.length() - 1)); }
public void encodeJSONArray(String paramName, JSONArray jsonArray) throws IOException, JSONException { String json = jsonArray.toString(); json = ComponentUtils.escapeXml(json); getWrapped().write("\""); getWrapped().write(paramName); getWrapped().write("\":"); getWrapped().write(json); }
public void encodeJSONObject(String paramName, JSONObject jsonObject) throws IOException, JSONException { String json = jsonObject.toString(); json = ComponentUtils.escapeXml(json); getWrapped().write("\""); getWrapped().write(paramName); getWrapped().write("\":"); getWrapped().write(json); }