List of usage examples for org.springframework.http HttpInputMessage getBody
InputStream getBody() throws IOException;
From source file:org.urlshortener.core.converter.UrlShortenerMessageConverter.java
/** * {@inheritDoc}/*from w ww . ja va2 s . c o m*/ */ public String read(Class<? extends String> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { final String data = convertInputStreamToString(inputMessage.getBody()); return data; }
From source file:com.kixeye.chassis.transport.http.SerDeHttpMessageConverter.java
/** * @see org.springframework.http.converter.AbstractHttpMessageConverter#readInternal(java.lang.Class, org.springframework.http.HttpInputMessage) *///from ww w. j av a2 s .com protected Object readInternal(Class<? extends Object> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { return serDe.deserialize(inputMessage.getBody(), clazz); }
From source file:nl.flotsam.calendar.web.UriHttpMessageConverter.java
@Override protected URI readInternal(Class<? extends URI> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { InputStream in = null;//from www . j a va2s . c o m try { in = inputMessage.getBody(); String uri = IOUtils.toString(in); if (inputMessage.getHeaders().getContentType() == MediaType.APPLICATION_FORM_URLENCODED) { uri = URLDecoder.decode(uri, "UTF-8"); } return new URI(uri); } catch (URISyntaxException urie) { throw new HttpMessageNotReadableException("Failed to parse incoming String into a URI.", urie); } finally { IOUtils.closeQuietly(in); } }
From source file:nl.flotsam.greader.http.GsonHttpMessageConverter.java
@Override protected Object readInternal(Class<? extends Object> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { Reader reader = null;//ww w . j a v a2s.c o m try { reader = new InputStreamReader(inputMessage.getBody(), "UTF-8"); Gson gson = new Gson(); return gson.fromJson(reader, clazz); } finally { IOUtils.closeQuietly(reader); } }
From source file:cn.cuizuoli.appranking.http.converter.JsoupHttpMessageConverter.java
@Override protected Document readInternal(Class<? extends Document> clazz, HttpInputMessage inputMessage) throws IOException { Charset charset = getContentTypeCharset(inputMessage.getHeaders().getContentType()); return Jsoup.parse(inputMessage.getBody(), charset.name(), StringUtils.EMPTY); }
From source file:edu.mayo.cts2.framework.webapp.rest.converter.MappingGsonHttpMessageConverter.java
@Override protected Object readInternal(Class<? extends Object> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { Object obj = this.jsonConverter.fromJson(IOUtils.toString(inputMessage.getBody()), clazz); return obj;//from ww w . j a va 2 s. c o m }
From source file:com.alibaba.webmvc.extension.FastJsonHttpMessageConverter.java
@Override protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { StringBuilder sb = new StringBuilder(); InputStream in = inputMessage.getBody(); byte[] buf = new byte[8000]; int len;/*from w ww .j ava 2s . c o m*/ while ((len = in.read(buf)) >= 0) { sb.append(new String(buf, 0, len, DEFAULT_CHARSET)); } return JSON.parseObject(sb.toString(), clazz); }
From source file:org.zht.framework.web.converter.MappingFastjsonHttpMessageConverter.java
@Override protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); int i;// w w w . ja va 2 s. c om while ((i = inputMessage.getBody().read()) != -1) { baos.write(i); } return JSON.parseArray(baos.toString(), clazz); }
From source file:nl.flotsam.greader.http.PropertiesHttpMessageConverter.java
@Override protected Properties readInternal(Class<? extends Properties> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { InputStream in = null;//from w w w . ja va2 s. co m Properties result = new Properties(); try { in = inputMessage.getBody(); result.load(in); } finally { IOUtils.closeQuietly(in); } return result; }
From source file:com.eu.evaluation.server.mvc.UTF8StringHttpMessageConverter.java
@Override protected String readInternal(Class<? extends String> clazz, HttpInputMessage inputMessage) throws IOException { Charset charset = getContentTypeCharset(inputMessage.getHeaders().getContentType()); return StreamUtils.copyToString(inputMessage.getBody(), charset); }