2 * Copyright © 2020 Orange, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.transportpce.nbinotifications.listener;
11 import org.opendaylight.transportpce.nbinotifications.producer.Publisher;
12 import org.opendaylight.transportpce.nbinotifications.producer.PublisherAlarm;
13 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NbiNotificationsListener;
14 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationAlarmServiceBuilder;
15 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.NotificationServiceBuilder;
16 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationAlarmService;
17 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210628.PublishNotificationService;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
21 public class NbiNotificationsListenerImpl implements NbiNotificationsListener {
22 private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsListenerImpl.class);
23 private Map<String, Publisher> publishersServiceMap;
24 private Map<String, PublisherAlarm> publishersAlarmMap;
26 public NbiNotificationsListenerImpl(Map<String, Publisher> publishersServiceMap,
27 Map<String, PublisherAlarm> publishersAlarmMap) {
28 this.publishersServiceMap = publishersServiceMap;
29 this.publishersAlarmMap = publishersAlarmMap;
33 public void onPublishNotificationService(PublishNotificationService notification) {
34 LOG.info("Receiving request for publishing notification service");
35 String topic = notification.getTopic();
36 if (!publishersServiceMap.containsKey(topic)) {
37 LOG.error("Unknown topic {}", topic);
40 Publisher publisher = publishersServiceMap.get(topic);
41 publisher.sendEvent(new NotificationServiceBuilder().setCommonId(notification.getCommonId())
42 .setConnectionType(notification.getConnectionType()).setMessage(notification.getMessage())
43 .setOperationalState(notification.getOperationalState())
44 .setResponseFailed(notification.getResponseFailed())
45 .setServiceAEnd(notification.getServiceAEnd())
46 .setServiceName(notification.getServiceName())
47 .setServiceZEnd(notification.getServiceZEnd()).build());
51 public void onPublishNotificationAlarmService(PublishNotificationAlarmService notification) {
52 LOG.info("Receiving request for publishing notification alarm service");
53 String topic = notification.getTopic();
54 if (!publishersAlarmMap.containsKey(topic)) {
55 LOG.error("Unknown topic {}", topic);
58 PublisherAlarm publisherAlarm = publishersAlarmMap.get(topic);
59 publisherAlarm.sendEvent(new NotificationAlarmServiceBuilder().setConnectionType(notification
61 .setMessage(notification.getMessage())
62 .setOperationalState(notification.getOperationalState())
63 .setServiceName(notification.getServiceName())