aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorStanislav Marszalek <s.marszalek2@partner.samsung.com>2021-07-09 13:45:08 +0200
committerStanislav Marszalek <s.marszalek2@partner.samsung.com>2021-07-28 12:19:25 +0000
commitaaf4218122ed0e18912581a04ee677f6613b8e8f (patch)
tree51b199abecd9931c355ae3b9f69121cc9c69f981 /src/main/java
parent4ffe10537b208ee7ec6317e3592c398730a3ee8e (diff)
O1 PM Bulk support - File Ready Event creation
Issue-ID: INT-1945 Signed-off-by: Stanislav Marszalek <s.marszalek2@partner.samsung.com> Change-Id: If08908035719798d8d7b129ddcdb6ef89f1647fe
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java84
1 files changed, 84 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
index 47b338d..b5e7a9c 100644
--- a/src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java
+++ b/src/main/java/org/onap/a1pesimulator/service/fileready/FileReadyEventService.java
@@ -1,10 +1,22 @@
package org.onap.a1pesimulator.service.fileready;
import static org.onap.a1pesimulator.service.fileready.FtpServerService.deletePMBulkFile;
+import static org.onap.a1pesimulator.util.Constants.FILE_READY_CHANGE_IDENTIFIER;
+import static org.onap.a1pesimulator.util.Constants.FILE_READY_CHANGE_TYPE;
import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
import org.onap.a1pesimulator.data.fileready.FileData;
+import org.onap.a1pesimulator.data.fileready.FileReadyEvent;
+import org.onap.a1pesimulator.data.fileready.NotificationFields;
+import org.onap.a1pesimulator.data.fileready.NotificationFields.ArrayOfNamedHashMap;
+import org.onap.a1pesimulator.data.ves.CommonEventHeader;
+import org.onap.a1pesimulator.util.RanVesUtils;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import reactor.core.publisher.Mono;
@@ -16,6 +28,33 @@ import reactor.core.publisher.Mono;
@Service
public class FileReadyEventService {
+ private final FtpServerService ftpServerService;
+
+ @Value("${file.ready.version}")
+ private String version;
+
+ @Value("${file.ready.vesEventListenerVersion}")
+ private String vesEventListenerVersion;
+
+ @Value("${file.ready.domain}")
+ private String domain;
+
+ @Value("${file.ready.eventName}")
+ private String eventName;
+
+ @Value("${file.ready.fileFormatType}")
+ private String fileFormatType;
+
+ @Value("${file.ready.fileFormatVersion}")
+ private String fileFormatVersion;
+
+ @Value("${file.ready.notificationFieldsVersion}")
+ private String notificationFieldsVersion;
+
+ public FileReadyEventService(FtpServerService ftpServerService) {
+ this.ftpServerService = ftpServerService;
+ }
+
/**
* It will create FileReadyEvent.json which will go to VES Collector
*
@@ -34,10 +73,55 @@ public class FileReadyEventService {
* @return added newly created FileReadyEvent to FileData
*/
protected FileData createFileReadyEvent(FileData fileData) {
+ FileReadyEvent event = new FileReadyEvent();
+ event.setCommonEventHeader(getCommonHeader());
+ RanVesUtils.updateHeader(event);
+ event.setNotificationFields(getNotificationFields(fileData.getArchivedPmBulkFile().getName()));
+ fileData.setFileReadyEvent(event);
return fileData;
}
/**
+ * Creates NotificationFields section in FileReadyEvent
+ *
+ * @param fileName name of archived PM Bulk File
+ * @return NotificationFields object
+ */
+ private NotificationFields getNotificationFields(String fileName) {
+ NotificationFields notificationFields = NotificationFields.builder()
+ .changeIdentifier(FILE_READY_CHANGE_IDENTIFIER)
+ .changeType(FILE_READY_CHANGE_TYPE)
+ .notificationFieldsVersion(notificationFieldsVersion).build();
+
+ ArrayOfNamedHashMap arrayOfNamedHashMap = new ArrayOfNamedHashMap();
+ Map<String, String> hashMapItems = new HashMap<>();
+ hashMapItems.put("location", ftpServerService.getFtpPath() + fileName);
+ hashMapItems.put("compression", "gzip");
+ hashMapItems.put("fileFormatType", fileFormatType);
+ hashMapItems.put("fileFormatVersion", fileFormatVersion);
+
+ arrayOfNamedHashMap.setName(fileName);
+ arrayOfNamedHashMap.setHashMap(hashMapItems);
+ notificationFields.setArrayOfNamedHashMap(Collections.singletonList(arrayOfNamedHashMap));
+ return notificationFields;
+ }
+
+ /**
+ * Creates CommonEventHeader
+ *
+ * @return created CommonEventHeader
+ */
+ private CommonEventHeader getCommonHeader() {
+ return CommonEventHeader.builder()
+ .version(version)
+ .vesEventListenerVersion(vesEventListenerVersion)
+ .domain(domain)
+ .eventName(eventName)
+ .eventId(UUID.randomUUID().toString())
+ .build();
+ }
+
+ /**
* Deletes temporary archived PM Bulk File
*
* @param fileMono temporary archived PM Bulk File