+
+ @Override
+ public ListenableFuture<RpcResult<GetServiceInterfacePointDetailsOutput>>
+ getServiceInterfacePointDetails(GetServiceInterfacePointDetailsInput input) {
+ Uuid sipUuid = getUuidFromIput(input.getSipIdOrName());
+ Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips =
+ this.tapiContext.getTapiContext().getServiceInterfacePoint();
+ if (sips == null || sips.isEmpty()) {
+ return RpcResultBuilder.<GetServiceInterfacePointDetailsOutput>failed().withError(RpcError.ErrorType.RPC,
+ "No sips in datastore").buildFuture();
+ }
+ if (!sips.containsKey(new ServiceInterfacePointKey(sipUuid))) {
+ return RpcResultBuilder.<GetServiceInterfacePointDetailsOutput>failed().withError(RpcError.ErrorType.RPC,
+ "Sip doesnt exist in datastore").buildFuture();
+ }
+ org.opendaylight.yang.gen.v1.urn
+ .onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.details.output.Sip outSip =
+ new org.opendaylight.yang.gen.v1.urn
+ .onf.otcc.yang.tapi.common.rev181210.get.service._interface.point.details.output.SipBuilder(
+ sips.get(new ServiceInterfacePointKey(sipUuid)))
+ .build();
+ return RpcResultBuilder.success(new GetServiceInterfacePointDetailsOutputBuilder().setSip(outSip).build())
+ .buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<GetServiceInterfacePointListOutput>>
+ getServiceInterfacePointList(GetServiceInterfacePointListInput input) {
+ Map<ServiceInterfacePointKey, ServiceInterfacePoint> sips =
+ this.tapiContext.getTapiContext().getServiceInterfacePoint();
+ if (sips == null || sips.isEmpty()) {
+ return RpcResultBuilder.<GetServiceInterfacePointListOutput>failed().withError(RpcError.ErrorType.RPC,
+ "No sips in datastore").buildFuture();
+ }
+ Map<SipKey, Sip> outSipMap = new HashMap<>();
+ for (ServiceInterfacePoint sip : sips.values()) {
+ Sip si = new SipBuilder(sip).build();
+ outSipMap.put(si.key(), si);
+ }
+ return RpcResultBuilder.success(new GetServiceInterfacePointListOutputBuilder().setSip(outSipMap).build())
+ .buildFuture();
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<UpdateServiceInterfacePointOutput>>
+ updateServiceInterfacePoint(UpdateServiceInterfacePointInput input) {
+ // TODO --> not yet implemented
+ return null;
+ }
+
+ private Uuid getUuidFromIput(String serviceIdOrName) {
+ try {
+ UUID.fromString(serviceIdOrName);
+ LOG.info("Given attribute {} is a UUID", serviceIdOrName);
+ return new Uuid(serviceIdOrName);
+ } catch (IllegalArgumentException e) {
+ LOG.info("Given attribute {} is not a UUID", serviceIdOrName);
+ return new Uuid(UUID.nameUUIDFromBytes(serviceIdOrName.getBytes(StandardCharsets.UTF_8)).toString());
+ }
+ }