@Test public void simpleNonStringValuesShouldBeUnwrappedVerbatim() throws Exception { final Message in = new DefaultMessage(camelContext); exchange.setIn(in); in.setBody("{\"body\":123}"); processor.process(exchange); assertThat(in.getHeaders()).containsOnly(entry(Exchange.CONTENT_TYPE, "text/plain")); assertThat(in.getBody()).isEqualTo("123"); }
@Override public void process(final Exchange exchange) throws Exception { final Message message = exchange.getIn(); final Object body = message.getBody(); final JsonNode data = parseBody(body); if (data == null) { return; } final JsonNode paramMap = data.get("parameters"); final JsonNode bodyData = data.get("body"); if (paramMap != null || bodyData != null) { if (paramMap != null) { for (final String key : parameters) { final JsonNode valueNode = paramMap.get(key); if (valueNode != null) { final String val = valueNode.asText(); message.setHeader(key, val); } } } if (bodyData == null) { message.setBody(null); return; } if (bodyData.isContainerNode()) { message.setBody(JsonUtils.toString(bodyData)); return; } message.setHeader(Exchange.CONTENT_TYPE, "text/plain"); message.setBody(bodyData.asText()); } }
HttpRequestUnwrapperProcessor implements Processor { @Override public void process(final Exchange exchange) throws Exception { final Message message = exchange.getIn(); final Object body = message.getBody(); final JsonNode data = parseBody(body); if (data == null) { return; } final JsonNode paramMap = data.get("parameters"); final JsonNode bodyData = data.get("body"); if (paramMap != null || bodyData != null) { if (paramMap != null) { for (final String key : parameters) { final JsonNode valueNode = paramMap.get(key); if (valueNode != null) { final String val = valueNode.asText(); message.setHeader(key, val); } } } if (bodyData == null) { message.setBody(null); return; } if (bodyData.isContainerNode()) { message.setBody(JsonUtils.toString(bodyData)); return; } message.setHeader(Exchange.CONTENT_TYPE, "text/plain"); message.setBody(bodyData.asText()); } } }
HttpRequestUnwrapperProcessor implements Processor { @Override public void process(final Exchange exchange) throws Exception { final Message message = exchange.getIn(); final Object body = message.getBody(); final JsonNode data = parseBody(body); if (data == null) { return; } final JsonNode paramMap = data.get("parameters"); final JsonNode bodyData = data.get("body"); if (paramMap != null || bodyData != null) { if (paramMap != null) { for (final String key : parameters) { final JsonNode valueNode = paramMap.get(key); if (valueNode != null) { final String val = valueNode.asText(); message.setHeader(key, val); } } } if (bodyData == null) { message.setBody(null); return; } if (bodyData.isContainerNode()) { message.setBody(JsonUtils.toString(bodyData)); return; } message.setHeader(Exchange.CONTENT_TYPE, "text/plain"); message.setBody(bodyData.asText()); } } HttpRequestUnwrapperProcessor(final JsonNode schema); }
HttpRequestUnwrapperProcessor implements Processor { @Override public void process(final Exchange exchange) throws Exception { final Message message = exchange.getIn(); final Object body = message.getBody(); final JsonNode data = parseBody(body); if (data == null) { return; } final JsonNode paramMap = data.get("parameters"); final JsonNode bodyData = data.get("body"); if (paramMap != null || bodyData != null) { if (paramMap != null) { for (final String key : parameters) { final JsonNode valueNode = paramMap.get(key); if (valueNode != null) { final String val = valueNode.asText(); message.setHeader(key, val); } } } if (bodyData == null) { message.setBody(null); return; } if (bodyData.isContainerNode()) { message.setBody(JsonUtils.toString(bodyData)); return; } message.setHeader(Exchange.CONTENT_TYPE, "text/plain"); message.setBody(bodyData.asText()); } } HttpRequestUnwrapperProcessor(final JsonNode schema); @Override void process(final Exchange exchange); }
HttpRequestUnwrapperProcessor implements Processor { @Override public void process(final Exchange exchange) throws Exception { final Message message = exchange.getIn(); final Object body = message.getBody(); final JsonNode data = parseBody(body); if (data == null) { return; } final JsonNode paramMap = data.get("parameters"); final JsonNode bodyData = data.get("body"); if (paramMap != null || bodyData != null) { if (paramMap != null) { for (final String key : parameters) { final JsonNode valueNode = paramMap.get(key); if (valueNode != null) { final String val = valueNode.asText(); message.setHeader(key, val); } } } if (bodyData == null) { message.setBody(null); return; } if (bodyData.isContainerNode()) { message.setBody(JsonUtils.toString(bodyData)); return; } message.setHeader(Exchange.CONTENT_TYPE, "text/plain"); message.setBody(bodyData.asText()); } } HttpRequestUnwrapperProcessor(final JsonNode schema); @Override void process(final Exchange exchange);  }