diff options
author | Chuanyu Chen <chenchuanyu@huawei.com> | 2020-02-24 03:52:47 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-02-24 03:52:47 +0000 |
commit | bdb6b6a26ce2ad63bf1505e5d81a7c76a4f23085 (patch) | |
tree | 9f5b1a31e6f6ac8755ef91dcb05f004338b87e8c /mso-api-handlers | |
parent | 5376a65d586b37f13342f9e108f224b73d4149fc (diff) | |
parent | 5d34a0a94ccc7852ad75e57fd90198b2014cdd97 (diff) |
Merge "Add PUT API for OrchestrationTask"
Diffstat (limited to 'mso-api-handlers')
-rw-r--r-- | mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java | 35 |
1 files changed, 35 insertions, 0 deletions
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 fc5769632b..4a591dbc58 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 @@ -138,4 +138,39 @@ public class OrchestrationTasks { } } + @PUT + @Path("/{version:[vV][4-7]}/{taskId}") + @Operation(description = "Update an Orchestrated Task", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + @Produces(MediaType.APPLICATION_JSON) + @Transactional + public Response UpdateOrchestrationTask(@PathParam("taskId") String taskId, String requestJson, + @PathParam("version") String version) { + try { + OrchestrationTask orchestrationTask = requestsDbClient.getOrchestrationTask(taskId); + } 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 Update", e); + Response response = + msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, + e.getMessage(), ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null, version); + return response; + } + + try { + OrchestrationTask orchestrationTask = mapper.readValue(requestJson, OrchestrationTask.class); + requestsDbClient.updateOrchestrationTask(taskId, 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 Update", e); + Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, + MsoException.ServiceException, e.getMessage(), ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null, + version); + return response; + } + } + } |