Search in sources :

Example 11 with LogExecutionTime

use of uk.nhs.adaptors.scr.logging.LogExecutionTime in project summary-care-record-api by NHSDigital.

the class SpineClient method sendAcsData.

@SneakyThrows
@Override
@LogExecutionTime
public Response<Document> sendAcsData(String requestBody, String nhsdAsid) {
    var url = spineConfiguration.getUrl() + spineConfiguration.getAcsEndpoint();
    LOGGER.info("Sending ACS Set Permission Spine request. URL: {}", url);
    LOGGER.debug("Body: {}", requestBody);
    var request = new HttpPost(url);
    setSoapHeaders(request, SET_PERMISSION_SOAP_ACTION, TEXT_XML_VALUE);
    request.setHeader(NHSD_ASID, nhsdAsid);
    request.setEntity(new StringEntity(requestBody, UTF_8));
    var response = spineHttpClient.sendRequest(request, xmlResponseHandler);
    var statusCode = response.getStatusCode();
    if (statusCode != OK.value()) {
        LOGGER.error("Unexpected spine ACS set permission response: {}", response);
        throw new UnexpectedSpineResponseException("Unexpected spine 'send data' response " + statusCode);
    }
    LOGGER.info("Received Spine {} interaction response: HTTP status {}", SET_PERMISSION_SOAP_ACTION, response.getStatusCode());
    return response;
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) UnexpectedSpineResponseException(uk.nhs.adaptors.scr.exceptions.UnexpectedSpineResponseException) LogExecutionTime(uk.nhs.adaptors.scr.logging.LogExecutionTime) SneakyThrows(lombok.SneakyThrows)

Example 12 with LogExecutionTime

use of uk.nhs.adaptors.scr.logging.LogExecutionTime in project summary-care-record-api by NHSDigital.

the class SpineClient method sendGetScr.

@SneakyThrows
@Override
@LogExecutionTime
public Response<Document> sendGetScr(String requestBody, String nhsdAsid) {
    var uri = spineConfiguration.getUrl() + spineConfiguration.getPsisQueriesEndpoint();
    var request = new HttpPost(uri);
    LOGGER.info("Sending GET SCR Spine request. URL: {}", uri);
    LOGGER.debug("Body: {}", requestBody);
    request.addHeader(SOAP_ACTION, PSIS_EVENT_QUERY_SOAP_ACTION);
    request.addHeader(CONTENT_TYPE, TEXT_XML_VALUE);
    request.addHeader(NHSD_ASID, nhsdAsid);
    request.setEntity(new StringEntity(requestBody, UTF_8));
    var response = spineHttpClient.sendRequest(request, xmlResponseHandler);
    var statusCode = response.getStatusCode();
    if (statusCode != OK.value()) {
        LOGGER.error("Unexpected spine GET SCR response: {} {}", statusCode, serialize(response.getBody()));
        throw new UnexpectedSpineResponseException("Unexpected spine send response " + statusCode);
    }
    LOGGER.info("Received Spine {} interaction response: HTTP status {}", PSIS_EVENT_QUERY_SOAP_ACTION, response.getStatusCode());
    return response;
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) UnexpectedSpineResponseException(uk.nhs.adaptors.scr.exceptions.UnexpectedSpineResponseException) LogExecutionTime(uk.nhs.adaptors.scr.logging.LogExecutionTime) SneakyThrows(lombok.SneakyThrows)

Aggregations

LogExecutionTime (uk.nhs.adaptors.scr.logging.LogExecutionTime)12 UnexpectedSpineResponseException (uk.nhs.adaptors.scr.exceptions.UnexpectedSpineResponseException)6 SneakyThrows (lombok.SneakyThrows)5 HttpPost (org.apache.http.client.methods.HttpPost)5 StringEntity (org.apache.http.entity.StringEntity)5 Bundle (org.hl7.fhir.r4.model.Bundle)4 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)2 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)2 Patient (org.hl7.fhir.r4.model.Patient)2 Document (org.w3c.dom.Document)2 EventListQueryResponse (uk.nhs.adaptors.scr.models.EventListQueryResponse)2 Mustache (com.github.mustachejava.Mustache)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 IOException (java.io.IOException)1 OffsetDateTime.now (java.time.OffsetDateTime.now)1 UTC (java.time.ZoneOffset.UTC)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 Arrays.asList (java.util.Arrays.asList)1 Stream (java.util.stream.Stream)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1