RED-7143 - Error 500 generated when entering very long text in editable fields of a file #329
@ -78,7 +78,7 @@ public class FileAttributesController implements FileAttributesResource {
|
||||
|
||||
@Override
|
||||
@PreAuthorize("hasAuthority('" + WRITE_FILE_ATTRIBUTES_CONFIG + "')")
|
||||
public FileAttributeConfig addOrUpdateFileAttribute(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId,@Valid @RequestBody FileAttributeConfig fileAttribute) {
|
||||
public FileAttributeConfig addOrUpdateFileAttribute(@PathVariable(DOSSIER_TEMPLATE_ID) String dossierTemplateId, @Valid @RequestBody FileAttributeConfig fileAttribute) {
|
||||
|
||||
var result = fileAttributeConfigPersistenceService.addOrUpdateFileAttribute(dossierTemplateId, MagicConverter.convert(fileAttribute, FileAttributeConfigEntity.class));
|
||||
auditPersistenceService.audit(AuditRequest.builder()
|
||||
@ -146,6 +146,7 @@ public class FileAttributesController implements FileAttributesResource {
|
||||
@PreAuthorize("hasAuthority('" + WRITE_FILE_ATTRIBUTES + "')")
|
||||
public void setFileAttributes(@PathVariable(DOSSIER_ID_PARAM) String dossierId, @PathVariable(FILE_ID) String fileId, @RequestBody FileAttributes fileAttributes) {
|
||||
|
||||
accessControlService.checkDossierExistenceAndAccessPermissionsToDossier(dossierId);
|
||||
var file = fileStatusService.getStatus(fileId);
|
||||
|
||||
if (file.getWorkflowStatus().equals(WorkflowStatus.APPROVED)) {
|
||||
|
||||
@ -34,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
@RequiredArgsConstructor
|
||||
public class FileStatusPersistenceService {
|
||||
|
||||
private final static int MAX_STATUS_NAME_LENGTH = 4000;
|
||||
private final FileRepository fileRepository;
|
||||
private final FileAttributesRepository fileAttributesRepository;
|
||||
private final FileAttributeConfigPersistenceService fileAttributeConfigPersistenceService;
|
||||
@ -286,11 +287,19 @@ public class FileStatusPersistenceService {
|
||||
.map(FileAttributeConfigEntity::getId)
|
||||
.orElseThrow(() -> new BadRequestException("Invalid File Attribute Id")));
|
||||
fa.setFileAttributeId(id);
|
||||
validateFileAttributeLength(entry.getValue());
|
||||
fa.setValue(StringUtils.isBlank(entry.getValue()) ? null : entry.getValue());
|
||||
return fa;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private void validateFileAttributeLength(String fileAttributesValue) {
|
||||
|
||||
if (!StringUtils.isBlank(fileAttributesValue) && fileAttributesValue.length() > MAX_STATUS_NAME_LENGTH) {
|
||||
throw new BadRequestException(String.format("The name is too long (%s), max length %s", fileAttributesValue.length(), MAX_STATUS_NAME_LENGTH));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional(value = Transactional.TxType.REQUIRES_NEW)
|
||||
public void addFileAttributes(String dossierId, String fileId, Set<FileAttribute> fileAttributes) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user