Collection syntax change because of Sonar
[aaf/authz.git] / cadi / aaf / src / main / java / org / onap / aaf / cadi / aaf / v2_0 / AbsAAFLocator.java
index ab0f595..f090906 100644 (file)
@@ -58,14 +58,24 @@ 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;
        private long earliest;
        private final long refreshWait;
 
 
        public AbsAAFLocator(Access access, String name, final long refreshMin) throws LocatorException {
                aaf_locator_host = access.getProperty(Config.AAF_LOCATE_URL, null);
+               if(aaf_locator_host==null) {
+                       aaf_locator_uri = null;
+               } else {
+                       try {
+                               aaf_locator_uri = new URI(aaf_locator_host);
+                       } catch (URISyntaxException e) {
+                               throw new LocatorException(e);
+                       }
+               }
 
-               epList = new LinkedList<EP>();
+               epList = new LinkedList<>();
                refreshWait = refreshMin;
 
                this.access = access;
@@ -82,21 +92,8 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
                        this.version = Config.AAF_DEFAULT_VERSION;
                } else {
                        String[] split = Split.split(':', name);
-                       
-                       switch(split.length) {
-                               case 1:
-                                       this.name = split[0];
-                                       this.version = Config.AAF_DEFAULT_VERSION;
-                                       break;
-                               case 0:
-                                       this.name = name;
-                                       this.version = Config.AAF_DEFAULT_VERSION;
-                                       break;
-                               default:
-                                       this.version = split[1];
-                                       this.name = split[0];
-                                       
-                       }
+                       this.name = split[0];
+                       this.version = (split.length > 1) ? split[1] : Config.AAF_DEFAULT_VERSION;
                }
                
        }
@@ -138,13 +135,11 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
                if(key.startsWith("http")) {
                        if(name!=null) {
                                if(locatorCreator != null) {
-                                       if(name!=null) {
-                                               AbsAAFLocator<?> aal = locatorCreator.create(name, version);
-                                               if(pathInfo!=null) {
-                                                       aal.setPathInfo(pathInfo);
-                                               }
-                                               return aal;
+                                       AbsAAFLocator<?> aal = locatorCreator.create(name, version);
+                                       if(pathInfo!=null) {
+                                               aal.setPathInfo(pathInfo);
                                        }
+                                       return aal;
                                }
                        } else {
                                return new PropertyLocator(key);
@@ -266,7 +261,7 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
                if(!hasItems()) {
                        throw new LocatorException("No Entries found" + (pathInfo==null?"":(" for " + pathInfo)));
                }
-               List<EP> lep = new ArrayList<EP>();
+               List<EP> lep = new ArrayList<>();
                EP first = null;
                // Note: Deque is sorted on the way by closest distance
                Iterator<EP> iter = getIterator();
@@ -491,7 +486,7 @@ public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
                        try {
                                return new URI(rv.getScheme(),rv.getUserInfo(),rv.getHost(),rv.getPort(),pathInfo,query,fragment);
                        } catch (URISyntaxException e) {
-                               throw new LocatorException("Error coping URL");
+                               throw new LocatorException("Error copying URL");
                        }
                }
                return rv;