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;
10 import java.util.HashMap;
12 import org.opendaylight.transportpce.nbinotifications.producer.Publisher;
13 import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NbiNotificationsListener;
14 import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.NotificationServiceBuilder;
15 import org.opendaylight.yang.gen.v1.nbi.notifications.rev201130.PublishNotificationService;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public class NbiNotificationsListenerImpl implements NbiNotificationsListener {
20 private static final Logger LOG = LoggerFactory.getLogger(NbiNotificationsListenerImpl.class);
21 private Map<String, Publisher> publishersMap = new HashMap<>();
23 public NbiNotificationsListenerImpl(Map<String, Publisher> publishersMap) {
24 this.publishersMap = publishersMap;
28 public void onPublishNotificationService(PublishNotificationService notification) {
29 LOG.info("Receiving request for publishing notification service");
30 String topic = notification.getTopic();
31 if (!publishersMap.containsKey(topic)) {
32 LOG.error("Unknown topic {}", topic);
35 Publisher publisher = publishersMap.get(topic);
36 publisher.sendEvent(new NotificationServiceBuilder().setCommonId(notification.getCommonId())
37 .setConnectionType(notification.getConnectionType()).setMessage(notification.getMessage())
38 .setOperationalState(notification.getOperationalState())
39 .setResponseFailed(notification.getResponseFailed())
40 .setServiceAEnd(notification.getServiceAEnd()).setServiceName(notification.getServiceName())
41 .setServiceZEnd(notification.getServiceZEnd()).build());