Code Review
/
aaf
/
authz.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Sonar fixes related to exceptions"
[aaf/authz.git]
/
cadi
/
aaf
/
src
/
main
/
java
/
org
/
onap
/
aaf
/
cadi
/
aaf
/
v2_0
/
AbsAAFLocator.java
diff --git
a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
index
fc29760
..
fca2374
100644
(file)
--- a/
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
+++ b/
cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java
@@
-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.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;
import org.onap.aaf.cadi.Locator;
import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.config.Config;
@@
-58,14
+59,24
@@
public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
protected String myhostname;
protected int myport;
protected final String aaf_locator_host;
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);
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;
refreshWait = refreshMin;
this.access = access;
@@
-77,6
+88,12
@@
public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
latitude = Double.parseDouble(lat);
longitude = Double.parseDouble(lng);
}
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;
if(name.startsWith("http")) { // simple URL
this.name = name;
this.version = Config.AAF_DEFAULT_VERSION;
@@
-118,6
+135,8
@@
public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
version = split[1];
name = split[0];
break;
version = split[1];
name = split[0];
break;
+ default:
+ break;
}
}
}
}
}
}
@@
-197,7
+216,7
@@
public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
}
private boolean noEntries() {
}
private boolean noEntries() {
- return epList.
size()<=0
;
+ return epList.
isEmpty()
;
}
@Override
}
@Override
@@
-249,9
+268,9
@@
public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
@Override
public Item best() throws LocatorException {
if(!hasItems()) {
@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
>();
+ List<EP> lep = new ArrayList<>();
EP first = null;
// Note: Deque is sorted on the way by closest distance
Iterator<EP> iter = getIterator();
EP first = null;
// Note: Deque is sorted on the way by closest distance
Iterator<EP> iter = getIterator();
@@
-406,8
+425,8
@@
public abstract class AbsAAFLocator<TRANS extends Trans> implements Locator<URI>
}
protected static class EP implements Comparable<EP> {
}
protected static class EP implements Comparable<EP> {
- p
ublic
URI uri;
- p
ublic
final double distance;
+ p
rivate
URI uri;
+ p
rivate
final double distance;
private boolean valid;
public EP(final Endpoint ep, double latitude, double longitude) throws URISyntaxException {
private boolean valid;
public EP(final Endpoint ep, double latitude, double longitude) throws URISyntaxException {
@@
-476,7
+495,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) {
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;
}
}
return rv;