From 8151f09eb4db8bf30b96722d710c952bb5a43445 Mon Sep 17 00:00:00 2001 From: Harry Huang Date: Fri, 21 Feb 2020 17:33:34 +0800 Subject: Add DELETE API for OrchestrationTask Issue-ID: SO-2368 Add method for delete a OrchestrationTask Change-Id: Ic0d480f8e8d05f5f2dcbdc729f2c825bc348ca32 Signed-off-by: Harry Huang --- .../so/apihandlerinfra/OrchestrationTasks.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'mso-api-handlers/mso-api-handler-infra/src') 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 4a591dbc58..21129d7c2d 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 @@ -173,4 +173,37 @@ public class OrchestrationTasks { } } + @DELETE + @Path("/{version:[vV][4-7]}/{taskId}") + @Operation(description = "Delete an Orchestrated Task", responses = @ApiResponse( + content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class))))) + @Produces(MediaType.APPLICATION_JSON) + @Transactional + public Response DeleteOrchestrationTask(@PathParam("taskId") String taskId, @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 Delete", e); + Response response = + msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, + e.getMessage(), ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null, version); + return response; + } + + try { + requestsDbClient.deleteOrchestrationTask(taskId); + return builder.buildResponse(HttpStatus.SC_OK, null, null, 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 Delete", 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