X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fcore%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Fconfig%2FRegistrationPropHolder.java;h=68a018d67561f4f86c0b3f8d13992ce9e5280253;hb=2b46f76d9a688acf326424659ec9672a2614fdcf;hp=b6cd533cb79b4f1592cafbe56f01236e2ad8501a;hpb=e43bc462af00e9c05384313514b279e11372fd79;p=aaf%2Fauthz.git diff --git a/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java b/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java index b6cd533c..68a018d6 100644 --- a/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java +++ b/cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java @@ -41,6 +41,7 @@ public class RegistrationPropHolder { public final String default_name; public final String lentries; public final String lcontainer; + public final String default_container; public RegistrationPropHolder(final Access access, final int port) throws UnknownHostException, CadiException { this.access = access; @@ -50,15 +51,15 @@ public class RegistrationPropHolder { lentries=access.getProperty(Config.AAF_LOCATOR_ENTRIES,""); - str = access.getProperty(Config.AAF_LOCATOR_CONTAINER, ""); - if(!str.isEmpty()) { - lcontainer=',' + str; // "" makes a blank default Public Entry - str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT+'.'+str, null); + default_container = access.getProperty(Config.AAF_LOCATOR_CONTAINER, ""); + if(!default_container.isEmpty()) { + lcontainer=',' + default_container; // "" makes a blank default Public Entry + str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT+'.'+default_container, null); if(str==null) { str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT, null); } } else { - lcontainer=str; + lcontainer=default_container; str = access.getProperty(Config.AAF_LOCATOR_PUBLIC_PORT, null); } if(str!=null) { @@ -149,47 +150,42 @@ public class RegistrationPropHolder { } - public String replacements(String source, final String name, final String dot_le) { + public String replacements(String source, final String name, final String _dot_le) { if(source == null) { return ""; } else if(source.isEmpty()) { return source; } - String str; - // aaf_locate_url - if(source.indexOf(Config.AAF_LOCATE_URL_TAG)>=0) { - str = access.getProperty(Config.AAF_LOCATE_URL, null); - if(str!=null) { - if(!str.endsWith("/")) { - str+='/'; - } - if(!str.endsWith("/locate/")) { - str+="locate/"; - } - source = source.replace("https://AAF_LOCATE_URL/", str); - } + + String dot_le; + if(_dot_le==null) { + dot_le = default_container.isEmpty()?"":'.'+default_container; + } else { + dot_le = _dot_le; } - if(source.indexOf("%NS")>=0) { - str = getNS(dot_le); - if(str==null || str.isEmpty()) { - source = source.replace("%NS"+'.', str); - } - source = source.replace("%NS", str); - } + String aaf_locator_host = access.getProperty(Config.AAF_LOCATE_URL+dot_le,null); + if(aaf_locator_host==null) { + aaf_locator_host = access.getProperty(Config.AAF_LOCATE_URL,null); + } - // aaf_root_ns - if(source.indexOf("AAF_NS")>=0) { - str = access.getProperty(Config.AAF_ROOT_NS, null); - if(str!=null) { - String temp = source.replace("%AAF_NS", str); - if(temp == source) { // intended - source = source.replace("AAF_NS", str); // Backward Compatibility - } else { - source = temp; + String str; + if(aaf_locator_host!=null) { + if("https://AAF_LOCATE_URL".equals(source)) { + source = aaf_locator_host; + } else { + str = aaf_locator_host; + if(source.indexOf(Config.AAF_LOCATE_URL_TAG)>=0) { + if(!str.endsWith("/")) { + str+='/'; + } + if(!str.endsWith("/locate/")) { + str+="locate/"; + } + source = source.replace("https://AAF_LOCATE_URL/", str); } } - } + } int atC = source.indexOf("%C"); if(atC>=0) { @@ -200,18 +196,44 @@ public class RegistrationPropHolder { } source = source.replace("%CNS", str); - str = access.getProperty(Config.AAF_LOCATOR_CONTAINER+dot_le, ""); + str = access.getProperty(Config.AAF_LOCATOR_CONTAINER+dot_le,default_container); if(str.isEmpty()) { source = source.replace("%C"+'.', str); } source = source.replace("%C", str); } + if(source.indexOf("%NS")>=0) { + str = getNS(dot_le); + if(str==null || str.isEmpty()) { + source = source.replace("%NS"+'.', str); + } + source = source.replace("%NS", str); + } + + // aaf_root_ns + if(source.indexOf("AAF_NS")>=0) { + str = access.getProperty(Config.AAF_ROOT_NS, Config.AAF_ROOT_NS_DEF); + String temp = source.replace("%AAF_NS", str); + if(temp.equals(source)) { // intended + source = source.replace("AAF_NS", str); // Backward Compatibility + } else { + source = temp; + } + } + + if(source.indexOf('%')>=0) { - // These shouldn't be expected to have dot elements - source = source.replace("%N", name); - source = source.replace("%DF", default_fqdn); - source = source.replace("%PH", public_hostname); + // These shouldn't be expected to have dot elements + if(name!=null) { + source = source.replace("%N", name); + } + if(default_fqdn!=null) { + source = source.replace("%DF", default_fqdn); + } + if(public_hostname!=null) { + source = source.replace("%PH", public_hostname); + } } return source; } @@ -221,4 +243,8 @@ public class RegistrationPropHolder { public_port: port; } + + public Access access() { + return access; + } } \ No newline at end of file