summaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2019-09-22 20:25:08 +0300
committerIttay Stern <ittay.stern@att.com>2019-09-22 20:25:08 +0300
commit5a824bbfbe95afd3b1fbaae8c029a8b4c5ad5401 (patch)
tree85524a7e7b0a98fec29fec278ffbf44641f0b9f6 /vid-app-common/src/main
parent15eeb03b12f2c8afd34c38ffad9f2d3a30e4af23 (diff)
Remove injections from filter, as filter is not Spring-controlled
Change-Id: Iecb4d6fbb79c5920d088fe536e6622690f8f881e Issue-ID: VID-253 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java8
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt24
2 files changed, 12 insertions, 20 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java b/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java
index c0fc96e03..ac93d8751 100644
--- a/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java
+++ b/vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java
@@ -58,12 +58,6 @@ public class PromiseRequestIdFilter extends GenericFilterBean {
private static final Pattern uuidRegex = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", Pattern.CASE_INSENSITIVE);
- private final Headers headers;
-
- public PromiseRequestIdFilter(Headers headers) {
- this.headers = headers;
- }
-
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
@@ -118,7 +112,7 @@ public class PromiseRequestIdFilter extends GenericFilterBean {
}
String highestPriorityHeader(HttpServletRequest httpRequest) {
- return defaultIfNull(headers.highestPriorityHeader(httpRequest), PROMISED_HEADER_NAME);
+ return defaultIfNull(Headers.highestPriorityHeader(httpRequest), PROMISED_HEADER_NAME);
}
private static class PromiseRequestIdRequestWrapper extends HttpServletRequestWrapper {
diff --git a/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt b/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt
index cc5ebf38c..e710fd973 100644
--- a/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt
+++ b/vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt
@@ -1,20 +1,18 @@
+@file:JvmName("Headers")
+
package org.onap.vid.logging
import org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID
-import org.springframework.stereotype.Component
import javax.servlet.http.HttpServletRequest
-@Component
-class Headers {
- fun prioritizedRequestIdHeaders() = listOf(
- "X-ONAP-RequestID",
- "X-RequestID",
- "X-TransactionID",
- ECOMP_REQUEST_ID
- )
+fun prioritizedRequestIdHeaders() = listOf(
+ "X-ONAP-RequestID",
+ "X-RequestID",
+ "X-TransactionID",
+ ECOMP_REQUEST_ID
+)
- fun highestPriorityHeader(httpRequest: HttpServletRequest): String? {
- val headers = httpRequest.headerNames.asSequence().toSet().map { it.toUpperCase() }
- return prioritizedRequestIdHeaders().firstOrNull { headers.contains(it.toUpperCase()) }
- }
+fun highestPriorityHeader(httpRequest: HttpServletRequest): String? {
+ val headers = httpRequest.headerNames.asSequence().toSet().map { it.toUpperCase() }
+ return prioritizedRequestIdHeaders().firstOrNull { headers.contains(it.toUpperCase()) }
}