public String toString() { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { FormUtils.writeMapToOutputStream(map, bos, "UTF-8", false); return bos.toString("UTF-8"); } catch (Exception ex) { // will not happen } return ""; } }
public static String formToString(Form form) { try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) { FormUtils.writeMapToOutputStream(form.asMap(), bos, StandardCharsets.UTF_8.name(), false); return bos.toString(StandardCharsets.UTF_8.name()); } catch (Exception ex) { // will not happen } return ""; }
public static void logRequestParametersIfNeeded(Map<String, List<String>> params, String enc) { String chain = PhaseInterceptorChain.getCurrentMessage().getInterceptorChain().toString(); if (chain.contains(LoggingInInterceptor.class.getSimpleName())) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { writeMapToOutputStream(params, bos, enc, false); LOG.info(bos.toString(enc)); } catch (IOException ex) { // ignore } } }
@SuppressWarnings("unchecked") public void writeTo(T obj, Class<?> c, Type t, Annotation[] anns, MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException, WebApplicationException { MultivaluedMap<String, String> map = (MultivaluedMap<String, String>)(obj instanceof Form ? ((Form)obj).asMap() : obj); boolean encoded = keepEncoded(anns); String enc = HttpUtils.getSetEncoding(mt, headers, StandardCharsets.UTF_8.name()); FormUtils.writeMapToOutputStream(map, os, enc, encoded); }
public static void logRequestParametersIfNeeded(Map<String, List<String>> params, String enc) { if ((PhaseInterceptorChain.getCurrentMessage() == null) || (PhaseInterceptorChain.getCurrentMessage().getInterceptorChain() == null)) { return; } String chain = PhaseInterceptorChain.getCurrentMessage().getInterceptorChain().toString(); if (chain.contains("LoggingInInterceptor")) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { writeMapToOutputStream(params, bos, enc, false); LOG.info(bos.toString(enc)); } catch (IOException ex) { // ignore } } }
@SuppressWarnings("unchecked") public void writeTo(T obj, Class<?> c, Type t, Annotation[] anns, MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException, WebApplicationException { MultivaluedMap<String, String> map = (MultivaluedMap<String, String>)(obj instanceof Form ? ((Form)obj).getData() : obj); boolean encoded = keepEncoded(anns); String enc = HttpUtils.getSetEncoding(mt, headers, "UTF-8"); FormUtils.writeMapToOutputStream(map, os, enc, encoded); }