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
|
@SneakyThrows
|
||||||
@PreAuthorize("hasAuthority('" + WRITE_DATA_FORMATS + "')")
|
@PreAuthorize("hasAuthority('" + WRITE_DATA_FORMATS + "')")
|
||||||
public ResponseEntity<List<DateFormatPatternErrorMessage>> uploadDateFormats(String dossierTemplateId, MultipartFile file) {
|
public ResponseEntity<?> uploadDateFormats(String dossierTemplateId, MultipartFile file) {
|
||||||
|
|
||||||
dossierTemplatePersistenceService.checkDossierTemplateExistsOrElseThrow404(dossierTemplateId);
|
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);
|
String dateFormats = new String(file.getBytes(), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
List<DateFormatPatternErrorMessage> dateFormatPatternErrorMessages = dateFormatsValidationService.validateDateFormats(dateFormats);
|
List<DateFormatPatternErrorMessage> dateFormatPatternErrorMessages = dateFormatsValidationService.validateDateFormats(dateFormats);
|
||||||
|
if (!dateFormatPatternErrorMessages.isEmpty()) {
|
||||||
|
return new ResponseEntity<>(dateFormatPatternErrorMessages, HttpStatus.UNPROCESSABLE_ENTITY);
|
||||||
|
}
|
||||||
|
|
||||||
dateFormatsPersistenceService.setDateFormats(dateFormats, dossierTemplateId);
|
dateFormatsPersistenceService.setDateFormats(dateFormats, dossierTemplateId);
|
||||||
|
|
||||||
auditPersistenceService.audit(AuditRequest.builder()
|
auditPersistenceService.audit(AuditRequest.builder()
|
||||||
.userId(KeycloakSecurity.getUserId())
|
.userId(KeycloakSecurity.getUserId())
|
||||||
.objectId(dossierTemplateId)
|
.objectId(dossierTemplateId)
|
||||||
@ -186,8 +193,7 @@ public class DossierTemplateControllerV2 implements DossierTemplateResource {
|
|||||||
.message("date formats have been updated")
|
.message("date formats have been updated")
|
||||||
.build());
|
.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)
|
@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)
|
@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.")
|
@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.")})
|
@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<List<DateFormatPatternErrorMessage>> uploadDateFormats(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId,
|
ResponseEntity<?> uploadDateFormats(@PathVariable(DOSSIER_TEMPLATE_ID_PARAM) String dossierTemplateId,
|
||||||
@Schema(type = "string", format = "binary", name = "file") @RequestPart(name = "file") MultipartFile file);
|
@Schema(type = "string", format = "binary", name = "file") @RequestPart(name = "file") MultipartFile file);
|
||||||
|
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@ResponseStatus(value = HttpStatus.OK)
|
@ResponseStatus(value = HttpStatus.NO_CONTENT)
|
||||||
@Operation(summary = "Returns file containing the currently used date formats.")
|
@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.")})
|
@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)
|
@GetMapping(value = PATH + DOSSIER_TEMPLATE_ID_PATH_VARIABLE + DATE_FORMATS_PATH)
|
||||||
|
|||||||
@ -14,6 +14,8 @@ dd MMMM yyyy
|
|||||||
d MMMM yyyy
|
d MMMM yyyy
|
||||||
MMMM dd, yyyy
|
MMMM dd, yyyy
|
||||||
MMMM d, yyyy
|
MMMM d, yyyy
|
||||||
|
MMMM, d yyyy
|
||||||
|
MMMM d,yyyy
|
||||||
dd.MM.yyyy
|
dd.MM.yyyy
|
||||||
d.MM.yyyy
|
d.MM.yyyy
|
||||||
yyyy/MM/dd
|
yyyy/MM/dd
|
||||||
@ -28,6 +30,7 @@ dd['.'] MMM yyyy
|
|||||||
d['.'] MMM yyyy
|
d['.'] MMM yyyy
|
||||||
dd['th']['st']['nd']['rd'] 'of' MMMM, yyyy
|
dd['th']['st']['nd']['rd'] 'of' MMMM, yyyy
|
||||||
d['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 dd['th']['st']['nd']['rd'], yyyy
|
||||||
MMMM d['th']['st']['nd']['rd'], yyyy
|
MMMM d['th']['st']['nd']['rd'], yyyy
|
||||||
yyyy, MMMM dd
|
yyyy, MMMM dd
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user