diff options
Diffstat (limited to 'datafile-app-server')
-rw-r--r-- | datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java index de45da31..42a6fea3 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/ScheduledTasks.java @@ -220,17 +220,26 @@ public class ScheduledTasks { private boolean shouldBePublished(FileDataWithContext fileData) { Path localFilePath = fileData.fileData.getLocalFilePath(); - if (publishedFilesCache.put(localFilePath) == null) { - try { - return !createPublishedChecker().isFilePublished(fileData.fileData.name(), + boolean shouldBePublished = (publishedFilesCache.put(localFilePath) == null); + if (shouldBePublished) { + shouldBePublished = checkIfFileIsNotPublishedInDataRouter(fileData); + } + + if (!shouldBePublished) { + logger.debug("File: {} is being processed or was already published. Skipping.", fileData.fileData.name()); + } + return shouldBePublished; + } + + private boolean checkIfFileIsNotPublishedInDataRouter(FileDataWithContext fileData) { + boolean isNotPublished = true; + try { + isNotPublished = !createPublishedChecker().isFilePublished(fileData.fileData.name(), fileData.fileData.messageMetaData().changeIdentifier(), fileData.context); - } catch (DatafileTaskException e) { - logger.error("Cannot check if a file {} is published", fileData.fileData.name(), e); - return true; // Publish it then - } - } else { - return false; + } catch (DatafileTaskException e) { + logger.error("Cannot check if a file {} is published", fileData.fileData.name(), e); } + return isNotPublished; } private Mono<FilePublishInformation> fetchFile(FileDataWithContext fileData) { |