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=ef9ab45e3e992a9cc464e1355ff0edd4f3545af8;hb=a0180adc6a1e1ec09472549596428b70d48db3fc;hp=3026e8700cf879a5b27a6e08773287c8526b11a6;hpb=ace0b71ff6e424193ff6d6519a529d279e7ade58;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 3026e870..ef9ab45e 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 @@ -1,8 +1,8 @@ /*- * ========================LICENSE_START================================= - * ORAN-OSC + * 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. @@ -21,8 +21,7 @@ package org.oransc.ric.portal.dashboard.config; import java.lang.invoke.MethodHandles; -import org.oransc.ric.e2mgr.client.api.E2ManagerApi; -import org.oransc.ric.e2mgr.client.invoker.ApiClient; +import org.oransc.ric.portal.dashboard.model.RicRegionList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -30,37 +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.util.Assert; -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 e2mgrBasepath; + private final String urlSuffix; + private final RicRegionList instanceConfig; @Autowired - public E2ManagerConfiguration(@Value("${e2mgr.basepath}") final String e2mgrBasepath) { - Assert.notNull(e2mgrBasepath, "base path must not be null"); - logger.info("Configuring E2 Manager at base path {}", e2mgrBasepath); - this.e2mgrBasepath = e2mgrBasepath; - } - - private ApiClient apiClient() { - ApiClient apiClient = new ApiClient(new RestTemplate()); - apiClient.setBasePath(e2mgrBasepath); - return apiClient; + public E2ManagerConfiguration(@Value("${e2mgr.url.suffix}") final String urlSuffix, + final RicRegionList instanceConfig) { + logger.info("ctor: URL suffix {}", urlSuffix); + this.urlSuffix = urlSuffix; + this.instanceConfig = instanceConfig; } @Bean - public E2ManagerApi e2ManagerApi() { - return new E2ManagerApi(apiClient()); + // The bean (method) name must be globally unique + public E2ManagerApiBuilder e2ManagerApiBuilder() { + return new E2ManagerApiBuilder(instanceConfig, urlSuffix); } }