245807ec3828fab0f081abf2f564da07117dd68d
[ccsdk/features.git] /
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt mountpoint-registrar
4  * =================================================================================================
5  * Copyright (C) 2021 Samsung Electronics Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18
19 package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl;
20 import com.fasterxml.jackson.core.JsonProcessingException;
21 import com.fasterxml.jackson.databind.JsonNode;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24
25 public class DMaaPCMVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
26
27     private static final Logger LOG = LoggerFactory.getLogger(DMaaPCMVESMsgConsumer.class);
28
29     public DMaaPCMVESMsgConsumer(GeneralConfig generalConfig) {
30         super(generalConfig);
31         LOG.info("DMaaPCMVESMsgConsumer started successfully");
32     }
33
34     @Override
35     public void processMsg(String msg) throws InvalidMessageException, JsonProcessingException {
36         LOG.debug("Processing CM message {}", msg);
37         JsonNode rootNode = convertMessageToJsonNode(msg);
38         JsonNode dataNode;
39         JsonNode notificationNode;
40         try {
41             dataNode = rootNode.get("event").get("stndDefinedFields").get("data").requireNonNull();
42             if(dataNode.get("notificationType").textValue().equalsIgnoreCase("notifyMOIChanges")) {
43                 notificationNode = dataNode.get("moiChanges");
44                 LOG.info("Read CM message from DMaaP topic that is moiChanges type with id {}", dataNode.get("notificationId"));
45             }
46         } catch (NullPointerException e) {
47             LOG.warn("Message is invalid, sending aborted, processing stopped because one of fields is missing");
48             throw new InvalidMessageException("Missing field");
49         }
50         // take required data from notificationNode
51     }
52
53 }