X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=netconf-server%2Fsrc%2Fmain%2Fjava%2Forg%2Fcommscope%2Ftr069adapter%2Fnetconf%2Frestapi%2FNetConfServerManagerRestApi.java;h=5418a8cb8cea1d2cd4330aad2be2d948a6a08067;hb=76744e810f35c84ecbd1d9998e361052466e9483;hp=6057c67bac14fba19710cb4aac5ec73d6a3a6ab2;hpb=ce4e2d38e3d42725f61c39dd172325d2def4bc44;p=oam%2Ftr069-adapter.git diff --git a/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/restapi/NetConfServerManagerRestApi.java b/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/restapi/NetConfServerManagerRestApi.java index 6057c67..5418a8c 100644 --- a/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/restapi/NetConfServerManagerRestApi.java +++ b/netconf-server/src/main/java/org/commscope/tr069adapter/netconf/restapi/NetConfServerManagerRestApi.java @@ -1,86 +1,93 @@ -/* - * ============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.netconf.restapi; - -import java.util.List; - -import org.commscope.tr069adapter.mapper.model.NetConfServerDetails; -import org.commscope.tr069adapter.netconf.server.NetConfServerManagerImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/netConfServerManagerService") -public class NetConfServerManagerRestApi { - - private static final Logger LOG = LoggerFactory.getLogger(NetConfServerManagerRestApi.class); - - @Autowired - NetConfServerManagerImpl manager; - - @PostMapping("/createServer") - public NetConfServerDetails createNetConfServerInstance(@RequestParam String deviceId, - @RequestParam String enodeBName, @RequestParam String swVersion, - @RequestParam String hwVersion) { - LOG.info("Received Create NetConf Server request for deviceID: {}, enodeBName: {}, swversion: {}", deviceId, - enodeBName, swVersion); - NetConfServerDetails serverDetails = - manager.createServer(deviceId, enodeBName, swVersion, hwVersion); - LOG.info("Successfully processed NetConf Server wit server details : {}", serverDetails); - return serverDetails; - } - - @PostMapping("/restartOnVersionChange") - public NetConfServerDetails restartOnVersionChange(@RequestParam String deviceId, - @RequestParam String enodeBName, @RequestParam String swVersion, - @RequestParam String hwVersion) { - LOG.info("Received Create NetConf Server request for deviceID: {}, enodeBName: {}", deviceId, - enodeBName); - NetConfServerDetails serverDetails = - manager.restartOnVersionChange(deviceId, enodeBName, swVersion, hwVersion); - LOG.info("Successfully processed NetConf Server wit server details : {}", serverDetails); - return serverDetails; - } - - @GetMapping("/listServers") - public List listNetConfServersInfo() { - LOG.info("Received request to list all NetConf Servers information"); - List serverDetails = manager.getServersInfo(); - LOG.info("Successfully processed request to list all NetConf Servers information"); - return serverDetails; - } - - @PostMapping("/unregisterServer") - public String unregisterNetConfServerInstance(@RequestParam String deviceId, - @RequestParam String enodeBName) { - LOG.info("Received request for Unregister NetConf Server for deviceID: {}, enodeBName: {} ", - deviceId, enodeBName); - String result = manager.unregister(deviceId, enodeBName); - LOG.info("Unregister request is processed. NetConf Server for deviceID: {} , unregisted= {}", - deviceId, result); - return result; - } - -} +/* + * ============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.netconf.restapi; + +import java.util.List; + +import org.commscope.tr069adapter.mapper.model.NetConfServerDetails; +import org.commscope.tr069adapter.netconf.server.NetConfServerManagerImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/netConfServerManagerService") +public class NetConfServerManagerRestApi { + + private static final Logger LOG = LoggerFactory.getLogger(NetConfServerManagerRestApi.class); + public static final String PATTERN = "[\n|\r|\t]"; + + @Autowired + NetConfServerManagerImpl manager; + + @PostMapping("/createServer") + public NetConfServerDetails createNetConfServerInstance(@RequestParam String deviceId, + @RequestParam String enodeBName, @RequestParam String swVersion, + @RequestParam String hwVersion) { + deviceId = deviceId.replaceAll(PATTERN, "_"); + enodeBName = enodeBName.replaceAll(PATTERN, "_"); + LOG.info("Received Create NetConf Server request for deviceID: {}, enodeBName: {}, swversion: {}", deviceId, + enodeBName, swVersion); + NetConfServerDetails serverDetails = + manager.createServer(deviceId, enodeBName, swVersion, hwVersion); + LOG.info("Successfully processed NetConf Server wit server details : {}", serverDetails); + return serverDetails; + } + + @PostMapping("/restartOnVersionChange") + public NetConfServerDetails restartOnVersionChange(@RequestParam String deviceId, + @RequestParam String enodeBName, @RequestParam String swVersion, + @RequestParam String hwVersion) { + deviceId = deviceId.replaceAll(PATTERN, "_"); + enodeBName = enodeBName.replaceAll(PATTERN, "_"); + LOG.info("Received Create NetConf Server request for deviceID: {}, enodeBName: {}", deviceId, + enodeBName); + NetConfServerDetails serverDetails = + manager.restartOnVersionChange(deviceId, enodeBName, swVersion, hwVersion); + LOG.info("Successfully processed NetConf Server wit server details : {}", serverDetails); + return serverDetails; + } + + @GetMapping("/listServers") + public List listNetConfServersInfo() { + LOG.info("Received request to list all NetConf Servers information"); + List serverDetails = manager.getServersInfo(); + LOG.info("Successfully processed request to list all NetConf Servers information"); + return serverDetails; + } + + @PostMapping("/unregisterServer") + public String unregisterNetConfServerInstance(@RequestParam String deviceId, + @RequestParam String enodeBName) { + deviceId = deviceId.replaceAll(PATTERN, "_"); + enodeBName = enodeBName.replaceAll(PATTERN, "_"); + LOG.info("Received request for Unregister NetConf Server for deviceID: {}, enodeBName: {} ", + deviceId, enodeBName); + String result = manager.unregister(deviceId, enodeBName); + LOG.info("Unregister request is processed. NetConf Server for deviceID: {} , unregisted= {}", + deviceId, result); + return result; + } + +}