X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fclient%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Fhttp%2FHClient.java;h=9255128c756fa2993f807680d5b11d541ca49b17;hb=4ac37bffd664bbc2d6d419d9420393193573320d;hp=d885283490171e7630b6ab36aa98820eaf43fc6b;hpb=7e966914050e66219689001ff4ab601a49eef0ac;p=aaf%2Fauthz.git 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..9255128c 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 @@ -109,24 +109,23 @@ public class HClient implements EClient { @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 +148,14 @@ public class HClient implements EClient { 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) { @@ -163,6 +168,10 @@ public class HClient implements EClient { public URI getURI() { return uri; } + + public void setURI(URI uri) { + this.uri = uri; + } public int timeout() { return connectTimeout; @@ -171,9 +180,7 @@ public class HClient implements EClient { 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();