hotfix: fixed startup problem

This commit is contained in:
Dominique Eifländer 2024-04-19 09:27:48 +02:00
parent f4e9a35a12
commit 7f04fa0b28
4 changed files with 72 additions and 43 deletions

View File

@ -3,6 +3,7 @@ package com.iqser.red.persistence.service.v1.external.api.impl.controller;
import com.iqser.red.service.persistence.management.v1.processor.entity.migration.SaasMigrationStatusEntity; import com.iqser.red.service.persistence.management.v1.processor.entity.migration.SaasMigrationStatusEntity;
import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException; import com.iqser.red.service.persistence.management.v1.processor.exception.BadRequestException;
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException; import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
import com.iqser.red.service.persistence.management.v1.processor.migration.SaasMigrationAsyncService;
import com.iqser.red.service.persistence.management.v1.processor.migration.SaasMigrationService; import com.iqser.red.service.persistence.management.v1.processor.migration.SaasMigrationService;
import com.iqser.red.service.persistence.management.v1.processor.service.FileStatusService; import com.iqser.red.service.persistence.management.v1.processor.service.FileStatusService;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.SaasMigrationStatusPersistenceService; import com.iqser.red.service.persistence.management.v1.processor.service.persistence.SaasMigrationStatusPersistenceService;
@ -34,6 +35,8 @@ public class MigrationStatusController implements MigrationStatusResource {
FileStatusService fileStatusService; FileStatusService fileStatusService;
SaasMigrationAsyncService saasMigrationAsyncService;
public MigrationStatusResponse migrationStatus() { public MigrationStatusResponse migrationStatus() {
@ -93,14 +96,14 @@ public class MigrationStatusController implements MigrationStatusResource {
throw new BadRequestException("There are still files processing, please wait until migration has finished to retry!"); throw new BadRequestException("There are still files processing, please wait until migration has finished to retry!");
} }
saasMigrationService.requeueErrorFiles(); saasMigrationAsyncService.requeueErrorFiles();
return ResponseEntity.ok().build(); return ResponseEntity.ok().build();
} }
public void retryZipFiles(){ public void retryZipFiles(){
saasMigrationService.restartZipFiles(); saasMigrationAsyncService.restartZipFiles();
} }

View File

@ -0,0 +1,45 @@
package com.iqser.red.service.persistence.management.v1.processor.migration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.iqser.red.service.persistence.management.v1.processor.service.job.AutomaticAnalysisJob;
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.SaasMigrationStatusPersistenceService;
import com.iqser.red.service.persistence.service.v1.api.shared.model.dossiertemplate.dossier.file.SaasMigrationStatus;
import com.knecon.fforesight.tenantcommons.TenantContext;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Service
@RequiredArgsConstructor
@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE)
public class SaasMigrationAsyncService {
AutomaticAnalysisJob automaticAnalysisJob;
SaasMigrationStatusPersistenceService saasMigrationStatusPersistenceService;
UncompressedFilesMigrationService uncompressedFilesMigrationService;
SaasMigrationService saasMigrationService;
@Async
public void requeueErrorFiles() {
automaticAnalysisJob.stopForTenant(TenantContext.getTenantId());
saasMigrationStatusPersistenceService.findAllByStatus(SaasMigrationStatus.ERROR)
.forEach(migrationStatus -> saasMigrationService.startMigrationForFile(migrationStatus.getDossierId(), migrationStatus.getFileId()));
}
@Async
public void restartZipFiles(){
log.info("Starting uncompressed files migration ...");
uncompressedFilesMigrationService.migrateUncompressedFiles(TenantContext.getTenantId());
log.info("Finished uncompressed files migration ...");
}
}

View File

@ -9,7 +9,6 @@ import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId; import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId;
@ -99,8 +98,8 @@ public class SaasMigrationService implements TenantSyncService {
var dossier = dossierService.getDossierById(file.getDossierId()); var dossier = dossierService.getDossierById(file.getDossierId());
if (dossier.getHardDeletedTime() != null){ if (dossier.getHardDeletedTime() != null) {
if (fileStatusPersistenceService.getStatus(file.getFileId()).getHardDeletedTime() != null){ if (fileStatusPersistenceService.getStatus(file.getFileId()).getHardDeletedTime() != null) {
saasMigrationStatusPersistenceService.updateStatus(file.getFileId(), SaasMigrationStatus.FINISHED); saasMigrationStatusPersistenceService.updateStatus(file.getFileId(), SaasMigrationStatus.FINISHED);
return; return;
} else { } else {
@ -109,7 +108,7 @@ public class SaasMigrationService implements TenantSyncService {
return; return;
} }
} }
if (fileStatusPersistenceService.getStatus(file.getFileId()).getHardDeletedTime() != null){ if (fileStatusPersistenceService.getStatus(file.getFileId()).getHardDeletedTime() != null) {
saasMigrationStatusPersistenceService.updateStatus(file.getFileId(), SaasMigrationStatus.FINISHED); saasMigrationStatusPersistenceService.updateStatus(file.getFileId(), SaasMigrationStatus.FINISHED);
return; return;
} }
@ -141,8 +140,8 @@ public class SaasMigrationService implements TenantSyncService {
var dossier = dossierService.getDossierById(dossierId); var dossier = dossierService.getDossierById(dossierId);
if (dossier.getHardDeletedTime() != null){ if (dossier.getHardDeletedTime() != null) {
if (fileStatusPersistenceService.getStatus(fileId).getHardDeletedTime() != null){ if (fileStatusPersistenceService.getStatus(fileId).getHardDeletedTime() != null) {
saasMigrationStatusPersistenceService.updateStatus(fileId, SaasMigrationStatus.FINISHED); saasMigrationStatusPersistenceService.updateStatus(fileId, SaasMigrationStatus.FINISHED);
return; return;
} else { } else {
@ -151,7 +150,7 @@ public class SaasMigrationService implements TenantSyncService {
return; return;
} }
} }
if (fileStatusPersistenceService.getStatus(fileId).getHardDeletedTime() != null){ if (fileStatusPersistenceService.getStatus(fileId).getHardDeletedTime() != null) {
saasMigrationStatusPersistenceService.updateStatus(fileId, SaasMigrationStatus.FINISHED); saasMigrationStatusPersistenceService.updateStatus(fileId, SaasMigrationStatus.FINISHED);
return; return;
} }
@ -163,24 +162,6 @@ public class SaasMigrationService implements TenantSyncService {
} }
@Async
public void requeueErrorFiles() {
automaticAnalysisJob.stopForTenant(TenantContext.getTenantId());
saasMigrationStatusPersistenceService.findAllByStatus(SaasMigrationStatus.ERROR)
.forEach(migrationStatus -> startMigrationForFile(migrationStatus.getDossierId(), migrationStatus.getFileId()));
}
@Async
public void restartZipFiles(){
log.info("Starting uncompressed files migration ...");
uncompressedFilesMigrationService.migrateUncompressedFiles(TenantContext.getTenantId());
log.info("Finished uncompressed files migration ...");
}
public void handleLayoutParsingFinished(String dossierId, String fileId) { public void handleLayoutParsingFinished(String dossierId, String fileId) {
if (!layoutParsingFilesExist(dossierId, fileId)) { if (!layoutParsingFilesExist(dossierId, fileId)) {
@ -201,14 +182,14 @@ public class SaasMigrationService implements TenantSyncService {
String dossierTemplateId = dossierService.getDossierById(dossierId).getDossierTemplateId(); String dossierTemplateId = dossierService.getDossierById(dossierId).getDossierTemplateId();
rabbitTemplate.convertAndSend(MIGRATION_QUEUE, rabbitTemplate.convertAndSend(MIGRATION_QUEUE,
MigrationRequest.builder() MigrationRequest.builder()
.dossierTemplateId(dossierTemplateId) .dossierTemplateId(dossierTemplateId)
.dossierId(dossierId) .dossierId(dossierId)
.fileId(fileId) .fileId(fileId)
.fileIsApproved(fileStatusPersistenceService.getStatus(fileId).getWorkflowStatus().equals(WorkflowStatus.APPROVED)) .fileIsApproved(fileStatusPersistenceService.getStatus(fileId).getWorkflowStatus().equals(WorkflowStatus.APPROVED))
.manualRedactions(manualRedactionProviderService.getManualRedactions(fileId, ManualChangesQueryOptions.allWithoutDeleted())) .manualRedactions(manualRedactionProviderService.getManualRedactions(fileId, ManualChangesQueryOptions.allWithoutDeleted()))
.entitiesWithComments(commentService.getCommentCounts(fileId).keySet()) .entitiesWithComments(commentService.getCommentCounts(fileId).keySet())
.build()); .build());
} catch (Exception e) { } catch (Exception e) {
log.error("Queuing of entityLog migration failed with {}", e.getMessage()); log.error("Queuing of entityLog migration failed with {}", e.getMessage());
saasMigrationStatusPersistenceService.updateErrorStatus(fileId, String.format("Queuing of entityLog migration failed with %s", e.getMessage())); saasMigrationStatusPersistenceService.updateErrorStatus(fileId, String.format("Queuing of entityLog migration failed with %s", e.getMessage()));
@ -220,9 +201,9 @@ public class SaasMigrationService implements TenantSyncService {
private boolean layoutParsingFilesExist(String dossierId, String fileId) { private boolean layoutParsingFilesExist(String dossierId, String fileId) {
return storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_STRUCTURE)) // return storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_STRUCTURE)) //
&& storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_TEXT)) // && storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_TEXT)) //
&& storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_PAGES)) // && storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_PAGES)) //
&& storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_POSITION)); && storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, FileType.DOCUMENT_POSITION));
} }
@ -329,10 +310,10 @@ public class SaasMigrationService implements TenantSyncService {
updateAnnotationIds(fileId, idMapping); updateAnnotationIds(fileId, idMapping);
} catch (Exception e) { } catch (Exception e) {
String message = String.format("Error during annotation id migration for tenant %s dossier %s and file %s, cause %s", String message = String.format("Error during annotation id migration for tenant %s dossier %s and file %s, cause %s",
TenantContext.getTenantId(), TenantContext.getTenantId(),
dossierId, dossierId,
fileId, fileId,
e.getMessage()); e.getMessage());
saasMigrationStatusPersistenceService.updateErrorStatus(fileId, message); saasMigrationStatusPersistenceService.updateErrorStatus(fileId, message);
log.error(message); log.error(message);
throw e; throw e;

View File

@ -57,7 +57,7 @@ import io.micrometer.observation.aop.ObservedAspect;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
@EnableAsync(proxyTargetClass=true) @EnableAsync
@EnableRetry @EnableRetry
@EnableScheduling @EnableScheduling
@EnableCaching @EnableCaching