Non-functional changes to silence Sonar
[portal/ric-dashboard.git] / webapp-backend / src / main / java / org / oransc / ric / portal / dashboard / config / E2ManagerConfiguration.java
index 3026e87..4289a88 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ========================LICENSE_START=================================
- * ORAN-OSC
+ * O-RAN-SC
  * %%
  * Copyright (C) 2019 AT&T Intellectual Property and Nokia
  * %%
@@ -21,7 +21,8 @@ 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.api.HealthCheckApi;
+import org.oransc.ric.e2mgr.client.api.NodebApi;
 import org.oransc.ric.e2mgr.client.invoker.ApiClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,8 +31,8 @@ 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.
@@ -43,24 +44,33 @@ 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 E2ManagerApi e2ManagerApi() {
-               return new E2ManagerApi(apiClient());
+       // The bean (method) name must be globally unique
+       public HealthCheckApi e2MgrHealthCheckApi() {
+               return new HealthCheckApi(apiClient());
+       }
+
+       @Bean
+       // The bean (method) name must be globally unique
+       public NodebApi e2MgrNodebApi() {
+               return new NodebApi(apiClient());
        }
 
 }