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