From 5293c3c248caa7373d6d512d78ea04c5d4ae61e1 Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Fri, 21 Feb 2020 16:13:19 +0800 Subject: Add POST API for OrchestrationTask Issue-ID: SO-2368 Add methods for create a OrchestrationTask Change-Id: I0d049b4e60ead8dbb4e524ae4081f17433ac78bd Signed-off-by: Harry Huang --- .../so/apihandlerinfra/OrchestrationTasks.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'mso-api-handlers/mso-api-handler-infra') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java index 7961cb0886..fc5769632b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java @@ -116,4 +116,26 @@ public class OrchestrationTasks { } } + @POST + @Path("/{version:[vV][4-7]}/") + @Operation(description = "Create an Orchestrated Task", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + @Produces(MediaType.APPLICATION_JSON) + @Transactional + public Response CreateOrchestrationTask(String requestJson, @PathParam("version") String version) { + try { + OrchestrationTask orchestrationTask = mapper.readValue(requestJson, OrchestrationTask.class); + requestsDbClient.createOrchestrationTask(orchestrationTask); + return builder.buildResponse(HttpStatus.SC_OK, null, orchestrationTask, version); + } catch (Exception e) { + logger.error(LoggingAnchor.FOUR, MessageEnum.APIH_DB_ACCESS_EXC.toString(), MSO_PROP_APIHANDLER_INFRA, + ErrorCode.AvailabilityError.getValue(), + "Exception while communciate with Request DB - Orchestration Task Create", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, + MsoException.ServiceException, e.getMessage(), ErrorNumbers.COULD_NOT_WRITE_TO_REQUESTS_DB, null, + version); + return response; + } + } + } -- cgit 1.2.3-korg