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 org.opendaylight.transportpce.nbinotifications.impl.NbiNotificationsProvider;
12 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.Uuid;
13 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceDetails;
14 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceDetailsInput;
15 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceDetailsOutput;
16 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.GetNotificationSubscriptionServiceDetailsOutputBuilder;
17 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.context.NotificationContext;
18 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.get.notification.subscription.service.details.output.SubscriptionServiceBuilder;
19 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev221121.notification.context.NotifSubscriptionKey;
20 import org.opendaylight.yangtools.yang.common.ErrorType;
21 import org.opendaylight.yangtools.yang.common.RpcResult;
22 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
27 public class GetNotificationSubscriptionServiceDetailsImpl implements GetNotificationSubscriptionServiceDetails {
28 private static final Logger LOG = LoggerFactory.getLogger(GetNotificationSubscriptionServiceDetailsImpl.class);
30 private NbiNotificationsProvider nbiNotifications;
32 public GetNotificationSubscriptionServiceDetailsImpl(NbiNotificationsProvider nbiNotifications) {
33 this.nbiNotifications = nbiNotifications;
37 public ListenableFuture<RpcResult<GetNotificationSubscriptionServiceDetailsOutput>> invoke(
38 GetNotificationSubscriptionServiceDetailsInput input) {
39 if (input == null || input.getUuid() == null) {
40 LOG.warn("Missing mandatory params for input {}", input);
41 return RpcResultBuilder.<GetNotificationSubscriptionServiceDetailsOutput>failed()
42 .withError(ErrorType.RPC, "Missing input parameters")
45 Uuid notifSubsUuid = input.getUuid();
46 NotificationContext notificationContext = nbiNotifications.getNotificationContext();
47 if (notificationContext == null) {
48 return RpcResultBuilder.<GetNotificationSubscriptionServiceDetailsOutput>failed()
49 .withError(ErrorType.APPLICATION, "Notification context is empty")
52 var subsc = notificationContext.getNotifSubscription();
54 return RpcResultBuilder
56 new GetNotificationSubscriptionServiceDetailsOutputBuilder()
57 .setSubscriptionService(new SubscriptionServiceBuilder().build())
61 if (subsc.containsKey(new NotifSubscriptionKey(notifSubsUuid))) {
62 return RpcResultBuilder
64 new GetNotificationSubscriptionServiceDetailsOutputBuilder()
65 .setSubscriptionService(
66 new SubscriptionServiceBuilder(subsc.get(new NotifSubscriptionKey(notifSubsUuid))).build())
70 return RpcResultBuilder.<GetNotificationSubscriptionServiceDetailsOutput>failed()
71 .withError(ErrorType.APPLICATION, "Notification subscription service doesnt exist")