@Override public void writeData(Attributes attributes) throws IOException { String content = Joiner.on("\n").join(readServerLog()); attributes.getResponse().getOutputStream().write(content.getBytes(Charsets.UTF_8)); } });
@Override public void writeData(Attributes attributes) throws IOException { try (InputStream is = new FileInputStream(attachmentFile);) { IOUtils.copy(is, attributes.getResponse().getOutputStream()); } }
@Override public void writeData(Attributes attributes) throws IOException { ((IResourceStreamWriter)resourceStream).write(attributes.getResponse().getOutputStream()); close(resourceStream); } });
/** * Convenience method to write an {@link InputStream} to response. * * @param attributes * request attributes * @param stream * input stream */ protected final void writeStream(Attributes attributes, InputStream stream) throws IOException { final Response response = attributes.getResponse(); Streams.copy(stream, response.getOutputStream()); } }
/** * Convenience method to write an {@link InputStream} to response. * * @param attributes * request attributes * @param stream * input stream */ protected final void writeStream(Attributes attributes, InputStream stream) throws IOException { final Response response = attributes.getResponse(); Streams.copy(stream, response.getOutputStream()); } }
@Override public void writeData(Attributes attributes) throws IOException { ((IResourceStreamWriter)resourceStream).write(attributes.getResponse().getOutputStream()); close(resourceStream); } });
@Override public void writeData(Attributes attributes) throws IOException { OutputStream outputStream = attributes.getResponse().getOutputStream(); new XliffDownloadHelper(projectVersion, languageMap, filter, outputStream).handleXliffDownload(); } });
@Override public void writeData(Attributes attributes) throws IOException { OutputStream out = attributes.getResponse().getOutputStream(); GZIPOutputStream gzipOut = new GZIPOutputStream(out); ODatabaseDocumentInternal db = (ODatabaseDocumentInternal)OrientDbWebSession.get().getDatabase(); ODatabaseExport dbExport = new ODatabaseExport(db, gzipOut, LoggerOCommandOutputListener.INSTANCE); configureODatabaseExport(dbExport); dbExport.exportDatabase(); } });
private void jFreeChartExport() { try { final ExportJFreeChart exportJFreeChart = (ExportJFreeChart) groovyResult.getResult(); final StringBuilder sb = new StringBuilder(); sb.append("pf_chart_"); sb.append(DateHelper.getTimestampAsFilenameSuffix(new Date())); final Response response = getResponse(); final String extension = exportJFreeChart.write(response.getOutputStream()); sb.append('.').append(extension); final String filename = sb.toString(); final int width = exportJFreeChart.getWidth(); final int height = exportJFreeChart.getHeight(); final JFreeChartImage image = new JFreeChartImage("image", exportJFreeChart.getJFreeChart(), exportJFreeChart.getImageType(), width, height); image.add(AttributeModifier.replace("width", String.valueOf(width))); image.add(AttributeModifier.replace("height", String.valueOf(height))); imageResultContainer.removeAll(); imageResultContainer.add(image).setVisible(true); ((WebResponse) response).setAttachmentHeader(filename); ((WebResponse) response).setContentType(DownloadUtils.getContentType(filename)); log.info("Starting download for file. filename:" + filename + ", content-type:" + DownloadUtils.getContentType(filename)); response.getOutputStream().flush(); } catch (final Exception ex) { error(getLocalizedMessage("error", ex.getMessage())); log.error(ex.getMessage(), ex); } }
@Override public void writeData(final Attributes attributes) throws IOException { try { InputStream inputStream = webExternalResourceStream.getInputStream(); try { Streams.copy(inputStream, attributes.getResponse().getOutputStream()); } finally { IOUtils.closeQuietly(inputStream); } } catch (ResourceStreamNotFoundException rsnfx) { throw new WicketRuntimeException(rsnfx); } } });
@Override public void writeData(final Attributes attributes) throws IOException { try { InputStream inputStream = webExternalResourceStream.getInputStream(); try { Streams.copy(inputStream, attributes.getResponse().getOutputStream()); } finally { IOUtils.closeQuietly(inputStream); } } catch (ResourceStreamNotFoundException rsnfx) { throw new WicketRuntimeException(rsnfx); } } });
@Override public void writeData(Attributes attributes) throws IOException { IReportDocument cache; try { cache = reportData.getReportCache(); IRenderTask renderTask = reportData.getReportEngine().createRenderTask(cache); OutputStream outputStream = attributes.getResponse().getOutputStream(); renderTask.setRenderOption(getRenderOptions(outputStream)); //run the report renderTask.render(); cache.close(); } catch (EngineException e) { LOG.error("BIRT report generation failed", e); } } });
OutputStream outputStream = attributes.getResponse().getOutputStream(); byte[] buffer = new byte[getBufferSize()];
OutputStream outputStream = attributes.getResponse().getOutputStream(); byte[] buffer = new byte[getBufferSize()];
@Override public void writeData(Attributes attributes) throws IOException { try (InputStream is = getInputStream(blob)) { Long startByte = RequestCycle.get().getMetaData(CONTENT_RANGE_STARTBYTE); Long endByte = RequestCycle.get().getMetaData(CONTENT_RANGE_ENDBYTE); if (startByte == null) startByte = 0L; if (endByte == null || endByte == -1) endByte = blob.getSize() - 1; copyRange(is, attributes.getResponse().getOutputStream(), startByte, endByte); } }
@Override public void writeData(Attributes attributes) throws IOException { if (format.equals("zip")) ArchiveCommand.registerFormat(format, new ZipFormat()); else ArchiveCommand.registerFormat(format, new TgzFormat()); try { ArchiveCommand archive = Git.wrap(project.getRepository()).archive(); archive.setFormat(format); archive.setTree(project.getRevCommit(revision).getId()); archive.setOutputStream(attributes.getResponse().getOutputStream()); archive.call(); } catch (GitAPIException e) { throw new RuntimeException(e); } finally { ArchiveCommand.unregisterFormat(format); } } });