Example usage for org.springframework.http HttpOutputMessage getBody

List of usage examples for org.springframework.http HttpOutputMessage getBody

Introduction

In this page you can find the example usage for org.springframework.http HttpOutputMessage getBody.

Prototype

OutputStream getBody() throws IOException;

Source Link

Document

Return the body of the message as an output stream.

Usage

From source file:com.boundlessgeo.geoserver.api.converters.JSONMessageConverter.java

@Override
protected void writeInternal(JSONWrapper obj, HttpOutputMessage message)
        throws IOException, HttpMessageNotWritableException {
    JSONWrapper.write(obj, message.getBody());
}

From source file:jetbrains.buildServer.vsoRooms.rest.impl.StringJsonConverter.java

public void write(String teamRoomMessage, MediaType mediaType, HttpOutputMessage httpOutputMessage)
        throws IOException, HttpMessageNotWritableException {
    httpOutputMessage.getBody().write(teamRoomMessage.getBytes());
}

From source file:org.cloudfoundry.caldecott.server.converter.ByteBufferHttpMessageConverter.java

@Override
protected void writeInternal(ByteBuffer buffer, HttpOutputMessage outputMessage) throws IOException {
    WritableByteChannel channel = Channels.newChannel(outputMessage.getBody());
    channel.write(buffer);//w  w w  . j a  v a  2  s.c  o  m
}

From source file:io.lavagna.web.helper.GsonHttpMessageConverter.java

@Override
protected void writeInternal(Object t, HttpOutputMessage outputMessage) throws IOException {
    try (Writer writer = new OutputStreamWriter(outputMessage.getBody(), StandardCharsets.UTF_8)) {
        gson.toJson(t, writer);//from w w w  .  j av  a 2s. c o m
    }
}

From source file:ca.weblite.contacts.webservice.CN1DataMapperMessageConverter.java

@Override
protected void writeInternal(Object t, HttpOutputMessage hom)
        throws IOException, HttpMessageNotWritableException {
    DataOutputStream out = new DataOutputStream(hom.getBody());
    System.out.println("Writing object of type " + t.getClass());

    Map m = (Map) Mappers.getInstance().jsonify(t);
    System.out.println(m);//from   w  ww  . j a  va 2 s . c o m
    com.codename1.io.Util.writeObject(m, out);
}

From source file:org.hobsoft.symmetry.spring.SymmetryHttpMessageConverter.java

@Override
protected void writeInternal(T component, HttpOutputMessage outputMessage) throws IOException {
    OutputStream bodyStream = outputMessage.getBody();
    Charset charset = getCharset(outputMessage);
    Writer bodyWriter = new OutputStreamWriter(bodyStream, charset);

    try {//from w w  w . j a v  a  2  s .c o m
        reflector.reflect(component, bodyWriter);
    } catch (ReflectorException exception) {
        throw new HttpMessageNotWritableException("Error writing component", exception);
    }

    bodyWriter.flush();
}

From source file:com.mylaensys.dhtmlx.adapter.DhtmlxHttpMessageConverter.java

@Override
protected void writeInternal(Object object, HttpOutputMessage outputMessage)
        throws IOException, HttpMessageNotWritableException {
    Adapter adapter = (Adapter) object;/* ww  w  . ja v  a2 s. c o  m*/
    outputMessage.getBody()
            .write(adapter
                    .serialize(((ServletServerHttpResponse) outputMessage).getServletResponse().getLocale())
                    .getBytes());
}

From source file:com.boundlessgeo.geoserver.api.converters.ResourceMessageConverter.java

@Override
protected void writeInternal(Resource resource, HttpOutputMessage msg)
        throws IOException, HttpMessageNotWritableException {
    InputStream in = resource.in();
    try {//from www .  j  av a2s.co m
        IOUtils.copy(in, msg.getBody());
    } finally {
        IOUtils.closeQuietly(in);
    }
}

From source file:com.comcast.drivethru.spring.AbstractCerealHttpMessageConverter.java

@Override
public void writeInternal(Object t, HttpOutputMessage outputMessage) throws IOException {
    try {//from  w  w  w.  j a v a  2  s  . co m
        Writer writer = new OutputStreamWriter(outputMessage.getBody());
        engine.write(t, writer);
        writer.close();
    } catch (CerealException cex) {
        throw new IOException("Failed to cerealize the content", cex);
    } finally {
        IOUtils.closeQuietly(outputMessage.getBody());
    }
}

From source file:nl.flotsam.greader.http.PropertiesHttpMessageConverter.java

@Override
protected void writeInternal(Properties properties, HttpOutputMessage outputMessage)
        throws IOException, HttpMessageNotWritableException {
    OutputStream out = null;/*from  ww w . j  ava  2  s. c  om*/
    try {
        out = outputMessage.getBody();
        properties.store(out, "");
    } finally {
        IOUtils.closeQuietly(out);
    }
}