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.context.annotation.Profile;
34 import org.springframework.jms.core.JmsTemplate;
35 import org.springframework.stereotype.Component;
38 //@Profile(value="default")
39 public class TR069EventNotificationService {
41 private static final Logger logger = LoggerFactory.getLogger(TR069EventNotificationService.class);
43 private static final String CLIENT_STR = "client";
46 private JmsTemplate jmsTemplate;
49 * @param deviceNotification
51 public void sendDeviceInformToNBI(DeviceInform deviceNotification) {
52 String deviceId = deviceNotification.getDeviceDetails().getDeviceId();
54 MDC.put(CLIENT_STR, deviceId);
56 TR069InformType notificationType = (TR069InformType) deviceNotification.getInformType();
58 logger.debug("Device Inform Event received: '{}'", notificationType.getNotificationCode());
59 jmsTemplate.convertAndSend(NBI_NOTIFICATION_Q, deviceNotification);
60 logger.debug("Successfully posted the device inform event to DM to forward to NBI");
61 } catch (Exception e) {
62 logger.error("Posting Device Inform event to mapper failed, Reason: {}", e.getMessage());
64 MDC.remove(CLIENT_STR);
69 * @param deviceRPCResponse
71 public void sendOperationResultToNBI(DeviceRPCResponse deviceRPCResponse) {
72 String deviceId = deviceRPCResponse.getDeviceDetails().getDeviceId();
74 MDC.put(CLIENT_STR, deviceId);
76 if (deviceRPCResponse.getOperationResponse()
77 .getOperationCode() instanceof TR069OperationCode) {
78 TR069OperationCode operCode =
79 (TR069OperationCode) deviceRPCResponse.getOperationResponse().getOperationCode();
80 opercode = operCode.name();
81 logger.debug("Device RPC Response received for operation: {} with operation ID: {}",
82 opercode, deviceRPCResponse.getOperationId());
84 } else if (deviceRPCResponse.getOperationResponse()
85 .getOperationCode() instanceof CustomOperationCode) {
86 CustomOperationCode operCode =
87 (CustomOperationCode) deviceRPCResponse.getOperationResponse().getOperationCode();
88 opercode = operCode.name();
89 logger.debug("Device RPC Response received for operation: {} with operation ID: {}",
90 opercode, deviceRPCResponse.getOperationId());
92 jmsTemplate.convertAndSend(NBI_OP_RESULT_Q, deviceRPCResponse);
93 logger.debug("Successfully posted the operation result event to DM to forward to NBI");
94 } catch (Exception e) {
95 logger.error("Posting Device RPC response event to mapper failed, Reason: {}",
98 MDC.remove(CLIENT_STR);