Development of NETCONF RPCs for tr-069 adapter to
[oam/tr069-adapter.git] / acs / requestprocessor / src / main / java / org / commscope / tr069adapter / acs / requestprocessor / impl / TR069EventNotificationService.java
index 634f9df..2f1ac6f 100644 (file)
@@ -1,95 +1,99 @@
-/*\r
- * ============LICENSE_START========================================================================\r
- * ONAP : tr-069-adapter\r
- * =================================================================================================\r
- * Copyright (C) 2020 CommScope Inc Intellectual Property.\r
- * =================================================================================================\r
- * This tr-069-adapter software file is distributed by CommScope Inc under the Apache License,\r
- * Version 2.0 (the "License"); you may not use this file except in compliance with the License. You\r
- * may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,\r
- * either express or implied. See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ===============LICENSE_END=======================================================================\r
- */\r
-\r
-package org.commscope.tr069adapter.acs.requestprocessor.impl;\r
-\r
-import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_NOTIFICATION_Q;\r
-import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.NBI_OP_RESULT_Q;\r
-\r
-import org.commscope.tr069adapter.acs.common.DeviceInform;\r
-import org.commscope.tr069adapter.acs.common.DeviceRPCResponse;\r
-import org.commscope.tr069adapter.acs.common.dto.CustomOperationCode;\r
-import org.commscope.tr069adapter.acs.common.dto.TR069InformType;\r
-import org.commscope.tr069adapter.acs.common.dto.TR069OperationCode;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-import org.slf4j.MDC;\r
-import org.springframework.beans.factory.annotation.Autowired;\r
-import org.springframework.jms.core.JmsTemplate;\r
-import org.springframework.stereotype.Component;\r
-\r
-@Component\r
-public class TR069EventNotificationService {\r
-\r
-  private static final Logger logger = LoggerFactory.getLogger(TR069EventNotificationService.class);\r
-\r
-  private static final String CLIENT_STR = "client";\r
-\r
-  @Autowired\r
-  private JmsTemplate jmsTemplate;\r
-\r
-  /**\r
-   * @param deviceNotification\r
-   */\r
-  public void sendDeviceInformToNBI(DeviceInform deviceNotification) {\r
-    String deviceId = deviceNotification.getDeviceDetails().getDeviceId();\r
-    try {\r
-      MDC.put(CLIENT_STR, deviceId);\r
-      TR069InformType notificationType = (TR069InformType) deviceNotification.getInformType();\r
-\r
-      logger.debug("Device Inform Event received: '{}'", notificationType.getNotificationCode());\r
-      jmsTemplate.convertAndSend(NBI_NOTIFICATION_Q, deviceNotification);\r
-      logger.debug("Successfully posted the device inform event to DM to forward to NBI");\r
-    } catch (Exception e) {\r
-      logger.error("Posting Device Inform event to mapper failed, Reason: {}", e.getMessage());\r
-    } finally {\r
-      MDC.remove(CLIENT_STR);\r
-    }\r
-  }\r
-\r
-  /**\r
-   * @param deviceRPCResponse\r
-   */\r
-  public void sendOperationResultToNBI(DeviceRPCResponse deviceRPCResponse) {\r
-    String deviceId = deviceRPCResponse.getDeviceDetails().getDeviceId();\r
-    try {\r
-      MDC.put(CLIENT_STR, deviceId);\r
-      if (deviceRPCResponse.getOperationResponse()\r
-          .getOperationCode() instanceof TR069OperationCode) {\r
-        TR069OperationCode operCode =\r
-            (TR069OperationCode) deviceRPCResponse.getOperationResponse().getOperationCode();\r
-        logger.debug("Device RPC Response received for operation: '" + operCode.name()\r
-            + "' with operation ID:" + deviceRPCResponse.getOperationId());\r
-      } else if (deviceRPCResponse.getOperationResponse()\r
-          .getOperationCode() instanceof CustomOperationCode) {\r
-        CustomOperationCode operCode =\r
-            (CustomOperationCode) deviceRPCResponse.getOperationResponse().getOperationCode();\r
-        logger.debug("Device RPC Response received for operation: '" + operCode.getJndiName()\r
-            + "' with operation ID:" + deviceRPCResponse.getOperationId());\r
-      }\r
-      jmsTemplate.convertAndSend(NBI_OP_RESULT_Q, deviceRPCResponse);\r
-      logger.debug("Successfully posted the operation result event to DM to forward to NBI");\r
-    } catch (Exception e) {\r
-      logger.error("Posting Device RPC response event to mapper failed, Reason: {}",\r
-          e.getMessage());\r
-    } finally {\r
-      MDC.remove(CLIENT_STR);\r
-    }\r
-  }\r
-\r
-}\r
+/*
+ * ============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);
+    }
+  }
+
+}