X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=sdnc-a1-controller%2Fnorthbound%2Fnonrt-ric-api%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fsdnc%2Fnorthbound%2Fprovider%2FNonrtRicApiProvider.java;h=b41615b517a321b0b5637810601646ce003f2701;hb=f700867fa65c7172cee7fca229eb10f2ecdf77dd;hp=95acacb2fe0ae2baf1af28be215375aa7dc34193;hpb=8ca0695e455183b0fa23c3b5cd4b65ca08dd9e24;p=nonrtric.git diff --git a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/provider/NonrtRicApiProvider.java b/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/provider/NonrtRicApiProvider.java index 95acacb2..b41615b5 100644 --- a/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/provider/NonrtRicApiProvider.java +++ b/sdnc-a1-controller/northbound/nonrt-ric-api/provider/src/main/java/org/onap/sdnc/northbound/provider/NonrtRicApiProvider.java @@ -23,11 +23,9 @@ package org.onap.sdnc.northbound.provider; import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; -import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.onap.sdnc.northbound.restadapter.NearRicUrlProvider; import org.onap.sdnc.northbound.restadapter.RestAdapter; import org.onap.sdnc.northbound.restadapter.RestAdapterImpl; import org.opendaylight.controller.md.sal.binding.api.DataBroker; @@ -37,21 +35,23 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.A1ADAPTERAPIService; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.DeletePolicyInput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.DeletePolicyOutput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.DeletePolicyOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyIdentitiesInput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyIdentitiesOutput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyIdentitiesOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeIdentitiesInput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeIdentitiesOutput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeIdentitiesOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeInput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeOutput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetPolicyTypeOutputBuilder; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.PutPolicyInput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.PutPolicyOutput; -import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.PutPolicyOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.DeleteA1PolicyInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.DeleteA1PolicyOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.DeleteA1PolicyOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetA1PolicyInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetA1PolicyInputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetA1PolicyOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetA1PolicyOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetA1PolicyStatusInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetA1PolicyStatusOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetA1PolicyStatusOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetA1PolicyTypeInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetA1PolicyTypeOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.GetA1PolicyTypeOutputBuilder; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.PutA1PolicyInput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.a1.adapter.rev200122.PutA1PolicyOutput; +import org.opendaylight.yang.gen.v1.org.onap.sdnc.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; @@ -59,10 +59,10 @@ import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; /** - * 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-RIC throught the IP passed over the payload and calls the corresponding Near-RIC over - * Rest API + * 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-RIC throught the IP passed + * over the payload and calls the corresponding Near-RIC over Rest API * *
* @@ -86,10 +86,8 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService { protected RpcProviderRegistry rpcRegistry; protected BindingAwareBroker.RpcRegistration> rpcRegistration; private RestAdapter restAdapter; - private NearRicUrlProvider nearRicUrlProvider; - public NonrtRicApiProvider(DataBroker dataBroker, - NotificationPublishService notificationPublishService, + public NonrtRicApiProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService, RpcProviderRegistry rpcProviderRegistry) { log.info("Creating provider for {}", APP_NAME); executor = Executors.newFixedThreadPool(1); @@ -104,7 +102,6 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService { log.info("Initializing provider for {}", APP_NAME); createContainers(); restAdapter = new RestAdapterImpl(); - nearRicUrlProvider = new NearRicUrlProvider(); log.info("Initialization complete for {}", APP_NAME); } @@ -130,8 +127,7 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService { public void setNotificationService(NotificationPublishService notificationService) { this.notificationService = notificationService; if (log.isDebugEnabled()) { - log.debug("Notification Service set to {}", - notificationService == null ? NULL_PARAM : NON_NULL_PARAM); + log.debug("Notification Service set to {}", notificationService == null ? NULL_PARAM : NON_NULL_PARAM); } } @@ -158,84 +154,91 @@ public class NonrtRicApiProvider implements AutoCloseable, A1ADAPTERAPIService { } @Override - public ListenableFuture> getPolicyTypeIdentities( - GetPolicyTypeIdentitiesInput input) { - log.info("Start of getPolicyTypeIdentities"); - GetPolicyTypeIdentitiesOutputBuilder responseBuilder = new GetPolicyTypeIdentitiesOutputBuilder(); - String uri = nearRicUrlProvider.policyTypesUrl(String.valueOf(input.getNearRtRicUrl())); - ResponseEntity > response = restAdapter.get(uri, List.class); + public ListenableFuture
> putA1Policy(PutA1PolicyInput input) { + log.info("Start of putPolicy"); + final Uri uri = input.getNearRtRicUrl(); + + log.info("PUT Request input.GetA1Policy() : {} ", uri); + ResponseEntity response = restAdapter.put(uri.getValue(), input.getBody(), String.class); + PutA1PolicyOutputBuilder responseBuilder = new PutA1PolicyOutputBuilder(); if (response.hasBody()) { - log.info("Response getPolicyTypeIdentities : {} ", response.getBody()); - responseBuilder.setPolicyTypeIdList(response.getBody()); + log.info("Response PutA1Policy : {} ", response.getBody()); + responseBuilder.setBody(response.getBody()); } - log.info("End of getPolicyTypeIdentities"); - RpcResult rpcResult = RpcResultBuilder. status(true) + responseBuilder.setHttpStatus(response.getStatusCodeValue()); + log.info("End of PutA1Policy"); + RpcResult rpcResult = RpcResultBuilder. status(true) .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @Override - public ListenableFuture > getPolicyIdentities(GetPolicyIdentitiesInput input) { - log.info("Start of getPolicyIdentities"); - GetPolicyIdentitiesOutputBuilder responseBuilder = new GetPolicyIdentitiesOutputBuilder(); - String uri = nearRicUrlProvider.policiesUrl(String.valueOf(input.getNearRtRicUrl())); - ResponseEntity > response = restAdapter.get(uri, List.class); + public ListenableFuture
> deleteA1Policy(DeleteA1PolicyInput input) { + log.info("Start of DeleteA1Policy"); + final Uri uri = input.getNearRtRicUrl(); + ResponseEntity