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.tapi.impl.rpc;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.HashMap;
13 import org.opendaylight.transportpce.tapi.utils.TapiContext;
14 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointList;
15 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointListInput;
16 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointListOutput;
17 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.GetServiceInterfacePointListOutputBuilder;
18 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.list.output.Sip;
19 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.list.output.SipBuilder;
20 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.get.service._interface.point.list.output.SipKey;
21 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePoint;
22 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev221121.tapi.context.ServiceInterfacePointKey;
23 import org.opendaylight.yangtools.yang.common.ErrorType;
24 import org.opendaylight.yangtools.yang.common.RpcResult;
25 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
30 public class GetServiceInterfacePointListImpl implements GetServiceInterfacePointList {
31 private static final Logger LOG = LoggerFactory.getLogger(GetServiceInterfacePointListImpl.class);
32 private final TapiContext tapiContext;
34 public GetServiceInterfacePointListImpl(TapiContext tapiContext) {
35 this.tapiContext = tapiContext;
39 public ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>> invoke(
40 GetServiceInterfacePointListInput input) {
41 Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips =
42 this.tapiContext.getTapiContext().getServiceInterfacePoint();
43 if (sips == null || sips.isEmpty()) {
44 return RpcResultBuilder.<GetServiceInterfacePointListOutput>failed()
45 .withError(ErrorType.RPC, "No sips in datastore")
48 Map<SipKey, Sip> outSipMap = new HashMap<>();
49 for (ServiceInterfacePoint sip : sips.values()) {
50 Sip si = new SipBuilder(sip).build();
51 outSipMap.put(si.key(), si);
53 return RpcResultBuilder
54 .success(new GetServiceInterfacePointListOutputBuilder().setSip(outSipMap).build())