Merge branch 'RED-10353-4.3' into 'release/2.589.x'

RED-10353: Added error code to file

See merge request redactmanager/persistence-service!830
This commit is contained in:
Dominique Eifländer 2024-11-05 15:09:33 +01:00
commit be4e3c8633
14 changed files with 59 additions and 12 deletions

View File

@ -10,6 +10,7 @@ import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import com.iqser.red.service.persistence.management.v1.processor.utils.JSONIntegerSetConverter;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.ErrorCode;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.ProcessingStatus;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.WorkflowStatus;
@ -201,6 +202,11 @@ public class FileEntity {
@Column
private OffsetDateTime errorTimestamp;
@Column
@Enumerated(EnumType.STRING)
private ErrorCode errorCode;
@ElementCollection(fetch = FetchType.EAGER)
private List<FileEntityComponentMappingVersionEntity> componentMappingVersions;

View File

@ -213,12 +213,13 @@ public class FileStatusPersistenceService {
public void updateStatusErrorInfo(String fileId, FileErrorInfo fileErrorInfo) {
if (fileErrorInfo == null) {
fileRepository.updateStatusErrorInfo(fileId, null, null, null, null);
fileRepository.updateStatusErrorInfo(fileId, null, null, null, null, null);
} else {
fileRepository.updateStatusErrorInfo(fileId,
fileErrorInfo.getCause().substring(0, Math.min(fileErrorInfo.getCause().length(), 255)),
fileErrorInfo.getQueue(),
fileErrorInfo.getService(),
fileErrorInfo.getErrorCode(),
fileErrorInfo.getTimestamp());
}
@ -233,7 +234,7 @@ public class FileStatusPersistenceService {
}
if (processingStatus == ProcessingStatus.PROCESSED) {
// reset the error info
fileRepository.updateStatusErrorInfo(fileId, null, null, null, null);
fileRepository.updateStatusErrorInfo(fileId, null, null, null, null, null);
// In case the file is updated to "processed", "lastProcessed" date should be updated to "now"
fileRepository.updateProcessingStatus(fileId,
processingStatus,

View File

@ -15,6 +15,7 @@ import com.iqser.red.service.persistence.management.v1.processor.entity.projecti
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.projection.FilePageCountsProjection;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.projection.FileProcessingStatusProjection;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.projection.FileWorkflowStatusProjection;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.ErrorCode;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.ProcessingStatus;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.WorkflowStatus;
@ -133,11 +134,12 @@ public interface FileRepository extends JpaRepository<FileEntity, String> {
@Modifying
@Query("update FileEntity f set f.errorCause = :cause, f.errorQueue = :queue, f.errorService = :service, f.errorTimestamp = :timestamp " + "where f.id = :fileId")
@Query("update FileEntity f set f.errorCause = :cause, f.errorQueue = :queue, f.errorService = :service, f.errorTimestamp = :timestamp, f.errorCode = :errorCode where f.id = :fileId")
void updateStatusErrorInfo(@Param("fileId") String fileId,
@Param("cause") String cause,
@Param("queue") String queue,
@Param("service") String service,
@Param("errorCode") ErrorCode errorCode,
@Param("timestamp") OffsetDateTime timestamp);

View File

@ -18,7 +18,7 @@ public class FileModelMapper implements BiConsumer<FileEntity, FileModel> {
fileEntity.getFileAttributes()
.forEach(fa -> fileModel.getFileAttributes().put(fa.getFileAttributeId().getFileAttributeConfigId(), fa.getValue()));
fileModel.setFileErrorInfo(new FileErrorInfo(fileEntity.getErrorCause(), fileEntity.getErrorQueue(), fileEntity.getErrorService(), fileEntity.getErrorTimestamp()));
fileModel.setFileErrorInfo(new FileErrorInfo(fileEntity.getErrorCause(), fileEntity.getErrorQueue(), fileEntity.getErrorService(), fileEntity.getErrorTimestamp(), fileEntity.getErrorCode()));
fileModel.setComponentMappingVersions(getComponentMappingVersions(fileEntity));
}

View File

@ -230,12 +230,14 @@ databaseChangeLog:
- include:
file: db/changelog/tenant/143-modify-download-redaction-file-status-details.yaml
- include:
file: db/changelog/tenant/144-add-protobuf-migration-done-to-file.yaml
file: db/changelog/tenant/144-add-error-code-to-file.yaml
- include:
file: db/changelog/tenant/145-add-indexes-to-file-table.yaml
file: db/changelog/tenant/145-add-protobuf-migration-done-to-file.yaml
- include:
file: db/changelog/tenant/146-add-layout-parsing-type-to-dossier-template.yaml
file: db/changelog/tenant/146-add-indexes-to-file-table.yaml
- include:
file: db/changelog/tenant/147-add-quotechar-to-component-mapping.yaml
file: db/changelog/tenant/147-add-layout-parsing-type-to-dossier-template.yaml
- include:
file: db/changelog/tenant/148-remove-based-on-dict-annotation-id-columns.yaml
file: db/changelog/tenant/148-add-quotechar-to-component-mapping.yaml
- include:
file: db/changelog/tenant/149-remove-based-on-dict-annotation-id-columns.yaml

View File

@ -0,0 +1,11 @@
databaseChangeLog:
- changeSet:
id: 144-add-error-code-to-file
author: dom
changes:
- addColumn:
columns:
- column:
name: error_code
type: VARCHAR(255)
tableName: file

View File

@ -76,7 +76,7 @@ public class ComponentOverrideTest extends AbstractPersistenceServerServiceTest
var dossierTemplate = dossierTemplateClient.getDossierTemplate(dossier.getDossierTemplateId());
var file = fileTesterAndProvider.testAndProvideFile(dossier, "filename");
var file = fileTesterAndProvider.testAndProvideFile(dossier, "filename1");
System.out.println("DOSSIER TEMPLATE ID: " + dossierTemplate.getId());
System.out.println("DOSSIER ID: " + dossier.getId());
@ -199,7 +199,7 @@ public class ComponentOverrideTest extends AbstractPersistenceServerServiceTest
var dossierTemplate = dossierTemplateClient.getDossierTemplate(dossier.getDossierTemplateId());
var file = fileTesterAndProvider.testAndProvideFile(dossier, "filename");
var file = fileTesterAndProvider.testAndProvideFile(dossier, "filename2");
System.out.println("DOSSIER TEMPLATE ID: " + dossierTemplate.getId());
System.out.println("DOSSIER ID: " + dossier.getId());
@ -261,7 +261,7 @@ public class ComponentOverrideTest extends AbstractPersistenceServerServiceTest
assertTrue(overrides.getComponentOverrides().isEmpty());
// case 2: re-upload file that was deleted before overrides should also not be returned anymore
fileTesterAndProvider.testAndProvideFile(dossier, "filename");
fileTesterAndProvider.testAndProvideFile(dossier, "filename3");
var e = assertThrows(FeignException.class, () -> componentClient.getOverrides(dossierTemplate.getId(), dossier.getId(), file.getId()));
assertEquals(e.status(), 404);

View File

@ -0,0 +1,5 @@
package com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file;
public enum ErrorCode {
RULES_EXECUTION_TIMEOUT, LOCKED_RULES, MISSING_DOCX_PDFTRON_LICENSE
}

View File

@ -18,6 +18,7 @@ public class FileErrorInfo {
private String queue;
private String service;
private OffsetDateTime timestamp;
private ErrorCode errorCode;
public FileErrorInfo(String cause, String queue, String service) {
@ -28,4 +29,23 @@ public class FileErrorInfo {
this.timestamp = OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS);
}
public FileErrorInfo(String cause, String queue, String service, OffsetDateTime timestamp) {
this.cause = cause;
this.queue = queue;
this.service = service;
this.timestamp = timestamp;
}
public FileErrorInfo(String cause, String queue, String service, ErrorCode errorCode) {
this.cause = cause;
this.queue = queue;
this.service = service;
this.timestamp = OffsetDateTime.now().truncatedTo(ChronoUnit.MILLIS);
this.errorCode = errorCode;
}
}