2 * ============LICENSE_START========================================================================
3 * ONAP : tr-069-adapter
4 * =================================================================================================
5 * Copyright (C) 2020 CommScope Inc Intellectual Property.
6 * =================================================================================================
7 * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You
9 * may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14 * either express or implied. See the License for the specific language governing permissions and
15 * limitations under the License.
16 * ===============LICENSE_END=======================================================================
19 package org.commscope.tr069adapter.acs.requestprocessor.impl;
21 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_NOTIFICATION_Q;
22 import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_OP_RESULT_Q;
24 import org.commscope.tr069adapter.acs.common.DeviceInform;
25 import org.commscope.tr069adapter.acs.common.DeviceRPCResponse;
26 import org.commscope.tr069adapter.acs.common.dto.CustomOperationCode;
27 import org.commscope.tr069adapter.acs.common.dto.TR069InformType;
28 import org.commscope.tr069adapter.acs.common.dto.TR069OperationCode;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.jms.core.JmsTemplate;
34 import org.springframework.stereotype.Component;
37 public class TR069EventNotificationService {
39 private static final Logger logger = LoggerFactory.getLogger(TR069EventNotificationService.class);
41 private static final String CLIENT_STR = "client";
44 private JmsTemplate jmsTemplate;
47 * @param deviceNotification
49 public void sendDeviceInformToNBI(DeviceInform deviceNotification) {
50 String deviceId = deviceNotification.getDeviceDetails().getDeviceId();
52 MDC.put(CLIENT_STR, deviceId);
53 TR069InformType notificationType = (TR069InformType) deviceNotification.getInformType();
55 logger.debug("Device Inform Event received: '{}'", notificationType.getNotificationCode());
56 jmsTemplate.convertAndSend(NBI_NOTIFICATION_Q, deviceNotification);
57 logger.debug("Successfully posted the device inform event to DM to forward to NBI");
58 } catch (Exception e) {
59 logger.error("Posting Device Inform event to mapper failed, Reason: {}", e.getMessage());
61 MDC.remove(CLIENT_STR);
66 * @param deviceRPCResponse
68 public void sendOperationResultToNBI(DeviceRPCResponse deviceRPCResponse) {
69 String deviceId = deviceRPCResponse.getDeviceDetails().getDeviceId();
71 MDC.put(CLIENT_STR, deviceId);
73 if (deviceRPCResponse.getOperationResponse()
74 .getOperationCode() instanceof TR069OperationCode) {
75 TR069OperationCode operCode =
76 (TR069OperationCode) deviceRPCResponse.getOperationResponse().getOperationCode();
77 opercode = operCode.name();
78 logger.debug("Device RPC Response received for operation: {} with operation ID: {}",
79 opercode, deviceRPCResponse.getOperationId());
81 } else if (deviceRPCResponse.getOperationResponse()
82 .getOperationCode() instanceof CustomOperationCode) {
83 CustomOperationCode operCode =
84 (CustomOperationCode) deviceRPCResponse.getOperationResponse().getOperationCode();
85 opercode = operCode.name();
86 logger.debug("Device RPC Response received for operation: {} with operation ID: {}",
87 opercode, deviceRPCResponse.getOperationId());
89 jmsTemplate.convertAndSend(NBI_OP_RESULT_Q, deviceRPCResponse);
90 logger.debug("Successfully posted the operation result event to DM to forward to NBI");
91 } catch (Exception e) {
92 logger.error("Posting Device RPC response event to mapper failed, Reason: {}",
95 MDC.remove(CLIENT_STR);