From be43e73e5d94e79b9295e846784c4a922f27b5f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Politowski?= Date: Wed, 18 Sep 2024 09:52:49 +0200 Subject: [PATCH] Don't base the use of id mappings on hardcoded provenance There will be more sources that need id mappings. Just use them if defined. --- .../urls_controller/services/BulkImportServiceImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/openaire/urls_controller/services/BulkImportServiceImpl.java b/src/main/java/eu/openaire/urls_controller/services/BulkImportServiceImpl.java index 6077937..c26e813 100644 --- a/src/main/java/eu/openaire/urls_controller/services/BulkImportServiceImpl.java +++ b/src/main/java/eu/openaire/urls_controller/services/BulkImportServiceImpl.java @@ -134,9 +134,9 @@ public class BulkImportServiceImpl implements BulkImportService { bulkImportReport.addEvent(msg); fileUtils.writeToFile(bulkImportReportLocation, bulkImportReport.getJsonReport(), false); - // If we have "provenance" = "springerImport", then we have to load the file-id-mappings. + // load the file-id-mappings if defined final ConcurrentHashMap idMappings; - if ( provenance.equals("springerImport") ) { + if ( bulkImportSource.getIdMappingFilePath() != null ) { idMappings = jsonUtils.loadIdMappings(bulkImportDirName + bulkImportSource.getIdMappingFilePath(), numOfFiles, additionalLoggingMsg); if ( idMappings == null ) { String errorMsg = "Could not load the file-id-mappings! As a result, the OpenAIRE-IDs cannot be generated!"; @@ -441,7 +441,7 @@ public class BulkImportServiceImpl implements BulkImportService { String fileLocation = docFileData.getLocation(); FileLocationData fileLocationData = null; String fileId; - if ( provenance.equals("springerImport") ) { + if ( idMappings != null ) { String relativeFileLocation = StringUtils.replace(fileLocation, bulkImportDirName, "", 1); if ( (fileId = idMappings.get(relativeFileLocation)) == null ) { // Take the "DOI" id matching to this file-ID. logger.error("File '" + fileLocation + "' could not have its relative-path (" + relativeFileLocation + ") mapped with an ID!" + additionalLoggingMsg);