X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=sdnc-a1-controller%2Fnorthbound%2Fnonrt-ric-api%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fo_ran_sc%2Fnonrtric%2Fsdnc_a1%2Fnorthbound%2Fprovider%2FNonrtRicApiProvider.java;fp=sdnc-a1-controller%2Fnorthbound%2Fnonrt-ric-api%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fo_ran_sc%2Fnonrtric%2Fsdnc_a1%2Fnorthbound%2Fprovider%2FNonrtRicApiProvider.java;h=0000000000000000000000000000000000000000;hb=b2ef1d832b94af02c7a3acefb4c8c5e4db03242b;hp=cf7ea35ecce0ec2d341ca677aa79bc766124052d;hpb=dfff24a65d219ce3985edbf744b034d1882e452f;p=nonrtric.git diff --git a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/o_ran_sc/nonrtric/sdnc_a1/northbound/provider/NonrtRicApiProvider.java b/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/o_ran_sc/nonrtric/sdnc_a1/northbound/provider/NonrtRicApiProvider.java deleted file mode 100644 index cf7ea35e..00000000 --- a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/o_ran_sc/nonrtric/sdnc_a1/northbound/provider/NonrtRicApiProvider.java +++ /dev/null @@ -1,247 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.o_ran_sc.nonrtric.sdnc_a1.northbound.provider; - -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import org.o_ran_sc.nonrtric.sdnc_a1.northbound.restadapter.RestAdapter; -import org.o_ran_sc.nonrtric.sdnc_a1.northbound.restadapter.RestAdapterImpl; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.A1ADAPTERAPIService; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.DeleteA1PolicyInput; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.DeleteA1PolicyOutput; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.DeleteA1PolicyOutputBuilder; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.GetA1PolicyInput; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.GetA1PolicyInputBuilder; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.GetA1PolicyOutput; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.GetA1PolicyOutputBuilder; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.GetA1PolicyStatusInput; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.GetA1PolicyStatusOutput; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.GetA1PolicyStatusOutputBuilder; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.GetA1PolicyTypeInput; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.GetA1PolicyTypeOutput; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.GetA1PolicyTypeOutputBuilder; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.PutA1PolicyInput; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.PutA1PolicyOutput; -import org.opendaylight.yang.gen.v1.org.o_ran_sc.nonrtric.sdnc_a1.northbound.a1.adapter.rev200122.PutA1PolicyOutputBuilder; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestClientResponseException; - -/** - * Defines a base implementation for your provider. This class overrides the - * generated interface from the YANG model and implements the request model for - * the A1 interface. This class identifies the Near-RT RIC throught the IP passed - * over the payload and calls the corresponding Near-RT RIC over Rest API - * - *
- * - * @author lathishbabu.ganesan@est.tech - * - */ - -@SuppressWarnings("squid:S1874") // "@Deprecated" code should not be used -public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService { - - protected static final String APP_NAME = "nonrt-ric-api"; - protected static final String NO_SERVICE_LOGIC_ACTIVE = "No service logic active for "; - private static final String NON_NULL_PARAM = "non-null"; - private static final String NULL_PARAM = "null"; - private static final String REST_CLIENT_RESPONSE_EXCEPTION_MSG = "Caught RestClientResponseException: {}"; - - private final Logger log = LoggerFactory.getLogger(NonrtRicApiProvider.class); - private final ExecutorService executor; - - protected DataBroker dataBroker; - protected NotificationPublishService notificationService; - protected RpcProviderRegistry rpcRegistry; - private RestAdapter restAdapter; - - public NonrtRicApiProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService, - RpcProviderRegistry rpcProviderRegistry) { - log.info("Creating provider for {}", APP_NAME); - executor = Executors.newFixedThreadPool(1); - setDataBroker(dataBroker); - setNotificationService(notificationPublishService); - setRpcRegistry(rpcProviderRegistry); - initialize(); - } - - public void initialize() { - log.info("Initializing provider for {}", APP_NAME); - restAdapter = new RestAdapterImpl(); - log.info("Initialization complete for {}", APP_NAME); - } - - @Override - public void close() throws Exception { - log.info("Closing provider for {}", APP_NAME); - executor.shutdown(); - log.info("Successfully closed provider for {}", APP_NAME); - } - - public void setDataBroker(DataBroker dataBroker) { - this.dataBroker = dataBroker; - if (log.isDebugEnabled()) { - log.debug("DataBroker set to {}", dataBroker == null ? NULL_PARAM : NON_NULL_PARAM); - } - } - - public void setNotificationService(NotificationPublishService notificationService) { - this.notificationService = notificationService; - if (log.isDebugEnabled()) { - log.debug("Notification Service set to {}", notificationService == null ? NULL_PARAM : NON_NULL_PARAM); - } - } - - public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { - this.rpcRegistry = rpcRegistry; - if (log.isDebugEnabled()) { - log.debug("RpcRegistry set to {}", rpcRegistry == null ? NULL_PARAM : NON_NULL_PARAM); - } - } - - @Override - public ListenableFuture> putA1Policy(PutA1PolicyInput input) { - log.info("Start of putPolicy"); - PutA1PolicyOutputBuilder putPolicyResponseBuilder = new PutA1PolicyOutputBuilder(); - - try { - final Uri uri = input.getNearRtRicUrl(); - log.info("PUT Request input.GetA1Policy() : {} ", uri); - ResponseEntity putPolicyResponse = restAdapter.put(uri.getValue(), input.getBody(), String.class); - if (putPolicyResponse.hasBody()) { - log.info("Response PutA1Policy : {} ", putPolicyResponse.getBody()); - putPolicyResponseBuilder.setBody(putPolicyResponse.getBody()); - } - putPolicyResponseBuilder.setHttpStatus(putPolicyResponse.getStatusCodeValue()); - } catch (RestClientResponseException ex) { - log.error(REST_CLIENT_RESPONSE_EXCEPTION_MSG, ex.getMessage()); - if (ex.getResponseBodyAsByteArray() != null) { - putPolicyResponseBuilder.setBody(ex.getResponseBodyAsString()); - } - putPolicyResponseBuilder.setHttpStatus(ex.getRawStatusCode()); - } - - log.info("End of PutA1Policy"); - RpcResult rpcResult = RpcResultBuilder. status(true) - .withResult(putPolicyResponseBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - @Override - public ListenableFuture > deleteA1Policy(DeleteA1PolicyInput input) { - log.info("Start of DeleteA1Policy"); - DeleteA1PolicyOutputBuilder deletePolicyResponseBuilder = new DeleteA1PolicyOutputBuilder(); - - try { - final Uri uri = input.getNearRtRicUrl(); - ResponseEntity