Switch to new Locate Features
[aaf/authz.git] / cadi / aaf / src / main / java / org / onap / aaf / cadi / register / RegistrationCreator.java
index ac71516..cbf0339 100644 (file)
@@ -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,18 +96,29 @@ 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);
-                                       String subprotocols = access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL + dot_le, null);
-                                       if(subprotocols!=null) {
-                                               List<String> ls = locate.getSubprotocol();
-                                               for (String s : Split.split(',', subprotocols)) {
-                                                       ls.add(s);
-                                               }
-                                       }
+                                               List<String> ls = locate.getSubprotocol();
+                                               // ls cannot be null, per generated getSubprotocol code
+                                               if(ls.isEmpty()) {
+                                               String subprotocols = access.getProperty(Config.AAF_LOCATOR_SUBPROTOCOL + dot_le, null);
+                                               if(subprotocols==null) {
+                                                       subprotocols = access.getProperty(Config.CADI_PROTOCOLS, null);
+                                               }
+                                               if(subprotocols!=null) {
+                                                       for (String s : Split.split(',', subprotocols)) {
+                                                               ls.add(s);
+                                                       }
+                                               } else {
+                                                       access.printf(Level.ERROR, "%s is required for Locator Registration of %s",
+                                                                       Config.AAF_LOCATOR_SUBPROTOCOL,Config.AAF_LOCATOR_PROTOCOL);
+                                               }
+                                               }
+                                       lme.add(locate);
+                               } else {
+                                       access.printf(Level.ERROR, "%s is required for Locator Registration",Config.AAF_LOCATOR_PROTOCOL);
                                }
-                               lme.add(locate);
                        }
                }
        } catch (NumberFormatException | UnknownHostException e) {