use of uk.nhs.adaptors.scr.logging.LogExecutionTime in project summary-care-record-api by NHSDigital.
the class UploadScrService method uploadScr.
@LogExecutionTime
public void uploadScr(RequestData requestData) {
Bundle bundle = fhirParser.parseResource(requestData.getBody(), Bundle.class);
var spineRequest = bundleMapper.map(bundle, requestData.getNhsdAsid());
checkPermission(bundle, requestData.getNhsdAsid(), requestData.getClientIp());
var response = spineClient.sendScrData(spineRequest, requestData.getNhsdAsid(), requestData.getNhsdIdentity(), requestData.getNhsdSessionUrid());
String contentLocation;
long retryAfter;
try {
contentLocation = getHeader(response.getHeaders(), CONTENT_LOCATION);
retryAfter = parseLong(getHeader(response.getHeaders(), RETRY_AFTER));
} catch (Exception ex) {
throw new UnexpectedSpineResponseException("Unable to extract required headers", ex);
}
var processingResult = spineClient.getScrProcessingResult(contentLocation, retryAfter, requestData.getNhsdAsid(), requestData.getNhsdIdentity(), requestData.getNhsdSessionUrid());
validateProcessingResult(processingResult);
}
use of uk.nhs.adaptors.scr.logging.LogExecutionTime in project summary-care-record-api by NHSDigital.
the class BundleMapper method map.
@LogExecutionTime
public String map(Bundle bundle, String nhsdAsid) {
try {
GpSummary gpSummary = GpSummary.fromBundle(bundle, nhsdAsid);
gpSummary.setPartyIdFrom(scrConfiguration.getPartyIdFrom());
gpSummary.setPartyIdTo(scrConfiguration.getPartyIdTo());
gpSummary.setNhsdAsidTo(scrConfiguration.getNhsdAsidTo());
return TemplateUtils.fillTemplate(REPC_RM150007UK05_TEMPLATE, gpSummary);
} catch (Exception ex) {
throw new FhirMappingException(ex.getMessage());
}
}
use of uk.nhs.adaptors.scr.logging.LogExecutionTime in project summary-care-record-api by NHSDigital.
the class SpineHttpClient method sendRequest.
@SuppressFBWarnings(value = "RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE", justification = "SpotBugs issue with fix not yet released https://github.com/spotbugs/spotbugs/pull/1248")
@LogExecutionTime
public <T> Response<T> sendRequest(HttpRequestBase request, ResponseHandler<? extends Response<T>> responseHandler) {
LOGGER.debug("Attempting to send SPINE request: {}", request.getRequestLine().toString());
try {
LOGGER.info("Leased connections: " + clientConnectionManager.getTotalStats().getLeased());
LOGGER.info("Available connections: " + clientConnectionManager.getTotalStats().getAvailable());
return client.execute(request, responseHandler, HttpClientContext.create());
} catch (IOException e) {
LOGGER.error("Error while sending SPINE request", e);
throw new ScrBaseException("Unexpected exception while sending Spine request", e);
}
}
use of uk.nhs.adaptors.scr.logging.LogExecutionTime in project summary-care-record-api by NHSDigital.
the class SpineClient method sendGetScrId.
@SneakyThrows
@Override
@LogExecutionTime
public Response<Document> sendGetScrId(String requestBody, String nhsdAsid) {
LOGGER.info("Sending GET SCR ID Spine request");
LOGGER.debug("Body: {}", requestBody);
var request = new HttpPost(spineConfiguration.getUrl() + spineConfiguration.getPsisQueriesEndpoint());
setSoapHeaders(request, PSIS_EVENT_LIST_QUERY, TEXT_XML_VALUE);
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 ID response: {} {}", statusCode, serialize(response.getBody()));
throw new UnexpectedSpineResponseException("Unexpected spine send response " + statusCode);
}
LOGGER.info("Received Spine {} interaction response: HTTP status {}", PSIS_EVENT_LIST_QUERY, response.getStatusCode());
return response;
}
use of uk.nhs.adaptors.scr.logging.LogExecutionTime in project summary-care-record-api by NHSDigital.
the class SpineClient method sendAlert.
@Override
@SneakyThrows
@LogExecutionTime
public Response<String> sendAlert(String requestBody, String nhsdAsid, String nhsdIdentity, String nhsdSessionUrid) {
LOGGER.info("Sending ALERT Spine request");
LOGGER.debug("Body: {}", requestBody);
var request = new HttpPost(spineConfiguration.getUrl() + spineConfiguration.getAlertEndpoint());
request.addHeader(CONTENT_TYPE, APPLICATION_FHIR_JSON_VALUE);
setCommonHeaders(request, nhsdAsid, nhsdIdentity, nhsdSessionUrid);
request.setEntity(new StringEntity(requestBody, UTF_8));
Response<String> response = spineHttpClient.sendRequest(request, stringResponseHandler);
LOGGER.info("Received Spine {} FHIR operation response: HTTP status {}", spineConfiguration.getAlertEndpoint(), response.getStatusCode());
return response;
}
Aggregations