diff options
author | Instrumental <jonathan.gathman@att.com> | 2019-01-22 10:27:32 -0600 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2019-01-22 10:32:14 -0600 |
commit | 12414fe43077e12d7ef711951b1633ad31d73573 (patch) | |
tree | 475166cee68c104b2f36625ef864a912aab50fa4 /cadi/client/src/main | |
parent | a5bcce655e339151445fbce2c129687e3bc8610a (diff) |
Public and Private Locate entries
Issue-ID: AAF-723
Change-Id: I9dcd2e732ce64b39aaa57a6e9404f275f7ad540c
Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/client/src/main')
3 files changed, 32 insertions, 24 deletions
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java index d8852834..daca47df 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HClient.java @@ -40,6 +40,7 @@ import org.onap.aaf.cadi.SecuritySetter; import org.onap.aaf.cadi.client.EClient; import org.onap.aaf.cadi.client.Future; import org.onap.aaf.cadi.client.Rcli; +import org.onap.aaf.cadi.util.FixURIinfo; import org.onap.aaf.misc.env.APIException; import org.onap.aaf.misc.env.Data; import org.onap.aaf.misc.env.Data.TYPE; @@ -109,24 +110,23 @@ public class HClient implements EClient<HttpURLConnection> { @Override public void send() throws APIException { - try { - // Build URL from given URI plus current Settings - if (uri.getPath()==null) { - throw new APIException("Invalid URL entered for HClient"); - } - StringBuilder pi=null; - if (pathinfo!=null) { // additional pathinfo - pi = new StringBuilder(uri.getPath()); - if (!pathinfo.startsWith("/")) { - pi.append('/'); - } - pi.append(pathinfo); + // Build URL from given URI plus current Settings + if (uri.getPath()==null) { + throw new APIException("Invalid URL entered for HClient"); + } + StringBuilder pi=null; + if (pathinfo!=null) { // additional pathinfo + pi = new StringBuilder(uri.getPath()); + if (!pathinfo.startsWith("/")) { + pi.append('/'); } - URI sendURI = new URI( + pi.append(pathinfo); + } + URI sendURI = null; + try { + sendURI = new URI( uri.getScheme(), - uri.getUserInfo(), - uri.getHost(), - uri.getPort(), + uri.getAuthority(), pi==null?uri.getPath():pi.toString(), query==null?uri.getQuery():query, fragment==null?uri.getFragment():fragment @@ -149,8 +149,14 @@ public class HClient implements EClient<HttpURLConnection> { transfer.transfer(huc.getOutputStream()); } // TODO other settings? There's a bunch here. + } catch (APIException e) { + throw e; } catch (Exception e) { - throw new APIException(e); + if(sendURI==null) { + throw new APIException("Cannot connect to Root URI: " + uri.toString(),e); + } else { + throw new APIException("Cannot connect to " + sendURI.toString() + "(Root URI: " + uri.toString() +')',e); + } } finally { // ensure all these are reset after sends meth=pathinfo=null; if (headers!=null) { @@ -171,9 +177,7 @@ public class HClient implements EClient<HttpURLConnection> { protected HttpURLConnection getConnection(URI uri, StringBuilder pi) throws IOException, URISyntaxException { URL url = new URI( uri.getScheme(), - uri.getUserInfo(), - uri.getHost(), - uri.getPort(), + uri.getAuthority(), pi==null?uri.getPath():pi.toString(), query, fragment).toURL(); diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java index 8e3138af..1e5c5211 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java @@ -30,14 +30,15 @@ import java.net.URISyntaxException; import javax.net.ssl.SSLHandshakeException; import org.onap.aaf.cadi.Access; +import org.onap.aaf.cadi.Access.Level; import org.onap.aaf.cadi.CadiException; import org.onap.aaf.cadi.Locator; +import org.onap.aaf.cadi.Locator.Item; import org.onap.aaf.cadi.LocatorException; import org.onap.aaf.cadi.SecuritySetter; -import org.onap.aaf.cadi.Access.Level; -import org.onap.aaf.cadi.Locator.Item; import org.onap.aaf.cadi.client.Rcli; import org.onap.aaf.cadi.client.Retryable; +import org.onap.aaf.cadi.util.FixURIinfo; import org.onap.aaf.misc.env.APIException; public class HMangr { @@ -174,7 +175,8 @@ public class HMangr { loc.refresh(); for (Item li=loc.first();li!=null;li=loc.next(li)) { URI uri=loc.get(li); - if (host!=null && !host.equals(uri.getHost())) { + FixURIinfo fui = new FixURIinfo(uri); + if (host!=null && !host.equals(fui.getHost())) { break; } try { diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java index eb0ecf11..bccb8116 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java @@ -36,6 +36,7 @@ import java.util.TimerTask; import org.onap.aaf.cadi.Locator; import org.onap.aaf.cadi.LocatorException; +import org.onap.aaf.cadi.util.FixURIinfo; import org.onap.aaf.misc.env.util.Split; public class PropertyLocator implements Locator<URI> { @@ -181,7 +182,8 @@ public class PropertyLocator implements Locator<URI> { String realname; for (int i = 0; i < orig.length ; ++i) { try { - InetAddress ia[] = InetAddress.getAllByName(orig[i].getHost()); + FixURIinfo fui = new FixURIinfo(orig[i]); + InetAddress ia[] = InetAddress.getAllByName(fui.getHost()); URI o,n; for (int j=0;j<ia.length;++j) { |