diff options
Diffstat (limited to 'datafile-app-server/src/main')
4 files changed, 11 insertions, 21 deletions
diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/FileData.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/FileData.java index d0d1f91a..037bd0d3 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/FileData.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/model/FileData.java @@ -20,7 +20,6 @@ import java.net.URI; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Optional; - import org.immutables.gson.Gson; import org.immutables.value.Value; import org.onap.dcaegen2.collectors.datafile.ftp.FileServerData; @@ -35,7 +34,7 @@ import org.onap.dcaegen2.collectors.datafile.ftp.Scheme; @Value.Immutable @Gson.TypeAdapters public abstract class FileData { - private static final String DATAFILE_TMPDIR = "/tmp/onap_datafile/"; + public static final String DATAFILE_TMPDIR = "/tmp/onap_datafile/"; /** * @return the file name with no path @@ -71,12 +70,8 @@ public abstract class FileData { return URI.create(location()).getPath(); } - public Path getLocalFileName() { - return createLocalFileName(messageMetaData().sourceName(), name()); - } - - public static Path createLocalFileName(String sourceName, String fileName) { - return Paths.get(DATAFILE_TMPDIR, sourceName + "_" + fileName); + public Path getLocalFilePath() { + return Paths.get(DATAFILE_TMPDIR, name()); } public FileServerData fileServerData() { diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java index 4207d1fc..8c1a2cf4 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java @@ -26,7 +26,6 @@ import static org.onap.dcaegen2.collectors.datafile.model.logging.MdcVariables.X import com.google.gson.JsonElement; import com.google.gson.JsonParser; - import java.io.IOException; import java.io.InputStream; import java.net.URI; @@ -34,7 +33,6 @@ import java.nio.file.Path; import java.time.Duration; import java.util.Map; import java.util.UUID; - import org.apache.commons.io.IOUtils; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpPut; @@ -52,7 +50,6 @@ import org.slf4j.MDC; import org.springframework.core.io.FileSystemResource; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; - import reactor.core.publisher.Mono; /** @@ -129,7 +126,7 @@ public class DataRouterPublisher { metaData.getAsJsonObject().remove(NAME_JSON_TAG).getAsString(); metaData.getAsJsonObject().remove(INTERNAL_LOCATION_JSON_TAG); put.addHeader(X_DMAAP_DR_META, metaData.toString()); - put.setURI(getPublishUri(model.getInternalLocation().getFileName().toString())); + put.setURI(getPublishUri(model.getName())); } private void prepareBody(ConsumerDmaapModel model, HttpPut put) throws IOException { diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java index 8849b45e..158bcb29 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/FileCollector.java @@ -65,7 +65,7 @@ public class FileCollector { logger.trace("starting to collectFile {}", fileData.name()); final String remoteFile = fileData.remoteFilePath(); - final Path localFile = fileData.getLocalFileName(); + final Path localFile = fileData.getLocalFilePath(); try (FileCollectClient currentClient = createClient(fileData)) { currentClient.open(); 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 b4096c73..2a6e4c0d 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 @@ -22,7 +22,6 @@ import java.time.Duration; import java.time.Instant; import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; - import org.onap.dcaegen2.collectors.datafile.configuration.AppConfig; import org.onap.dcaegen2.collectors.datafile.model.ConsumerDmaapModel; import org.onap.dcaegen2.collectors.datafile.model.FileData; @@ -34,7 +33,6 @@ import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.core.scheduler.Scheduler; @@ -144,9 +142,9 @@ public class ScheduledTasks { private boolean shouldBePublished(FileData fileData, Map<String, String> contextMap) { boolean result = false; - Path localFileName = fileData.getLocalFileName(); - if (alreadyPublishedFiles.put(localFileName) == null) { - result = !createPublishedChecker().execute(localFileName.getFileName().toString(), contextMap); + Path localFilePath = fileData.getLocalFilePath(); + if (alreadyPublishedFiles.put(localFilePath) == null) { + result = !createPublishedChecker().execute(fileData.name(), contextMap); } return result; } @@ -160,10 +158,10 @@ public class ScheduledTasks { private Mono<ConsumerDmaapModel> handleFetchFileFailure(FileData fileData, Map<String, String> contextMap) { MdcVariables.setMdcContextMap(contextMap); - Path localFileName = fileData.getLocalFileName(); + Path localFilePath = fileData.getLocalFilePath(); logger.error("File fetching failed, fileData {}", fileData); - deleteFile(localFileName, contextMap); - alreadyPublishedFiles.remove(localFileName); + deleteFile(localFilePath, contextMap); + alreadyPublishedFiles.remove(localFilePath); currentNumberOfTasks.decrementAndGet(); return Mono.empty(); } |