Revise user controller to answer real data
[portal/ric-dashboard.git] / webapp-backend / src / main / java / org / oransc / ric / portal / dashboard / config / AnrXappConfiguration.java
index d6063ab..dbb78c7 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.
@@ -21,7 +21,6 @@ package org.oransc.ric.portal.dashboard.config;
 
 import java.lang.invoke.MethodHandles;
 
-import org.oransc.ric.anrxapp.client.api.GnodebsApi;
 import org.oransc.ric.anrxapp.client.api.HealthApi;
 import org.oransc.ric.anrxapp.client.api.NcrtApi;
 import org.oransc.ric.anrxapp.client.invoker.ApiClient;
@@ -32,45 +31,44 @@ 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 instances of the ANR xApp client APIs.
  */
 @Configuration
-@Profile("!mock")
+@Profile("!test")
 public class AnrXappConfiguration {
 
        private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
        // Populated by the autowired constructor
-       private final String anrXappBasepath;
+       private final String anrXappUrl;
 
        @Autowired
-       public AnrXappConfiguration(@Value("${anrxapp.basepath}") final String anrXappBasepath) {
-               Assert.notNull(anrXappBasepath, "base path must not be null");
-               logger.info("Configuring ANR client at base path {}", anrXappBasepath);
-               this.anrXappBasepath = anrXappBasepath;
+       public AnrXappConfiguration(@Value("${anrxapp.url.prefix}") final String urlPrefix,
+                       @Value("${anrxapp.url.suffix}") final String urlSuffix) {
+               logger.debug("ctor prefix '{}' suffix '{}'", urlPrefix, urlSuffix);
+               anrXappUrl = new DefaultUriBuilderFactory(urlPrefix.trim()).builder().path(urlSuffix.trim()).build().normalize()
+                               .toString();
+               logger.info("Configuring ANR client at URL {}", anrXappUrl);
        }
 
        private ApiClient apiClient() {
                ApiClient apiClient = new ApiClient(new RestTemplate());
-               apiClient.setBasePath(anrXappBasepath);
+               apiClient.setBasePath(anrXappUrl);
                return apiClient;
        }
 
        @Bean
+       // The bean (method) name must be globally unique
        public HealthApi anrHealthApi() {
                return new HealthApi(apiClient());
        }
 
        @Bean
-       public GnodebsApi anrGnodebsApi() {
-               return new GnodebsApi(apiClient());
-       }
-
-       @Bean
+       // The bean (method) name must be globally unique
        public NcrtApi anrNcrtApi() {
                return new NcrtApi(apiClient());
        }