import java.util.LinkedList;
import java.util.List;
+import org.onap.aaf.cadi.Access;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.SecuritySetter;
import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.cadi.config.SecurityInfoC;
import org.onap.aaf.cadi.http.HClient;
+import org.onap.aaf.cadi.util.FixURIinfo;
import org.onap.aaf.cadi.util.Split;
import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.Data.TYPE;
public AAFLocator(SecurityInfoC<HttpURLConnection> si, URI locatorURI) throws LocatorException {
super(si.access, nameFromLocatorURI(locatorURI), 10000L /* Wait at least 10 seconds between refreshes */);
synchronized(sr) {
- if(env==null) {
+ if (env==null) {
env = new RosettaEnv(access.getProperties());
}
}
int connectTimeout = Integer.parseInt(si.access.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF));
try {
String[] path = Split.split('/',locatorURI.getPath());
- String host = locatorURI.getHost();
- if(host==null) {
- host = locatorURI.getAuthority(); // this happens when no port
- }
- if("AAF_LOCATE_URL".equals(host)) {
- URI uri = new URI(
- locatorURI.getScheme(),
- locatorURI.getUserInfo(),
- aaf_locator_uri.getHost(),
- aaf_locator_uri.getPort(),
- "/locate"+locatorURI.getPath(),
- null,
- null
- );
- client = createClient(si.defSS, uri, connectTimeout);
- } else if(path.length>1 && "locate".equals(path[1])) {
+ FixURIinfo fui = new FixURIinfo(locatorURI);
+ if ("AAF_LOCATE_URL".equals(fui.getHost())) {
+ client = createClient(si.defSS, locatorURI, connectTimeout);
+ } else if (path.length>1 && "locate".equals(path[1])) {
StringBuilder sb = new StringBuilder();
- for(int i=3;i<path.length;++i) {
+ for (int i=3;i<path.length;++i) {
sb.append('/');
sb.append(path[i]);
}
setPathInfo(sb.toString());
- URI uri = new URI(
- locatorURI.getScheme(),
- locatorURI.getUserInfo(),
- locatorURI.getHost(),
- locatorURI.getPort(),
- "/locate/"+name + ':' + version,
- null,
- null
- );
- client = createClient(si.defSS, uri, connectTimeout);
+// URI uri = new URI(
+// locatorURI.getScheme(),
+// locatorURI.getAuthority(),
+// locatorURI.getPath(),
+// null,
+// null
+// );
+ client = createClient(si.defSS, locatorURI, connectTimeout);
} else {
client = new HClient(si.defSS, locatorURI, connectTimeout);
}
epsDF = env.newDataFactory(Endpoints.class);
- } catch (APIException | URISyntaxException e) {
+
+ } catch (APIException /*| URISyntaxException*/ e) {
throw new LocatorException(e);
}
+
+ if(si.access.willLog(Access.Level.DEBUG)) {
+ si.access.log(Access.Level.DEBUG, "Root URI:",client.getURI());
+ }
}
@Override
client.setMethod("GET");
client.send();
Future<Endpoints> fr = client.futureRead(epsDF, TYPE.JSON);
- if(fr.get(client.timeout())) {
+ if (fr.get(client.timeout())) {
List<EP> epl = new LinkedList<>();
- for(Endpoint endpoint : fr.value.getEndpoint()) {
+ for (Endpoint endpoint : fr.value.getEndpoint()) {
epl.add(new EP(endpoint,latitude,longitude));
}
protected HClient createClient(SecuritySetter<HttpURLConnection> ss, URI uri, int connectTimeout) throws LocatorException {
return new HClient(ss, uri, connectTimeout);
}
+
}