Pull request #380: hotfix: migration to skip missing redaction logs
Merge in RED/persistence-service from kbudisantoso/hotfix-migration to release/1.156.x * commit '634c1c98dc3d93f2241b89ae425818fcd30f22a1': hotfix: migration to skip missing redaction logs (e.g. for deleted files w/o redaction log)
This commit is contained in:
commit
bb2157f4e1
@ -9,6 +9,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.iqser.red.service.peristence.v1.server.migration.Migration;
|
||||
import com.iqser.red.service.peristence.v1.server.service.FileManagementStorageService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.exception.NotFoundException;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DossierPersistenceService;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.FileStatusPersistenceService;
|
||||
import com.iqser.red.service.persistence.service.v1.api.model.dossiertemplate.dossier.file.FileType;
|
||||
@ -48,7 +49,6 @@ public class DictionaryToEntityMigration2 extends Migration {
|
||||
@Override
|
||||
protected void migrate() {
|
||||
|
||||
|
||||
var dossiers = dossierPersistenceService.findAllDossiers();
|
||||
dossiers.forEach(dossier -> {
|
||||
var files = fileStatusPersistenceService.getStatusesForDossier(dossier.getId());
|
||||
@ -57,32 +57,33 @@ public class DictionaryToEntityMigration2 extends Migration {
|
||||
log.info("Start migration of file {}", file.getId());
|
||||
if (file.getHardDeletedTime() == null) {
|
||||
var newRedactionLogEntries = new ArrayList<RedactionLogEntry>();
|
||||
var redactionLog = fileManagementStorageService.getRedactionLog(dossier.getId(), file.getId());
|
||||
|
||||
redactionLog.getRedactionLogEntry().forEach(entry -> {
|
||||
|
||||
if (entry.getType().equals("false_positive")){
|
||||
log.info("skipping false_positive for dossier {} and file {}", dossier.getId(), file.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.getType().startsWith("recommendation_")) {
|
||||
entry.setType(entry.getType().substring(15));
|
||||
entry.setRecommendation(true);
|
||||
log.info("removed _recommendation");
|
||||
}
|
||||
|
||||
newRedactionLogEntries.add(entry);
|
||||
});
|
||||
|
||||
redactionLog.setRedactionLogEntry(newRedactionLogEntries);
|
||||
try {
|
||||
var redactionLog = fileManagementStorageService.getRedactionLog(dossier.getId(), file.getId());
|
||||
redactionLog.getRedactionLogEntry().forEach(entry -> {
|
||||
|
||||
if (entry.getType().equals("false_positive")) {
|
||||
log.info("skipping false_positive for dossier {} and file {}", dossier.getId(), file.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.getType().startsWith("recommendation_")) {
|
||||
entry.setType(entry.getType().substring(15));
|
||||
entry.setRecommendation(true);
|
||||
log.info("removed _recommendation");
|
||||
}
|
||||
|
||||
newRedactionLogEntries.add(entry);
|
||||
});
|
||||
|
||||
redactionLog.setRedactionLogEntry(newRedactionLogEntries);
|
||||
fileManagementStorageService.storeObject(dossier.getId(), file.getId(), FileType.REDACTION_LOG, objectMapper.writeValueAsBytes(redactionLog));
|
||||
log.info("Stored dossierId: {} and fileId: {}", dossier.getId(), file.getId());
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException("Migration failed");
|
||||
} catch (NotFoundException e) {
|
||||
log.info("redactionLog {} does not exsist", file.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user