migration-fp-hotfix
This commit is contained in:
parent
fe3b437b80
commit
b6c8ec2f7c
@ -130,11 +130,31 @@ public class SaasMigrationService implements TenantSyncService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.info("Added {} documents for tenant {} to Layout-Parsing queue for saas migration", numberOfFiles, TenantContext.getTenantId());
|
log.info("Added {} documents for tenant {} to Layout-Parsing queue for saas migration", numberOfFiles, TenantContext.getTenantId());
|
||||||
|
if (numberOfFiles == 0) {
|
||||||
|
finalizeMigration();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void startMigrationForFile(String dossierId, String fileId) {
|
public void startMigrationForFile(String dossierId, String fileId) {
|
||||||
|
|
||||||
|
var dossier = dossierService.getDossierById(dossierId);
|
||||||
|
|
||||||
|
if (dossier.getHardDeletedTime() != null) {
|
||||||
|
if (fileStatusPersistenceService.getStatus(fileId).getHardDeletedTime() != null) {
|
||||||
|
saasMigrationStatusPersistenceService.updateStatus(fileId, SaasMigrationStatus.FINISHED);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
fileStatusPersistenceService.hardDelete(fileId, dossier.getHardDeletedTime());
|
||||||
|
saasMigrationStatusPersistenceService.updateStatus(fileId, SaasMigrationStatus.FINISHED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (fileStatusPersistenceService.getStatus(fileId).getHardDeletedTime() != null) {
|
||||||
|
saasMigrationStatusPersistenceService.updateStatus(fileId, SaasMigrationStatus.FINISHED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
log.info("Starting Migration for dossierId {} and fileId {}", dossierId, fileId);
|
log.info("Starting Migration for dossierId {} and fileId {}", dossierId, fileId);
|
||||||
saasMigrationStatusPersistenceService.createMigrationRequiredStatus(dossierId, fileId);
|
saasMigrationStatusPersistenceService.createMigrationRequiredStatus(dossierId, fileId);
|
||||||
var layoutParsingRequest = layoutParsingRequestFactory.build(dossierId, fileId, false);
|
var layoutParsingRequest = layoutParsingRequestFactory.build(dossierId, fileId, false);
|
||||||
@ -142,15 +162,6 @@ public class SaasMigrationService implements TenantSyncService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void requeueErrorFiles() {
|
|
||||||
|
|
||||||
automaticAnalysisJob.stopForTenant(TenantContext.getTenantId());
|
|
||||||
saasMigrationStatusPersistenceService.findAllByStatus(SaasMigrationStatus.ERROR)
|
|
||||||
.forEach(migrationStatus -> startMigrationForFile(migrationStatus.getDossierId(), migrationStatus.getFileId()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void handleLayoutParsingFinished(String dossierId, String fileId) {
|
public void handleLayoutParsingFinished(String dossierId, String fileId) {
|
||||||
|
|
||||||
if (!layoutParsingFilesExist(dossierId, fileId)) {
|
if (!layoutParsingFilesExist(dossierId, fileId)) {
|
||||||
@ -171,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()));
|
||||||
@ -190,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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -299,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;
|
||||||
@ -313,7 +324,7 @@ public class SaasMigrationService implements TenantSyncService {
|
|||||||
private void finalizeMigration() {
|
private void finalizeMigration() {
|
||||||
|
|
||||||
if (saasMigrationStatusPersistenceService.countByStatus(SaasMigrationStatus.FINISHED) == saasMigrationStatusPersistenceService.countAll()) {
|
if (saasMigrationStatusPersistenceService.countByStatus(SaasMigrationStatus.FINISHED) == saasMigrationStatusPersistenceService.countAll()) {
|
||||||
// automaticAnalysisJob.startForTenant(TenantContext.getTenantId());
|
// automaticAnalysisJob.startForTenant(TenantContext.getTenantId()); // AutomaticAnalysisJob should be re-enabled by re-starting the persistence service pod after a rule change
|
||||||
tenantProvider.updateDetails(TenantContext.getTenantId(), UpdateDetailsRequest.builder().key("persistence-service-ready").value(true).build());
|
tenantProvider.updateDetails(TenantContext.getTenantId(), UpdateDetailsRequest.builder().key("persistence-service-ready").value(true).build());
|
||||||
log.info("Saas migration finished for tenantId {}, re-enabled scheduler", TenantContext.getTenantId());
|
log.info("Saas migration finished for tenantId {}, re-enabled scheduler", TenantContext.getTenantId());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user