Merge branch 'RED-9205-fix' into 'release/2.262.x'
RED-9205 - Fix download job failing See merge request redactmanager/persistence-service!499
This commit is contained in:
commit
674db96824
@ -37,6 +37,7 @@ import lombok.SneakyThrows;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -46,21 +47,24 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
|
||||
public class DownloadPreparationService {
|
||||
|
||||
DownloadStatusPersistenceService downloadStatusPersistenceService;
|
||||
FileManagementStorageService fileManagementStorageService;
|
||||
ReportTemplatePersistenceService reportTemplatePersistenceService;
|
||||
NotificationPersistenceService notificationPersistenceService;
|
||||
RabbitTemplate rabbitTemplate;
|
||||
ObjectMapper objectMapper;
|
||||
DownloadReportCleanupService downloadReportCleanupService;
|
||||
ColorsService colorsService;
|
||||
FileManagementServiceSettings settings;
|
||||
DossierTemplatePersistenceService dossierTemplatePersistenceService;
|
||||
DownloadRedactionFileStatusRepository downloadRedactionFileStatusRepository;
|
||||
private final DownloadStatusPersistenceService downloadStatusPersistenceService;
|
||||
private final FileManagementStorageService fileManagementStorageService;
|
||||
private final ReportTemplatePersistenceService reportTemplatePersistenceService;
|
||||
private final NotificationPersistenceService notificationPersistenceService;
|
||||
private final RabbitTemplate rabbitTemplate;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final DownloadReportCleanupService downloadReportCleanupService;
|
||||
private final ColorsService colorsService;
|
||||
private final FileManagementServiceSettings settings;
|
||||
private final DossierTemplatePersistenceService dossierTemplatePersistenceService;
|
||||
private final DownloadRedactionFileStatusRepository downloadRedactionFileStatusRepository;
|
||||
|
||||
@Value("${storage.backend}")
|
||||
private String storageBackend;
|
||||
|
||||
private static final String REPORT_INFO = "/REPORT_INFO.json";
|
||||
|
||||
@Transactional
|
||||
public void createDownload(ReportResultMessage reportResultMessage) {
|
||||
@ -321,13 +325,31 @@ public class DownloadPreparationService {
|
||||
@SneakyThrows
|
||||
private List<StoredFileInformation> getStoredFileInformation(String downloadId) {
|
||||
|
||||
var storageId = downloadId.substring(0, downloadId.length() - 3) + "/REPORT_INFO.json";
|
||||
String storageId;
|
||||
if (storageBackend.equals("s3")) {
|
||||
storageId = generateReportJsonStorageIdForS3(downloadId);
|
||||
} else {
|
||||
storageId = generateReportJsonStorageIdForAzure(downloadId);
|
||||
}
|
||||
|
||||
return objectMapper.readValue(fileManagementStorageService.getStoredObjectBytes(storageId), new TypeReference<>() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
private String generateReportJsonStorageIdForS3(String storageId) {
|
||||
|
||||
return storageId.substring(0, storageId.length() - 3) + REPORT_INFO;
|
||||
}
|
||||
|
||||
|
||||
private String generateReportJsonStorageIdForAzure(String storageId) {
|
||||
|
||||
return storageId.substring(0, storageId.length() - 4) + REPORT_INFO;
|
||||
}
|
||||
|
||||
|
||||
private String createFileName(FileEntity fileStatus, ReportTemplateEntity reportTemplate) {
|
||||
|
||||
if (fileStatus != null) {
|
||||
|
||||
@ -41,7 +41,7 @@ public class DownloadReadyJob implements Job {
|
||||
|
||||
int numberOfFiles = download.getFiles().size();
|
||||
var downloadRedactionFileStatus = downloadRedactionFileStatusRepository.findAllByDownloadStorageId(download.getStorageId());
|
||||
if (downloadRedactionFileStatus.size() == numberOfFiles) {
|
||||
if (downloadRedactionFileStatus.size() >= numberOfFiles) {
|
||||
downloadPreparationService.createDownload(downloadRedactionFileStatus, download.getStorageId());
|
||||
downloadPreparationService.clearRedactionStatusEntries(download.getStorageId());
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ import org.springframework.data.jpa.repository.Query;
|
||||
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.AnnotationEntityId;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.IdRemovalEntity;
|
||||
import com.iqser.red.service.persistence.management.v1.processor.entity.annotations.ManualRedactionEntryEntity;
|
||||
import com.iqser.red.service.persistence.service.v1.api.shared.model.annotations.AnnotationStatus;
|
||||
|
||||
public interface RemoveRedactionRepository extends JpaRepository<IdRemovalEntity, AnnotationEntityId>, AnnotationEntityRepository {
|
||||
@ -24,13 +23,15 @@ public interface RemoveRedactionRepository extends JpaRepository<IdRemovalEntity
|
||||
@Query("update IdRemovalEntity idr set idr.status = :annotationStatus where idr.id = :annotationEntityId")
|
||||
void updateStatus(AnnotationEntityId annotationEntityId, AnnotationStatus annotationStatus);
|
||||
|
||||
|
||||
@Query("select idr from IdRemovalEntity idr where idr.id = :annotationEntityId and idr.softDeletedTime is null")
|
||||
Optional<IdRemovalEntity> findByIdAndNotSoftDeleted(AnnotationEntityId annotationEntityId);
|
||||
|
||||
|
||||
@Query("select idr from IdRemovalEntity idr where idr.id.fileId = :fileId and (:includeDeletions = true or idr.softDeletedTime is null)")
|
||||
@Query("select idr from IdRemovalEntity idr left join fetch idr.typeIdsOfModifiedDictionaries where idr.id.fileId = :fileId and (:includeDeletions = true or idr.softDeletedTime is null)")
|
||||
List<IdRemovalEntity> findByFileIdIncludeDeletions(String fileId, boolean includeDeletions);
|
||||
|
||||
|
||||
@Query("select idr from IdRemovalEntity idr where idr.id.fileId = :fileId and idr.processedDate is null")
|
||||
List<IdRemovalEntity> findByFileIdAndUnprocessed(String fileId);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user