List of usage examples for org.springframework.http HttpInputMessage getBody
InputStream getBody() throws IOException;
From source file:com.expedia.seiso.web.httpmessageconverter.ItemKeyHttpMessageConverter.java
@Override protected ItemKey readInternal(Class<? extends ItemKey> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { val uri = StreamUtils.copyToString(inputMessage.getBody(), StandardCharsets.UTF_8); return uriToItemKeyConverter.convert(uri); }
From source file:org.talend.components.webtest.JsonIo2HttpMessageConverter.java
/** * Deserializes JSON to object/*ww w . j a v a 2 s . c o m*/ * * @param clazz type of object to return. Not used * @param inputMessage the HTTP input message to read from * @return deserialized object */ @Override protected Object readInternal(Class<? extends Object> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { return JsonReader.jsonToJava(inputMessage.getBody(), null); }
From source file:com.comcast.drivethru.spring.AbstractCerealHttpMessageConverter.java
@Override public Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException { try {//ww w . ja v a 2s. c o m Reader reader = new InputStreamReader(inputMessage.getBody()); return engine.read(reader, clazz); } catch (CerealException cex) { throw new IOException("Failed to decerealize the content", cex); } finally { IOUtils.closeQuietly(inputMessage.getBody()); } }
From source file:nl.flotsam.calendar.web.UriListHttpMessageConverter.java
@Override protected List<URI> readInternal(Class<? extends List<URI>> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { InputStream in = inputMessage.getBody(); try {//w w w .jav a 2s . com String text = IOUtils.toString(in, "UTF-8"); List<URI> result = parseURIs(text); logger.info("Produced a list of " + result.size() + " items: " + result); return result; } catch (URISyntaxException e) { throw new HttpMessageNotReadableException("Illegal URI in list of URIs: " + e.getInput()); } finally { IOUtils.closeQuietly(in); } }
From source file:org.spearal.spring.rest.SpearalMessageConverter.java
public Object read(Class<? extends Object> type, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { SpearalDecoder decoder = factory.newDecoder(inputMessage.getBody()); return decoder.readAny(type); }
From source file:example.xmlbeam.XmlBeamHttpMessageConverter.java
@Override public Object read(Class<? extends Object> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { return projectionFactory.io().stream(inputMessage.getBody()).read(clazz); }
From source file:org.obiba.onyx.core.service.impl.ParticipantHttpMessageConverter.java
public Participant read(Class<? extends Participant> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { XStream xstream = new XStream(); return (Participant) xstream.fromXML(inputMessage.getBody()); }
From source file:com.github.cherimojava.data.spring.EntityConverter.java
private Entity fromJson(Class<? extends Entity> clazz, HttpInputMessage inputMessage) throws IOException { return factory.readEntity(clazz, IOUtils.toString(inputMessage.getBody(), Charsets.UTF_8.name())); }
From source file:com.wisemapping.rest.DebugMappingJacksonHttpMessageConverter.java
@Override protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, JsonHttpMessageNotReadableException { try {/*ww w . java2s. c o m*/ final byte[] bytes = IOUtils.toByteArray(inputMessage.getBody()); final ByteArrayInputStream bais = new ByteArrayInputStream(bytes); final WrapHttpInputMessage wrap = new WrapHttpInputMessage(bais, inputMessage.getHeaders()); return super.readInternal(clazz, wrap); } catch (org.springframework.http.converter.HttpMessageNotReadableException e) { throw new JsonHttpMessageNotReadableException("Request Body could not be read", e); } catch (IOException e) { throw new JsonHttpMessageNotReadableException("Request Body could not be read", e); } }
From source file:ca.weblite.contacts.webservice.CN1DataMapperMessageConverter.java
@Override protected Object readInternal(Class type, HttpInputMessage him) throws IOException, HttpMessageNotReadableException { System.out.println("In readInternal"); DataInputStream in = new DataInputStream(him.getBody()); Map m = (Map) com.codename1.io.Util.readObject(in); System.out.println("Read object " + m); return Mappers.getInstance().readMap(m, type); }