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=87ea94ed49d34b5277b89cb0017818ddb9cc0138;hb=HEAD;hp=b6025f0bbbadd1436ff0255a614ce82db3be2789;hpb=a58ada8fd244e69cf2ebe48a251fcdd4d48acec4;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 b6025f0..87ea94e 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,86 +1,102 @@ -/* - * ============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.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); - TR069OperationCode operCode = - (TR069OperationCode) deviceRPCResponse.getOperationResponse().getOperationCode(); - String opCodeName = operCode.name(); - logger.debug("Device RPC Response received for operation: '{}' with operation ID: {}", - opCodeName, 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.context.annotation.Profile; +import org.springframework.jms.core.JmsTemplate; +import org.springframework.stereotype.Component; + +@Component +//@Profile(value="default") +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); + } + } + +}