X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=acs%2Frequestprocessor%2Fsrc%2Fmain%2Fjava%2Forg%2Fcommscope%2Ftr069adapter%2Facs%2Frequestprocessor%2Fimpl%2FTR069EventNotificationService.java;h=2f1ac6fb9e08e25bd0f8cff010afdd35fab3294b;hb=76744e810f35c84ecbd1d9998e361052466e9483;hp=634f9df105dcae18b4ed5d407a440ab005ae3336;hpb=ce4e2d38e3d42725f61c39dd172325d2def4bc44;p=oam%2Ftr069-adapter.git diff --git a/acs/requestprocessor/src/main/java/org/commscope/tr069adapter/acs/requestprocessor/impl/TR069EventNotificationService.java b/acs/requestprocessor/src/main/java/org/commscope/tr069adapter/acs/requestprocessor/impl/TR069EventNotificationService.java index 634f9df..2f1ac6f 100644 --- a/acs/requestprocessor/src/main/java/org/commscope/tr069adapter/acs/requestprocessor/impl/TR069EventNotificationService.java +++ b/acs/requestprocessor/src/main/java/org/commscope/tr069adapter/acs/requestprocessor/impl/TR069EventNotificationService.java @@ -1,95 +1,99 @@ -/* - * ============LICENSE_START======================================================================== - * ONAP : tr-069-adapter - * ================================================================================================= - * Copyright (C) 2020 CommScope Inc Intellectual Property. - * ================================================================================================= - * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License, - * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You - * may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - * ===============LICENSE_END======================================================================= - */ - -package org.commscope.tr069adapter.acs.requestprocessor.impl; - -import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_NOTIFICATION_Q; -import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_OP_RESULT_Q; - -import org.commscope.tr069adapter.acs.common.DeviceInform; -import org.commscope.tr069adapter.acs.common.DeviceRPCResponse; -import org.commscope.tr069adapter.acs.common.dto.CustomOperationCode; -import org.commscope.tr069adapter.acs.common.dto.TR069InformType; -import org.commscope.tr069adapter.acs.common.dto.TR069OperationCode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jms.core.JmsTemplate; -import org.springframework.stereotype.Component; - -@Component -public class TR069EventNotificationService { - - private static final Logger logger = LoggerFactory.getLogger(TR069EventNotificationService.class); - - private static final String CLIENT_STR = "client"; - - @Autowired - private JmsTemplate jmsTemplate; - - /** - * @param deviceNotification - */ - public void sendDeviceInformToNBI(DeviceInform deviceNotification) { - String deviceId = deviceNotification.getDeviceDetails().getDeviceId(); - try { - MDC.put(CLIENT_STR, deviceId); - TR069InformType notificationType = (TR069InformType) deviceNotification.getInformType(); - - logger.debug("Device Inform Event received: '{}'", notificationType.getNotificationCode()); - jmsTemplate.convertAndSend(NBI_NOTIFICATION_Q, deviceNotification); - logger.debug("Successfully posted the device inform event to DM to forward to NBI"); - } catch (Exception e) { - logger.error("Posting Device Inform event to mapper failed, Reason: {}", e.getMessage()); - } finally { - MDC.remove(CLIENT_STR); - } - } - - /** - * @param deviceRPCResponse - */ - public void sendOperationResultToNBI(DeviceRPCResponse deviceRPCResponse) { - String deviceId = deviceRPCResponse.getDeviceDetails().getDeviceId(); - try { - MDC.put(CLIENT_STR, deviceId); - if (deviceRPCResponse.getOperationResponse() - .getOperationCode() instanceof TR069OperationCode) { - TR069OperationCode operCode = - (TR069OperationCode) deviceRPCResponse.getOperationResponse().getOperationCode(); - logger.debug("Device RPC Response received for operation: '" + operCode.name() - + "' with operation ID:" + deviceRPCResponse.getOperationId()); - } else if (deviceRPCResponse.getOperationResponse() - .getOperationCode() instanceof CustomOperationCode) { - CustomOperationCode operCode = - (CustomOperationCode) deviceRPCResponse.getOperationResponse().getOperationCode(); - logger.debug("Device RPC Response received for operation: '" + operCode.getJndiName() - + "' with operation ID:" + deviceRPCResponse.getOperationId()); - } - jmsTemplate.convertAndSend(NBI_OP_RESULT_Q, deviceRPCResponse); - logger.debug("Successfully posted the operation result event to DM to forward to NBI"); - } catch (Exception e) { - logger.error("Posting Device RPC response event to mapper failed, Reason: {}", - e.getMessage()); - } finally { - MDC.remove(CLIENT_STR); - } - } - -} +/* + * ============LICENSE_START======================================================================== + * ONAP : tr-069-adapter + * ================================================================================================= + * Copyright (C) 2020 CommScope Inc Intellectual Property. + * ================================================================================================= + * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License, + * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You + * may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + * ===============LICENSE_END======================================================================= + */ + +package org.commscope.tr069adapter.acs.requestprocessor.impl; + +import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_NOTIFICATION_Q; +import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_OP_RESULT_Q; + +import org.commscope.tr069adapter.acs.common.DeviceInform; +import org.commscope.tr069adapter.acs.common.DeviceRPCResponse; +import org.commscope.tr069adapter.acs.common.dto.CustomOperationCode; +import org.commscope.tr069adapter.acs.common.dto.TR069InformType; +import org.commscope.tr069adapter.acs.common.dto.TR069OperationCode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.slf4j.MDC; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jms.core.JmsTemplate; +import org.springframework.stereotype.Component; + +@Component +public class TR069EventNotificationService { + + private static final Logger logger = LoggerFactory.getLogger(TR069EventNotificationService.class); + + private static final String CLIENT_STR = "client"; + + @Autowired + private JmsTemplate jmsTemplate; + + /** + * @param deviceNotification + */ + public void sendDeviceInformToNBI(DeviceInform deviceNotification) { + String deviceId = deviceNotification.getDeviceDetails().getDeviceId(); + try { + MDC.put(CLIENT_STR, deviceId); + TR069InformType notificationType = (TR069InformType) deviceNotification.getInformType(); + + logger.debug("Device Inform Event received: '{}'", notificationType.getNotificationCode()); + jmsTemplate.convertAndSend(NBI_NOTIFICATION_Q, deviceNotification); + logger.debug("Successfully posted the device inform event to DM to forward to NBI"); + } catch (Exception e) { + logger.error("Posting Device Inform event to mapper failed, Reason: {}", e.getMessage()); + } finally { + MDC.remove(CLIENT_STR); + } + } + + /** + * @param deviceRPCResponse + */ + public void sendOperationResultToNBI(DeviceRPCResponse deviceRPCResponse) { + String deviceId = deviceRPCResponse.getDeviceDetails().getDeviceId(); + try { + MDC.put(CLIENT_STR, deviceId); + String opercode; + if (deviceRPCResponse.getOperationResponse() + .getOperationCode() instanceof TR069OperationCode) { + TR069OperationCode operCode = + (TR069OperationCode) deviceRPCResponse.getOperationResponse().getOperationCode(); + opercode = operCode.name(); + logger.debug("Device RPC Response received for operation: {} with operation ID: {}", + opercode, deviceRPCResponse.getOperationId()); + + } else if (deviceRPCResponse.getOperationResponse() + .getOperationCode() instanceof CustomOperationCode) { + CustomOperationCode operCode = + (CustomOperationCode) deviceRPCResponse.getOperationResponse().getOperationCode(); + opercode = operCode.name(); + logger.debug("Device RPC Response received for operation: {} with operation ID: {}", + opercode, deviceRPCResponse.getOperationId()); + } + jmsTemplate.convertAndSend(NBI_OP_RESULT_Q, deviceRPCResponse); + logger.debug("Successfully posted the operation result event to DM to forward to NBI"); + } catch (Exception e) { + logger.error("Posting Device RPC response event to mapper failed, Reason: {}", + e.getMessage()); + } finally { + MDC.remove(CLIENT_STR); + } + } + +}