List of usage examples for org.springframework.http HttpInputMessage getBody
InputStream getBody() throws IOException;
From source file:org.springframework.flex.http.AmfHttpMessageConverter.java
private Object readObject(HttpInputMessage inputMessage, AmfTrace trace) throws IOException { Amf3Input deserializer = new Amf3Input(new SerializationContext()); deserializer.setInputStream(inputMessage.getBody()); deserializer.setDebugTrace(trace);/* w w w .j a v a 2s. c om*/ try { return deserializer.readObject(); } catch (ClassNotFoundException cnfe) { throw new HttpMessageNotReadableException(AMF_ERROR, cnfe); } catch (MessageException se) { throw new HttpMessageNotReadableException(AMF_ERROR, se); } }
From source file:org.springframework.flex.http.AmfHttpMessageConverter.java
private ActionMessage readActionMessage(HttpInputMessage inputMessage, AmfTrace trace) throws IOException { AmfMessageDeserializer deserializer = new AmfMessageDeserializer(); deserializer.initialize(new SerializationContext(), inputMessage.getBody(), trace); try {/*from w w w . ja va2 s . c o m*/ ActionContext context = new ActionContext(); ActionMessage message = new ActionMessage(); context.setRequestMessage(message); deserializer.readMessage(message, context); return message; } catch (ClassNotFoundException cnfe) { throw new HttpMessageNotReadableException(ACTION_MSG_ERROR, cnfe); } catch (MessageException me) { throw new HttpMessageNotReadableException(ACTION_MSG_ERROR, me); } }
From source file:org.springframework.http.converter.FormHttpMessageConverter.java
@Override public MultiValueMap<String, String> read(@Nullable Class<? extends MultiValueMap<String, ?>> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { MediaType contentType = inputMessage.getHeaders().getContentType(); Charset charset = (contentType != null && contentType.getCharset() != null ? contentType.getCharset() : this.charset); String body = StreamUtils.copyToString(inputMessage.getBody(), charset); String[] pairs = StringUtils.tokenizeToStringArray(body, "&"); MultiValueMap<String, String> result = new LinkedMultiValueMap<>(pairs.length); for (String pair : pairs) { int idx = pair.indexOf('='); if (idx == -1) { result.add(URLDecoder.decode(pair, charset.name()), null); } else {// w w w. ja va2s. com String name = URLDecoder.decode(pair.substring(0, idx), charset.name()); String value = URLDecoder.decode(pair.substring(idx + 1), charset.name()); result.add(name, value); } } return result; }
From source file:org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.java
private Object readJavaType(JavaType javaType, HttpInputMessage inputMessage) { try {//from w w w . ja va 2s . com return this.objectMapper.readValue(inputMessage.getBody(), javaType); } catch (IOException ex) { throw new HttpMessageNotReadableException("Could not read JSON: " + ex.getMessage(), ex); } }
From source file:org.springframework.http.converter.json.replacement.MappingJacksonHttpMessageConverter.java
@Override protected Object readInternal(Class<? extends Object> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { return objectMapper.readValue(inputMessage.getBody(), clazz); }
From source file:org.springframework.sync.diffsync.web.JsonPatchHttpMessageConverter.java
@Override protected Patch readInternal(Class<? extends Patch> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { return jsonPatchMaker.convert(MAPPER.readTree(inputMessage.getBody())); }