From 7d3f5bfd2e4fefe02c7f2fcf59981bb33f026419 Mon Sep 17 00:00:00 2001 From: "adheli.tavares" Date: Thu, 14 Dec 2023 10:05:49 +0000 Subject: Apply lower case to any topics to be compatible with Kafka. Issue-ID: POLICY-4402 Change-Id: Iebaec5f52a1fa0feb881ccfcb5319bc8a951b496 Signed-off-by: adheli.tavares --- .../event/comm/bus/internal/BusTopicParams.java | 27 ++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java') diff --git a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java index f9537f52..d6fa21b6 100644 --- a/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java +++ b/policy-endpoints/src/main/java/org/onap/policy/common/endpoints/event/comm/bus/internal/BusTopicParams.java @@ -4,7 +4,7 @@ * ================================================================================ * Copyright (C) 2018 Samsung Electronics Co., Ltd. All rights reserved. * Modifications Copyright (C) 2018-2019, 2021 AT&T Intellectual Property. All rights reserved. - * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019, 2023 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -168,6 +168,26 @@ public class BusTopicParams { return additionalProps != null; } + public void setEffectiveTopic(String effectiveTopic) { + this.effectiveTopic = topicToLowerCase(effectiveTopic); + } + + public void setTopic(String topic) { + this.topic = topicToLowerCase(topic); + } + + public String getEffectiveTopic() { + return topicToLowerCase(effectiveTopic); + } + + public String getTopic() { + return topicToLowerCase(topic); + } + + private String topicToLowerCase(String topic) { + return (topic == null || topic.isEmpty()) ? topic : topic.toLowerCase(); + } + @NoArgsConstructor(access = AccessLevel.PRIVATE) public static class TopicParamsBuilder { @@ -179,12 +199,12 @@ public class BusTopicParams { } public TopicParamsBuilder topic(String topic) { - this.params.topic = topic; + this.params.setTopic(topic); return this; } public TopicParamsBuilder effectiveTopic(String effectiveTopic) { - this.params.effectiveTopic = effectiveTopic; + this.params.setEffectiveTopic(effectiveTopic); return this; } @@ -306,7 +326,6 @@ public class BusTopicParams { this.params.serializationProvider = serializationProvider; return this; } - } } -- cgit 1.2.3-korg