RED-8385: delete viewer doc, when rotating origin file, such that it is recreated with the rotation #348

Merged
kilian.schuettler1 merged 1 commits from RED-8385 into master 2024-02-12 16:27:50 +01:00
2 changed files with 145 additions and 111 deletions
Showing only changes of commit 768384a84c - Show all commits

View File

@ -253,6 +253,8 @@ public class FileManagementController implements FileManagementResource {
.pages(rotatePagesRequest.getPages()) .pages(rotatePagesRequest.getPages())
.build()); .build());
fileService.deleteViewerDocument(dossierId, fileId);
fileStatusManagementService.updateFileModificationDate(fileId); fileStatusManagementService.updateFileModificationDate(fileId);
FileModel fileModel = fileStatusManagementService.getFileStatus(fileId); FileModel fileModel = fileStatusManagementService.getFileStatus(fileId);

View File

@ -113,41 +113,47 @@ public class FileService {
public void softDeleteFile(String dossierId, String fileId, OffsetDateTime softDeletedTime) { public void softDeleteFile(String dossierId, String fileId, OffsetDateTime softDeletedTime) {
forceRedactionPersistenceService.findForceRedactions(fileId, false).forEach(annotation -> { forceRedactionPersistenceService.findForceRedactions(fileId, false)
forceRedactionPersistenceService.softDelete(fileId, annotation.getId().getAnnotationId(), softDeletedTime); .forEach(annotation -> {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), false) forceRedactionPersistenceService.softDelete(fileId, annotation.getId().getAnnotationId(), softDeletedTime);
.forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime)); commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), false)
}); .forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime));
});
removeRedactionPersistenceService.findRemoveRedactions(fileId, false).forEach(annotation -> { removeRedactionPersistenceService.findRemoveRedactions(fileId, false)
removeRedactionPersistenceService.softDelete(fileId, annotation.getId().getAnnotationId(), softDeletedTime); .forEach(annotation -> {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), false) removeRedactionPersistenceService.softDelete(fileId, annotation.getId().getAnnotationId(), softDeletedTime);
.forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime)); commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), false)
}); .forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime));
});
addRedactionPersistenceService.findAddRedactions(fileId, false).forEach(annotation -> { addRedactionPersistenceService.findAddRedactions(fileId, false)
addRedactionPersistenceService.softDelete(fileId, annotation.getId().getAnnotationId(), softDeletedTime); .forEach(annotation -> {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), false) addRedactionPersistenceService.softDelete(fileId, annotation.getId().getAnnotationId(), softDeletedTime);
.forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime)); commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), false)
}); .forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime));
});
recategorizationPersistenceService.findRecategorizations(fileId, false).forEach(recatigorization -> { recategorizationPersistenceService.findRecategorizations(fileId, false)
recategorizationPersistenceService.softDelete(fileId, recatigorization.getId().getAnnotationId(), softDeletedTime); .forEach(recatigorization -> {
commentPersistenceService.findCommentsByAnnotationId(fileId, recatigorization.getId().getAnnotationId(), false) recategorizationPersistenceService.softDelete(fileId, recatigorization.getId().getAnnotationId(), softDeletedTime);
.forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime)); commentPersistenceService.findCommentsByAnnotationId(fileId, recatigorization.getId().getAnnotationId(), false)
}); .forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime));
});
resizeRedactionPersistenceService.findResizeRedactions(fileId, false).forEach(annotation -> { resizeRedactionPersistenceService.findResizeRedactions(fileId, false)
resizeRedactionPersistenceService.softDelete(fileId, annotation.getId().getAnnotationId(), softDeletedTime); .forEach(annotation -> {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), false) resizeRedactionPersistenceService.softDelete(fileId, annotation.getId().getAnnotationId(), softDeletedTime);
.forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime)); commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), false)
}); .forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime));
});
legalBasisChangePersistenceService.findLegalBasisChanges(fileId, false).forEach(legalBasisChange -> { legalBasisChangePersistenceService.findLegalBasisChanges(fileId, false)
legalBasisChangePersistenceService.softDelete(fileId, legalBasisChange.getId().getAnnotationId(), softDeletedTime); .forEach(legalBasisChange -> {
commentPersistenceService.findCommentsByAnnotationId(fileId, legalBasisChange.getId().getAnnotationId(), false) legalBasisChangePersistenceService.softDelete(fileId, legalBasisChange.getId().getAnnotationId(), softDeletedTime);
.forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime)); commentPersistenceService.findCommentsByAnnotationId(fileId, legalBasisChange.getId().getAnnotationId(), false)
}); .forEach(comment -> commentPersistenceService.softDelete(comment.getId(), softDeletedTime));
});
viewedPagesPersistenceService.deleteForFile(fileId); viewedPagesPersistenceService.deleteForFile(fileId);
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2); indexingService.addToIndexingQueue(IndexMessageType.UPDATE, null, dossierId, fileId, 2);
@ -170,43 +176,49 @@ public class FileService {
public void hardDeleteFile(String dossierId, String fileId) { public void hardDeleteFile(String dossierId, String fileId) {
Arrays.stream(FileType.values()).forEach(fileType -> { Arrays.stream(FileType.values())
try { .forEach(fileType -> {
fileManagementStorageService.deleteObject(dossierId, fileId, fileType); try {
} catch (Exception e) { fileManagementStorageService.deleteObject(dossierId, fileId, fileType);
log.warn("Failed to physically delete file: {} with type {}", fileId, fileType); } catch (Exception e) {
} log.warn("Failed to physically delete file: {} with type {}", fileId, fileType);
}); }
});
forceRedactionPersistenceService.findForceRedactions(fileId, true).forEach(annotation -> { forceRedactionPersistenceService.findForceRedactions(fileId, true)
forceRedactionPersistenceService.hardDelete(fileId, annotation.getId().getAnnotationId()); .forEach(annotation -> {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true) forceRedactionPersistenceService.hardDelete(fileId, annotation.getId().getAnnotationId());
.forEach(comment -> commentPersistenceService.hardDelete(comment.getId())); commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true)
}); .forEach(comment -> commentPersistenceService.hardDelete(comment.getId()));
});
removeRedactionPersistenceService.findRemoveRedactions(fileId, true).forEach(annotation -> { removeRedactionPersistenceService.findRemoveRedactions(fileId, true)
removeRedactionPersistenceService.hardDelete(fileId, annotation.getId().getAnnotationId()); .forEach(annotation -> {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true) removeRedactionPersistenceService.hardDelete(fileId, annotation.getId().getAnnotationId());
.forEach(comment -> commentPersistenceService.hardDelete(comment.getId())); commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true)
}); .forEach(comment -> commentPersistenceService.hardDelete(comment.getId()));
});
addRedactionPersistenceService.findAddRedactions(fileId, true).forEach(annotation -> { addRedactionPersistenceService.findAddRedactions(fileId, true)
addRedactionPersistenceService.hardDelete(fileId, annotation.getId().getAnnotationId()); .forEach(annotation -> {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true) addRedactionPersistenceService.hardDelete(fileId, annotation.getId().getAnnotationId());
.forEach(comment -> commentPersistenceService.hardDelete(comment.getId())); commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true)
}); .forEach(comment -> commentPersistenceService.hardDelete(comment.getId()));
});
recategorizationPersistenceService.findRecategorizations(fileId, true).forEach(recatigorization -> { recategorizationPersistenceService.findRecategorizations(fileId, true)
recategorizationPersistenceService.hardDelete(fileId, recatigorization.getId().getAnnotationId()); .forEach(recatigorization -> {
commentPersistenceService.findCommentsByAnnotationId(fileId, recatigorization.getId().getAnnotationId(), true) recategorizationPersistenceService.hardDelete(fileId, recatigorization.getId().getAnnotationId());
.forEach(comment -> commentPersistenceService.hardDelete(comment.getId())); commentPersistenceService.findCommentsByAnnotationId(fileId, recatigorization.getId().getAnnotationId(), true)
}); .forEach(comment -> commentPersistenceService.hardDelete(comment.getId()));
});
resizeRedactionPersistenceService.findResizeRedactions(fileId, true).forEach(annotation -> { resizeRedactionPersistenceService.findResizeRedactions(fileId, true)
resizeRedactionPersistenceService.hardDelete(fileId, annotation.getId().getAnnotationId()); .forEach(annotation -> {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true) resizeRedactionPersistenceService.hardDelete(fileId, annotation.getId().getAnnotationId());
.forEach(comment -> commentPersistenceService.hardDelete(comment.getId())); commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true)
}); .forEach(comment -> commentPersistenceService.hardDelete(comment.getId()));
});
indexingService.addToDeleteFromIndexQueue(dossierId, fileId, 2); indexingService.addToDeleteFromIndexQueue(dossierId, fileId, 2);
} }
@ -232,75 +244,95 @@ public class FileService {
public void undeleteFile(String dossierTemplateId, String dossierId, String fileId, OffsetDateTime softDeletedTime) { public void undeleteFile(String dossierTemplateId, String dossierId, String fileId, OffsetDateTime softDeletedTime) {
forceRedactionPersistenceService.findForceRedactions(fileId, true).forEach(annotation -> { forceRedactionPersistenceService.findForceRedactions(fileId, true)
if (annotation.getSoftDeletedTime().equals(softDeletedTime) || annotation.getSoftDeletedTime().isAfter(softDeletedTime)) { .forEach(annotation -> {
forceRedactionPersistenceService.undelete(fileId, annotation.getId().getAnnotationId()); if (annotation.getSoftDeletedTime().equals(softDeletedTime) || annotation.getSoftDeletedTime().isAfter(softDeletedTime)) {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true).forEach(comment -> { forceRedactionPersistenceService.undelete(fileId, annotation.getId().getAnnotationId());
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) { commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true)
commentPersistenceService.undelete(comment.getId()); .forEach(comment -> {
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) {
commentPersistenceService.undelete(comment.getId());
}
});
} }
}); });
}
});
removeRedactionPersistenceService.findRemoveRedactions(fileId, true).forEach(annotation -> { removeRedactionPersistenceService.findRemoveRedactions(fileId, true)
if (annotation.getSoftDeletedTime().equals(softDeletedTime) || annotation.getSoftDeletedTime().isAfter(softDeletedTime)) { .forEach(annotation -> {
removeRedactionPersistenceService.undelete(fileId, annotation.getId().getAnnotationId()); if (annotation.getSoftDeletedTime().equals(softDeletedTime) || annotation.getSoftDeletedTime().isAfter(softDeletedTime)) {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true).forEach(comment -> { removeRedactionPersistenceService.undelete(fileId, annotation.getId().getAnnotationId());
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) { commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true)
commentPersistenceService.undelete(comment.getId()); .forEach(comment -> {
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) {
commentPersistenceService.undelete(comment.getId());
}
});
} }
}); });
}
});
addRedactionPersistenceService.findAddRedactions(fileId, true).forEach(annotation -> { addRedactionPersistenceService.findAddRedactions(fileId, true)
if (annotation != null && annotation.getSoftDeletedTime() != null && (annotation.getSoftDeletedTime().equals(softDeletedTime) || annotation.getSoftDeletedTime() .forEach(annotation -> {
.isAfter(softDeletedTime))) { if (annotation != null && annotation.getSoftDeletedTime() != null && (annotation.getSoftDeletedTime().equals(softDeletedTime) || annotation.getSoftDeletedTime()
addRedactionPersistenceService.undelete(fileId, annotation.getId().getAnnotationId()); .isAfter(softDeletedTime))) {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true).forEach(comment -> { addRedactionPersistenceService.undelete(fileId, annotation.getId().getAnnotationId());
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) { commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true)
commentPersistenceService.undelete(comment.getId()); .forEach(comment -> {
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) {
commentPersistenceService.undelete(comment.getId());
}
});
} }
}); });
}
});
recategorizationPersistenceService.findRecategorizations(fileId, true).forEach(recatigorization -> { recategorizationPersistenceService.findRecategorizations(fileId, true)
if (recatigorization.getSoftDeletedTime().equals(softDeletedTime) || recatigorization.getSoftDeletedTime().isAfter(softDeletedTime)) { .forEach(recatigorization -> {
recategorizationPersistenceService.undelete(fileId, recatigorization.getId().getAnnotationId()); if (recatigorization.getSoftDeletedTime().equals(softDeletedTime) || recatigorization.getSoftDeletedTime().isAfter(softDeletedTime)) {
commentPersistenceService.findCommentsByAnnotationId(fileId, recatigorization.getId().getAnnotationId(), true).forEach(comment -> { recategorizationPersistenceService.undelete(fileId, recatigorization.getId().getAnnotationId());
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) { commentPersistenceService.findCommentsByAnnotationId(fileId, recatigorization.getId().getAnnotationId(), true)
commentPersistenceService.undelete(comment.getId()); .forEach(comment -> {
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) {
commentPersistenceService.undelete(comment.getId());
}
});
} }
}); });
}
});
resizeRedactionPersistenceService.findResizeRedactions(fileId, true).forEach(annotation -> { resizeRedactionPersistenceService.findResizeRedactions(fileId, true)
if (annotation.getSoftDeletedTime().equals(softDeletedTime) || annotation.getSoftDeletedTime().isAfter(softDeletedTime)) { .forEach(annotation -> {
resizeRedactionPersistenceService.undelete(fileId, annotation.getId().getAnnotationId()); if (annotation.getSoftDeletedTime().equals(softDeletedTime) || annotation.getSoftDeletedTime().isAfter(softDeletedTime)) {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true).forEach(comment -> { resizeRedactionPersistenceService.undelete(fileId, annotation.getId().getAnnotationId());
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) { commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true)
commentPersistenceService.undelete(comment.getId()); .forEach(comment -> {
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) {
commentPersistenceService.undelete(comment.getId());
}
});
} }
}); });
}
});
legalBasisChangePersistenceService.findLegalBasisChanges(fileId, true).forEach(annotation -> { legalBasisChangePersistenceService.findLegalBasisChanges(fileId, true)
if (annotation.getSoftDeletedTime().equals(softDeletedTime) || annotation.getSoftDeletedTime().isAfter(softDeletedTime)) { .forEach(annotation -> {
legalBasisChangePersistenceService.undelete(fileId, annotation.getId().getAnnotationId()); if (annotation.getSoftDeletedTime().equals(softDeletedTime) || annotation.getSoftDeletedTime().isAfter(softDeletedTime)) {
commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true).forEach(comment -> { legalBasisChangePersistenceService.undelete(fileId, annotation.getId().getAnnotationId());
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) { commentPersistenceService.findCommentsByAnnotationId(fileId, annotation.getId().getAnnotationId(), true)
commentPersistenceService.undelete(comment.getId()); .forEach(comment -> {
if (comment.getSoftDeletedTime().equals(softDeletedTime) || comment.getSoftDeletedTime().isAfter(softDeletedTime)) {
commentPersistenceService.undelete(comment.getId());
}
});
} }
}); });
}
});
indexingService.addToIndexingQueue(IndexMessageType.UPDATE, dossierTemplateId, dossierId, fileId, 2); indexingService.addToIndexingQueue(IndexMessageType.UPDATE, dossierTemplateId, dossierId, fileId, 2);
} }
public void deleteViewerDocument(String dossierId, String fileId) {
if (fileManagementStorageService.objectExists(dossierId, fileId, FileType.VIEWER_DOCUMENT)) {
fileManagementStorageService.deleteObject(dossierId, fileId, FileType.VIEWER_DOCUMENT);
}
}
} }