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=======================================================
25 package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler;
27 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderInternal;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.PushNotifications;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogBuilder;
34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentBuilder;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogBuilder;
38 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity;
39 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
40 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationInput;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationInput;
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
45 public class RpcPushNotificationsHandler implements PushNotifications {
47 private static final Logger LOG = LoggerFactory.getLogger(RpcPushNotificationsHandler.class);
49 private static String OWNKEYNAME = "VES";
50 private final WebSocketServiceClientInternal webSocketService;
51 private final DataProvider databaseService;
52 private final DcaeForwarderInternal aotsDcaeForwarder;
54 public RpcPushNotificationsHandler(WebSocketServiceClientInternal webSocketService, DataProvider databaseService,
55 DcaeForwarderInternal aotsDcaeForwarder) {
57 this.webSocketService = webSocketService;
58 this.databaseService = databaseService;
59 this.aotsDcaeForwarder = aotsDcaeForwarder;
63 public void pushAttributeChangeNotification(PushAttributeChangeNotificationInput input) {
65 LOG.debug("Got attribute change event {}", input);
67 EventlogBuilder enventlogBuilder = new EventlogBuilder();
68 enventlogBuilder.setSourceType(SourceType.Ves);
69 enventlogBuilder.fieldsFrom(input);
70 EventlogEntity eventlogEntity = enventlogBuilder.build();
71 databaseService.writeEventLog(eventlogEntity);
72 webSocketService.sendViaWebsockets(OWNKEYNAME, new AttributeValueChangedNotificationXml(eventlogEntity));
77 public void pushFaultNotification(PushFaultNotificationInput input) {
79 LOG.debug("Got fault event {}", input);
81 FaultlogBuilder faultlogBuilder = new FaultlogBuilder();
82 faultlogBuilder.setSourceType(SourceType.Ves);
83 faultlogBuilder.fieldsFrom(input);
84 FaultlogEntity faultlogEntity = faultlogBuilder.build();
85 databaseService.writeFaultLog(faultlogEntity);
87 FaultcurrentBuilder faultcurrentBuilder = new FaultcurrentBuilder();
88 faultcurrentBuilder.fieldsFrom(input);
89 FaultcurrentEntity faultcurrentEntity = faultcurrentBuilder.build();
90 databaseService.updateFaultCurrent(faultcurrentEntity);
92 ProblemNotificationXml notificationXml = new ProblemNotificationXml(faultlogEntity);
93 aotsDcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(OWNKEYNAME, notificationXml);
94 webSocketService.sendViaWebsockets(OWNKEYNAME, notificationXml);