Add mock user data to backend
[portal/ric-dashboard.git] / webapp-backend / src / main / java / org / oransc / ric / portal / dashboard / config / XappManagerConfiguration.java
index 3714b82..1b699de 100644 (file)
@@ -1,6 +1,6 @@
 /*-
  * ========================LICENSE_START=================================
- * ORAN-OSC
+ * O-RAN-SC
  * %%
  * Copyright (C) 2019 AT&T Intellectual Property and Nokia
  * %%
 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.DefaultApi;
+import org.oransc.ric.xappmgr.client.api.HealthApi;
+import org.oransc.ric.xappmgr.client.api.XappApi;
 import org.oransc.ric.xappmgr.client.invoker.ApiClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -30,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;
 
 /**
@@ -44,23 +46,36 @@ 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(xappMgrUrl);
+               return apiClient;
        }
 
        /**
-        * @return A DefaultApi with an ApiClient configured from properties
+        * @return A HealthApi with an ApiClient configured from properties
         */
        @Bean
-       public DefaultApi xappClient() {
-               ApiClient apiClient = new ApiClient(new RestTemplate());
-               apiClient.setBasePath(xappMgrBasepath);
-               return new DefaultApi(apiClient);
+       // The bean (method) name must be globally unique
+       public HealthApi xappMgrHealthApi() {
+               return new HealthApi(apiClient());
        }
 
+       /**
+        * @return An XappApi with an ApiClient configured from properties
+        */
+       @Bean
+       // The bean (method) name must be globally unique
+       public XappApi xappMgrXappApi() {
+               return new XappApi(apiClient());
+       }
 }