Search in sources :

Example 6 with OrchestrationTask

use of org.onap.so.db.request.beans.OrchestrationTask in project so by onap.

the class OrchestrationTasks method CommitOrchestrationTask.

@POST
@Path("/{version:[vV][4-7]}/{taskId}/commit")
@Operation(description = "Commit an Orchestrated Task", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Response CommitOrchestrationTask(@PathParam("taskId") String taskId, @PathParam("version") String version) {
    OrchestrationTask orchestrationTask;
    try {
        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 Commit", e);
        Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND, MsoException.ServiceException, e.getMessage(), ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null, version);
        return response;
    }
    try {
        String taskName = orchestrationTask.getName();
        Map<String, String> commitVar = new HashMap<>();
        commitVar.put("taskAction", "commit");
        JSONObject msgJson = createMessageBody(taskId, taskName, commitVar);
        camundaRequestHandler.sendCamundaMessages(msgJson);
        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 Delete", e);
        Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, MsoException.ServiceException, e.getMessage(), ErrorNumbers.ERROR_FROM_BPEL, null, version);
        return response;
    }
}
Also used : ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse) Response(javax.ws.rs.core.Response) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) OrchestrationTask(org.onap.so.db.request.beans.OrchestrationTask) ApiException(org.onap.so.apihandlerinfra.exceptions.ApiException) Operation(io.swagger.v3.oas.annotations.Operation) Transactional(javax.transaction.Transactional)

Example 7 with OrchestrationTask

use of org.onap.so.db.request.beans.OrchestrationTask in project so by onap.

the class RequestsDbClient method updateOrchestrationTask.

public OrchestrationTask updateOrchestrationTask(String taskId, OrchestrationTask orchestrationTask) {
    String url = getUri(orchestrationTasksURI + "/" + taskId).toString();
    HttpHeaders headers = getHttpHeaders();
    HttpEntity<OrchestrationTask> entity = new HttpEntity<>(orchestrationTask, headers);
    return restTemplate.exchange(url, HttpMethod.PUT, entity, OrchestrationTask.class).getBody();
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) HttpEntity(org.springframework.http.HttpEntity) OrchestrationTask(org.onap.so.db.request.beans.OrchestrationTask)

Aggregations

OrchestrationTask (org.onap.so.db.request.beans.OrchestrationTask)7 Transactional (javax.transaction.Transactional)5 Operation (io.swagger.v3.oas.annotations.Operation)4 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)4 Response (javax.ws.rs.core.Response)4 ApiException (org.onap.so.apihandlerinfra.exceptions.ApiException)4 HashMap (java.util.HashMap)2 JSONObject (org.json.JSONObject)2 HttpEntity (org.springframework.http.HttpEntity)2 HttpHeaders (org.springframework.http.HttpHeaders)2 Date (java.util.Date)1 Test (org.junit.Test)1 NoEntityFoundException (org.onap.so.db.request.exceptions.NoEntityFoundException)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1