Skip to content

Commit

Permalink
[Fix partially kbss-cvut/record-manager-ui#36] Refactor handling of i…
Browse files Browse the repository at this point in the history
…nstitution request parameter.

- remove unnecessary annotations from method parameters
  • Loading branch information
kostobog committed Jul 10, 2024
1 parent 1918810 commit 0b985cd
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,13 @@ public ResponseEntity<?> exportRecords(

return switch (exportType.toString()){
case Constants.MEDIA_TYPE_EXCEL -> exportRecordsExcel(params, response);
case MediaType.APPLICATION_JSON_VALUE -> exportRecordsAsJson(institutionKey, params, uriBuilder, response);
case MediaType.APPLICATION_JSON_VALUE -> exportRecordsAsJson(params, uriBuilder, response);
default -> throw new IllegalArgumentException("Unsupported export type: " + exportType);
};
}

protected ResponseEntity<List<PatientRecord>> exportRecordsAsJson(
@RequestParam(name = "institution", required = false) String institutionKey,
@RequestParam MultiValueMap<String, String> params,
MultiValueMap<String, String> params,
UriComponentsBuilder uriBuilder, HttpServletResponse response){
final Page<PatientRecord> result = recordService.findAllFull(RecordFilterMapper.constructRecordFilter(params),
RestUtils.resolvePaging(params));
Expand All @@ -93,7 +92,7 @@ protected ResponseEntity<List<PatientRecord>> exportRecordsAsJson(
.body(result.getContent());
}

public ResponseEntity<InputStreamResource> exportRecordsExcel(@RequestParam(required = false) MultiValueMap<String, String> params, HttpServletResponse response){
public ResponseEntity<InputStreamResource> exportRecordsExcel(MultiValueMap<String, String> params, HttpServletResponse response){
RecordFilterParams filterParams = new RecordFilterParams();
filterParams.setMinModifiedDate(null);
filterParams.setMaxModifiedDate(null);
Expand All @@ -105,7 +104,6 @@ public ResponseEntity<InputStreamResource> exportRecordsExcel(@RequestParam(requ
.contentType(MediaType.parseMediaType(Constants.MEDIA_TYPE_EXCEL))
.header(HttpHeaders.CONTENT_DISPOSITION, contentDisposition.toString())
.body(new InputStreamResource(stream));

}

@PreAuthorize("hasRole('" + SecurityConstants.ROLE_ADMIN + "') or @securityUtils.isRecordInUsersInstitution(#key)")
Expand Down

0 comments on commit 0b985cd

Please sign in to comment.