aboutsummaryrefslogtreecommitdiffstats
path: root/vid-app-common/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'vid-app-common/src/main')
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/controller/filter/PromiseRequestIdFilter.java24
-rw-r--r--vid-app-common/src/main/java/org/onap/vid/logging/Headers.kt32
-rw-r--r--vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js6
-rwxr-xr-xvid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js8
4 files changed, 43 insertions, 27 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 ac93d8751..faaf55ae7 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
@@ -22,7 +22,6 @@ package org.onap.vid.controller.filter;
import static org.apache.commons.lang3.ObjectUtils.defaultIfNull;
-import static org.apache.commons.lang3.StringUtils.equalsIgnoreCase;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import static org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID;
@@ -43,6 +42,7 @@ import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
import org.onap.vid.logging.Headers;
+import org.onap.vid.logging.RequestIdHeader;
import org.springframework.web.filter.GenericFilterBean;
@WebFilter(urlPatterns = "/*")
@@ -53,7 +53,7 @@ public class PromiseRequestIdFilter extends GenericFilterBean {
// PROMISED_HEADER_NAME is set to ECOMP_REQUEST_ID as long as
// org.onap.portalsdk...UserUtils.getRequestId() is using the header
// "X-ECOMP-RequestID".
- private static final String PROMISED_HEADER_NAME = ECOMP_REQUEST_ID;
+ private static final RequestIdHeader PROMISED_HEADER = RequestIdHeader.ECOMP_ID;
private static final String REQUEST_ID_RESPONSE_HEADER = ECOMP_REQUEST_ID + "-echo";
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);
@@ -66,7 +66,7 @@ public class PromiseRequestIdFilter extends GenericFilterBean {
request = wrapIfNeeded(request);
if (response instanceof HttpServletResponse) {
- final String actualRequestId = ((HttpServletRequest) request).getHeader(PROMISED_HEADER_NAME);
+ final String actualRequestId = PROMISED_HEADER.getHeaderValue((HttpServletRequest) request);
((HttpServletResponse) response).addHeader(REQUEST_ID_RESPONSE_HEADER, actualRequestId);
}
}
@@ -77,8 +77,8 @@ public class PromiseRequestIdFilter extends GenericFilterBean {
public ServletRequest wrapIfNeeded(ServletRequest request) {
final HttpServletRequest httpRequest = (HttpServletRequest) request;
- final String highestPriorityHeader = highestPriorityHeader(httpRequest);
- final String originalRequestId = httpRequest.getHeader(highestPriorityHeader);
+ final RequestIdHeader highestPriorityHeader = highestPriorityHeader(httpRequest);
+ final String originalRequestId = highestPriorityHeader.getHeaderValue(httpRequest);
if (isWrapNeeded(highestPriorityHeader, originalRequestId)) {
// Copy originalRequestId to the promised header value
@@ -92,9 +92,9 @@ public class PromiseRequestIdFilter extends GenericFilterBean {
return isNotEmpty(value) && uuidRegex.matcher(value).matches();
}
- private boolean isWrapNeeded(String highestPriorityHeader, String originalRequestId) {
+ private boolean isWrapNeeded(RequestIdHeader highestPriorityHeader, String originalRequestId) {
boolean headerExistsAndValid =
- equalsIgnoreCase(highestPriorityHeader, PROMISED_HEADER_NAME) && verifyAndValidateUuid(originalRequestId);
+ PROMISED_HEADER == highestPriorityHeader && verifyAndValidateUuid(originalRequestId);
return !headerExistsAndValid;
}
@@ -111,8 +111,8 @@ public class PromiseRequestIdFilter extends GenericFilterBean {
}
}
- String highestPriorityHeader(HttpServletRequest httpRequest) {
- return defaultIfNull(Headers.highestPriorityHeader(httpRequest), PROMISED_HEADER_NAME);
+ RequestIdHeader highestPriorityHeader(HttpServletRequest httpRequest) {
+ return defaultIfNull(Headers.highestPriorityHeader(httpRequest), PROMISED_HEADER);
}
private static class PromiseRequestIdRequestWrapper extends HttpServletRequestWrapper {
@@ -142,9 +142,9 @@ public class PromiseRequestIdFilter extends GenericFilterBean {
@Override
public Enumeration<String> getHeaderNames() {
- if (null == super.getHeader(PROMISED_HEADER_NAME)) {
+ if (null == super.getHeader(PROMISED_HEADER.getHeaderName())) {
return Collections.enumeration(ImmutableList.<String>builder()
- .add(PROMISED_HEADER_NAME)
+ .add(PROMISED_HEADER.getHeaderName())
.addAll(Collections.list(super.getHeaderNames()))
.build());
}
@@ -153,7 +153,7 @@ public class PromiseRequestIdFilter extends GenericFilterBean {
}
private boolean isRequestIdHeaderName(String name) {
- return equalsIgnoreCase(name, PROMISED_HEADER_NAME);
+ return PROMISED_HEADER.stringEquals(name);
}
}
}
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 e710fd973..a0bbceea1 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
@@ -2,17 +2,33 @@
package org.onap.vid.logging
-import org.onap.portalsdk.core.util.SystemProperties.ECOMP_REQUEST_ID
+import org.onap.portalsdk.core.util.SystemProperties
+import org.onap.vid.logging.RequestIdHeader.*
import javax.servlet.http.HttpServletRequest
+enum class RequestIdHeader(val headerName: String) {
+
+ ONAP_ID("X-ONAP-RequestID"),
+ REQUEST_ID("X-RequestID"),
+ TRANSACTION_ID("X-TransactionID"),
+ ECOMP_ID(SystemProperties.ECOMP_REQUEST_ID),
+ ;
+
+ fun stringEquals(header: String) = headerName.equals(header, true)
+
+ fun getHeaderValue(request: HttpServletRequest): String? = request.getHeader(headerName)
+}
+
fun prioritizedRequestIdHeaders() = listOf(
- "X-ONAP-RequestID",
- "X-RequestID",
- "X-TransactionID",
- ECOMP_REQUEST_ID
+ ONAP_ID,
+ REQUEST_ID,
+ TRANSACTION_ID,
+ ECOMP_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): RequestIdHeader? {
+ val headers = httpRequest.headerNames.asSequence().toSet()
+ return prioritizedRequestIdHeaders().firstOrNull {
+ requestIdHeader -> headers.any { requestIdHeader.stringEquals(it) }
+ }
}
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
index 20e964c53..d966df8d9 100644
--- a/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/modals/new-change-management/new-change-management.controller.js
@@ -587,18 +587,18 @@
vm.vnfs = [];
vm.vfModules = [];
- let vnfRole = null;
+ let nfRole = null;
let cloudRegion = null;
if ($scope.isNewFilterChangeManagmentEnabled()) {
- vnfRole = vm.changeManagement.vnfType ? vm.changeManagement.vnfType : null;
+ nfRole = vm.changeManagement.vnfType ? vm.changeManagement.vnfType : null;
cloudRegion = vm.changeManagement.cloudRegion ? vm.changeManagement.cloudRegion : null;
}
AaiService.getVnfsByCustomerIdAndServiceType(
vm.changeManagement.subscriberId,
vm.changeManagement.serviceType["service-type"],
- vnfRole,
+ nfRole,
cloudRegion,
).then(function (response) {
vm.isSearchedVNF = true;
diff --git a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js
index d841e299b..d3075764e 100755
--- a/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js
+++ b/vid-app-common/src/main/webapp/app/vid/scripts/services/aaiService.js
@@ -86,13 +86,13 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE
}).join("&");
}
- function getConfigParams(vnfRole, cloudRegion) {
+ function getConfigParams(nfRole, cloudRegion) {
if (!featureFlags.isOn(COMPONENT.FEATURE_FLAGS.FLAG_FLASH_CLOUD_REGION_AND_NF_ROLE_OPTIONAL_SEARCH)) {
return null
}
let data = {
- vnfRole: vnfRole,
+ nfRole: nfRole,
cloudRegion: cloudRegion,
};
@@ -646,13 +646,13 @@ var AaiService = function ($http, $log, PropertyService, UtilityService, COMPONE
(UtilityService.runHttpErrorHandler);
},
- getVnfsByCustomerIdAndServiceType: function (globalSubscriberId, serviceType, vnfRole, cloudRegion) {
+ getVnfsByCustomerIdAndServiceType: function (globalSubscriberId, serviceType, nfRole, cloudRegion) {
let deferred = $q.defer();
let url = globalSubscriberId + COMPONENT.FORWARD_SLASH + serviceType
const path = COMPONENT.AAI_GET_VNF_BY_CUSTOMERID_AND_SERVICETYPE + url;
- let config = getConfigParams(vnfRole, cloudRegion);
+ let config = getConfigParams(nfRole, cloudRegion);
if (UtilityService.hasContents(globalSubscriberId) &&
UtilityService.hasContents(serviceType)) {