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 64e148a8..a6da2f72 100644 --- a/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java +++ b/src/main/java/cz/cvut/kbss/study/rest/PatientRecordController.java @@ -162,6 +162,24 @@ public ResponseEntity createRecord(@RequestBody PatientRecord record) { return new ResponseEntity<>(headers, HttpStatus.CREATED); } + @PreAuthorize( + "hasRole('" + SecurityConstants.ROLE_ADMIN + "') or @securityUtils.isMemberOfInstitution(#institutionKey)") + @PostMapping(value = "/publish", produces = {MediaType.APPLICATION_JSON_VALUE}) + public RecordImportResult publishRecords( + @RequestParam(name = "institution", required = false) String institutionKey, + @RequestParam(required = false) MultiValueMap params){ +// final Page result = recordService.findAllFull(RecordFilterMapper.constructRecordFilter(params), +// RestUtils.resolvePaging(params)); +// List records = result.getContent(); + List records = new ArrayList<>(); + String publishServiceUrl = configReader.getConfig(ConfigParam.PUBLISH_SERVICE_URL); + LOG.debug("Publishing records."); + RecordImportResult response = restTemplate.postForEntity(URI.create(publishServiceUrl), records, RecordImportResult.class).getBody(); + + LOG.debug("Publish server response: ", response); + return response; + } + @PostMapping(value = "/import/json", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public RecordImportResult importRecordsJson(@RequestPart("file") MultipartFile file, @RequestParam(name = "phase", required = false) String phase) { 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 dd5ca7fe..a2e9fc4b 100644 --- a/src/main/java/cz/cvut/kbss/study/util/ConfigParam.java +++ b/src/main/java/cz/cvut/kbss/study/util/ConfigParam.java @@ -10,6 +10,7 @@ public enum ConfigParam { FORM_GEN_SERVICE_URL("formGenServiceUrl"), ON_UPDATE_RECORD_SERVICE_URL("onRecordUpdateServiceUrl"), + PUBLISH_SERVICE_URL("publishServiceUrl"), EXCEL_IMPORT_SERVICE_URL("excelImportServiceUrl"), APP_CONTEXT("appContext"),