Agent correctly sort Cert Chain/Truststore
[aaf/authz.git] / cadi / aaf / src / main / java / org / onap / aaf / cadi / aaf / v2_0 / AbsAAFLocator.java
index 14878d3..3941b15 100644 (file)
@@ -60,7 +60,7 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
     protected String myhostname;
     protected int myport;
     protected final String aaf_locator_host;
-    protected final URI aaf_locator_uri;
+    protected URI aaf_locator_uri;
     private long earliest;
     private final long refreshWait;
 
@@ -73,14 +73,19 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
                        throw new LocatorException(e1);
                }
         try {
-               aaf_locator_host = rph.replacements("https://"+Config.AAF_LOCATE_URL_TAG,null,null);
-            aaf_locator_uri = new URI(aaf_locator_host);
+               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);
         }
 
-        name = rph.replacements(name, null,null);
+        name = rph.replacements(getClass().getSimpleName(),name, null,null);
         access.printf(Level.INFO, "AbsAAFLocator name is %s",aaf_locator_uri);
 
         epList = new LinkedList<>();
@@ -229,7 +234,7 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
     @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<EP> lep = new ArrayList<>();
         EP first = null;
@@ -462,5 +467,10 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
         return rv;
     }
 
+    protected void clear() {
+       epList.clear();
+       earliest=0L;
+    }
+
 
 }