aboutsummaryrefslogtreecommitdiffstats
path: root/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java
diff options
context:
space:
mode:
authorPatrikBuhr <patrik.buhr@est.tech>2022-05-11 13:10:40 +0200
committerPatrikBuhr <patrik.buhr@est.tech>2022-08-17 12:53:13 +0200
commit97ace6245fb8b7238d2f7f871797ba03df2d435f (patch)
tree94f6f437cd0e62b192a23eabc58d95fc71f5b82b /a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java
parenta3e382b49db0cbdee32396cf9c7028d9f9b4a231 (diff)
NONRTRIC PMS, Cherry-pick the recent changes into Jakarta Release1.3.3
Sqasch of cherrypicked commits for the maintenance release. Issue-ID: CCSDK-3742 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS added support for custom A1 adapters Added support for added external A1-P adapter. This makes it possible to design and include adapter to APIs for accessing of A1 policies (in a NearRT-RIC) without any changes in this SW. Issue-ID: CCSDK-3655 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS added support for custom A1 adapters Updates of the json schema for configuration. Made it stricter and added the customAdapterClass prpoperty. Issue-ID: CCSDK-3655 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS removalof usage of immutable Issue-ID: CCSDK-3629 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS, Sporadic instability Attempt to stablize the synch. Issue-ID: CCSDK-3683 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS, Sporadic instability Attempt to stablize the synch. Issue-ID: CCSDK-3683 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS, Sporadic instability Some further simplifications and added test. Issue-ID: CCSDK-3683 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> Change-Id: I1ec98017d63047a0036db5ea12f770db00b1152b NONRTRIC PMS, updated SDNC rest interface Update path and output-json for SDNC rest interface - A1 Kohn Issue-ID: CCSDK-3193 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS, Bugfix If the auth-token-file parameter in the file application.yaml is missing, it would not default to an empty file name. Issue-ID: CCSDK-3683 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> NONRTRIC PMS, updated certs Updated certificate (which was expired). Issue-ID: CCSDK-3683 Signed-off-by: PatrikBuhr <patrik.buhr@est.tech> Change-Id: I34ffc932d855ba3b94cfff23dcb56f30780dbecc
Diffstat (limited to 'a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java')
-rw-r--r--a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java32
1 files changed, 27 insertions, 5 deletions
diff --git a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java
index 1d465c3a..75ba2515 100644
--- a/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java
+++ b/a1-policy-management/src/main/java/org/onap/ccsdk/oran/a1policymanagementservice/clients/A1ClientFactory.java
@@ -20,9 +20,12 @@
package org.onap.ccsdk.oran.a1policymanagementservice.clients;
+import java.lang.reflect.Constructor;
+
import org.onap.ccsdk.oran.a1policymanagementservice.clients.A1Client.A1ProtocolType;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ApplicationConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.configuration.ControllerConfig;
+import org.onap.ccsdk.oran.a1policymanagementservice.configuration.RicConfig;
import org.onap.ccsdk.oran.a1policymanagementservice.exceptions.ServiceException;
import org.onap.ccsdk.oran.a1policymanagementservice.repository.Ric;
import org.slf4j.Logger;
@@ -83,6 +86,8 @@ public class A1ClientFactory {
|| version == A1ProtocolType.CCSDK_A1_ADAPTER_OSC_V1
|| version == A1ProtocolType.CCSDK_A1_ADAPTER_STD_V2_0_0) {
return new CcsdkA1AdapterClient(version, ric.getConfig(), getControllerConfig(ric), this.restClientFactory);
+ } else if (version == A1ProtocolType.CUSTOM_PROTOCOL) {
+ return createCustomAdapter(ric);
} else {
logger.error("Unhandled protocol: {}", version);
throw new ServiceException("Unhandled protocol");
@@ -90,7 +95,7 @@ public class A1ClientFactory {
}
private ControllerConfig getControllerConfig(Ric ric) throws ServiceException {
- String controllerName = ric.getConfig().controllerName();
+ String controllerName = ric.getConfig().getControllerName();
if (controllerName.isEmpty()) {
ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
throw new ServiceException("No controller configured for Near-RT RIC: " + ric.id());
@@ -103,8 +108,27 @@ public class A1ClientFactory {
}
}
+ private A1Client createCustomAdapter(Ric ric) throws ServiceException {
+ try {
+ Class<?> clazz = Class.forName(ric.getConfig().getCustomAdapterClass());
+ if (A1Client.class.isAssignableFrom(clazz)) {
+ Constructor<?> constructor = clazz.getConstructor(RicConfig.class, AsyncRestClientFactory.class);
+ return (A1Client) constructor.newInstance(ric.getConfig(), this.restClientFactory);
+ } else if (A1Client.Factory.class.isAssignableFrom(clazz)) {
+ A1Client.Factory factory = (A1Client.Factory) clazz.getDeclaredConstructor().newInstance();
+ return factory.create(ric.getConfig(), this.restClientFactory);
+ } else {
+ throw new ServiceException("The custom class must either implement A1Client.Factory or A1Client");
+ }
+ } catch (ClassNotFoundException e) {
+ throw new ServiceException("Could not find class: " + ric.getConfig().getCustomAdapterClass(), e);
+ } catch (Exception e) {
+ throw new ServiceException("Cannot create custom adapter: " + ric.getConfig().getCustomAdapterClass(), e);
+ }
+ }
+
private void assertNoControllerConfig(Ric ric, A1ProtocolType version) throws ServiceException {
- if (!ric.getConfig().controllerName().isEmpty()) {
+ if (!ric.getConfig().getControllerName().isEmpty()) {
ric.setProtocolVersion(A1ProtocolType.UNKNOWN);
throw new ServiceException(
"Controller config should be empty, ric: " + ric.id() + " when using protocol version: " + version);
@@ -128,9 +152,7 @@ public class A1ClientFactory {
.doOnNext(ric::setProtocolVersion)
.doOnNext(version -> logger.debug("Established protocol version:{} for Near-RT RIC: {}", version,
ric.id())) //
- .doOnError(notUsed -> logger.warn("Could not get protocol version from Near-RT RIC: {}", ric.id())) //
- .onErrorResume(
- notUsed -> Mono.error(new ServiceException("Protocol negotiation failed for " + ric.id())));
+ .doOnError(notUsed -> logger.warn("Could not get protocol version from Near-RT RIC: {}", ric.id()));
} else {
return Mono.just(ric.getProtocolVersion());
}