Merge "Sonar fixes related to exceptions"
authorJonathan Gathman <jonathan.gathman@att.com>
Fri, 20 Jul 2018 21:57:39 +0000 (21:57 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 20 Jul 2018 21:57:39 +0000 (21:57 +0000)
1  2 
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java

@@@ -32,7 -32,6 +32,7 @@@ import java.util.NoSuchElementException
  
  import org.onap.aaf.cadi.Access;
  import org.onap.aaf.cadi.Access.Level;
 +import org.onap.aaf.cadi.aaf.Defaults;
  import org.onap.aaf.cadi.Locator;
  import org.onap.aaf.cadi.LocatorException;
  import org.onap.aaf.cadi.config.Config;
@@@ -88,12 -87,6 +88,12 @@@ public abstract class AbsAAFLocator<TRA
                        latitude = Double.parseDouble(lat);
                        longitude = Double.parseDouble(lng);
                }
 +              if(name.startsWith(Defaults.AAF_NS)) {
 +                      String root_ns = access.getProperty(Config.AAF_ROOT_NS, null);
 +                      if(root_ns!=null) {
 +                              name=name.replace(Defaults.AAF_NS, root_ns);
 +                      }
 +              }
                if(name.startsWith("http")) { // simple URL
                        this.name = name;
                        this.version = Config.AAF_DEFAULT_VERSION;
                                                version = split[1];
                                                name = split[0];
                                                break;
+                                       default:
+                                               break;
                                }
                        }
                }
        }
  
        private boolean noEntries() {
-               return epList.size()<=0;
+               return epList.isEmpty();
        }
  
        @Override
        @Override
        public Item best() throws LocatorException {
                if(!hasItems()) {
 -                      throw new LocatorException("No Entries found" + (pathInfo==null?"":(" for " + pathInfo)));
 +                      throw new LocatorException("No Entries found for '" + aaf_locator_uri.toString() + "/locate/" + name + ':' + version + '\'');
                }
                List<EP> lep = new ArrayList<>();
                EP first = null;
                }
  
        protected static class EP implements Comparable<EP> {
-               public URI uri;
-               public final double distance;
+               private URI uri;
+               private final double distance;
                private boolean valid;
                
                public EP(final Endpoint ep, double latitude, double longitude) throws URISyntaxException {
                        try {
                                return new URI(rv.getScheme(),rv.getUserInfo(),rv.getHost(),rv.getPort(),pathInfo,query,fragment);
                        } catch (URISyntaxException e) {
-                               throw new LocatorException("Error copying URL");
+                               throw new LocatorException("Error copying URL", e);
                        }
                }
                return rv;