private InputStream copyIn(InputStream in) throws Exception { try (CachedOutputStream bos = new CachedOutputStream()) { IOUtils.copyAndCloseInput(in, bos); in = bos.getInputStream(); bos.close(); return in; } }
@Override protected void doClose() { Reader transformedReader = null; try { transformedReader = XSLTUtils.transform(xsltTemplate, getReader()); IOUtils.copyAndCloseInput(transformedReader, origWriter, IOUtils.DEFAULT_BUFFER_SIZE); } catch (IOException e) { throw new Fault("READER_COPY", LOG, e, e.getMessage()); } finally { try { origWriter.close(); } catch (IOException e) { LOG.warning("Cannot close stream after transformation: " + e.getMessage()); } } }
@Override public void onClose(CachedOutputStream wrapper) { InputStream transformedStream = null; try { transformedStream = XSLTUtils.transform(xsltTemplate, wrapper.getInputStream()); IOUtils.copyAndCloseInput(transformedStream, origStream); } catch (IOException e) { throw new Fault("STREAM_COPY", LOG, e, e.getMessage()); } finally { try { origStream.close(); } catch (IOException e) { LOG.warning("Cannot close stream after transformation: " + e.getMessage()); } } }