From c63a3402b0054642bfe07465278dc80246b0321b Mon Sep 17 00:00:00 2001 From: Tal Gitelman Date: Sun, 5 Aug 2018 17:16:15 +0300 Subject: Updating the Jetty version Change-Id: Id492fab0745479556a6c63af5aec32a49765cb67 Issue-ID: SDC-1545 Signed-off-by: Tal Gitelman --- .../org/openecomp/sdc/be/monitoring/EsGateway.java | 24 ++--------- catalog-fe/pom.xml | 1 - .../openecomp/sdc/fe/servlets/FeProxyServlet.java | 6 +-- .../openecomp/sdc/fe/servlets/KibanaServlet.java | 20 +-------- .../openecomp/sdc/fe/servlets/SSLProxyServlet.java | 48 ++++++++++------------ .../openecomp/sdc/fe/impl/HttpRequestInfoTest.java | 1 - .../openecomp/sdc/servlets/FeProxyServletTest.java | 12 +----- pom.xml | 4 +- 8 files changed, 33 insertions(+), 83 deletions(-) diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java b/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java index 5f3fd10eb1..fed36b5653 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/monitoring/EsGateway.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. @@ -20,8 +20,6 @@ package org.openecomp.sdc.be.monitoring; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.proxy.ProxyServlet; import org.openecomp.sdc.be.components.impl.MonitoringBusinessLogic; import org.openecomp.sdc.be.impl.WebAppContextWrapper; @@ -31,8 +29,6 @@ import org.springframework.web.context.WebApplicationContext; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.net.URI; public class EsGateway extends ProxyServlet { @@ -40,25 +36,13 @@ public class EsGateway extends ProxyServlet { private static final Logger log = Logger.getLogger(EsGateway.class); @Override - public URI rewriteURI(HttpServletRequest request) { + public String rewriteTarget(HttpServletRequest request) { String originalUrl = request.getRequestURI(); - String redirectedUrl = getModifiedUrl(request); log.debug("EsGateway Redirecting request from: {} , to: {}", originalUrl, redirectedUrl); - return URI.create(redirectedUrl); - } - - @Override - public void customizeProxyRequest(Request proxyRequest, HttpServletRequest request) { - super.customizeProxyRequest(proxyRequest, request); - - } - - @Override - protected void onResponseSuccess(HttpServletRequest request, HttpServletResponse response, Response proxyResponse) { - super.onResponseSuccess(request, response, proxyResponse); + return redirectedUrl; } public String getModifiedUrl(HttpServletRequest request) { diff --git a/catalog-fe/pom.xml b/catalog-fe/pom.xml index dcefb5f6d3..a5ebc4b719 100644 --- a/catalog-fe/pom.xml +++ b/catalog-fe/pom.xml @@ -320,7 +320,6 @@ ${jetty.version} - / / .*/.*jersey-[^/]\.jar$ diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java index 0540fad269..395b3073d8 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/FeProxyServlet.java @@ -22,8 +22,6 @@ package org.openecomp.sdc.fe.servlets; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import java.net.MalformedURLException; -import java.net.URL; import org.eclipse.jetty.client.api.Response; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.fe.config.Configuration; @@ -39,6 +37,8 @@ import org.slf4j.MDC; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.net.MalformedURLException; +import java.net.URL; import java.util.concurrent.TimeUnit; public class FeProxyServlet extends SSLProxyServlet { @@ -213,8 +213,6 @@ public class FeProxyServlet extends SSLProxyServlet { private PluginsConfiguration getPluginConfiguration(HttpServletRequest request) { return ((ConfigurationManager) request.getSession().getServletContext().getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).getPluginsConfiguration(); } - - private Configuration getConfiguration(HttpServletRequest request) { return ((ConfigurationManager) request.getSession().getServletContext().getAttribute(Constants.CONFIGURATION_MANAGER_ATTR)).getConfiguration(); } diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java index fb75a06c1d..b3bbf4708d 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/KibanaServlet.java @@ -20,8 +20,6 @@ package org.openecomp.sdc.fe.servlets; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.client.api.Response; import org.eclipse.jetty.proxy.ProxyServlet; import org.openecomp.sdc.common.api.Constants; import org.openecomp.sdc.fe.config.Configuration; @@ -30,15 +28,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.net.URI; public class KibanaServlet extends ProxyServlet { private static final long serialVersionUID = 1L; private static Logger log = LoggerFactory.getLogger(KibanaServlet.class.getName()); @Override - public URI rewriteURI(HttpServletRequest request) { + public String rewriteTarget(HttpServletRequest request) { String originalUrl = request.getRequestURI(); @@ -46,19 +42,7 @@ public class KibanaServlet extends ProxyServlet { log.debug("KibanaServlet Redirecting request from: {} , to: {}", originalUrl, redirectedUrl); - return URI.create(redirectedUrl); - } - - @Override - public void customizeProxyRequest(Request proxyRequest, HttpServletRequest request) { - super.customizeProxyRequest(proxyRequest, request); - - } - - @Override - protected void onResponseSuccess(HttpServletRequest request, HttpServletResponse response, Response proxyResponse) { - - super.onResponseSuccess(request, response, proxyResponse); + return redirectedUrl; } public String getModifiedUrl(HttpServletRequest request) { diff --git a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java index ffed2dde8c..182d198013 100644 --- a/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java +++ b/catalog-fe/src/main/java/org/openecomp/sdc/fe/servlets/SSLProxyServlet.java @@ -21,8 +21,6 @@ package org.openecomp.sdc.fe.servlets; import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.api.Request; -import org.eclipse.jetty.http.HttpHeader; import org.eclipse.jetty.proxy.ProxyServlet; import org.eclipse.jetty.util.ssl.SslContextFactory; import org.openecomp.sdc.common.api.Constants; @@ -33,34 +31,31 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import java.util.Enumeration; public abstract class SSLProxyServlet extends ProxyServlet { private static final long serialVersionUID = 1L; private static Logger log = LoggerFactory.getLogger(SSLProxyServlet.class.getName()); - - - @Override - public void customizeProxyRequest(Request proxyRequest, HttpServletRequest request) { - super.customizeProxyRequest(proxyRequest, request); - // Add Missing Headers to proxy request - @SuppressWarnings("unchecked") - Enumeration headerNames = request.getHeaderNames(); - while (headerNames.hasMoreElements()) { - String headerName = headerNames.nextElement(); - if (!proxyRequest.getHeaders().containsKey(headerName)) { - String headerVal = request.getHeader(headerName); - log.debug("Adding missing header to request, header name: {} , header value: {}", headerName, - headerVal); - proxyRequest.header(headerName, headerVal); - } - } - proxyRequest.getHeaders().remove(HttpHeader.HOST); - - } + //TODO If no problems will arise remove in next merge + /*@Override + protected void sendProxyRequest(HttpServletRequest clientRequest, HttpServletResponse proxyResponse, Request proxyRequest) { + // Add Missing Headers to proxy request + @SuppressWarnings("unchecked") + Enumeration headerNames = clientRequest.getHeaderNames(); + while (headerNames.hasMoreElements()) { + String headerName = headerNames.nextElement(); + if (!proxyRequest.getHeaders().containsKey(headerName)) { + String headerVal = clientRequest.getHeader(headerName); + log.debug("Adding missing header to request, header name: {} , header value: {}", headerName, + headerVal); + proxyRequest.header(headerName, headerVal); + } + } + proxyRequest.getHeaders().remove(HttpHeader.HOST); + + super.sendProxyRequest(clientRequest, proxyResponse, proxyRequest); + }*/ @Override protected HttpClient createHttpClient() throws ServletException { @@ -88,10 +83,11 @@ public abstract class SSLProxyServlet extends ProxyServlet { // Start HttpClient try { httpClient.start(); - - return httpClient; } catch (Exception x) { + log.error("Exception thrown while starting httpClient {}", x); throw new ServletException(x); } + + return httpClient; } } diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/HttpRequestInfoTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/HttpRequestInfoTest.java index 3bb0006a26..53959b757d 100644 --- a/catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/HttpRequestInfoTest.java +++ b/catalog-fe/src/test/java/org/openecomp/sdc/fe/impl/HttpRequestInfoTest.java @@ -7,7 +7,6 @@ import javax.servlet.http.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; import java.security.Principal; import java.util.Collection; import java.util.Enumeration; diff --git a/catalog-fe/src/test/java/org/openecomp/sdc/servlets/FeProxyServletTest.java b/catalog-fe/src/test/java/org/openecomp/sdc/servlets/FeProxyServletTest.java index 9597928fc0..d80e6f3d36 100644 --- a/catalog-fe/src/test/java/org/openecomp/sdc/servlets/FeProxyServletTest.java +++ b/catalog-fe/src/test/java/org/openecomp/sdc/servlets/FeProxyServletTest.java @@ -40,7 +40,7 @@ import java.util.List; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.when; public class FeProxyServletTest { /* @@ -179,16 +179,6 @@ public class FeProxyServletTest { assertTrue(rewriteURI.equals(expectedChangedUrl)); } - - - @Test - public void testCustomizeProxyRequest() { - feProxy.customizeProxyRequest(proxyRequest, servletRequest); - verify(proxyRequest).header(HEADER_3, HEADER_3_VAL); - verify(proxyRequest, times(1)).header(Mockito.anyString(), Mockito.anyString()); - - } - @Test public void testRewriteURIWithWFAPIRequest() { when(servletRequest.getRequestURI()).thenReturn("/sdc1/feProxy/wf/workflows"); diff --git a/pom.xml b/pom.xml index e3af467f1a..5f4326e572 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@ 2.4.0 1.0.0-SNAPSHOT 1.0.0-SNAPSHOT - 9.2.22.v20170606 + 9.3.20.v20170531 2.8.10 @@ -475,4 +475,4 @@ dav:${nexus.proxy}${sitePath} - \ No newline at end of file + -- cgit 1.2.3-korg