summaryrefslogtreecommitdiffstats
path: root/hv-collector-core
diff options
context:
space:
mode:
authorFilip Krzywka <filip.krzywka@nokia.com>2018-09-06 13:37:27 +0200
committerFilip Krzywka <filip.krzywka@nokia.com>2018-09-11 07:28:16 +0000
commit6b1777bf08c682fab15f158e9946e36f3cb9698a (patch)
treeb3c7c0893d4f4655120eabb609e04e71cd2d7b5e /hv-collector-core
parent83c14bf9d6f908abfb5f5ad681570615a9ce541d (diff)
Fix common event header parsing
During JSON parsing we were using 3 times 'version' field. Replaced parsing with protobuf parser to avoid mistakes like this in future Change-Id: I6224dc6533ab553e7e2315a95567a1fa48c1c5ad Issue-ID: DCAEGEN2-710 Signed-off-by: Filip Krzywka <filip.krzywka@nokia.com>
Diffstat (limited to 'hv-collector-core')
-rw-r--r--hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt16
1 files changed, 2 insertions, 14 deletions
diff --git a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt
index 543d7dc6..8affa0b1 100644
--- a/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt
+++ b/hv-collector-core/src/main/kotlin/org/onap/dcae/collectors/veshv/impl/MessageValidator.kt
@@ -19,29 +19,17 @@
*/
package org.onap.dcae.collectors.veshv.impl
+import org.onap.dcae.collectors.veshv.domain.headerRequiredFieldDescriptors
import org.onap.dcae.collectors.veshv.model.VesMessage
import org.onap.ves.VesEventV5.VesEvent.CommonEventHeader
internal object MessageValidator {
- private val requiredFieldDescriptors = listOf(
- "version",
- "eventName",
- "domain",
- "eventId",
- "sourceName",
- "reportingEntityName",
- "priority",
- "startEpochMicrosec",
- "lastEpochMicrosec",
- "sequence")
- .map { fieldName -> CommonEventHeader.getDescriptor().findFieldByName(fieldName) }
-
fun isValid(message: VesMessage): Boolean {
return allMandatoryFieldsArePresent(message.header)
}
private fun allMandatoryFieldsArePresent(header: CommonEventHeader) =
- requiredFieldDescriptors
+ headerRequiredFieldDescriptors
.all { fieldDescriptor -> header.hasField(fieldDescriptor) }
}