Skip to content

Commit

Permalink
[Fix partially kbss-cvut/record-manager-ui#182] Call onRecordUpdateSe…
Browse files Browse the repository at this point in the history
…rviceUrl if configured when record is updated.
  • Loading branch information
kostobog committed Jul 11, 2024
1 parent dcc2cab commit ba41ba1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/cz/cvut/kbss/study/util/ConfigParam.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit ba41ba1

Please sign in to comment.