aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/mountpoint-registrar/provider/src
diff options
context:
space:
mode:
authorRafal Wrzesniak <r.wrzesniak@partner.samsung.com>2021-09-28 13:54:41 +0200
committerRafal Wrzesniak <r.wrzesniak@partner.samsung.com>2021-09-29 07:34:20 +0200
commit628e725fc6a17d1746000222623901228fa26171 (patch)
treec5ca2f7f4c573d0868ebb881bc9fa58edda38f17 /sdnr/wt/mountpoint-registrar/provider/src
parentf5bd3c0b3fe9e2a813f9f34bb09f8cc3e93882d8 (diff)
Add new message validator interface
And its simple implementation in basic consumer class Issue-ID: CCSDK-3465 Signed-off-by: Rafal Wrzesniak <r.wrzesniak@partner.samsung.com> Change-Id: I84c01ccce48e721ea83756b8081e5a3d57d8bac4
Diffstat (limited to 'sdnr/wt/mountpoint-registrar/provider/src')
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java18
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgValidator.java25
2 files changed, 36 insertions, 7 deletions
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
index 4dcbfbb3e..015e3ada1 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
@@ -19,20 +19,15 @@
package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl;
-import java.util.List;
import java.util.Properties;
-import java.util.function.Consumer;
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.JsonNodeType;
import org.onap.dmaap.mr.client.MRClientFactory;
import org.onap.dmaap.mr.client.MRConsumer;
import org.onap.dmaap.mr.client.response.MRConsumerResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
+public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer, DMaaPVESMsgValidator {
private static final Logger LOG = LoggerFactory.getLogger(DMaaPVESMsgConsumerImpl.class);
private static final String DEFAULT_SDNRUSER = "admin";
@@ -68,7 +63,9 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
for (String msg : consumerResponse.getActualMessages()) {
noData = false;
LOG.debug("{} received ActualMessage from DMaaP VES Message topic {}", name,msg);
- processMsg(msg);
+ if(isMessageValid(msg)) {
+ processMsg(msg);
+ }
}
if (noData) {
@@ -81,6 +78,8 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
}
pauseThread();
}
+ } catch (JsonProcessingException jsonProcessingException) {
+ LOG.warn("Failed to convert message to JsonNode: {}", jsonProcessingException.getMessage());
} catch (Exception e) {
LOG.error("Caught exception reading from DMaaP VES Message Topic", e);
running = false;
@@ -89,6 +88,11 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
}
}
+ @Override
+ public boolean isMessageValid(String message) {
+ return true;
+ }
+
/*
* Create a consumer by specifying properties containing information such as topic name, timeout, URL etc
*/
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgValidator.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgValidator.java
new file mode 100644
index 000000000..0532334ef
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgValidator.java
@@ -0,0 +1,25 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt mountpoint-registrar
+ * =================================================================================================
+ * Copyright (C) 2021 Samsung Electronics Intellectual Property. 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. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ * ============LICENSE_END==========================================================================
+ */
+
+package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl;
+
+public interface DMaaPVESMsgValidator {
+
+ boolean isMessageValid(String message);
+
+}