2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=======================================================
24 package org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler;
26 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderInternal;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.PushNotifications;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentBuilder;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationInput;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationInput;
41 import org.slf4j.Logger;
42 import org.slf4j.LoggerFactory;
44 public class RpcPushNotificationsHandler implements PushNotifications {
46 private static final Logger LOG = LoggerFactory.getLogger(RpcPushNotificationsHandler.class);
48 private static String OWNKEYNAME = "VES";
49 private final WebSocketServiceClientInternal webSocketService;
50 private final DataProvider databaseService;
51 private final DcaeForwarderInternal aotsDcaeForwarder;
53 public RpcPushNotificationsHandler(WebSocketServiceClientInternal webSocketService, DataProvider databaseService,
54 DcaeForwarderInternal aotsDcaeForwarder) {
56 this.webSocketService = webSocketService;
57 this.databaseService = databaseService;
58 this.aotsDcaeForwarder = aotsDcaeForwarder;
62 public void pushAttributeChangeNotification(PushAttributeChangeNotificationInput input) {
64 LOG.debug("Got attribute change event {}", input);
66 EventlogBuilder enventlogBuilder = new EventlogBuilder();
67 enventlogBuilder.setSourceType(SourceType.Ves);
68 enventlogBuilder.fieldsFrom(input);
69 EventlogEntity eventlogEntity = enventlogBuilder.build();
70 databaseService.writeEventLog(eventlogEntity);
71 webSocketService.sendViaWebsockets(OWNKEYNAME, new AttributeValueChangedNotificationXml(eventlogEntity));
76 public void pushFaultNotification(PushFaultNotificationInput input) {
78 LOG.debug("Got fault event {}", input);
80 FaultlogBuilder faultlogBuilder = new FaultlogBuilder();
81 faultlogBuilder.setSourceType(SourceType.Ves);
82 faultlogBuilder.fieldsFrom(input);
83 FaultlogEntity faultlogEntity = faultlogBuilder.build();
84 databaseService.writeFaultLog(faultlogEntity);
86 FaultcurrentBuilder faultcurrentBuilder = new FaultcurrentBuilder();
87 faultcurrentBuilder.fieldsFrom(input);
88 FaultcurrentEntity faultcurrentEntity = faultcurrentBuilder.build();
89 databaseService.updateFaultCurrent(faultcurrentEntity);
91 ProblemNotificationXml notificationXml = new ProblemNotificationXml(faultlogEntity);
92 aotsDcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(OWNKEYNAME, notificationXml);
93 webSocketService.sendViaWebsockets(OWNKEYNAME, notificationXml);