From ba41ba10f69424030fe08079ca0666e77b37f725 Mon Sep 17 00:00:00 2001 From: Bogdan Kostov Date: Thu, 11 Jul 2024 19:20:26 +0200 Subject: [PATCH] [Fix partially kbss-cvut/record-manager-ui#182] Call onRecordUpdateServiceUrl if configured when record is updated. --- .../study/rest/PatientRecordController.java | 17 +++++++++++++++++ .../cz/cvut/kbss/study/util/ConfigParam.java | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java b/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java index f29138fb..e3aaccf3 100644 --- a/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java +++ b/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java @@ -171,6 +171,23 @@ public void updateRecord(@PathVariable("key") String key, @RequestBody PatientRe if (LOG.isTraceEnabled()) { LOG.trace("Patient record {} successfully updated.", record); } + + onUpdateRecord(record.getUri()); + } + + private void onUpdateRecord(URI uri){ + Objects.nonNull(uri); + String onRecordUpdateServiceUrl = configReader.getConfig(ConfigParam.ON_UPDATE_RECORD_SERVICE_URL); + if(onRecordUpdateServiceUrl == null || onRecordUpdateServiceUrl.isBlank()) { + LOG.debug("No onRecordUpdateServiceUrl service url provided, noop."); + return; + } + + LOG.debug("calling onRecordUpdateServiceUrl: {} with parameter {}", onRecordUpdateServiceUrl, uri); + String requestUrl = UriComponentsBuilder.fromHttpUrl(onRecordUpdateServiceUrl) + .queryParam("record", uri) + .toUriString(); + restTemplate.getForObject(requestUrl,String.class); } @DeleteMapping(value = "/{key}") diff --git a/src/main/java/cz/cvut/kbss/study/util/ConfigParam.java b/src/main/java/cz/cvut/kbss/study/util/ConfigParam.java index 9a9c3360..9cb58769 100644 --- a/src/main/java/cz/cvut/kbss/study/util/ConfigParam.java +++ b/src/main/java/cz/cvut/kbss/study/util/ConfigParam.java @@ -9,6 +9,8 @@ public enum ConfigParam { FORM_GEN_REPOSITORY_URL("formGenRepositoryUrl"), FORM_GEN_SERVICE_URL("formGenServiceUrl"), + ON_UPDATE_RECORD_SERVICE_URL("onRecordUpdateServiceUrl"), + APP_CONTEXT("appContext"), SMTP_HOST("smtp.host"),