/** * Read bytes from an InputStream and generate SAX characters events in Base64 encoding. The * InputStream is closed when done. * * <p>The caller has to close the stream if needed. */ public static void inputStreamToBase64Characters(InputStream is, ContentHandler contentHandler) { try { final OutputStream os = new ContentHandlerOutputStream(contentHandler, false); NetUtils.copyStream(new BufferedInputStream(is), os); os.close(); // necessary with ContentHandlerOutputStream to make sure all extra characters // are written } catch (Exception e) { throw new OXFException(e); } }
public static void wrapWithRequestElement(ContentHandlerHelper helper, DebugXML debugXML) { helper.startDocument(); final ExternalContext externalContext = NetUtils.getExternalContext(); final ExternalContext.Request request = (externalContext != null) ? externalContext.getRequest() : null; helper.startElement( "request", new String[] { "request-uri", (request != null) ? request.getRequestURI() : null, "query-string", (request != null) ? request.getQueryString() : null, "method", (request != null) ? request.getMethod() : null }); debugXML.toXML(helper); helper.endElement(); helper.endDocument(); }