Merge branch 'RED-9933' into 'master'
RED-9933: DocuMine DateFormat config in dossier templates Closes RED-9933 See merge request redactmanager/persistence-service!766
This commit is contained in:
commit
87eeddded3
@ -169,16 +169,23 @@ public class DossierTemplateControllerV2 implements DossierTemplateResource {
|
||||
|
||||
@SneakyThrows
|
||||
@PreAuthorize("hasAuthority('" + WRITE_DATA_FORMATS + "')")
|
||||
public ResponseEntity<List<DateFormatPatternErrorMessage>> uploadDateFormats(String dossierTemplateId, MultipartFile file) {
|
||||
public ResponseEntity<?> uploadDateFormats(String dossierTemplateId, MultipartFile file) {
|
||||
|
||||
dossierTemplatePersistenceService.checkDossierTemplateExistsOrElseThrow404(dossierTemplateId);
|
||||
|
||||
String originalFilename = file.getOriginalFilename();
|
||||
if (originalFilename == null || !originalFilename.endsWith(".txt")) {
|
||||
throw new BadRequestException("Only .txt files can be parsed.");
|
||||
}
|
||||
|
||||
String dateFormats = new String(file.getBytes(), StandardCharsets.UTF_8);
|
||||
|
||||
List<DateFormatPatternErrorMessage> dateFormatPatternErrorMessages = dateFormatsValidationService.validateDateFormats(dateFormats);
|
||||
if (!dateFormatPatternErrorMessages.isEmpty()) {
|
||||
return new ResponseEntity<>(dateFormatPatternErrorMessages, HttpStatus.UNPROCESSABLE_ENTITY);
|
||||
}
|
||||
|
||||
dateFormatsPersistenceService.setDateFormats(dateFormats, dossierTemplateId);
|
||||
|
||||
auditPersistenceService.audit(AuditRequest.builder()
|
||||
.userId(KeycloakSecurity.getUserId())
|
||||
.objectId(dossierTemplateId)
|
||||
@ -186,8 +193,7 @@ public class DossierTemplateControllerV2 implements DossierTemplateResource {
|
||||
.message("date formats have been updated")
|
||||
.build());
|
||||
|
||||
return new ResponseEntity<>(dateFormatPatternErrorMessages, HttpStatus.OK);
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -125,13 +125,13 @@ public interface DossierTemplateResource {
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
@PostMapping(value = PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE + DATE_FORMATS_PATH, consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Upload a date formats file for a specific DossierTemplate.")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Date formats upload successful."), @ApiResponse(responseCode = "404", description = "The DossierTemplate is not found."), @ApiResponse(responseCode = "400", description = "Uploaded rules could not be verified."), @ApiResponse(responseCode = "422", description = "Uploaded rules could not be compiled.")})
|
||||
ResponseEntity<List<DateFormatPatternErrorMessage>> uploadDateFormats(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId,
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "204", description = "Date formats upload successful."), @ApiResponse(responseCode = "404", description = "The DossierTemplate is not found."), @ApiResponse(responseCode = "400", description = "Uploaded date formats could not be verified."), @ApiResponse(responseCode = "422", description = "Uploaded date formats file could not be parsed.")})
|
||||
ResponseEntity<?> uploadDateFormats(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId,
|
||||
@Schema(type = "string", format = "binary", name = "file") @RequestPart(name = "file") MultipartFile file);
|
||||
|
||||
|
||||
@ResponseBody
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||
@Operation(summary = "Returns file containing the currently used date formats.")
|
||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK"), @ApiResponse(responseCode = "404", description = "The DossierTemplate is not found.")})
|
||||
@GetMapping(value = PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE + DATE_FORMATS_PATH)
|
||||
|
||||
@ -14,6 +14,8 @@ dd MMMM yyyy
|
||||
d MMMM yyyy
|
||||
MMMM dd, yyyy
|
||||
MMMM d, yyyy
|
||||
MMMM, d yyyy
|
||||
MMMM d,yyyy
|
||||
dd.MM.yyyy
|
||||
d.MM.yyyy
|
||||
yyyy/MM/dd
|
||||
@ -28,6 +30,7 @@ dd['.'] MMM yyyy
|
||||
d['.'] MMM yyyy
|
||||
dd['th']['st']['nd']['rd'] 'of' MMMM, yyyy
|
||||
d['th']['st']['nd']['rd'] 'of' MMMM, yyyy
|
||||
d['st']['nd']['rd']['th'] MMMM yyyy
|
||||
MMMM dd['th']['st']['nd']['rd'], yyyy
|
||||
MMMM d['th']['st']['nd']['rd'], yyyy
|
||||
yyyy, MMMM dd
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user