diff options
Diffstat (limited to 'src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java')
-rw-r--r-- | src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java b/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java index f2c444c..39cfbd1 100644 --- a/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java +++ b/src/main/java/org/onap/dcaegen2/services/sonhms/DmaapNotificationsComponent.java @@ -26,9 +26,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import fj.data.Either; import java.io.IOException; - import org.onap.dcaegen2.services.sonhms.dao.DmaapNotificationsRepository; +import org.onap.dcaegen2.services.sonhms.dao.PerformanceNotificationsRepository; import org.onap.dcaegen2.services.sonhms.model.Notification; +import org.onap.dcaegen2.services.sonhms.model.PMNotification; import org.onap.dcaegen2.services.sonhms.utils.BeanUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,12 +39,15 @@ public class DmaapNotificationsComponent { private static Logger log = LoggerFactory.getLogger(DmaapNotificationsComponent.class); /** - * Get dmaap notifications. + * Get sdnr notifications */ - public Either<Notification, Integer> getDmaapNotifications() { + public Either<Notification, Integer> getSdnrNotifications() { DmaapNotificationsRepository dmaapNotificationsRepository = BeanUtil .getBean(DmaapNotificationsRepository.class); String notificationString = dmaapNotificationsRepository.getNotificationFromQueue(); + if (notificationString == null) { + return Either.right(404); + } ObjectMapper mapper = new ObjectMapper(); Notification notification = new Notification(); @@ -55,5 +59,26 @@ public class DmaapNotificationsComponent { return Either.right(400); } } + + /** + * Get pm notifications + */ + public Either<PMNotification,Integer> getPmNotifications(){ + PerformanceNotificationsRepository pmNotificationRepository = BeanUtil.getBean(PerformanceNotificationsRepository.class); + String pmNotificationString = pmNotificationRepository.getPerformanceNotificationFromQueue(); + if (pmNotificationString == null) { + return Either.right(404); + } + ObjectMapper mapper = new ObjectMapper(); + PMNotification pmNotification = new PMNotification(); + + try { + pmNotification = mapper.readValue(pmNotificationString, PMNotification.class); + return Either.left(pmNotification); + } catch(IOException e) { + log.error("Exception in parsing pm notification ",pmNotificationString,e); + return Either.right(400); + } + } } |