Initial source code
[oam/tr069-adapter.git] / acs / nbi / src / main / java / org / commscope / tr069adapter / acs / nbi / mapper / service / MapperRequestRESTService.java
diff --git a/acs/nbi/src/main/java/org/commscope/tr069adapter/acs/nbi/mapper/service/MapperRequestRESTService.java b/acs/nbi/src/main/java/org/commscope/tr069adapter/acs/nbi/mapper/service/MapperRequestRESTService.java
new file mode 100644 (file)
index 0000000..9ea4eec
--- /dev/null
@@ -0,0 +1,62 @@
+/*\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.nbi.mapper.service;\r
+\r
+import static org.commscope.tr069adapter.acs.common.utils.AcsConstants.MAPPER_SERVICE_QUALILFIER;\r
+\r
+import org.commscope.tr069adapter.acs.common.DeviceRPCRequest;\r
+import org.commscope.tr069adapter.acs.common.exception.MapperServiceException;\r
+import org.commscope.tr069adapter.acs.common.mapper.ACSServiceAPI;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.beans.factory.annotation.Qualifier;\r
+import org.springframework.web.bind.annotation.PostMapping;\r
+import org.springframework.web.bind.annotation.RequestBody;\r
+import org.springframework.web.bind.annotation.RequestMapping;\r
+import org.springframework.web.bind.annotation.RestController;\r
+\r
+@RestController\r
+@RequestMapping("/MapperService")\r
+public class MapperRequestRESTService {\r
+\r
+  private static final Logger logger = LoggerFactory.getLogger(MapperRequestRESTService.class);\r
+\r
+  @Qualifier(value = MAPPER_SERVICE_QUALILFIER)\r
+  @Autowired\r
+  ACSServiceAPI acsServiceAPI;\r
+\r
+  @PostMapping("/initiateDeviceOperation")\r
+  public Long initiateDeviceOperation(@RequestBody DeviceRPCRequest deviceRPCRequest) {\r
+    logger.debug("Received a Device operation request from Mapper");\r
+    Long operationId = 0l;\r
+    try {\r
+      operationId = acsServiceAPI.performDeviceOperation(deviceRPCRequest);\r
+      logger.debug(\r
+          "Successfully initiated device operation, The operation id for the request is: {}",\r
+          operationId);\r
+    } catch (MapperServiceException e) {\r
+      logger.error("An exception occurred while calling the device operation, Reason: {}",\r
+          e.getMessage());\r
+    }\r
+\r
+    return operationId;\r
+  }\r
+\r
+}\r