X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=webapp-backend%2Fsrc%2Fmain%2Fjava%2Forg%2Foransc%2Fric%2Fportal%2Fdashboard%2Fconfig%2FAnrXappConfiguration.java;h=dbb78c7b6ede546172a51e62fcc623fcc63b51bf;hb=50fb3b40ec45a65ba7c687e290a3d7f491484b49;hp=d6063abbaedfb40608357da95fc7b1f209dc8d32;hpb=c95e48b5c8cdf93a351859889bb785b317253dde;p=portal%2Fric-dashboard.git diff --git a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AnrXappConfiguration.java b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AnrXappConfiguration.java index d6063abb..dbb78c7b 100644 --- a/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AnrXappConfiguration.java +++ b/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/AnrXappConfiguration.java @@ -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()); }