ca5f15a1f03dcbaf28be83406ea79924298c11f6
[oam/tr069-adapter.git] / mapper / src / main / java / org / commscope / tr069adapter / mapper / netconf / controller / NetConfRequestReceiver.java
1 /*\r
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
10  *\r
11  * http://www.apache.org/licenses/LICENSE-2.0\r
12  *\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
17  */\r
18 \r
19 package org.commscope.tr069adapter.mapper.netconf.controller;\r
20 \r
21 import org.commscope.tr069adapter.mapper.model.NetConfRequest;\r
22 import org.commscope.tr069adapter.mapper.model.NetConfResponse;\r
23 import org.commscope.tr069adapter.mapper.model.NetConfServerDetails;\r
24 import org.commscope.tr069adapter.mapper.netconf.NetConfRequestHandler;\r
25 import org.slf4j.Logger;\r
26 import org.slf4j.LoggerFactory;\r
27 import org.springframework.beans.factory.annotation.Autowired;\r
28 import org.springframework.web.bind.annotation.PostMapping;\r
29 import org.springframework.web.bind.annotation.RequestBody;\r
30 import org.springframework.web.bind.annotation.RequestMapping;\r
31 import org.springframework.web.bind.annotation.RestController;\r
32 \r
33 @RestController\r
34 @RequestMapping("/tr069MapperNBI")\r
35 public class NetConfRequestReceiver {\r
36 \r
37   private static final Logger LOG = LoggerFactory.getLogger(NetConfRequestReceiver.class);\r
38 \r
39   @Autowired\r
40   NetConfRequestHandler handler;\r
41 \r
42   @PostMapping("/setConfig")\r
43   public NetConfResponse setConfigRequest(@RequestBody NetConfRequest request) {\r
44     LOG.info("Received request for SET-CONFIG. Request : {}", request);\r
45     NetConfResponse response = handler.handleSetConfigRequest(request);\r
46     LOG.info("Processed SET-CONFIG request. Response : {}", response);\r
47     return response;\r
48   }\r
49 \r
50   @PostMapping("/get")\r
51   public NetConfResponse getRequest(@RequestBody NetConfRequest request) {\r
52     LOG.info("Received request for GET. Request : {}", request);\r
53     NetConfResponse response = handler.handleGetRequest(request);\r
54     LOG.info("Processed GET request. Response : {}", response);\r
55     return response;\r
56   }\r
57 \r
58   @PostMapping("/getConfig")\r
59   public NetConfResponse getConfigRequest(@RequestBody NetConfRequest request) {\r
60     LOG.info("Received request for GET-CONFIG. Request : {}", request);\r
61     NetConfResponse response = handler.handleGetConfigRequest(request);\r
62     LOG.info("Processed GET-CONFIG request. Response : {}", response);\r
63     return response;\r
64   }\r
65 \r
66   @PostMapping("/delConfig")\r
67   public NetConfResponse delConfigRequest(@RequestBody NetConfRequest request) {\r
68     LOG.info("Received request for DEL-CONFIG. Request : {}", request);\r
69     NetConfResponse response = handler.handleDelConfigRequest(request);\r
70     LOG.info("Processed DEL-CONFIG request. Response : {}", response);\r
71     return response;\r
72   }\r
73 \r
74   @PostMapping("/softwareDowload")\r
75   public NetConfResponse swDownloadRequest(@RequestBody NetConfRequest request) {\r
76     LOG.info("Received request for SW-DOWNLOAD. Request : {}", request);\r
77     NetConfResponse response = handler.handleSWDownloadRequest(request);\r
78     LOG.info("Processed SW-DOWNLOAD request. Response : ");\r
79     return response;\r
80   }\r
81 \r
82   @PostMapping("/softwareActivate")\r
83   public NetConfResponse swActivateRequest(@RequestBody NetConfRequest request) {\r
84     LOG.info("Received request for SW-ACTIVATE. Request : {}", request);\r
85     LOG.info("Processed SW-ACTIVATE request. Response : ");\r
86     return null;\r
87   }\r
88 \r
89   @PostMapping("/registerNetconfServer")\r
90   public boolean handelRegisterEvent(@RequestBody NetConfServerDetails request) {\r
91     LOG.info("Received request for register event. Request : {}", request);\r
92     boolean result = handler.handelRegisterEvent(request);\r
93     LOG.info("Processed register event request. Response : {}", request);\r
94     return result;\r
95   }\r
96 \r
97 }\r