summaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
authorTimoney, Dan (dt5972) <dt5972@att.com>2018-06-15 16:13:55 -0400
committerTimoney, Dan (dt5972) <dt5972@att.com>2018-06-15 16:13:55 -0400
commita7d1da3308031c3cce5e2e09b1f2727f1fceef02 (patch)
tree2a507f625b889293f11ab01e642104a34b6bbb3a /filters
parent1a71779b7b1104ba6d5e289e6dc839bb4b9493d5 (diff)
Update sli/core to ODL Oxygen
Update sli/core artifacts to compile cleanly against ODL Oxygen version of CCSDK parent poms. Change-Id: I9f3b4c40b1ae62cdda1c35836466f8faf7da3b39 Issue-ID: CCSDK-280 Signed-off-by: Timoney, Dan (dt5972) <dt5972@att.com>
Diffstat (limited to 'filters')
-rw-r--r--filters/features/ccsdk-filters/pom.xml25
-rwxr-xr-xfilters/provider/pom.xml14
-rw-r--r--filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java299
-rw-r--r--filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java28
-rw-r--r--filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java36
5 files changed, 70 insertions, 332 deletions
diff --git a/filters/features/ccsdk-filters/pom.xml b/filters/features/ccsdk-filters/pom.xml
index b35f5ec9e..a995790d5 100644
--- a/filters/features/ccsdk-filters/pom.xml
+++ b/filters/features/ccsdk-filters/pom.xml
@@ -17,31 +17,8 @@
<name>ccsdk-sli-core :: filters :: ${project.artifactId}</name>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>mdsal-model-artifacts</artifactId>
- <version>0.11.1</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.6.1</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
+
<dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>odl-mdsal-broker</artifactId>
- <type>xml</type>
- <classifier>features</classifier>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
diff --git a/filters/provider/pom.xml b/filters/provider/pom.xml
index dd78b2a64..c7d356ba3 100755
--- a/filters/provider/pom.xml
+++ b/filters/provider/pom.xml
@@ -42,27 +42,23 @@
</dependency>
- <dependency>
- <groupId>equinoxSDK381</groupId>
- <artifactId>org.eclipse.osgi</artifactId>
- <version>${equinox.osgi.version}</version>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
- <version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
- <version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
- <version>${commons.codec.version}</version>
</dependency>
<dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java
deleted file mode 100644
index 359136565..000000000
--- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseDbLoggingFilter.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP : CCSDK
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.ccsdk.sli.core.filters;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.util.zip.GZIPInputStream;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpServletResponseWrapper;
-
-import org.onap.ccsdk.sli.core.sli.MessageWriter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-@Deprecated
-public class RequestResponseDbLoggingFilter implements Filter {
-
- private static Logger log = LoggerFactory.getLogger(RequestResponseDbLoggingFilter.class);
-
- public static final String REQUEST_ID = "X-ECOMP-RequestID";
-
- private static class ByteArrayServletStream extends ServletOutputStream {
-
- ByteArrayOutputStream baos;
-
- ByteArrayServletStream(ByteArrayOutputStream baos) {
- this.baos = baos;
- }
-
- @Override
- public void write(int param) throws IOException {
- baos.write(param);
- }
- }
-
- private static class ByteArrayPrintWriter {
-
- private ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- private PrintWriter pw = new PrintWriter(baos);
-
- private ServletOutputStream sos = new ByteArrayServletStream(baos);
-
- public PrintWriter getWriter() {
- return pw;
- }
-
- public ServletOutputStream getStream() {
- return sos;
- }
-
- byte[] toByteArray() {
- return baos.toByteArray();
- }
- }
-
- private class BufferedServletInputStream extends ServletInputStream {
-
- ByteArrayInputStream bais;
-
- public BufferedServletInputStream(ByteArrayInputStream bais) {
- this.bais = bais;
- }
-
- @Override
- public int available() {
- return bais.available();
- }
-
- @Override
- public int read() {
- return bais.read();
- }
-
- @Override
- public int read(byte[] buf, int off, int len) {
- return bais.read(buf, off, len);
- }
-
- }
-
- private class BufferedRequestWrapper extends HttpServletRequestWrapper {
-
- ByteArrayInputStream bais;
-
- ByteArrayOutputStream baos;
-
- BufferedServletInputStream bsis;
-
- byte[] buffer;
-
- public BufferedRequestWrapper(HttpServletRequest req) throws IOException {
- super(req);
-
- InputStream is = req.getInputStream();
- baos = new ByteArrayOutputStream();
- byte buf[] = new byte[1024];
- int letti;
- while ((letti = is.read(buf)) > 0) {
- baos.write(buf, 0, letti);
- }
- buffer = baos.toByteArray();
-
- }
-
- @Override
- public ServletInputStream getInputStream() {
- try {
- bais = new ByteArrayInputStream(buffer);
- bsis = new BufferedServletInputStream(bais);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
-
- return bsis;
- }
-
- public byte[] getBuffer() {
- return buffer;
- }
-
- }
-
- @Override
- public void init(FilterConfig filterConfig) throws ServletException {
- }
-
- @Override
- public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain filterChain)
- throws IOException, ServletException {
-
- if (request == null || !(request instanceof HttpServletRequest)) {
- filterChain.doFilter(request, response);
- return;
- }
-
- long t1 = System.currentTimeMillis();
-
- final HttpServletRequest httpRequest = (HttpServletRequest) request;
- BufferedRequestWrapper bufferedRequest = new BufferedRequestWrapper(httpRequest);
-
- String requestId = httpRequest.getHeader(REQUEST_ID);
- if (requestId == null || requestId.trim().length() == 0) {
- log.warn("Could not write request in DB: " + REQUEST_ID + " is missing in the HTTP headers.");
- return;
- }
-
- String requestHost = request.getRemoteHost();
- if (requestHost == null)
- requestHost = request.getRemoteAddr();
-
- String requestStr = new String(bufferedRequest.getBuffer());
-
- MessageWriter.saveIncomingRequest(requestId, null, requestHost, requestStr);
-
- long t2 = System.currentTimeMillis();
-
- log.info("Request saved in DB for request-id: " + requestId + ". TIme: " + (t2 - t1));
-
- final HttpServletResponse httpResponse = (HttpServletResponse) response;
-
- final ByteArrayPrintWriter pw = new ByteArrayPrintWriter();
- HttpServletResponse wrappedResp = new HttpServletResponseWrapper(httpResponse) {
-
- @Override
- public PrintWriter getWriter() {
- return pw.getWriter();
- }
-
- @Override
- public ServletOutputStream getOutputStream() {
- return pw.getStream();
- }
- };
-
- try {
-
- filterChain.doFilter(bufferedRequest, wrappedResp);
-
- } finally {
-
- if (request != null && request instanceof HttpServletRequest) {
-
- t1 = System.currentTimeMillis();
-
- byte[] bytes = pw.toByteArray();
- response.getOutputStream().write(bytes);
- response.getOutputStream().flush();
-
- String responseStr = null;
- if ("gzip".equals(httpResponse.getHeader("Content-Encoding"))) {
- responseStr = decompressGZIPByteArray(bytes);
- } else {
- responseStr = new String(bytes);
- }
-
- MessageWriter.saveIncomingResponse(requestId, httpResponse.getStatus(), responseStr);
-
- t2 = System.currentTimeMillis();
-
- log.info("Response saved in DB for request-id: " + requestId + ". TIme: " + (t2 - t1));
- }
- }
-
- }
-
- @Override
- public void destroy() {
- }
-
- private String decompressGZIPByteArray(byte[] bytes) {
-
- BufferedReader in = null;
- InputStreamReader inR = null;
- ByteArrayInputStream byteS = null;
- GZIPInputStream gzS = null;
- StringBuilder str = new StringBuilder();
- try {
- byteS = new ByteArrayInputStream(bytes);
- gzS = new GZIPInputStream(byteS);
- inR = new InputStreamReader(gzS);
- in = new BufferedReader(inR);
-
- if (in != null) {
-
- String content;
-
- while ((content = in.readLine()) != null) {
- str.append(content);
- }
- }
-
- } catch (Exception e) {
- log.error("Failed get read GZIPInputStream", e);
- } finally {
-
- if (byteS != null)
- try {
- byteS.close();
- } catch (IOException e1) {
- log.error("Failed to close ByteStream", e1);
- }
- if (gzS != null)
- try {
- gzS.close();
- } catch (IOException e2) {
- log.error("Failed to close GZStream", e2);
- }
- if (inR != null)
- try {
- inR.close();
- } catch (IOException e3) {
- log.error("Failed to close InputReader", e3);
- }
- if (in != null)
- try {
- in.close();
- } catch (IOException e) {
- log.error("Failed to close BufferedReader", e);
- }
- }
- return str.toString();
- }
-}
diff --git a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java
index 440aa41bd..ffe6d71d6 100644
--- a/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java
+++ b/filters/provider/src/main/java/org/onap/ccsdk/sli/core/filters/RequestResponseLoggingFilter.java
@@ -34,11 +34,13 @@ import java.util.zip.GZIPInputStream;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
+import javax.servlet.ReadListener;
import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletOutputStream;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
+import javax.servlet.WriteListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
@@ -60,6 +62,17 @@ public class RequestResponseLoggingFilter implements Filter {
public void write(int param) throws IOException {
baos.write(param);
}
+
+ @Override
+ public boolean isReady() {
+ return true;
+ }
+
+ @Override
+ public void setWriteListener(WriteListener arg0) {
+
+
+ }
}
private static class ByteArrayPrintWriter {
@@ -106,6 +119,21 @@ public class RequestResponseLoggingFilter implements Filter {
return bais.read(buf, off, len);
}
+ @Override
+ public boolean isFinished() {
+ return available() < 1;
+ }
+
+ @Override
+ public boolean isReady() {
+ return true;
+ }
+
+ @Override
+ public void setReadListener(ReadListener arg0) {
+
+ }
+
}
private class BufferedRequestWrapper extends HttpServletRequestWrapper {
diff --git a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java
index 9f36fe11e..7ce856e68 100644
--- a/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java
+++ b/filters/provider/src/test/java/org/onap/ccsdk/sli/core/filters/TestRequestResponseLoggingFilter.java
@@ -18,9 +18,11 @@ import java.util.LinkedList;
import java.util.UUID;
import java.util.Vector;
import javax.servlet.FilterChain;
+import javax.servlet.ReadListener;
import javax.servlet.ServletException;
import javax.servlet.ServletInputStream;
import javax.servlet.ServletOutputStream;
+import javax.servlet.WriteListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.codec.binary.Base64;
@@ -58,6 +60,30 @@ public class TestRequestResponseLoggingFilter {
}
+ @Override
+ public boolean isFinished() {
+ try {
+ return stream.available() < 1;
+ } catch (IOException e) {
+ return true;
+ }
+ }
+
+
+ @Override
+ public boolean isReady() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+
+ @Override
+ public void setReadListener(ReadListener arg0) {
+ // TODO Auto-generated method stub
+
+ }
+
+
}
@@ -74,6 +100,16 @@ public class TestRequestResponseLoggingFilter {
ostr.write(b);
}
+ @Override
+ public boolean isReady() {
+ return true;
+ }
+
+ @Override
+ public void setWriteListener(WriteListener arg0) {
+
+ }
+
}
/**