X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-backend%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fconfig%2FE2ManagerConfiguration.java;h=4b25622af8b7af89afcf0e00d244c79f5d9d0f3b;hb=e020df304f6faa1d90f64ddea14407aec1c15dcb;hp=6e791e3cef12d99a80ce94dd48ddf52576dc5e54;hpb=81c5a43871449332f9a9560c7cf25d07cf714d8e;p=portal%2Fric-dashboard.git diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/E2ManagerConfiguration.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/E2ManagerConfiguration.java index 6e791e3c..4b25622a 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/E2ManagerConfiguration.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/E2ManagerConfiguration.java @@ -2,7 +2,7 @@ * ========================LICENSE_START================================= * O-RAN-SC * %% - * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * Copyright (C) 2019 AT&T Intellectual Property * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,12 +20,8 @@ package org.oransc.ric.portal.dashboard.config; import java.lang.invoke.MethodHandles; -import java.net.MalformedURLException; -import java.net.URL; -import org.oransc.ric.e2mgr.client.api.HealthCheckApi; -import org.oransc.ric.e2mgr.client.api.NodebApi; -import org.oransc.ric.e2mgr.client.invoker.ApiClient; +import org.oransc.ric.portal.dashboard.model.RicInstanceList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -33,43 +29,33 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; -import org.springframework.web.client.RestTemplate; /** - * Creates an E2 manager client as a bean to be managed by the Spring container. + * Creates an E2 manager client builder as a bean to be managed by the Spring + * container. */ @Configuration -@Profile("!mock") +@Profile("!test") public class E2ManagerConfiguration { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); // Populated by the autowired constructor - private final String e2mgrUrl; + private final String urlSuffix; + private final RicInstanceList instanceConfig; @Autowired - public E2ManagerConfiguration(@Value("${e2mgr.url}") final String url) throws MalformedURLException { - logger.info("Configuring E2 Manager at base URL {}", url); - new URL(url); - this.e2mgrUrl = url; - } - - private ApiClient apiClient() { - ApiClient apiClient = new ApiClient(new RestTemplate()); - apiClient.setBasePath(e2mgrUrl); - return apiClient; - } - - @Bean - // The bean (method) name must be globally unique - public HealthCheckApi e2MgrHealthCheckApi() { - return new HealthCheckApi(apiClient()); + public E2ManagerConfiguration(@Value("${e2mgr.url.suffix}") final String urlSuffix, + final RicInstanceList instanceConfig) { + logger.info("ctor: URL suffix {}", urlSuffix); + this.urlSuffix = urlSuffix; + this.instanceConfig = instanceConfig; } @Bean // The bean (method) name must be globally unique - public NodebApi e2MgrNodebApi() { - return new NodebApi(apiClient()); + public E2ManagerApiBuilder e2ManagerApiBuilder() { + return new E2ManagerApiBuilder(instanceConfig, urlSuffix); } }