aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/common/src/main/java
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2021-01-29 12:46:06 -0500
committerDan Timoney <dtimoney@att.com>2021-01-29 12:47:35 -0500
commit4e69f3358d31173a222b275e2a82da692846aa1a (patch)
tree7355744a66614a0811113ee6a43a423e68257fe3 /sdnr/wt/common/src/main/java
parent123b423cddbe01bdaba0bea50d986ff1b18a25bc (diff)
Revert "update common and data-provider"
This reverts commit a3e70a1a48d13193d9f28a2d91089d5b253d3e91. Change was incomplete - many modules still reference version 2.1.0 (Sodium-based) of CCSDK parent poms, causing version conflicts in odlsli docker. Issue-ID: CCSDK-3076 Signed-off-by: Dan Timoney <dtimoney@att.com> Change-Id: I447371239a1bfe102b705e7ecbd964f368780657
Diffstat (limited to 'sdnr/wt/common/src/main/java')
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java11
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java41
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java10
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java15
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java18
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java20
7 files changed, 20 insertions, 103 deletions
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java
index 529853e08..5a011eec9 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java
@@ -45,6 +45,10 @@ public class SearchResult<T> {
this.total = total;
}
+ // public SearchResult(List<T> hits,long total) {
+ // this.hits = hits;
+ // this.total = total;
+ // }
public SearchResult() {
this.hits = new ArrayList<>();
this.total = 0;
@@ -65,11 +69,4 @@ public class SearchResult<T> {
public void add(T object) {
this.hits.add(object);
}
-
- @Override
- public String toString() {
- return "SearchResult [hits=" + hits + ", total=" + total + "]";
- }
-
-
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
index 198fb920c..155e51609 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
@@ -48,11 +48,7 @@ import java.security.interfaces.RSAPrivateKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import javax.annotation.Nonnull;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
@@ -60,7 +56,7 @@ import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
-import javax.servlet.http.HttpServletRequest;
+import javax.xml.bind.DatatypeConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -115,29 +111,6 @@ public class BaseHTTPClient {
throws IOException {
return this.sendRequest(uri, method, body != null ? body.getBytes(CHARSET) : null, headers);
}
- public BaseHTTPResponse sendRequest(HttpServletRequest req) throws IOException {
- final String method = req.getMethod();
- byte[] buffer=null;
-
- if(!"GET".equals(method)) {
- InputStream is = req.getInputStream();
- buffer=is.readAllBytes();
- is.close();
-
- }
- return this.sendRequest(req.getRequestURI(), method, buffer,mapHeaders(req));
- }
-
- private Map<String, String> mapHeaders(HttpServletRequest req) {
- Map<String,String> headers = new HashMap<>();
- Enumeration<String> keys = req.getHeaderNames();
- String key;
- while(keys.hasMoreElements()) {
- key=keys.nextElement();
- headers.put(key,req.getHeader(key));
- }
- return headers;
- }
protected @Nonnull BaseHTTPResponse sendRequest(String uri, String method, byte[] body, Map<String, String> headers)
throws IOException {
@@ -191,16 +164,10 @@ public class BaseHTTPClient {
// Receive answer
int responseCode = ((HttpURLConnection) http).getResponseCode();
String sresponse = "";
- Map<String,String> responseHeaders = null;
InputStream response = null;
try {
if (responseCode >= 200 && responseCode < 300) {
response = http.getInputStream();
- responseHeaders = new HashMap<>();
- for(Entry<String,List<String>> entry:http.getHeaderFields().entrySet()) {
- responseHeaders.put(entry.getKey(), String.join(";", entry.getValue()));
- }
-
} else {
response = ((HttpURLConnection) http).getErrorStream();
if (response == null) {
@@ -228,7 +195,7 @@ public class BaseHTTPClient {
}
LOG.debug("ResponseCode: " + responseCode);
LOG.trace("Response (len:{}): {}", String.valueOf(lensum), sresponse);
- return new BaseHTTPResponse(responseCode, sresponse,responseHeaders);
+ return new BaseHTTPResponse(responseCode, sresponse);
}
public static SSLContext setupSsl(boolean trustall)
@@ -332,7 +299,7 @@ public class BaseHTTPClient {
String data = new String(pem);
String[] tokens = data.split(beginDelimiter);
tokens = tokens[1].split(endDelimiter);
- return Base64.getDecoder().decode(tokens[0]);
+ return DatatypeConverter.parseBase64Binary(tokens[0]);
}
protected static RSAPrivateKey generatePrivateKeyFromDER(byte[] keyBytes)
@@ -370,6 +337,4 @@ public class BaseHTTPClient {
return SSLCERT_PEM;
}
-
-
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java
index a0fd7220e..91a2cc27c 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java
@@ -21,8 +21,6 @@
*/
package org.onap.ccsdk.features.sdnr.wt.common.http;
-import java.util.Map;
-
public class BaseHTTPResponse {
public static final int CODE404 = 404;
@@ -30,14 +28,10 @@ public class BaseHTTPResponse {
public static final BaseHTTPResponse UNKNOWN = new BaseHTTPResponse(-1, "");
public final int code;
public final String body;
- public final Map<String,String> headers;
+
public BaseHTTPResponse(int code, String body) {
- this(code, body, null);
- }
- public BaseHTTPResponse(int code, String body, Map<String,String> rawData) {
this.code = code;
this.body = body;
- this.headers = rawData;
}
@Override
@@ -46,6 +40,6 @@ public class BaseHTTPResponse {
}
public boolean isSuccess() {
- return this.code >= CODE200 && this.code<300;
+ return this.code == CODE200;
}
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java
index f66070200..59e4e7705 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java
@@ -32,6 +32,7 @@ import java.security.NoSuchAlgorithmException;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;
+
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
@@ -40,6 +41,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -326,9 +328,9 @@ public abstract class BaseServlet extends HttpServlet {
response = http.getInputStream();
} else {
response = http.getErrorStream();
-// if (response == null) {
-// response = http.getInputStream();
-// }
+ if (response == null) {
+ http.getInputStream();
+ }
}
LOG.debug("ResponseCode: {}", responseCode);
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java
index 6475ac3c9..b926ff65c 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java
@@ -23,7 +23,6 @@ package org.onap.ccsdk.features.sdnr.wt.common.test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import javax.servlet.ReadListener;
import javax.servlet.ServletInputStream;
public class ServletInputStreamFromByteArrayInputStream extends ServletInputStream {
@@ -43,18 +42,4 @@ public class ServletInputStreamFromByteArrayInputStream extends ServletInputStre
return bis.read();
}
- @Override
- public boolean isFinished() {
- return false;
- }
-
- @Override
- public boolean isReady() {
- return false;
- }
-
- @Override
- public void setReadListener(ReadListener readListener) {
- }
-
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java
index 3ea607cc0..1914d9b67 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java
@@ -24,7 +24,6 @@ package org.onap.ccsdk.features.sdnr.wt.common.test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import javax.servlet.ServletOutputStream;
-import javax.servlet.WriteListener;
public class ServletOutputStreamToByteArrayOutputStream extends ServletOutputStream {
@@ -33,21 +32,12 @@ public class ServletOutputStreamToByteArrayOutputStream extends ServletOutputStr
// end of variables
- public ByteArrayOutputStream getByteArrayOutputStream() {
- return out;
- }
-
- @Override
- public void setWriteListener(WriteListener writeListener) {
- }
-
@Override
- public void write(int b) throws IOException {
- out.write(b);
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
}
- @Override
- public boolean isReady() {
- return false;
+ public ByteArrayOutputStream getByteArrayOutputStream() {
+ return out;
}
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java
index 48d9f940f..57ed596ae 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java
@@ -24,7 +24,6 @@ package org.onap.ccsdk.features.sdnr.wt.common.test;
import java.io.IOException;
import java.io.StringWriter;
import javax.servlet.ServletOutputStream;
-import javax.servlet.WriteListener;
public class ServletOutputStreamToStringWriter extends ServletOutputStream {
@@ -32,28 +31,13 @@ public class ServletOutputStreamToStringWriter extends ServletOutputStream {
private StringWriter out = new StringWriter();
// end of variables
- public StringWriter getStringWriter() {
- return out;
- }
-
@Override
public void write(int arg0) throws IOException {
out.write(arg0);
}
- @Override
- public String toString() {
- return out.toString();
- }
-
- @Override
- public boolean isReady() {
- return false;
- }
-
- @Override
- public void setWriteListener(WriteListener writeListener) {
+ public StringWriter getStringWriter() {
+ return out;
}
-
}