Updates for DirectLocator 93/90693/1
authorInstrumental <jonathan.gathman@att.com>
Fri, 28 Jun 2019 22:16:33 +0000 (17:16 -0500)
committerInstrumental <jonathan.gathman@att.com>
Fri, 28 Jun 2019 22:16:37 +0000 (17:16 -0500)
Issue-ID: AAF-857
Change-Id: I55cdedad9dfaf4be8c785aa5f503f71fe4504070
Signed-off-by: Instrumental <jonathan.gathman@att.com>
auth/auth-cass/src/main/java/org/onap/aaf/auth/direct/DirectAAFLocator.java
auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
cadi/core/src/main/java/org/onap/aaf/cadi/config/RegistrationPropHolder.java

index 9845967..2f1d150 100644 (file)
@@ -73,9 +73,11 @@ public class DirectAAFLocator extends AbsAAFLocator<AuthzTrans> {
         }
         
         try {
-               String aaf_url = access.getProperty(Config.AAF_URL, null);
-               if(aaf_url==null) {
-                       aaf_url = "https://"+Config.AAF_LOCATE_URL_TAG+"/%NS."+name;
+               String aaf_url;
+               if(name.indexOf('.')>=0) {
+               aaf_url = "https://"+Config.AAF_LOCATE_URL_TAG+'/'+name+':'+version;
+               } else {
+               aaf_url = "https://"+Config.AAF_LOCATE_URL_TAG+"/%NS."+name+':'+version;
                }
                RegistrationPropHolder rph = new RegistrationPropHolder(access,0);
                aaf_url = rph.replacements(getClass().getSimpleName(),aaf_url, null,null);
index 26d0cc3..5ebabed 100644 (file)
@@ -199,8 +199,8 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
                        } catch (UnknownHostException | CadiException e) {
                                throw new LocatorException(e);
                        }
-            gui_locator = AbsAAFLocator.create(rph.getPublicEntryName("gui", rph.default_container),
-               Config.AAF_DEFAULT_API_VERSION);
+               String url = rph.getPublicEntryName("gui", rph.default_container);
+            gui_locator = AbsAAFLocator.create(url,Config.AAF_DEFAULT_API_VERSION);
         }
         return gui_locator;
     }
index 3941b15..e43250a 100644 (file)
@@ -122,6 +122,9 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
     }
         
     public static Locator<URI> create(final String name, final String version) throws LocatorException {
+       if(locatorCreator==null) {
+               throw new LocatorException("LocatorCreator is not set");
+       }
         return locatorCreator.create(name, version);
     }
 
index adb6918..2655b4c 100644 (file)
@@ -855,15 +855,30 @@ public class Config {
                        Method aalMth = aalCls.getMethod("create", String.class,String.class);
                        int colon = _url.lastIndexOf(':');
                        if(colon>=0) {
-                               String version = _url.substring(colon+1);
-                               int slash = _url.lastIndexOf('/',colon);
+                               int slash = _url.indexOf('/',colon);
+                               String version;
+                               if(slash<0) {
+                                       version = _url.substring(colon+1);
+                               } else {
+                                       version = _url.substring(colon+1,slash);
+                               }
+                               slash = _url.lastIndexOf('/',colon);
                                if(slash>=0) {
                                        Object aal = aalMth.invoke(null/*static*/, _url.substring(slash+1, colon),version);
                                        return (Locator<URI>)aal;
                                }
                        }
                } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
-                       access.log(Level.DEBUG, "Configured AbsAAFLocator not found.  Continuing Locator creation");
+                       String msg;
+                       char quote;
+                       if(e.getCause()!=null) {
+                               msg=e.getCause().getMessage();
+                               quote='"';
+                       } else {
+                               msg = "-";
+                               quote=' ';
+                       }
+                       access.printf(Level.DEBUG, "Configured AbsAAFLocator not found%c%s%cContinuing Locator creation ",quote,msg,quote);
                }
 //            String url = _url.replace("/AAF_NS.", "/%C%CID%AAF_NS.");
 //            String root_ns = access.getProperty(Config.AAF_ROOT_NS, null);
index 50f17e8..2a8760f 100644 (file)
@@ -263,9 +263,10 @@ public class RegistrationPropHolder {
                if(value.indexOf("%NS")>=0) {
                        str = getNS(dot_le);
                        if(str==null || str.isEmpty()) {
-                               value = value.replace("%NS"+'.', str);
+                               value = value.replace("%NS"+'.', "");
+                       } else {
+                               value = value.replace("%NS", str);
                        }
-                       value = value.replace("%NS", str);
                }
 
                // aaf_root_ns