Revise user controller to answer real data
[portal/ric-dashboard.git] / webapp-backend / src / main / java / org / oransc / ric / portal / dashboard / config / E2ManagerConfiguration.java
index 92bef31..21ca863 100644 (file)
@@ -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,8 +20,6 @@
 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;
@@ -34,12 +32,13 @@ import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.Profile;
 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());
@@ -48,10 +47,12 @@ public class E2ManagerConfiguration {
        private final String e2mgrUrl;
 
        @Autowired
-       public E2ManagerConfiguration(@Value("${e2mgr.url}") final String url) throws MalformedURLException {
-               logger.info("Configuring E2 Manager at base path {}", url);
-               new URL(url);
-               this.e2mgrUrl = url;
+       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() {
@@ -61,12 +62,14 @@ public class E2ManagerConfiguration {
        }
 
        @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());
        }