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=21ca8637077e2a611e5d76a083921a043795ba33;hb=50fb3b40ec45a65ba7c687e290a3d7f491484b49;hp=1983623036d001b86202f3ad63ebf29026c5f955;hpb=4d6f9a14931a6aaaab28b482d73380e0960a82d6;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 19836230..21ca8637 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. @@ -31,41 +31,45 @@ 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; +import org.springframework.web.util.DefaultUriBuilderFactory; /** * Creates an E2 manager client 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 e2mgrUrl; @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; + public E2ManagerConfiguration(@Value("${e2mgr.url.prefix}") final String urlPrefix, + @Value("${e2mgr.url.suffix}") final String urlSuffix) { + logger.debug("ctor prefix '{}' suffix '{}'", urlPrefix, urlSuffix); + e2mgrUrl = new DefaultUriBuilderFactory(urlPrefix.trim()).builder().path(urlSuffix.trim()).build().normalize() + .toString(); + logger.info("Configuring E2 Manager at URL {}", e2mgrUrl); } private ApiClient apiClient() { ApiClient apiClient = new ApiClient(new RestTemplate()); - apiClient.setBasePath(e2mgrBasepath); + apiClient.setBasePath(e2mgrUrl); return apiClient; } @Bean - public HealthCheckApi e2HealthCheckApi() { + // The bean (method) name must be globally unique + public HealthCheckApi e2MgrHealthCheckApi() { return new HealthCheckApi(apiClient()); } @Bean - public NodebApi e2NodebApi() { + // The bean (method) name must be globally unique + public NodebApi e2MgrNodebApi() { return new NodebApi(apiClient()); }