Add mock user data to backend
[portal/ric-dashboard.git] / webapp-backend / src / main / java / org / oransc / ric / portal / dashboard / config / XappManagerConfiguration.java
index 00cd939..1b699de 100644 (file)
@@ -20,6 +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.xappmgr.client.api.HealthApi;
 import org.oransc.ric.xappmgr.client.api.XappApi;
@@ -31,7 +33,6 @@ 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;
 
 /**
@@ -45,18 +46,18 @@ public class XappManagerConfiguration {
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        // Populated by the autowired constructor
-       private final String xappMgrBasepath;
+       private final String xappMgrUrl;
 
        @Autowired
-       public XappManagerConfiguration(@Value("${xappmgr.basepath}") final String xappMgrBasepath) {
-               Assert.notNull(xappMgrBasepath, "base path must not be null");
-               logger.info("Configuring xApp Manager at base path {}", xappMgrBasepath);
-               this.xappMgrBasepath = xappMgrBasepath;
+       public XappManagerConfiguration(@Value("${xappmgr.url}") final String url) throws MalformedURLException {
+               logger.info("Configuring xApp Manager at base URL {}", url);
+               new URL(url);
+               this.xappMgrUrl = url;
        }
 
        private ApiClient apiClient() {
                ApiClient apiClient = new ApiClient(new RestTemplate());
-               apiClient.setBasePath(xappMgrBasepath);
+               apiClient.setBasePath(xappMgrUrl);
                return apiClient;
        }
 
@@ -64,7 +65,8 @@ public class XappManagerConfiguration {
         * @return A HealthApi with an ApiClient configured from properties
         */
        @Bean
-       public HealthApi xappHealthApi() {
+       // The bean (method) name must be globally unique
+       public HealthApi xappMgrHealthApi() {
                return new HealthApi(apiClient());
        }
 
@@ -72,7 +74,8 @@ public class XappManagerConfiguration {
         * @return An XappApi with an ApiClient configured from properties
         */
        @Bean
-       public XappApi xappMgrApi() {
+       // The bean (method) name must be globally unique
+       public XappApi xappMgrXappApi() {
                return new XappApi(apiClient());
        }
 }