diff options
author | Instrumental <jonathan.gathman@att.com> | 2019-10-15 08:19:50 -0500 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2019-10-15 08:35:35 -0500 |
commit | 1296352d8eafee57f982a4342ad79ada4aa56d28 (patch) | |
tree | 355cdb89d85530a861319f892b0f24236e6adc50 /cadi/client/src/main/java/org | |
parent | bdce7667a6e272e2fa32e298d957a0d9090c5bc9 (diff) |
Sonar Fixes, Formatting
Issue-ID: AAF-1019
Change-Id: Ica49d9e7323aad9622ff9d95cc21b87430c22c54
Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/client/src/main/java/org')
25 files changed, 225 insertions, 225 deletions
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java index da85702d..1db9317a 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsAuthentication.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,19 +29,19 @@ import org.onap.aaf.cadi.config.SecurityInfoC; /** * AbsAuthentication is a class representing how to Authenticate onto a Client. - * + * * Methods of setting Authentication on a Client vary, so CLIENT is a Generic Type - * This allows the ability to apply security onto Different Client Types, as they come + * This allows the ability to apply security onto Different Client Types, as they come * into vogue, or change over time. - * + * * Password is encrypted at rest. - * + * * @author Jonathan * * @param <CLIENT> */ public abstract class AbsAuthentication<CLIENT> implements SecuritySetter<CLIENT> { - // HTTP Header for Authentication is "Authorization". This was from an early stage of internet where + // HTTP Header for Authentication is "Authorization". This was from an early stage of internet where // Access by Credential "Authorized" you for everything on the site. Since those early days, it became // clear that "full access" wasn't appropriate, so the split between Authentication and Authorization // came into being... But the Header remains. @@ -57,14 +57,14 @@ public abstract class AbsAuthentication<CLIENT> implements SecuritySetter<CLIENT protected final SecurityInfoC<CLIENT> securityInfo; protected long lastMiss; protected int count; - + static { try { symm = Symm.encrypt.obtain(); } catch (IOException e) { throw new RuntimeException("Cannot create critical internal encryption key",e); } - + } public AbsAuthentication(final SecurityInfoC<CLIENT> securityInfo, final String user, final byte[] headValue) throws IOException { @@ -82,11 +82,11 @@ public abstract class AbsAuthentication<CLIENT> implements SecuritySetter<CLIENT return new String(symm.decode(headValue)); } } - + protected void setUser(String id) { user = id; } - + @Override public String getID() { return user; diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsTransferSS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsTransferSS.java index baac6daa..80234460 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsTransferSS.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/AbsTransferSS.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,10 +29,10 @@ import org.onap.aaf.cadi.principal.TaggedPrincipal; /** * This client represents the ability to Transfer the Identity of the caller to the authenticated - * user being transferred to. This ability is critical for App-to-App communication to ensure that + * user being transferred to. This ability is critical for App-to-App communication to ensure that * Authorization can happen on the End-Users' credentials when appropriate, even though Authentication * to App1 by App2 must be by App2's credentials. - * + * * @author Jonathan * * @param <CLIENT> @@ -59,8 +59,8 @@ public abstract class AbsTransferSS<CLIENT> implements SecuritySetter<CLIENT> { if (principal==null) { return; } else { - value = principal.getName() + ':' + - app + ':' + + value = principal.getName() + ':' + + app + ':' + principal.tag() + ':' + "AS"; } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/BasicAuth.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/BasicAuth.java index 1eb8d7c4..021229ce 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/BasicAuth.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/BasicAuth.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/EClient.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/EClient.java index 9aa9cad6..7a437e39 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/EClient.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/EClient.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,7 +44,7 @@ public interface EClient<CT> { public<T> Future<T> futureRead(RosettaDF<T> df,Data.TYPE type); public<T> Future<T> future(T t); public Future<Void> future(HttpServletResponse resp, int expected) throws APIException; - + public interface Transfer { public void transfer(OutputStream os) throws IOException, APIException; } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Future.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Future.java index 39f88687..de32d959 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Future.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Future.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import org.onap.aaf.cadi.CadiException; public abstract class Future<T> { public T value; public abstract boolean get(int timeout) throws CadiException; - + public abstract int code(); public abstract String body(); public abstract String header(String tag); diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Holder.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Holder.java index af97c465..8744e896 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Holder.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Holder.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,7 +36,7 @@ public class Holder<T> { value = t; return t; } - + public T get() { return value; } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java index 6b486b8e..cfc52fb4 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Rcli.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -94,9 +94,9 @@ public abstract class Rcli<CT> { rv.apiVersion = apiVersion; return rv; } - + protected abstract Rcli<CT> clone(URI uri, SecuritySetter<CT> ss); - + public abstract void invalidate() throws CadiException; public Rcli<CT> readTimeout(int millis) { @@ -118,7 +118,7 @@ public abstract class Rcli<CT> { this.apiVersion = apiVersion; return this; } - + public boolean isApiVersion(String prospective) { return apiVersion.equals(prospective); } @@ -294,7 +294,7 @@ public abstract class Rcli<CT> { /** * Read String, using POST for keyInfo - * + * * @param pathinfo * @param df * @param t @@ -335,7 +335,7 @@ public abstract class Rcli<CT> { */ public<T,R> Future<R> readPost(String pathinfo, final RosettaDF<T> df, final T t, final RosettaDF<R> resp) throws APIException, CadiException { final ParsePath pp = new ParsePath(pathinfo); - + EClient<CT> client = client(); client.setMethod(POST); client.addHeader(CONTENT_TYPE,typeString(df.getTypeClass())); @@ -371,11 +371,11 @@ public abstract class Rcli<CT> { public Future<String> read(String pathinfo, String accept, String ... headers) throws APIException, CadiException { final ParsePath pp = new ParsePath(pathinfo); - + EClient<CT> client = client(); client.setMethod(GET); client.addHeader(ACCEPT, accept); - + for (int i=1;i<headers.length;i=i+2) { client.addHeader(headers[i-1],headers[i]); } @@ -416,7 +416,7 @@ public abstract class Rcli<CT> { client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); client.setFragment(pp.frag()); - + client.setPayload(null); client.send(); return client.futureRead(df,type); @@ -430,7 +430,7 @@ public abstract class Rcli<CT> { client.addHeader(ACCEPT, typeString(cls)); client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); - client.setFragment(pp.frag()); + client.setFragment(pp.frag()); client.setPayload(null); client.send(); @@ -445,7 +445,7 @@ public abstract class Rcli<CT> { client.addHeader(CONTENT_TYPE,contentType); client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); - client.setFragment(pp.frag()); + client.setFragment(pp.frag()); client.setPayload(new EClient.Transfer() { @Override public void transfer(OutputStream os) throws IOException, APIException { @@ -455,16 +455,16 @@ public abstract class Rcli<CT> { client.send(); return client.future(t); } - + public<T> Future<String> updateRespondString(String pathinfo, final RosettaDF<T> df, final T t) throws APIException, CadiException { final ParsePath pp = new ParsePath(pathinfo); - + EClient<CT> client = client(); client.setMethod(PUT); client.addHeader(CONTENT_TYPE, typeString(df.getTypeClass())); client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); - client.setFragment(pp.frag()); + client.setFragment(pp.frag()); client.setPayload(new EClient.Transfer() { @Override @@ -476,7 +476,7 @@ public abstract class Rcli<CT> { client.send(); return client.futureReadString(); } - + public Future<String> update(String pathinfo, String contentType, EClient.Transfer content) throws APIException, CadiException { final ParsePath pp = new ParsePath(pathinfo); @@ -502,8 +502,8 @@ public abstract class Rcli<CT> { client.addHeader(CONTENT_TYPE, typeString(df.getTypeClass())); client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); - client.setFragment(pp.frag()); - + client.setFragment(pp.frag()); + client.setPayload(new EClient.Transfer() { @Override public void transfer(OutputStream os) throws IOException, APIException { @@ -513,16 +513,16 @@ public abstract class Rcli<CT> { client.send(); return client.future(t); } - + public<T> Future<T> update(String pathinfo, Class<?> cls, final RosettaDF<T> df, final T t) throws APIException, CadiException { final ParsePath pp = new ParsePath(pathinfo); - + EClient<CT> client = client(); client.setMethod(PUT); client.addHeader(CONTENT_TYPE, typeString(cls)); client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); - client.setFragment(pp.frag()); + client.setFragment(pp.frag()); client.setPayload(new EClient.Transfer() { @Override @@ -533,7 +533,7 @@ public abstract class Rcli<CT> { client.send(); return client.future(t); } - + /** @@ -553,7 +553,7 @@ public abstract class Rcli<CT> { client.addHeader(CONTENT_TYPE, typeString(Void.class)); client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); - client.setFragment(pp.frag()); + client.setFragment(pp.frag()); // client.setPayload(new EClient.Transfer() { // @Override @@ -563,7 +563,7 @@ public abstract class Rcli<CT> { client.send(); return client.future(null); } - + public<T> Future<T> delete(String pathinfo, String contentType, final RosettaDF<T> df, final T t) throws APIException, CadiException { final ParsePath pp = new ParsePath(pathinfo); @@ -573,7 +573,7 @@ public abstract class Rcli<CT> { client.addHeader(CONTENT_TYPE, contentType); client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); - client.setFragment(pp.frag()); + client.setFragment(pp.frag()); client.setPayload(new EClient.Transfer() { @Override @@ -593,7 +593,7 @@ public abstract class Rcli<CT> { client.addHeader(CONTENT_TYPE, typeString(cls)); client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); - client.setFragment(pp.frag()); + client.setFragment(pp.frag()); client.setPayload(new EClient.Transfer() { @Override public void transfer(OutputStream os) throws IOException, APIException { @@ -612,7 +612,7 @@ public abstract class Rcli<CT> { client.addHeader(CONTENT_TYPE, typeString(df.getTypeClass())); client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); - client.setFragment(pp.frag()); + client.setFragment(pp.frag()); client.setPayload(new EClient.Transfer() { @Override public void transfer(OutputStream os) throws IOException, APIException { @@ -633,7 +633,7 @@ public abstract class Rcli<CT> { client.addHeader(CONTENT_TYPE, typeString(cls)); client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); - client.setFragment(pp.frag()); + client.setFragment(pp.frag()); client.setPayload(null); client.send(); @@ -648,7 +648,7 @@ public abstract class Rcli<CT> { client.addHeader(CONTENT_TYPE, contentType); client.setPathInfo(pp.path()); client.setQueryParams(pp.query()); - client.setFragment(pp.frag()); + client.setFragment(pp.frag()); client.setPayload(null); client.send(); @@ -681,7 +681,7 @@ public abstract class Rcli<CT> { int read; // reuse Buffers Pooled<byte[]> pbuff = buffPool.get(); - try { + try { while ((read=is.read(pbuff.content))>=0) { os.write(pbuff.content,0,read); } @@ -713,13 +713,13 @@ public abstract class Rcli<CT> { queryEnd = pound>=0?pound:path.length(); if (oneCallQueryParams==null) { if (query>=0) { - queryParams = path.substring(query+1,queryEnd); + queryParams = path.substring(query+1,queryEnd); } else { queryParams=null; } } else { if (query>=0) { - queryParams = oneCallQueryParams + '&' + path.substring(query+1,queryEnd); + queryParams = oneCallQueryParams + '&' + path.substring(query+1,queryEnd); } else { queryParams = oneCallQueryParams; } @@ -727,7 +727,7 @@ public abstract class Rcli<CT> { } } } - + public String path() { if (query>=0) { if (pound>=0) { @@ -740,11 +740,11 @@ public abstract class Rcli<CT> { return path; } } - + public String query() { return queryParams; } - + public String frag() { if (pound>=0) { return path.substring(pound+1); diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Result.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Result.java index 0e2a4b16..5b8bf920 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Result.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Result.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,7 +35,7 @@ public class Result<T> { public static<T> Result<T> ok(int code,T t) { return new Result<T>(code,t,null); } - + public static<T> Result<T> err(int code,String body) { return new Result<T>(code,null,body); } @@ -47,7 +47,7 @@ public class Result<T> { public boolean isOK() { return error==null; } - + public String toString() { StringBuilder sb = new StringBuilder("Code: "); sb.append(code); diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Retryable.java b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Retryable.java index 58e7718d..6d85a420 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/client/Retryable.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/client/Retryable.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,7 @@ import org.onap.aaf.cadi.Locator; import org.onap.aaf.misc.env.APIException; /** - * + * * @author Jonathan * * @param <RT> @@ -38,7 +38,7 @@ public abstract class Retryable<RET> { // be able to hold state for consistent Connections. Not required for all connection types. public Rcli<?> lastClient; private Locator.Item item; - + public Retryable() { lastClient = null; item = null; @@ -57,7 +57,7 @@ public abstract class Retryable<RET> { public Locator.Item item() { return item; } - + public abstract RET code(Rcli<?> client) throws CadiException, ConnectException, APIException; /** diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HAuthorizationHeader.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HAuthorizationHeader.java index c2f56458..744aba43 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HAuthorizationHeader.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HAuthorizationHeader.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,7 +31,7 @@ import org.onap.aaf.cadi.client.AbsAuthentication; import org.onap.aaf.cadi.config.SecurityInfoC; public class HAuthorizationHeader extends AbsAuthentication<HttpURLConnection> { - + public HAuthorizationHeader(SecurityInfoC<HttpURLConnection> si, String user, String headValue) throws IOException { super(si,user,headValue==null?null:headValue.getBytes()); } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java index 38465da4..d280b9cb 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HBasicAuthSS.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,12 +42,12 @@ public class HBasicAuthSS extends HAuthorizationHeader implements BasicAuth { this(si,si.access.getProperty(Config.AAF_APPID, null), si.access.decrypt(si.access.getProperty(Config.AAF_APPPASS, null), false)); } - + public HBasicAuthSS(SecurityInfoC<HttpURLConnection> si, boolean setDefault) throws IOException { this(si,si.access.getProperty(Config.AAF_APPID, null), si.access.decrypt(si.access.getProperty(Config.AAF_APPPASS, null), false),setDefault); } - + public HBasicAuthSS(SecurityInfoC<HttpURLConnection> si, String user, String pass, boolean asDefault) throws IOException { this(si, user,pass); @@ -55,11 +55,11 @@ public class HBasicAuthSS extends HAuthorizationHeader implements BasicAuth { si.set(this); } } - + public HBasicAuthSS(BasicPrincipal bp, SecurityInfoC<HttpURLConnection> si) throws IOException { this(si, bp.getName(),new String(bp.getCred())); } - + public HBasicAuthSS(BasicPrincipal bp, SecurityInfoC<HttpURLConnection> si, boolean asDefault) throws IOException { this(si, bp.getName(),new String(bp.getCred())); if (asDefault) { 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 61112c47..cef4ae47 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -49,7 +49,7 @@ import org.onap.aaf.misc.rosetta.env.RosettaDF; /** * Low Level Http Client Mechanism. Chances are, you want the high level "HRcli" * for Rosetta Object Translation - * + * * @author Jonathan * */ @@ -72,7 +72,7 @@ public class HClient implements EClient<HttpURLConnection> { this.uri = uri; this.ss = ss; this.connectTimeout = connectTimeout; - pathinfo = query = fragment = null; + pathinfo = query = fragment = null; } @Override @@ -89,7 +89,7 @@ public class HClient implements EClient<HttpURLConnection> { public void setPayload(Transfer transfer) { this.transfer = transfer; } - + @Override public void addHeader(String tag, String value) { if (headers == null) @@ -133,10 +133,10 @@ public class HClient implements EClient<HttpURLConnection> { huc = getConnection(sendURI, pi); huc.setRequestMethod(meth); if (ss!=null) { - ss.setSecurity(huc); + ss.setSecurity(huc); } if (headers != null) - for (Header d : headers) { + for (Header d : headers) { huc.addRequestProperty(d.tag, d.value); } huc.setDoInput(true); @@ -164,11 +164,11 @@ public class HClient implements EClient<HttpURLConnection> { pathinfo = query = fragment = ""; } } - + public URI getURI() { return uri; } - + public void setURI(URI uri) { this.uri = uri; } @@ -176,31 +176,31 @@ public class HClient implements EClient<HttpURLConnection> { public int timeout() { return connectTimeout; } - + protected HttpURLConnection getConnection(URI uri, StringBuilder pi) throws IOException, URISyntaxException { URL url = new URI( - uri.getScheme(), + uri.getScheme(), uri.getAuthority(), - pi==null?uri.getPath():pi.toString(), + pi==null?uri.getPath():pi.toString(), query, fragment).toURL(); return (HttpURLConnection) url.openConnection(); } - + public abstract class HFuture<T> extends Future<T> { protected HttpURLConnection huc; protected int respCode; protected IOException exception; protected StringBuilder errContent; - + public HFuture(final HttpURLConnection huc) { this.huc = huc; } - + protected boolean evalInfo(HttpURLConnection huc) throws APIException, IOException{ return respCode == 200; }; - + @Override public final boolean get(int timeout) throws CadiException { try { @@ -219,7 +219,7 @@ public class HClient implements EClient<HttpURLConnection> { close(); } } - + private void extractError() { InputStream is = huc.getErrorStream(); try { @@ -237,7 +237,7 @@ public class HClient implements EClient<HttpURLConnection> { exception = e; } } - + // Typically only used by Read public StringBuilder inputStreamToString(InputStream is) { // Avoids Carriage returns, and is reasonably efficient, given @@ -260,26 +260,26 @@ public class HClient implements EClient<HttpURLConnection> { return null; } } - - + + @Override public int code() { return respCode; } - + public HttpURLConnection huc() { return huc; } - + public IOException exception() { return exception; } - + @Override public String header(String tag) { return huc.getHeaderField(tag); } - + public void close() { if (huc!=null) { huc.disconnect(); @@ -393,7 +393,7 @@ public class HClient implements EClient<HttpURLConnection> { is = huc.getInputStream(); // reuse Buffers Pooled<byte[]> pbuff = Rcli.buffPool.get(); - try { + try { while ((read=is.read(pbuff.content))>=0) { os.write(pbuff.content,0,read); } @@ -409,7 +409,7 @@ public class HClient implements EClient<HttpURLConnection> { if (is!=null) { errContent = new StringBuilder(); Pooled<byte[]> pbuff = Rcli.buffPool.get(); - try { + try { while ((read=is.read(pbuff.content))>=0) { os.write(pbuff.content,0,read); } @@ -436,12 +436,12 @@ public class HClient implements EClient<HttpURLConnection> { this.tag = t; this.value = v; } - + public String toString() { return tag + '=' + value; } } - + public String toString() { return "HttpURLConnection Client configured to " + uri.toString(); } 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 19e40b3a..1d1f2732 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,7 +46,7 @@ public class HMangr { private int readTimeout, connectionTimeout; public final Locator<URI> loc; private Access access; - + public HMangr(Access access, Locator<URI> loc) throws LocatorException { readTimeout = 10000; connectionTimeout=3000; @@ -58,18 +58,18 @@ public class HMangr { } /** - * Reuse the same service. This is helpful for multiple calls that change service side cached data so that + * Reuse the same service. This is helpful for multiple calls that change service side cached data so that * there is not a speed issue. - * + * * If the service goes down, another service will be substituted, if available. - * + * * @param access * @param loc * @param ss * @param item * @param retryable * @return - * @throws URISyntaxException + * @throws URISyntaxException * @throws Exception */ public<RET> RET same(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable) throws APIException, CadiException, LocatorException { @@ -107,7 +107,7 @@ public class HMangr { } else { client.setSecuritySetter(ss); } - + retry = false; try { ret = retryable.code(client); @@ -118,14 +118,14 @@ public class HMangr { try { Throwable ec = e.getCause(); if (ec instanceof java.net.ConnectException) { - if (client!=null && loc.hasItems()) { + if (client!=null && loc.hasItems()) { access.log(Level.WARN,"Connection refused, trying next available service"); retry = true; } else { throw new CadiException("Connection refused, no more services to try"); } } else if (ec instanceof java.net.SocketException) { - if (client!=null && loc.hasItems()) { + if (client!=null && loc.hasItems()) { access.log(Level.WARN,"Socket prematurely closed, trying next available service"); retry = true; } else { @@ -155,8 +155,8 @@ public class HMangr { } return ret; } - - + + public<RET> RET best(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable) throws LocatorException, CadiException, APIException { retryable.item(loc.best()); return same(ss,retryable); @@ -168,7 +168,7 @@ public class HMangr { public<RET> RET all(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable,boolean notify) throws LocatorException, CadiException, APIException { return call(ss,retryable,notify,null); } - + public <RET> RET allExcept(SecuritySetter<HttpURLConnection> ss, Retryable<RET> retryable,boolean notify, String selfHost) throws LocatorException, CadiException, APIException { return call(ss,retryable,notify,selfHost); } @@ -211,12 +211,12 @@ public class HMangr { access.log(Level.ERROR,"Connection to",uri,"refused during call to all services"); } } - - if (ret == null && notify) + + if (ret == null && notify) throw new LocatorException("No available clients to call"); return ret; } - + public void close() { // TODO Anything here? @@ -230,7 +230,7 @@ public class HMangr { public int readTimeout() { return readTimeout; } - + public void connectionTimeout(int t) { connectionTimeout = t; } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HNoAuthSS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HNoAuthSS.java index 1fecce2b..2b6a9ac2 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HNoAuthSS.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HNoAuthSS.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java index cbd7b33e..70ca4902 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HRcli.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -36,9 +36,9 @@ import org.onap.aaf.misc.env.Data.TYPE; /** * Rosetta Client - * + * * JAXB defined JSON or XML over HTTP/S - * + * * @author Jonathan * * @param <T> @@ -74,10 +74,10 @@ public class HRcli extends Rcli<HttpURLConnection> { /** - * + * * @return - * @throws APIException - * @throws DME2Exception + * @throws APIException + * @throws DME2Exception */ protected EClient<HttpURLConnection> client() throws CadiException { try { @@ -93,7 +93,7 @@ public class HRcli extends Rcli<HttpURLConnection> { throw new CadiException(e); } } - + /* (non-Javadoc) * @see org.onap.aaf.cadi.client.Rcli#setSecuritySetter(org.onap.aaf.cadi.SecuritySetter) */ @@ -117,7 +117,7 @@ public class HRcli extends Rcli<HttpURLConnection> { throw new CadiException(e); } } - + public HRcli setManager(HMangr hman) { this.hman = hman; return this; @@ -126,5 +126,5 @@ public class HRcli extends Rcli<HttpURLConnection> { public String toString() { return uri.toString(); } - + } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HSecurityInfoInit.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HSecurityInfoInit.java index 7c7d391f..0da76e91 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HSecurityInfoInit.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HSecurityInfoInit.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,7 +32,7 @@ import org.onap.aaf.misc.env.APIException; /** * This class will pick out the best default SS for Clients per Client type - * + * * @author Instrumental * */ diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTokenSS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTokenSS.java index cd20585f..99b73ed7 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTokenSS.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTokenSS.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTransferSS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTransferSS.java index f68c1f61..d8c8d5ad 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTransferSS.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HTransferSS.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -37,7 +37,7 @@ public class HTransferSS extends AbsTransferSS<HttpURLConnection> { public HTransferSS(TaggedPrincipal principal, String app) throws IOException { super(principal, app); } - + public HTransferSS(TaggedPrincipal principal, String app, SecurityInfoC<HttpURLConnection> si) { super(principal, app, si); } @@ -55,7 +55,7 @@ public class HTransferSS extends AbsTransferSS<HttpURLConnection> { securityInfo.setSocketFactoryOn((HttpsURLConnection)huc); } } - + @Override public int setLastResponse(int respCode) { return 0; diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HX509SS.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HX509SS.java index f441186e..89c11b69 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HX509SS.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HX509SS.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -57,11 +57,11 @@ public class HX509SS implements SecuritySetter<HttpURLConnection> { public HX509SS(SecurityInfoC<HttpURLConnection> si) throws APIException, CadiException { this(null,si,false); } - + public HX509SS(SecurityInfoC<HttpURLConnection> si, boolean asDefault) throws APIException, CadiException { this(null,si,asDefault); } - + public HX509SS(final String sendAlias, SecurityInfoC<HttpURLConnection> si) throws APIException, CadiException { this(sendAlias, si, false); } @@ -75,7 +75,7 @@ public class HX509SS implements SecuritySetter<HttpURLConnection> { alias = si.defaultAlias; } } - + priv=null; X509KeyManager[] xkms = si.getKeyManagers(); if (xkms==null || xkms.length==0) { @@ -88,9 +88,9 @@ public class HX509SS implements SecuritySetter<HttpURLConnection> { for (int i=0;cert==null&&i<xkms.length;++i) { X509Certificate[] chain = xkms[i].getCertificateChain(alias); if (chain!=null&&chain.length>0) { - algo = chain[0].getSigAlgName(); + algo = chain[0].getSigAlgName(); pub = chain[0].getEncoded(); - ByteArrayOutputStream baos = new ByteArrayOutputStream(pub.length*2); + ByteArrayOutputStream baos = new ByteArrayOutputStream(pub.length*2); ByteArrayInputStream bais = new ByteArrayInputStream(pub); Symm.base64noSplit.encode(bais,baos,X509); cert = baos.toString(); @@ -111,32 +111,32 @@ public class HX509SS implements SecuritySetter<HttpURLConnection> { } if (alias==null) { // must be a one-way huc.setRequestProperty(AbsAuthentication.AUTHORIZATION, cert); - + // Test Signed content try { String data = "SignedContent["+ inc() + ']' + Chrono.dateTime(); huc.setRequestProperty("Data", data); - + Signature sig = Signature.getInstance(algo); sig.initSign(priv); sig.update(data.getBytes()); byte[] signature = sig.sign(); - + ByteArrayOutputStream baos = new ByteArrayOutputStream((int)(signature.length*1.3)); ByteArrayInputStream bais = new ByteArrayInputStream(signature); Symm.base64noSplit.encode(bais, baos); huc.setRequestProperty("Signature", new String(baos.toByteArray())); - + } catch (Exception e) { throw new CadiException(e); } } } - + private synchronized int inc() { return ++count; } - + /* (non-Javadoc) * @see org.onap.aaf.cadi.SecuritySetter#getID() */ @@ -144,7 +144,7 @@ public class HX509SS implements SecuritySetter<HttpURLConnection> { public String getID() { return alias; } - + @Override public int setLastResponse(int respCode) { return 0; diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java index 8053dabf..c0b9f375 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ import org.onap.aaf.cadi.LocatorException; public class DNSLocator implements SizedLocator<URI> { private static enum Status {UNTRIED, OK, INVALID, SLOW}; private static final int CHECK_TIME = 3000; - + private String host, protocol; private Access access; private Host[] hosts; @@ -41,7 +41,7 @@ public class DNSLocator implements SizedLocator<URI> { private String suffix; private int size = 1; // initial, until refreshed. - + public DNSLocator(Access access, String protocol, String host, String range) { this.host = host; this.protocol = protocol; @@ -164,7 +164,7 @@ public class DNSLocator implements SizedLocator<URI> { } return false; } - + private String parseHostAndPorts(String aaf_locate, int _start, int defaultPort) throws LocatorException { int slash, start; int colon = aaf_locate.indexOf(':',_start); @@ -193,7 +193,7 @@ public class DNSLocator implements SizedLocator<URI> { if(slash>=0) { suffix = aaf_locate.substring(slash); } - + } else { slash = aaf_locate.indexOf('/', start); if (slash == start) { @@ -211,7 +211,7 @@ public class DNSLocator implements SizedLocator<URI> { host = slash<_start?aaf_locate.substring(_start):aaf_locate.substring(_start,slash); startPort = endPort = defaultPort; } - + return host; } @@ -219,18 +219,18 @@ public class DNSLocator implements SizedLocator<URI> { private URI uri; private InetAddress ia; private Status status; - + public Host(InetAddress inetAddress, int port, String suffix) throws URISyntaxException { ia = inetAddress; uri = new URI(protocol,null,inetAddress.getCanonicalHostName(),port,suffix,null,null); status = Status.UNTRIED; } - + public String toString() { return uri.toString() + " - " + status.name(); } } - + private class DLItem implements Item { public DLItem(int i) { cnt = i; @@ -238,7 +238,7 @@ public class DNSLocator implements SizedLocator<URI> { private int cnt; } - + public void destroy() {} public int size() { diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HClientHotPeerLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HClientHotPeerLocator.java index 488d35d5..57eca417 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HClientHotPeerLocator.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HClientHotPeerLocator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,7 +35,7 @@ public class HClientHotPeerLocator extends HotPeerLocator<HClient> { public HClientHotPeerLocator(Access access, String urlstr, long invalidateTime, String localLatitude, String localLongitude, HX509SS ss) throws LocatorException { super(access, urlstr, invalidateTime, localLatitude, localLongitude); - + this.ss = ss; } 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 34889138..d332a7f3 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 @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -54,7 +54,7 @@ public class PropertyLocator implements Locator<URI> { } /** * comma delimited root url list - * + * * @param locList * @throws LocatorException */ @@ -67,9 +67,9 @@ public class PropertyLocator implements Locator<URI> { } String[] locarray = Split.split(',',locList); List<URI> uriList = new ArrayList<>(); - + random = new SecureRandom(); - + for (int i=0;i<locarray.length;++i) { try { int range = locarray[i].indexOf(":["); @@ -234,7 +234,7 @@ public class PropertyLocator implements Locator<URI> { } else { newCurrent = current; } - + for (int i=0; i< end; ++i) { if (newCurrent[i]==null){ newCurrent[i]=new PLItem(i); @@ -257,14 +257,14 @@ public class PropertyLocator implements Locator<URI> { protected Socket createSocket() { return new Socket(); } - + private class PLItem implements Item { public int idx,order; - + public PLItem(int i) { idx = order =i; } - + public String toString() { return "Item: " + idx + " order: " + order; } @@ -294,7 +294,7 @@ public class PropertyLocator implements Locator<URI> { } return sb.toString(); } - + public void destroy() { } } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java index b0654cfa..862868f0 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,19 +28,19 @@ import org.onap.aaf.cadi.LocatorException; public class SingleEndpointLocator implements SizedLocator<URI> { private final URI uri; - private final static Item item = new Item() {}; + private final static Item item = new Item() {}; private Date noRetryUntil; - + public SingleEndpointLocator(final URI uri) { this.uri = uri; } - + public SingleEndpointLocator(final String endpoint) throws LocatorException { try { - this.uri = new URI(endpoint); - } catch (URISyntaxException e) { - throw new LocatorException(e); - } + this.uri = new URI(endpoint); + } catch (URISyntaxException e) { + throw new LocatorException(e); + } } @Override @@ -63,7 +63,7 @@ public class SingleEndpointLocator implements SizedLocator<URI> { @Override public void invalidate(Item item) throws LocatorException { // one minute timeout, because there is no other item - noRetryUntil = new Date(System.currentTimeMillis()+60000); + noRetryUntil = new Date(System.currentTimeMillis()+60000); } @Override @@ -87,10 +87,10 @@ public class SingleEndpointLocator implements SizedLocator<URI> { // Never refreshed return true; } - + @Override public int size() { - return 1; + return 1; } @Override diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SizedLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SizedLocator.java index 65a34738..40792649 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SizedLocator.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SizedLocator.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,5 +24,5 @@ package org.onap.aaf.cadi.locator; import org.onap.aaf.cadi.Locator; public interface SizedLocator<T> extends Locator<T> { - public abstract int size(); + public abstract int size(); } diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/routing/GreatCircle.java b/cadi/client/src/main/java/org/onap/aaf/cadi/routing/GreatCircle.java index 27eb507f..f72e5290 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/routing/GreatCircle.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/routing/GreatCircle.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,33 +24,33 @@ package org.onap.aaf.cadi.routing; import org.onap.aaf.misc.env.util.Split; public class GreatCircle { - // Note: multiplying by this constant is faster than calling Math equivalent function + // Note: multiplying by this constant is faster than calling Math equivalent function private static final double DEGREES_2_RADIANS = Math.PI/180.0; - + public static final double DEGREES_2_NM = 60; public static final double DEGREES_2_KM = DEGREES_2_NM * 1.852; // 1.852 is exact ratio per 1929 Standard Treaty, adopted US 1954 - public static final double DEGREES_2_MI = DEGREES_2_NM * 1.1507795; - + public static final double DEGREES_2_MI = DEGREES_2_NM * 1.1507795; + /** - * + * * Calculate the length of an arc on a perfect sphere based on Latitude and Longitudes of two points * Parameters are in Degrees (i.e. the coordinate system you get from GPS, Mapping WebSites, Phones, etc) - * + * * L1 = Latitude of point A * G1 = Longitude of point A * L2 = Latitude of point B * G2 = Longitude of point B - * + * * d = acos (sin(L1)*sin(L2) + cos(L1)*cos(L2)*cos(G1 - G2)) - * + * * Returns answer in Degrees - * + * * Since there are 60 degrees per nautical miles, you can convert to NM by multiplying by 60 - * - * Essential formula from a Princeton website, the "Law of Cosines" method. - * + * + * Essential formula from a Princeton website, the "Law of Cosines" method. + * * Refactored cleaned up for speed Jonathan 3/8/2013 - * + * * @param latA * @param lonA * @param latB @@ -66,19 +66,19 @@ public class GreatCircle { lonB *= DEGREES_2_RADIANS; return Math.acos( - Math.sin(latA) * Math.sin(latB) + + Math.sin(latA) * Math.sin(latB) + Math.cos(latA) * Math.cos(latB) * Math.cos(lonA-lonB) ) / DEGREES_2_RADIANS; } - - /** + + /** * Convert from "Lat,Long Lat,Long" String format * "Lat,Long,Lat,Long" Format * or all four entries "Lat Long Lat Long" - * + * * (Convenience function) - * + * * Since Distance is positive, a "-1" indicates an error in String formatting */ public static double calc(String ... coords) { @@ -111,7 +111,7 @@ public class GreatCircle { Double.parseDouble(coords[2]), Double.parseDouble(coords[3]) ); - + default: return -1; } @@ -124,7 +124,7 @@ public class GreatCircle { ///** //* Haverside method, from Princeton -//* +//* //* @param alat //* @param alon //* @param blat @@ -169,16 +169,16 @@ public class GreatCircle { // alon *= DEGREES_2_RADIANS; // blat *= DEGREES_2_RADIANS; // blon *= DEGREES_2_RADIANS; -// +// // // Reused values // double cosAlat,cosBlat; -// +// // return Math.acos( // ((cosAlat=Math.cos(alat))*Math.cos(alon)*(cosBlat=Math.cos(blat))*Math.cos(blon)) + // (cosAlat*Math.sin(alon)*cosBlat*Math.sin(blon)) + // (Math.sin(alat)*Math.sin(blat)) // )/DEGREES_2_RADIANS; -// +// //} /* |