use of com.b2international.snowowl.fhir.core.model.BatchRequest in project snow-owl by b2ihealthcare.
the class FhirParametersRequestEntryProcessor method doProcess.
@Override
public void doProcess(ArrayNode arrayNode, HttpServletRequest request) throws JsonMappingException, JsonProcessingException {
BatchRequest batchRequest = requestEntry.getRequest();
Code requestMethod = batchRequest.getMethod();
if (!requestMethod.equals(HttpVerb.POST.getCode())) {
createInvalidMethodResponse(arrayNode, requestMethod);
return;
}
HttpHeaders headers = getHeaders(request);
RestTemplate restTemplate = getRestTemplate();
StringBuilder uriBuilder = new StringBuilder(request.getScheme()).append("://").append(request.getServerName()).append(":").append(request.getLocalPort()).append(request.getRequestURI()).append(batchRequest.getUrl().getUriValue());
// TODO: change the RequestEntry to accommodate resources for non-operation bulk support
HttpEntity<?> httpEntity = new HttpEntity<>(requestEntry.getRequestResource(), headers);
ResponseEntity<String> response = restTemplate.exchange(uriBuilder.toString(), HttpMethod.POST, httpEntity, String.class);
String json = response.getBody();
ObjectNode resourceNode = (ObjectNode) objectMapper.readTree(json);
addResponse(arrayNode, resourceNode, String.valueOf(response.getStatusCode().value()));
}
Aggregations