Package ninja.utils

Examples of ninja.utils.ResponseStreams


                DEFAULT_CALLBACK_PARAMETER_NAME);
    }

    @Override
    public void invoke(Context context, Result result) {
        ResponseStreams responseStreams = context.finalizeHeaders(result);
        String callback = getCallbackName(context);
        try (OutputStream outputStream = responseStreams.getOutputStream()) {
            objectMapper.writeValue(outputStream, new JSONPObject(callback, result.getRenderable()));
        } catch (IOException e) {
            logger.error("Error while rendering jsonp.", e);
        }
    }
View Full Code Here


           
            throw new RuntimeException(iOException);
        }
       
       
        ResponseStreams responseStreams = context.finalizeHeaders(result);

        try (Writer writer = responseStreams.getWriter()) {
           
            freemarkerTemplate.process(map, writer);

        } catch (Exception e) {
           
View Full Code Here

               
                if (result.getContentType() == null) {
                    result.contentType(Result.TEXT_PLAIN);
                }
                ResponseStreams resultJsonCustom = context
                        .finalizeHeaders(result);
               
                try (Writer writer = resultJsonCustom.getWriter()) {
               
                    writer.write(string);
                   
                } catch (IOException ioException) {
               
View Full Code Here

            @Override
            public void render(Context context, Result result) {
                if (result.getContentType() == null) {
                    result.contentType(Result.APPLICATION_OCTET_STREAM);
                }
                ResponseStreams responseStreams = context
                        .finalizeHeaders(result);
               
                try (OutputStream outputStream = responseStreams.getOutputStream()) {

                    outputStream.write(bytes);
                   
                } catch (IOException ioException) {
                    throw new InternalServerErrorException(ioException);
View Full Code Here

    }

    @Override
    public void invoke(Context context, Result result) {

        ResponseStreams responseStreams = context.finalizeHeaders(result);
       
       
        try (OutputStream outputStream = responseStreams.getOutputStream()) {
           
                xmlMapper.writeValue(outputStream, result.getRenderable());
           
        } catch (IOException e) {
View Full Code Here

                                    && !mimeType.isEmpty()) {
                                result.contentType(mimeType);
                            }

                            // finalize headers:
                            ResponseStreams responseStreams = context
                                    .finalizeHeadersWithoutFlashAndSessionCookie(result);
                           
                            try (
                                InputStream inputStream = urlConnection.getInputStream();
                                OutputStream outputStream = responseStreams.getOutputStream()) {

                                ByteStreams.copy(inputStream, outputStream);
                            }

View Full Code Here

    }

    @Override
    public void invoke(Context context, Result result) {

        ResponseStreams responseStreams = context.finalizeHeaders(result);

        try (Writer outputWriter = responseStreams.getWriter()) {

           outputWriter.write(result.getRenderable().toString());

        } catch (IOException e) {
View Full Code Here

    }

    @Override
    public void invoke(Context context, Result result) {

        ResponseStreams responseStreams = context.finalizeHeaders(result);
       
        try (OutputStream outputStream  = responseStreams.getOutputStream()) {
           
            objectMapper.writeValue(outputStream, result.getRenderable());
           
        } catch (IOException e) {
View Full Code Here

                            result.contentType(contentType);
                        } else {
                            contentType = mimeTypes.getMimeType(name);
                        }

                        ResponseStreams responseStreams = context
                                .finalizeHeaders(result);

                        if (item.isFormField()) {
                            System.out.println("Form field " + name
                                    + " with value " + Streams.asString(stream)
                                    + " detected.");
                        } else {
                            System.out.println("File field " + name
                                    + " with file name " + item.getName()
                                    + " detected.");
                            // Process the input stream

                            ByteStreams.copy(stream,
                                    responseStreams.getOutputStream());

                        }
                    }

                }
View Full Code Here

TOP

Related Classes of ninja.utils.ResponseStreams

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.