diff options
Diffstat (limited to 'cadi')
6 files changed, 29 insertions, 9 deletions
diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java index 6d0ea956..e50b52d8 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/configure/Agent.java @@ -319,11 +319,11 @@ public class Agent { lhost=Config.AAF_LOCATE_URL_TAG; } String value = rph.replacements("Agent:loadURLs", - proto + lhost + "/AAF_NS." + ("aaf".equals(u)?"service":u) + ':' + version, + proto + lhost + "/%CNS.%AAF_NS." + ("aaf".equals(u)?"service":u) + ':' + version, null,dot_le); switch(u) { case "aaf": rv.put(Config.AAF_URL, value); break; - case "locate": rv.put(Config.AAF_LOCATE_URL, value); break; + case "locate": rv.put(Config.getAAFLocateUrl(access), value); break; case "token": rv.put(Config.AAF_OAUTH2_TOKEN_URL, value); break; case "introspect": rv.put(Config.AAF_OAUTH2_INTROSPECT_URL, value); break; case "cm": rv.put(Config.AAF_URL_CM, value); break; @@ -823,7 +823,7 @@ public class Agent { app.add(es.getKey(), es.getValue()); } - app.add(Config.AAF_LOCATE_URL, propAccess, null); + app.add(Config.AAF_LOCATE_URL, Config.getAAFLocateUrl(propAccess)); app.add(Config.AAF_ENV,propAccess, "DEV"); String release = propAccess.getProperty(Config.AAF_RELEASE); if(release!=null) { diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java index f4e0a688..cbf0339b 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RegistrationCreator.java @@ -51,6 +51,7 @@ public class RegistrationCreator { try { String dot_le; String version=null; + String defProtocol="https"; RegistrationPropHolder ph = new RegistrationPropHolder(access, port); @@ -67,7 +68,7 @@ public class RegistrationCreator { defData = locate = new MgmtEndpoint(); version = access.getProperty(Config.AAF_LOCATOR_VERSION, Defaults.AAF_VERSION); - locate.setProtocol(access.getProperty(Config.AAF_LOCATOR_PROTOCOL,null)); + locate.setProtocol(defProtocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL,defProtocol)); List<String> ls = locate.getSubprotocol(); for(String sp : Split.splitTrim(',', access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL,""))) { ls.add(sp); @@ -95,7 +96,7 @@ public class RegistrationCreator { locate.setMajor(split.length>0?Integer.parseInt(split[0]):0); } - String protocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL + dot_le, null); + String protocol = access.getProperty(Config.AAF_LOCATOR_PROTOCOL + dot_le, defProtocol); if (protocol!=null) { locate.setProtocol(protocol); List<String> ls = locate.getSubprotocol(); diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java index 883410c0..3672c624 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/register/RemoteRegistrant.java @@ -24,6 +24,7 @@ package org.onap.aaf.cadi.register; import java.net.HttpURLConnection; import java.net.URI; import java.net.URISyntaxException; +import java.net.UnknownHostException; import org.onap.aaf.cadi.Access; import org.onap.aaf.cadi.Access.Level; @@ -35,6 +36,7 @@ import org.onap.aaf.cadi.client.Future; import org.onap.aaf.cadi.client.Rcli; import org.onap.aaf.cadi.client.Result; import org.onap.aaf.cadi.config.Config; +import org.onap.aaf.cadi.config.RegistrationPropHolder; import org.onap.aaf.cadi.locator.PropertyLocator; import org.onap.aaf.cadi.locator.SingleEndpointLocator; import org.onap.aaf.misc.env.APIException; @@ -66,12 +68,14 @@ public class RemoteRegistrant<ENV extends BasicEnv> implements Registrant<ENV> { } else { // Note: want Property Locator or Single, not AAFLocator, because we want the core service, not what it can find try { + RegistrationPropHolder rph = new RegistrationPropHolder(access, 0); + aaf_locate = rph.replacements(getClass().getSimpleName(),aaf_locate, null,null); if (aaf_locate.indexOf(',')>=0) { locator = new PropertyLocator(aaf_locate); } else { locator = new SingleEndpointLocator(aaf_locate); } - } catch (URISyntaxException e) { + } catch (URISyntaxException | UnknownHostException e) { throw new CadiException(e); } } diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java index 7c589ae3..10acc887 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/sso/AAFSSO.java @@ -298,7 +298,7 @@ public class AAFSSO { err.append("-D" + Config.AAF_APPPASS + "=<passwd> "); } - String locateUrl = access.getProperty(Config.AAF_LOCATE_URL); + String locateUrl = Config.getAAFLocateUrl(access); if (locateUrl==null) { locateUrl=AAFSSO.cons.readLine("AAF Locator URL=https://"); if (locateUrl==null || locateUrl.length()==0) { diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java index af344d2f..216b8660 100644 --- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java +++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/register/test/JU_RegistrationCreator.java @@ -62,7 +62,7 @@ public class JU_RegistrationCreator { assertEquals(0,me.getPatch()); assertEquals(0,me.getPkg()); assertEquals(entry,me.getName()); - assertEquals(null,me.getProtocol()); + assertEquals("https",me.getProtocol()); assertEquals(0,me.getSpecialPorts().size()); } diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java index 52bb53ef..66fbe847 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java @@ -151,6 +151,9 @@ public class Config { public static final String AAF_ROOT_NS = "aaf_root_ns"; public static final String AAF_ROOT_NS_DEF = "org.osaaf.aaf"; public static final String AAF_ROOT_COMPANY = "aaf_root_company"; + /** + * Use Config.getAAFLocateUrl(access) to get correct property in/out of container + */ public static final String AAF_LOCATE_URL = "aaf_locate_url"; //URL for AAF locator public static final String AAF_LOCATE_URL_TAG = "AAF_LOCATE_URL"; // Name of Above for use in Config Variables. public static final String AAF_DEFAULT_API_VERSION = "2.1"; @@ -561,7 +564,7 @@ public class Config { } access.log(Level.INIT, sb); - Locator<URI> locator = loadLocator(si, logProp(rph, AAF_LOCATE_URL, null)); + Locator<URI> locator = loadLocator(si, logProp(rph, Config.getAAFLocateUrl(access), null)); taf = new HttpEpiTaf(access,locator, tc, htarray); // ok to pass locator == null String level = logProp(access, CADI_LOGLEVEL, null); @@ -904,6 +907,18 @@ public class Config { public static String getDefaultRealm() { return defaultRealm; } + + public static String getAAFLocateUrl(Access access) { + String rv = null; + String cont = access.getProperty(AAF_LOCATOR_CONTAINER,null); + if(cont!=null) { + rv = access.getProperty(AAF_LOCATE_URL + '.' +cont, null); + } + if(rv==null) { + rv = access.getProperty(AAF_LOCATE_URL, null); + } + return rv; + } private static class Priori<T> implements Comparable<Priori<T>> { public final T t; |