diff --git a/mosip-packet-creator/src/main/java/io/mosip/testrig/dslrig/packetcreator/controller/CommandsController.java b/mosip-packet-creator/src/main/java/io/mosip/testrig/dslrig/packetcreator/controller/CommandsController.java index 0c36d68a..e547b60f 100644 --- a/mosip-packet-creator/src/main/java/io/mosip/testrig/dslrig/packetcreator/controller/CommandsController.java +++ b/mosip-packet-creator/src/main/java/io/mosip/testrig/dslrig/packetcreator/controller/CommandsController.java @@ -1,40 +1,33 @@ - package io.mosip.testrig.dslrig.packetcreator.controller; - - import java.io.IOException; import java.util.Optional; import - java.util.Properties; - - import org.json.JSONObject; 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.PathVariable; import - org.springframework.web.bind.annotation.PostMapping; import - org.springframework.web.bind.annotation.PutMapping; import - org.springframework.web.bind.annotation.RequestBody; import - org.springframework.web.bind.annotation.RequestParam; import - org.springframework.web.bind.annotation.ResponseBody; import - org.springframework.web.bind.annotation.RestController; import - org.springframework.web.multipart.MultipartFile; - - import io.mosip.testrig.dslrig.dataprovider.util.CommonUtil; import - io.mosip.testrig.dslrig.dataprovider.variables.VariableManager; import - io.mosip.testrig.dslrig.packetcreator.service.CommandsService; import - io.swagger.v3.oas.annotations.tags.Tag; import - io.swagger.v3.oas.annotations.Operation; import - io.swagger.v3.oas.annotations.responses.ApiResponse; import - io.swagger.v3.oas.annotations.responses.ApiResponses; - - @RestController - - @Tag(name = "CommandsController", description = - "REST APIs for Command Center,x Kubernetes Control") public class - CommandsController { private static final Logger logger = - LoggerFactory.getLogger(CommandsController.class); - - @Autowired CommandsService commandsService; - - - +package io.mosip.testrig.dslrig.packetcreator.controller; + +import java.io.IOException; +import java.util.Properties; + +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.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import io.mosip.testrig.dslrig.packetcreator.service.CommandsService; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +@RestController + +@Tag(name = "CommandsController", description = "REST APIs for Command Center,x Kubernetes Control") +public class CommandsController { + private static final Logger logger = LoggerFactory.getLogger(CommandsController.class); + + @Autowired + CommandsService commandsService; + // @GetMapping(value = "/exec/{testcaseId}/{IsSynchronous}/{contextKey}") // // @Operation(summary = "Executing the job") @@ -109,40 +102,33 @@ // } catch (Exception e) { // // } return "{\"Free\"}"; } - - @PostMapping("/writeFile/{offset}/{contextKey}") - - @Operation(summary = "Creating the file") - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = - "File created successfully") }) public @ResponseBody String writeToFile( - // @RequestParam("offset") long offset, - - @PathVariable("offset") long offset, @RequestBody Properties reqestData, - - @PathVariable("contextKey") String contextKey) { - - try { - - return commandsService.writeToFile(contextKey, reqestData, offset); - - } catch (IOException e) { logger.error(e.getMessage()); } return "{Failed}"; - } - - - - @GetMapping(value = "/generatekey/{machineId}/{contextKey}") - - @Operation(summary = "Generate private key based on machineId", description = - "Generate a private key based on the provided machine ID.", responses = { - - @ApiResponse(responseCode = "200", description = - "Private key generated successfully") }) public String - generatekey(@PathVariable String machineId, @PathVariable("contextKey") - String contextKey) { try { return commandsService.generatekey(contextKey, - machineId); } catch (Exception e) { - - logger.error(e.getMessage()); } return "{Failed}"; } - - } - \ No newline at end of file + + @PostMapping("/writeFile/{offset}/{contextKey}") + @Operation(summary = "Creating the file") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "File created successfully") }) + public @ResponseBody String writeToFile( + // @RequestParam("offset") long offset, + @PathVariable("offset") long offset, @RequestBody Properties reqestData, + @PathVariable("contextKey") String contextKey) { + try { + return commandsService.writeToFile(contextKey, reqestData, offset); + } catch (IOException e) { + logger.error(e.getMessage()); + } + return "{Failed}"; + } + + @GetMapping(value = "/generatekey/{machineId}/{contextKey}") + @Operation(summary = "Generate private key based on machineId", description = "Generate a private key based on the provided machine ID.", responses = { + @ApiResponse(responseCode = "200", description = "Private key generated successfully") }) + public String generatekey(@PathVariable String machineId, @PathVariable("contextKey") String contextKey) { + try { + return commandsService.generatekey(contextKey, machineId); + } catch (Exception e) { + + logger.error(e.getMessage()); + } + return "{Failed}"; + } + +}