Merge branch 'RED-7500' into 'master'

RED-7500 - Delete Report json metadata from azure/s3 storage

Closes RED-7500

See merge request redactmanager/persistence-service!96
This commit is contained in:
Andrei Isvoran 2023-08-29 12:57:35 +02:00
commit 0fb7ccf7a2
2 changed files with 22 additions and 2 deletions

View File

@ -178,7 +178,17 @@ public class DownloadController implements DownloadResource {
removeDownloadRequest.getStorageIds().forEach(storageId -> {
downloadService.deleteDownloadStatus(JSONPrimitive.of(storageId));
fileManagementStorageService.deleteObject(storageId);
fileManagementStorageService.deleteObject(generateReportJsonStorageId(storageId));
String s3ReportJson = generateReportJsonStorageIdForS3(storageId);
if (fileManagementStorageService.objectExists(s3ReportJson)) {
fileManagementStorageService.deleteObject(s3ReportJson);
}
String azureReportJson = generateReportJsonStorageIdForAzure(storageId);
if (fileManagementStorageService.objectExists(azureReportJson)) {
fileManagementStorageService.deleteObject(azureReportJson);
}
auditPersistenceService.audit(AuditRequest.builder()
.userId(KeycloakSecurity.getUserId())
.objectId(storageId)
@ -292,9 +302,14 @@ public class DownloadController implements DownloadResource {
return DownloadRequest.builder().dossierId(request.getDossierId()).userId(KeycloakSecurity.getUserId()).fileIds(request.getFileIds()).build();
}
private String generateReportJsonStorageId(String storageId) {
private String generateReportJsonStorageIdForS3(String storageId) {
return storageId.replace("zip", "/REPORT_INFO.json.gz");
}
private String generateReportJsonStorageIdForAzure(String storageId) {
return storageId.replace(".zip", "/REPORT_INFO.json.gz");
}
}

View File

@ -120,6 +120,11 @@ public class FileManagementStorageService {
return storageService.objectExists(TenantContext.getTenantId(), StorageIdUtils.getStorageId(dossierId, fileId, origin));
}
public boolean objectExists(String storageId) {
return storageService.objectExists(TenantContext.getTenantId(), storageId);
}
public void deleteObject(String dossierId, String fileId, FileType fileType) {