Package javax.ws.rs.core

Examples of javax.ws.rs.core.StreamingOutput


    throws FileNotFoundException {
    return new RepositoryFileInputStream( repositoryFile );
  }

  public StreamingOutput getStreamingOutput( final InputStream is ) {
    return new StreamingOutput() {
      public void write( OutputStream output ) throws IOException {
        copy( is, output );
      }
    };
  }
View Full Code Here


  protected StreamingOutput getDownloadStream( RepositoryFile repositoryFile, BaseExportProcessor exportProcessor )
    throws ExportException, IOException {
    File zipFile = exportProcessor.performExport( repositoryFile );
    final FileInputStream is = new FileInputStream( zipFile );
    // copy streaming output
    return new StreamingOutput() {
      public void write( OutputStream output ) throws IOException {
        IOUtils.copy( is, output );
      }
    };
  }
View Full Code Here

      is = getFileInputStream( zipFile );
    } catch ( Exception e ) {
      return buildServerErrorResponse( e.toString() );
    }

    StreamingOutput streamingOutput = getStreamingOutput( is );

    return buildOkResponse( streamingOutput, APPLICATION_ZIP );
  }
View Full Code Here

  protected FileInputStream getFileInputStream( File file ) throws FileNotFoundException {
    return new FileInputStream( file );
  }

  protected StreamingOutput getStreamingOutput( final InputStream is ) {
    return new StreamingOutput() {
      public void write( OutputStream output ) throws IOException {
        IOUtils.copy( is, output );
      }
    };
  }
View Full Code Here

      return Response.status( Status.NOT_FOUND ).build();
    }

    final InputStream is = isTmp;

    StreamingOutput streamingOutput = new StreamingOutput() {
      public void write( OutputStream output ) throws IOException {
        try {
          IOUtils.copy( is, output );
        } finally {
          IOUtils.closeQuietly( is );
View Full Code Here

    doReturn( mockFile ).when( mockExporter ).doExportAsZip( mockRepositoryFile );

    InputStream mockInputStream = mock( FileInputStream.class );
    doReturn( mockInputStream ).when( fileResource ).getFileInputStream( mockFile );

    StreamingOutput mockOutput = mock( StreamingOutput.class );
    doReturn( mockOutput ).when( fileResource ).getStreamingOutput( mockInputStream );

    Response mockResponse = mock( Response.class );
    doReturn( mockResponse ).when( fileResource ).buildOkResponse( mockOutput, FileResource.APPLICATION_ZIP );
View Full Code Here

        @Path("bytes")
        public StreamingOutput getFluff(@QueryParam("size") final long size) {
            if (size <= 0L) {
                throw new IllegalArgumentException("Missing 'size'");
            }
            return new StreamingOutput() {
                @Override
                public void write(OutputStream output) throws IOException {
                    byte[] buf = new byte[1024];
                    for (int i = 0, end = buf.length; i < end; ++i) {
                        buf[i] = (byte) i;
View Full Code Here

  @GET
  @Produces("application/zip")
  @Path("/backup")
  public StreamingOutput getBackup() {
    return new StreamingOutput() {
      public void write(OutputStream output) throws IOException {
        BufferedOutputStream bus = new BufferedOutputStream(output);
        bus.write(datasourceService.exportRepository());

      }
View Full Code Here

   * @param filename - File to stream
   * @param removeOnFinish - Delete file after streaming?
   * @return File streaming output.
   */
  public static StreamingOutput streamingFileOutput(final String filename, final boolean removeOnFinish) {
    return new StreamingOutput() {     
      public void write(OutputStream output) throws IOException, WebApplicationException {
        // Read file, write to output buffer and close stream...
        File file = new File(filename);

        BufferedInputStream in = new java.io.BufferedInputStream(
View Full Code Here

    doReturn( mockData ).when( fileService.repository ).getDataForRead( any( Serializable.class ), any( Class.class ) );

    InputStream mockInputStream = mock( InputStream.class );
    doReturn( mockInputStream ).when( mockData ).getInputStream();

    StreamingOutput mockStreamingOutput = mock( StreamingOutput.class );
    doReturn( mockStreamingOutput ).when( fileService ).getStreamingOutput( mockInputStream );

    FileService.RepositoryFileToStreamWrapper wrapper = fileService.doGetFileAsInline( "test" );

    verify( fileService.repository, times( 1 ) ).getFile( anyString() );
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.StreamingOutput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.