From 4e69f3358d31173a222b275e2a82da692846aa1a Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Fri, 29 Jan 2021 12:46:06 -0500 Subject: 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 Change-Id: I447371239a1bfe102b705e7ecbd964f368780657 --- sdnr/wt/common/pom.xml | 13 ++++--- .../sdnr/wt/common/database/SearchResult.java | 11 +++--- .../sdnr/wt/common/http/BaseHTTPClient.java | 41 ++-------------------- .../sdnr/wt/common/http/BaseHTTPResponse.java | 10 ++---- .../features/sdnr/wt/common/http/BaseServlet.java | 8 +++-- ...ServletInputStreamFromByteArrayInputStream.java | 15 -------- ...ServletOutputStreamToByteArrayOutputStream.java | 18 +++------- .../test/ServletOutputStreamToStringWriter.java | 20 ++--------- sdnr/wt/common/src/test/resources/testpom.xml | 4 +-- 9 files changed, 30 insertions(+), 110 deletions(-) (limited to 'sdnr/wt/common') diff --git a/sdnr/wt/common/pom.xml b/sdnr/wt/common/pom.xml index 83b07536f..54ffc01c3 100644 --- a/sdnr/wt/common/pom.xml +++ b/sdnr/wt/common/pom.xml @@ -29,14 +29,14 @@ org.onap.ccsdk.parent binding-parent - 2.1.1-SNAPSHOT + 2.1.0 org.onap.ccsdk.features.sdnr.wt sdnr-wt-common 1.1.1-SNAPSHOT - bundle + jar ccsdk-features :: ${project.artifactId} @@ -47,6 +47,7 @@ + true true yyyy-MM-dd HH:mm ${maven.build.timestamp} UTC @@ -62,7 +63,7 @@ javax.servlet - javax.servlet-api + servlet-api org.osgi @@ -76,6 +77,7 @@ org.elasticsearch.client elasticsearch-rest-client + ${elasticsearch-rest-client.version} com.fasterxml.jackson.core @@ -90,8 +92,8 @@ jackson-databind - com.google.code.findbugs - annotations + com.google.code.findbugs + annotations @@ -112,6 +114,7 @@ com.github.alexcojocaru elasticsearch-maven-plugin + 6.16 ${skipTests} testCluster 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 { this.total = total; } + // public SearchResult(List 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 { 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 mapHeaders(HttpServletRequest req) { - Map headers = new HashMap<>(); - Enumeration 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 headers) throws IOException { @@ -191,16 +164,10 @@ public class BaseHTTPClient { // Receive answer int responseCode = ((HttpURLConnection) http).getResponseCode(); String sresponse = ""; - Map responseHeaders = null; InputStream response = null; try { if (responseCode >= 200 && responseCode < 300) { response = http.getInputStream(); - responseHeaders = new HashMap<>(); - for(Entry> 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 headers; + public BaseHTTPResponse(int code, String body) { - this(code, body, null); - } - public BaseHTTPResponse(int code, String body, Map 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; } - } diff --git a/sdnr/wt/common/src/test/resources/testpom.xml b/sdnr/wt/common/src/test/resources/testpom.xml index 6fba87af9..1adf713c1 100644 --- a/sdnr/wt/common/src/test/resources/testpom.xml +++ b/sdnr/wt/common/src/test/resources/testpom.xml @@ -29,13 +29,13 @@ org.onap.ccsdk.parent binding-parent - 2.0.0-SNAPSHOT + 2.1.0 org.onap.ccsdk.features.sdnr.wt sdnr-wt-common - 1.0.0-SNAPSHOT + 1.1.1-SNAPSHOT jar ccsdk-features :: ${project.artifactId} -- cgit 1.2.3-korg