From 12e331a59fdf5022a648d217d999c5ed210dbf76 Mon Sep 17 00:00:00 2001 From: Parisa Tejari Date: Mon, 25 Nov 2024 16:00:36 +0100 Subject: [PATCH 1/2] Handle the cases where the visas are a mix of Fega and non-fega visas --- .../localega/doa/mq/ExportRequestsListener.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/no/uio/ifi/localega/doa/mq/ExportRequestsListener.java b/src/main/java/no/uio/ifi/localega/doa/mq/ExportRequestsListener.java index 4c1ae81..f9a9077 100644 --- a/src/main/java/no/uio/ifi/localega/doa/mq/ExportRequestsListener.java +++ b/src/main/java/no/uio/ifi/localega/doa/mq/ExportRequestsListener.java @@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j; import no.uio.ifi.localega.doa.dto.DestinationFormat; import no.uio.ifi.localega.doa.dto.ExportRequest; +import no.uio.ifi.localega.doa.model.Dataset; import no.uio.ifi.localega.doa.model.DatasetEventLog; import no.uio.ifi.localega.doa.services.AAIService; import no.uio.ifi.localega.doa.services.MetadataService; @@ -26,6 +27,7 @@ import java.io.InputStream; import java.util.Base64; import java.util.Collection; +import java.util.Objects; /** * RabbitMQ listener that processes incoming export requests. @@ -81,7 +83,17 @@ public void listen(String message) { String stableDatasetId = metadataService.getDataset(datasetsDbTableId).getStableId(); log.info("Reference id {} mapped to dataset id {}", requestedDatasetId, stableDatasetId); requestedDatasetId = stableDatasetId; // use stable dataset id instead of reference to complete the export as normal - Collection approvedMappedDatasetIds = approvedDatasetIds.stream().map(x -> metadataService.getDataset(metadataService.findByReferenceId(x).getDatasetId()).getStableId()).toList(); + Collection approvedMappedDatasetIds = approvedDatasetIds.stream() + .map(x -> { + var reference = metadataService.findByReferenceId(x); + if (reference != null && reference.getDatasetId() != null) { + var dataset = metadataService.getDataset(reference.getDatasetId()); + return dataset != null ? dataset.getStableId() : x; + } else { + return x; + } + }) + .toList(); approvedDatasetIds = approvedMappedDatasetIds; } exportDataset(user, approvedDatasetIds, requestedDatasetId, exportRequest.getPublicKey(), exportRequest.getStartCoordinate(), exportRequest.getEndCoordinate()); From 9a1c554e74ca4eebac31da9efaa3b98901354aca Mon Sep 17 00:00:00 2001 From: Parisa Tejari Date: Mon, 25 Nov 2024 16:06:31 +0100 Subject: [PATCH 2/2] remove unused imports --- .../java/no/uio/ifi/localega/doa/mq/ExportRequestsListener.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/no/uio/ifi/localega/doa/mq/ExportRequestsListener.java b/src/main/java/no/uio/ifi/localega/doa/mq/ExportRequestsListener.java index f9a9077..1521518 100644 --- a/src/main/java/no/uio/ifi/localega/doa/mq/ExportRequestsListener.java +++ b/src/main/java/no/uio/ifi/localega/doa/mq/ExportRequestsListener.java @@ -9,7 +9,6 @@ import lombok.extern.slf4j.Slf4j; import no.uio.ifi.localega.doa.dto.DestinationFormat; import no.uio.ifi.localega.doa.dto.ExportRequest; -import no.uio.ifi.localega.doa.model.Dataset; import no.uio.ifi.localega.doa.model.DatasetEventLog; import no.uio.ifi.localega.doa.services.AAIService; import no.uio.ifi.localega.doa.services.MetadataService; @@ -27,7 +26,6 @@ import java.io.InputStream; import java.util.Base64; import java.util.Collection; -import java.util.Objects; /** * RabbitMQ listener that processes incoming export requests.