X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Faaf%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Faaf%2Fv2_0%2FAbsAAFLocator.java;h=5ef25bcdc43ae8ee70f4bbe5965370b6d0fadc13;hb=6309ef454e6960d95d13534645e1f15904de6862;hp=2405962c882a75b87674922b583738716dbbf0d4;hpb=133592f4d210a3e509c1c53a736e87ec2f1533ce;p=aaf%2Fauthz.git diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java index 2405962c..5ef25bcd 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java @@ -66,15 +66,20 @@ public abstract class AbsAAFLocator implements Locator public AbsAAFLocator(Access access, String name, final long refreshMin) throws LocatorException { - RegistrationPropHolder rph; - try { - rph = new RegistrationPropHolder(access, 0); - } catch (UnknownHostException | CadiException e1) { - throw new LocatorException(e1); - } + RegistrationPropHolder rph; try { - aaf_locator_host = rph.replacements(getClass().getSimpleName(),"https://"+Config.AAF_LOCATE_URL_TAG,null,null); - aaf_locator_uri = new URI(aaf_locator_host); + rph = new RegistrationPropHolder(access, 0); + } catch (UnknownHostException | CadiException e1) { + throw new LocatorException(e1); + } + URI aaf_locator_uri; + try { + aaf_locator_host = rph.replacements(getClass().getSimpleName(),"https://"+Config.AAF_LOCATE_URL_TAG,null,null); + if(aaf_locator_host.endsWith("/locate")) { + aaf_locator_uri = new URI(aaf_locator_host); + } else { + aaf_locator_uri = new URI(aaf_locator_host+"/locate"); + } access.printf(Level.INFO, "AbsAAFLocator AAF URI is %s",aaf_locator_uri); } catch (URISyntaxException e) { throw new LocatorException(e); @@ -105,9 +110,8 @@ public abstract class AbsAAFLocator implements Locator this.name = split[0]; this.version = (split.length > 1) ? split[1] : access.getProperty(Config.AAF_API_VERSION,Config.AAF_DEFAULT_API_VERSION); } - } - + /** * This is the way to setup specialized AAFLocators ahead of time. * @param preload @@ -117,6 +121,9 @@ public abstract class AbsAAFLocator implements Locator } public static Locator create(final String name, final String version) throws LocatorException { + if(locatorCreator==null) { + throw new LocatorException("LocatorCreator is not set"); + } return locatorCreator.create(name, version); } @@ -130,7 +137,7 @@ public abstract class AbsAAFLocator implements Locator if (path.length>1 && "locate".equals(path[1])) { return path[2]; } else if(path.length>1) { - return path[1]; + return path[1]; } else { return locatorURI.toString(); } @@ -229,7 +236,7 @@ public abstract class AbsAAFLocator implements Locator @Override public Item best() throws LocatorException { if (!hasItems()) { - throw new LocatorException("No Entries found for '" + aaf_locator_uri.toString() + "/locate/" + name + ':' + version + '\''); + throw new LocatorException("No Entries found for '" + aaf_locator_uri.toString() + '/' + name + ':' + version + '\''); } List lep = new ArrayList<>(); EP first = null; @@ -360,7 +367,7 @@ public abstract class AbsAAFLocator implements Locator } return null; } - + protected static class AAFLItem implements Item { private Iterator iter; private URI uri; @@ -463,8 +470,8 @@ public abstract class AbsAAFLocator implements Locator } protected void clear() { - epList.clear(); - earliest=0L; + epList.clear(); + earliest=0L; }