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