2 * Copyright © 2024 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.impl.rpc;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.HashSet;
13 import org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsImpl;
14 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OBJECTTYPE;
15 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OBJECTTYPEPROFILE;
16 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OBJECTTYPESERVICEINTERFACEPOINT;
17 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.OBJECTTYPETAPICONTEXT;
18 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CONNECTIVITYOBJECTTYPE;
19 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CONNECTIVITYOBJECTTYPECONNECTION;
20 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CONNECTIVITYOBJECTTYPECONNECTIONENDPOINT;
21 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.connectivity.rev221121.CONNECTIVITYOBJECTTYPECONNECTIVITYSERVICE;
22 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetSupportedNotificationTypes;
23 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetSupportedNotificationTypesInput;
24 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetSupportedNotificationTypesOutput;
25 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetSupportedNotificationTypesOutputBuilder;
26 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.NOTIFICATIONTYPE;
27 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.NOTIFICATIONTYPEATTRIBUTEVALUECHANGE;
28 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.NOTIFICATIONTYPEOBJECTCREATION;
29 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.NOTIFICATIONTYPEOBJECTDELETION;
30 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.context.NotificationContext;
31 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.TOPOLOGYOBJECTTYPEINTERRULEGROUP;
32 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.TOPOLOGYOBJECTTYPELINK;
33 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.TOPOLOGYOBJECTTYPENODE;
34 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.TOPOLOGYOBJECTTYPENODEEDGEPOINT;
35 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev221121.TOPOLOGYOBJECTTYPENODERULEGROUP;
36 import org.opendaylight.yangtools.yang.common.ErrorType;
37 import org.opendaylight.yangtools.yang.common.RpcResult;
38 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
41 public class GetSupportedNotificationTypesImpl implements GetSupportedNotificationTypes {
43 private NbiNotificationsImpl nbiNotifications;
45 public GetSupportedNotificationTypesImpl(NbiNotificationsImpl nbiNotifications) {
46 this.nbiNotifications = nbiNotifications;
50 public ListenableFuture<RpcResult<GetSupportedNotificationTypesOutput>> invoke(
51 GetSupportedNotificationTypesInput input) {
52 NotificationContext notificationContext = nbiNotifications.getNotificationContext();
53 if (notificationContext == null) {
54 return RpcResultBuilder.<GetSupportedNotificationTypesOutput>failed()
55 .withError(ErrorType.APPLICATION, "Couldnt get Notification Context from Datastore")
58 //TAPI 2.4 removes supported notification types from notif-subscription list and notification-context
59 //No way to store what notification types are supported
60 //Considers that by default all notification are supported
61 Set<NOTIFICATIONTYPE> notificationTypeList = new HashSet<>();
62 notificationTypeList.add(NOTIFICATIONTYPEOBJECTCREATION.VALUE);
63 notificationTypeList.add(NOTIFICATIONTYPEOBJECTDELETION.VALUE);
64 notificationTypeList.add(NOTIFICATIONTYPEATTRIBUTEVALUECHANGE.VALUE);
66 // if (notificationContext.getNotifSubscription() == null) {
67 // return RpcResultBuilder.success(new GetSupportedNotificationTypesOutputBuilder()
68 // .setSupportedNotificationTypes(new HashSet<>())
69 // .setSupportedObjectTypes(new HashSet<>()).build()).buildFuture();
71 // Set<NOTIFICATIONTYPE> notificationTypeList = new HashSet<>();
73 //TAPI 2.4 removes supported object types from notif-subscription list and notification-context
74 //No way to store what object types are supported
75 //Considers that by default all object are supported
76 Set<OBJECTTYPE> objectTypeList = new HashSet<>();
77 objectTypeList.add(OBJECTTYPESERVICEINTERFACEPOINT.VALUE);
78 objectTypeList.add(OBJECTTYPETAPICONTEXT.VALUE);
79 objectTypeList.add(OBJECTTYPEPROFILE.VALUE);
80 objectTypeList.add(TOPOLOGYOBJECTTYPENODE.VALUE);
81 objectTypeList.add(TOPOLOGYOBJECTTYPELINK.VALUE);
82 objectTypeList.add(TOPOLOGYOBJECTTYPENODEEDGEPOINT.VALUE);
83 objectTypeList.add(TOPOLOGYOBJECTTYPENODERULEGROUP.VALUE);
84 objectTypeList.add(TOPOLOGYOBJECTTYPEINTERRULEGROUP.VALUE);
85 objectTypeList.add(CONNECTIVITYOBJECTTYPE.VALUE);
86 objectTypeList.add(CONNECTIVITYOBJECTTYPECONNECTIVITYSERVICE.VALUE);
87 objectTypeList.add(CONNECTIVITYOBJECTTYPECONNECTIONENDPOINT.VALUE);
88 objectTypeList.add(CONNECTIVITYOBJECTTYPECONNECTION.VALUE);
89 // for (NotifSubscription notifSubscription:notificationContext.getNotifSubscription().values()) {
90 // if (notifSubscription.getSupportedNotificationTypes() != null) {
91 // notificationTypeList.addAll(notifSubscription.getSupportedNotificationTypes());
93 // if (notifSubscription.getSupportedObjectTypes() != null) {
94 // objectTypeList.addAll(notifSubscription.getSupportedObjectTypes());
97 return RpcResultBuilder.success(new GetSupportedNotificationTypesOutputBuilder()
98 .setSupportedNotificationTypes(notificationTypeList)
99 .setSupportedObjectTypes(objectTypeList).build()).buildFuture();