aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java')
-rw-r--r--src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java b/src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java
new file mode 100644
index 0000000..47b338d
--- /dev/null
+++ b/src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java
@@ -0,0 +1,48 @@
+package org.onap.a1pesimulator.service.fileready;
+
+import static org.onap.a1pesimulator.service.fileready.FtpServerService.deletePMBulkFile;
+
+import java.io.File;
+
+import org.onap.a1pesimulator.data.fileready.FileData;
+import org.springframework.stereotype.Service;
+
+import reactor.core.publisher.Mono;
+
+/**
+ * Service for PM Bulk File creation and its handling
+ */
+
+@Service
+public class FileReadyEventService {
+
+ /**
+ * It will create FileReadyEvent.json which will go to VES Collector
+ *
+ * @return created FileReadyEvent
+ */
+ protected Mono<FileData> createFileReadyEventAndDeleteTmpFile(Mono<FileData> fileMono) {
+ return fileMono
+ .map(this::createFileReadyEvent)
+ .doOnNext(file -> deleteTempArchivedBulkFile(file.getArchivedPmBulkFile()));
+ }
+
+ /**
+ * Creates File Ready Event
+ *
+ * @param fileData information about PM Bulk Files created in previous steps
+ * @return added newly created FileReadyEvent to FileData
+ */
+ protected FileData createFileReadyEvent(FileData fileData) {
+ return fileData;
+ }
+
+ /**
+ * Deletes temporary archived PM Bulk File
+ *
+ * @param fileMono temporary archived PM Bulk File
+ */
+ private void deleteTempArchivedBulkFile(File fileMono) {
+ deletePMBulkFile(fileMono);
+ }
+}