1 /*******************************************************************************
2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH 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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
19 package org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl;
21 import org.eclipse.jdt.annotation.NonNull;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.onap.ccsdk.features.sdnr.wt.common.HtAssert;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
30 public class DcaeForwarderImpl implements DcaeForwarderInternal, AutoCloseable {
32 private static final Logger LOG = LoggerFactory.getLogger(DcaeForwarderImpl.class);
34 private final @Nullable ProviderClient aotsmClient;
35 private final ProviderClient dcaeProvider;
36 private final MaintenanceService maintenanceService;
38 public DcaeForwarderImpl(@Nullable ProviderClient aotsmClient, @Nullable ProviderClient dcaeProvider,
39 @NonNull MaintenanceService maintenanceService) {
42 HtAssert.nonnull(maintenanceService);
43 this.aotsmClient = aotsmClient;
44 this.dcaeProvider = dcaeProvider;
45 this.maintenanceService = maintenanceService;
49 @SuppressWarnings("null")
50 public void sendProblemNotificationUsingMaintenanceFilter(String nodeId, ProblemNotificationXml notificationXml) {
51 if (!this.maintenanceService.isONFObjectInMaintenance(nodeId, notificationXml.getObjectId(),
52 notificationXml.getProblem())) {
53 if (dcaeProvider != null) {
54 this.dcaeProvider.sendProblemNotification(nodeId, notificationXml);
56 if (this.aotsmClient != null) {
57 this.aotsmClient.sendProblemNotification(nodeId, notificationXml);
60 LOG.debug("Notification will not be sent to external services. Device " + nodeId
61 + " is in maintenance mode");
66 public void sendProblemNotification(String nodeId, ProblemNotificationXml notificationXml) {
67 //to prevent push alarms on reconnect
68 //=> only pushed alarms are forwared to dcae
69 //dcaeProvider.sendProblemNotification(nodeName, notificationXml);
70 if(aotsmClient!=null) {
71 aotsmClient.sendProblemNotification(nodeId, notificationXml);
77 public void close() throws Exception {