summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog.md1
-rw-r--r--dpo/data-formats/ConsulConfig.json1
-rw-r--r--dpo/spec/vescollector-componentspec.json10
-rw-r--r--etc/api_version_description.json7
-rwxr-xr-xetc/collector.properties3
-rw-r--r--src/main/java/org/onap/dcae/ApplicationSettings.java4
-rw-r--r--src/main/java/org/onap/dcae/common/HeaderUtils.java40
-rw-r--r--src/main/java/org/onap/dcae/restapi/VesRestController.java2
-rw-r--r--src/main/resources/api_version_config.json7
-rw-r--r--src/test/java/org/onap/dcae/common/JsonDataLoader.java10
-rw-r--r--src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java4
11 files changed, 50 insertions, 39 deletions
diff --git a/Changelog.md b/Changelog.md
index 49697aa2..35f5006e 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -30,3 +30,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [DCAEGEN2-2264](https://jira.onap.org/browse/DCAEGEN2-2264) - Post stndDefined implementation fixes
## [1.7.5] - 09/09/2020
- [DCAEGEN2-2264](https://jira.onap.org/browse/DCAEGEN2-2264) - Update schema-map.json
+ - [DCAEGEN2-2426](https://jira.onap.org/browse/DCAEGEN2-2426) - Fix bug throwing exception when first event is collected \ No newline at end of file
diff --git a/dpo/data-formats/ConsulConfig.json b/dpo/data-formats/ConsulConfig.json
index f2276194..168eda06 100644
--- a/dpo/data-formats/ConsulConfig.json
+++ b/dpo/data-formats/ConsulConfig.json
@@ -76,6 +76,7 @@
"collector.service.secure.port": "8443",
"auth.method": "noAuth",
"collector.keystore.file.location": "/opt/app/VESCollector/etc/keystore",
+ "collector.description.api.version.location": "etc/api_version_description.json",
"services_calls": [],
"header.authlist": "sample1,$2a$10$0buh.2WeYwN868YMwnNNEuNEAMNYVU9.FSMJGyIKV3dGET/7oGOi6"
}
diff --git a/dpo/spec/vescollector-componentspec.json b/dpo/spec/vescollector-componentspec.json
index 5c3e4d9b..0d53dc8f 100644
--- a/dpo/spec/vescollector-componentspec.json
+++ b/dpo/spec/vescollector-componentspec.json
@@ -240,7 +240,7 @@
},
{
"name": "collector.dmaap.streamid",
- "value": "fault=ves-fault|syslog=ves-syslog|heartbeat=ves-heartbeat|measurementsForVfScaling=ves-measurement|measurement=ves-measurement|mobileFlow=ves-mobileflow|other=ves-other|stateChange=ves-statechange|thresholdCrossingAlert=ves-thresholdCrossingAlert|voiceQuality=ves-voicequality|sipSignaling=ves-sipsignaling|notification=ves-notification|pnfRegistration=ves-pnfRegistration|perf3gpp=ves-perf3gpp|stndDefined=ves-other",
+ "value": "fault=ves-fault|syslog=ves-syslog|heartbeat=ves-heartbeat|measurementsForVfScaling=ves-measurement|mobileFlow=ves-mobileflow|other=ves-other|stateChange=ves-statechange|thresholdCrossingAlert=ves-thresholdCrossingAlert|voiceQuality=ves-voicequality|sipSignaling=ves-sipsignaling|notification=ves-notification|pnfRegistration=ves-pnfRegistration|3GPP-FaultSupervision=ves-3gpp-fault-supervision|3GPP-Heartbeat=ves-3gpp-heartbeat|3GPP-Provisioning=ves-3gpp-provisioning|3GPP-PerformanceAssurance=ves-3gpp-performance-assurance",
"description": "domain-to-streamid mapping used by VESCollector to distributes events based on domain. Both primary and secondary config_key are included for resilency (multiple streamid can be included commma separated). The streamids MUST match to topic config_keys. For single site without resiliency deployment - configkeys with -secondary suffix can be removed",
"sourced_at_deployment": true,
"policy_editable": false,
@@ -333,6 +333,14 @@
"sourced_at_deployment": false,
"policy_editable": false,
"designer_editable": false
+ },
+ {
+ "name": "collector.description.api.version.location",
+ "value": "etc/api_version_description.json",
+ "description": "Path to the file containing description of api versions",
+ "sourced_at_deployment": false,
+ "policy_editable": false,
+ "designer_editable": false
}
],
"auxilary": {
diff --git a/etc/api_version_description.json b/etc/api_version_description.json
new file mode 100644
index 00000000..f2c7f1cc
--- /dev/null
+++ b/etc/api_version_description.json
@@ -0,0 +1,7 @@
+{
+ "apiVersion":
+ {
+ "eventListener": ["4.7.2","5.4.1","7.2"],
+ "eventListener_eventBatch": ["4.7.2","5.4.1","7.2"]
+ }
+}
diff --git a/etc/collector.properties b/etc/collector.properties
index 7482c5a8..10ae9c2a 100755
--- a/etc/collector.properties
+++ b/etc/collector.properties
@@ -65,6 +65,9 @@ event.externalSchema.stndDefinedDataPath=$.event.stndDefinedFields.data
collector.dmaap.streamid=fault=ves-fault|syslog=ves-syslog|heartbeat=ves-heartbeat|measurementsForVfScaling=ves-measurement|mobileFlow=ves-mobileflow|other=ves-other|stateChange=ves-statechange|thresholdCrossingAlert=ves-thresholdCrossingAlert|voiceQuality=ves-voicequality|sipSignaling=ves-sipsignaling|notification=ves-notification|pnfRegistration=ves-pnfRegistration|3GPP-FaultSupervision=ves-3gpp-fault-supervision|3GPP-Heartbeat=ves-3gpp-heartbeat|3GPP-Provisioning=ves-3gpp-provisioning|3GPP-PerformanceAssurance=ves-3gpp-performance-assurance
collector.dmaapfile=./etc/DmaapConfig.json
+## Path to the file containing description of api versions
+collector.description.api.version.location=etc/api_version_description.json
+
## Event transformation Flag - when set expects configurable transformation
## defined under ./etc/eventTransform.json
## Enabled by default; to disable set to 0
diff --git a/src/main/java/org/onap/dcae/ApplicationSettings.java b/src/main/java/org/onap/dcae/ApplicationSettings.java
index 7d5c7db2..9462a380 100644
--- a/src/main/java/org/onap/dcae/ApplicationSettings.java
+++ b/src/main/java/org/onap/dcae/ApplicationSettings.java
@@ -196,6 +196,10 @@ public class ApplicationSettings {
return eventTransformations;
}
+ public String getApiVersionDescriptionFilepath() {
+ return properties.getString("collector.description.api.version.location", "etc/api_version_description.json");
+ }
+
private void loadPropertiesFromFile() {
try {
properties.load(configurationFileLocation);
diff --git a/src/main/java/org/onap/dcae/common/HeaderUtils.java b/src/main/java/org/onap/dcae/common/HeaderUtils.java
index c046fb4c..81277d07 100644
--- a/src/main/java/org/onap/dcae/common/HeaderUtils.java
+++ b/src/main/java/org/onap/dcae/common/HeaderUtils.java
@@ -3,7 +3,7 @@
* PROJECT
* ================================================================================
* Copyright (C) 2019 VMware, Inc. All rights reserved.
- * Copyright (C) 2019 Nokia. All rights reserved.s
+ * Copyright (C) 2019-2020 Nokia. 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.
@@ -23,39 +23,33 @@ package org.onap.dcae.common;
import java.util.Collections;
import java.util.Map;
-import java.util.Objects;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Component;
/**
- * @author nil
+ * A class with methods used in HTTP header management.
*/
@Component
public class HeaderUtils {
- public String getApiVerFilePath(String fileName) {
- return Objects.requireNonNull(ClassLoader.getSystemClassLoader().getResource(fileName))
- .getPath();
- }
+ public String getRestApiIdentify(String uri) {
+ return isBatchRequest(uri) ? "eventListener_eventBatch" : "eventListener";
+ }
- public String getRestApiIdentify(String uri) {
- return isBatchRequest(uri) ? "eventListener_eventBatch" : "eventListener";
- }
+ public Map<String, String> extractHeaders(HttpServletRequest request) {
+ return Collections.list(request.getHeaderNames()).stream()
+ .collect(Collectors.toMap(h -> h, request::getHeader));
+ }
- public Map<String, String> extractHeaders(HttpServletRequest request) {
- return Collections.list(request.getHeaderNames()).stream()
- .collect(Collectors.toMap(h -> h, request::getHeader));
- }
+ public HttpHeaders fillHeaders(Map<String, String> headers) {
+ HttpHeaders httpHeaders = new HttpHeaders();
+ httpHeaders.setAll(headers);
+ return httpHeaders;
+ }
- public HttpHeaders fillHeaders(Map<String, String> headers) {
- HttpHeaders httpHeaders = new HttpHeaders();
- httpHeaders.setAll(headers);
- return httpHeaders;
- }
-
- private boolean isBatchRequest(String request) {
- return request.contains("eventBatch");
- }
+ private boolean isBatchRequest(String request) {
+ return request.contains("eventBatch");
+ }
}
diff --git a/src/main/java/org/onap/dcae/restapi/VesRestController.java b/src/main/java/org/onap/dcae/restapi/VesRestController.java
index de0392e6..0a5930f6 100644
--- a/src/main/java/org/onap/dcae/restapi/VesRestController.java
+++ b/src/main/java/org/onap/dcae/restapi/VesRestController.java
@@ -137,7 +137,7 @@ public class VesRestController {
private CustomHeaderUtils createHeaderUtils(String version, HttpServletRequest request) {
return new CustomHeaderUtils(version.toLowerCase().replace("v", ""),
headerUtils.extractHeaders(request),
- headerUtils.getApiVerFilePath("api_version_config.json"),
+ settings.getApiVersionDescriptionFilepath(),
headerUtils.getRestApiIdentify(request.getRequestURI()));
}
diff --git a/src/main/resources/api_version_config.json b/src/main/resources/api_version_config.json
deleted file mode 100644
index 23f585f9..00000000
--- a/src/main/resources/api_version_config.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
- "apiVersion":
- {
- "eventListener": ["4.7.2","5.4.1","7.0.1"],
- "eventListener_eventBatch": ["4.7.2","5.4.1","7.0.1"]
- }
-}
diff --git a/src/test/java/org/onap/dcae/common/JsonDataLoader.java b/src/test/java/org/onap/dcae/common/JsonDataLoader.java
index 2ea59aa0..8c2fdd6d 100644
--- a/src/test/java/org/onap/dcae/common/JsonDataLoader.java
+++ b/src/test/java/org/onap/dcae/common/JsonDataLoader.java
@@ -20,7 +20,9 @@
package org.onap.dcae.common;
import java.io.IOException;
+import java.net.URL;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.nio.file.Paths;
/**
@@ -35,15 +37,15 @@ public final class JsonDataLoader {
}
/**
- * This method is validating given event using schema adn throws exception if event is not valid
+ * This method is validating given event using schema and throws exception when event is invalid
*
* @param path to file that will be loaded
* @return contend of the file located under path, given in parameters, as string
* @throws IOException when file under given path was not found
*/
public static String loadContent(String path) throws IOException {
- return new String(
- Files.readAllBytes(Paths.get(JsonDataLoader.class.getResource(path).getPath()))
- );
+ URL resource = JsonDataLoader.class.getResource(path);
+ Path resourcePath = Paths.get(resource.getPath());
+ return new String(Files.readAllBytes(resourcePath));
}
}
diff --git a/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java b/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java
index 0a03c1a4..ce7e09d3 100644
--- a/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java
+++ b/src/test/java/org/onap/dcae/restapi/VesRestControllerTest.java
@@ -315,9 +315,7 @@ public class VesRestControllerTest {
private void configureHeadersForEventListener() {
when(headerUtils.getRestApiIdentify(anyString())).thenReturn("eventListener");
- when(headerUtils.getApiVerFilePath(anyString())).thenReturn(
- this.getClass().getResource("/api_version_config.json").getPath()
- );
+ when(applicationSettings.getApiVersionDescriptionFilepath()).thenReturn("etc/api_version_description.json");
}
private void verifyThatTransformedEventWasSend(DMaaPEventPublisher eventPublisher, String eventBeforeTransformation) {