Fix missing capability cli models.
[ccsdk/cds.git] / ms / blueprintsprocessor / modules / inbounds / selfservice-api / src / main / kotlin / org / onap / ccsdk / cds / blueprintsprocessor / selfservice / api / ExecutionServiceController.kt
index 60016fb..d48f0c7 100644 (file)
@@ -26,7 +26,8 @@ import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ACTION_MODE_ASYNC
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput
 import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceOutput
 import org.onap.ccsdk.cds.blueprintsprocessor.selfservice.api.utils.determineHttpStatusCode
-import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive
+import org.onap.ccsdk.cds.controllerblueprints.core.asJsonType
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.http.MediaType
 import org.springframework.http.ResponseEntity
@@ -37,36 +38,37 @@ import org.springframework.web.bind.annotation.*
 @RestController
 @RequestMapping("/api/v1/execution-service")
 @Api(value = "/api/v1/execution-service",
-    description = "Interaction with CBA.")
+        description = "Interaction with CBA.")
 open class ExecutionServiceController {
 
     @Autowired
     lateinit var executionServiceHandler: ExecutionServiceHandler
 
     @RequestMapping(path = ["/health-check"],
-        method = [RequestMethod.GET],
-        produces = [MediaType.APPLICATION_JSON_VALUE])
+            method = [RequestMethod.GET],
+            produces = [MediaType.APPLICATION_JSON_VALUE])
     @ResponseBody
     @ApiOperation(value = "Health Check", hidden = true)
     fun executionServiceControllerHealthCheck(): JsonNode = runBlocking {
-        JacksonUtils.getJsonNode("Success")
+        "Success".asJsonPrimitive()
     }
 
     @PostMapping(path = ["/upload"], consumes = [MediaType.MULTIPART_FORM_DATA_VALUE])
     @ResponseBody
     @PreAuthorize("hasRole('USER')")
     @ApiOperation(value = "Upload a CBA",
-        notes = "Upload the CBA package. This will also run validation on the CBA.",
-        produces = MediaType.APPLICATION_JSON_VALUE)
+            notes = "Upload the CBA package. This will also run validation on the CBA.",
+            produces = MediaType.APPLICATION_JSON_VALUE)
     fun upload(@ApiParam(value = "The ZIP file containing the overall CBA package.", required = true)
                @RequestPart("file") filePart: FilePart): JsonNode = runBlocking {
-        JacksonUtils.getJsonNode(executionServiceHandler.upload(filePart))
+        val uploadId = executionServiceHandler.upload(filePart)
+        """{"upload-id" : "$uploadId"}""".asJsonType()
     }
 
     @DeleteMapping("/name/{name}/version/{version}")
     @ApiOperation(value = "Delete a CBA",
-        notes = "Delete the CBA package identified by its name and version.",
-        produces = MediaType.APPLICATION_JSON_VALUE)
+            notes = "Delete the CBA package identified by its name and version.",
+            produces = MediaType.APPLICATION_JSON_VALUE)
     @PreAuthorize("hasRole('USER')")
     fun deleteBlueprint(@ApiParam(value = "Name of the CBA.", required = true)
                         @PathVariable(value = "name") name: String,
@@ -77,18 +79,18 @@ open class ExecutionServiceController {
 
     @RequestMapping(path = ["/process"], method = [RequestMethod.POST], produces = [MediaType.APPLICATION_JSON_VALUE])
     @ApiOperation(value = "Execute a CBA workflow (action)",
-        notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.",
-        produces = MediaType.APPLICATION_JSON_VALUE,
-        response = ExecutionServiceOutput::class)
+            notes = "Execute the appropriate CBA's action based on the ExecutionServiceInput object passed as input.",
+            produces = MediaType.APPLICATION_JSON_VALUE,
+            response = ExecutionServiceOutput::class)
     @ResponseBody
     @PreAuthorize("hasRole('USER')")
     fun process(@ApiParam(value = "ExecutionServiceInput payload.", required = true)
                 @RequestBody executionServiceInput: ExecutionServiceInput): ResponseEntity<ExecutionServiceOutput> =
-        runBlocking {
-            if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) {
-                throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.")
+            runBlocking {
+                if (executionServiceInput.actionIdentifiers.mode == ACTION_MODE_ASYNC) {
+                    throw IllegalStateException("Can't process async request through the REST endpoint. Use gRPC for async processing.")
+                }
+                val processResult = executionServiceHandler.doProcess(executionServiceInput)
+                ResponseEntity(processResult, determineHttpStatusCode(processResult.status.code))
             }
-            val processResult = executionServiceHandler.doProcess(executionServiceInput)
-            ResponseEntity(processResult, determineHttpStatusCode(processResult.status.code))
-        }
 }