use of org.onap.so.db.request.beans.OrchestrationTask in project so by onap.
the class RequestsDbClient method createOrchestrationTask.
public OrchestrationTask createOrchestrationTask(OrchestrationTask orchestrationTask) {
String url = UriBuilder.fromUri(getUri(orchestrationTasksURI + "/")).build().toString();
HttpHeaders headers = getHttpHeaders();
HttpEntity<OrchestrationTask> entity = new HttpEntity<>(orchestrationTask, headers);
return restTemplate.exchange(url, HttpMethod.POST, entity, OrchestrationTask.class).getBody();
}
use of org.onap.so.db.request.beans.OrchestrationTask in project so by onap.
the class OrchestrationTasks method AbortOrchestrationTask.
@POST
@Path("/{version:[vV][4-7]}/{taskId}/abort")
@Operation(description = "Commit an Orchestrated Task", responses = @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))))
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Response AbortOrchestrationTask(@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", "abort");
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;
}
}
use of org.onap.so.db.request.beans.OrchestrationTask in project so by onap.
the class OrchestrationTasks method CreateOrchestrationTask.
@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;
}
}
use of org.onap.so.db.request.beans.OrchestrationTask in project so by onap.
the class OrchestrationTaskTest method timeStampCreated.
@Test
@Transactional
public void timeStampCreated() throws NoEntityFoundException {
final String testTaskId = "test-task-id";
final String testRequestId = "test-request-id";
final String testTaskName = "test-task-name";
final String testTaskStatus = "test-task-status";
final String testIsManual = "test-is-manual";
OrchestrationTask task = new OrchestrationTask();
task.setTaskId(testTaskId);
task.setRequestId(testRequestId);
task.setName(testTaskName);
task.setStatus(testTaskStatus);
task.setIsManual(testIsManual);
repository.saveAndFlush(task);
OrchestrationTask found = repository.findById(testTaskId).orElseThrow(() -> new NoEntityFoundException("Cannot Find Task"));
Date createdTime = found.getCreatedTime();
assertNotNull(createdTime);
assertEquals(testTaskId, found.getTaskId());
assertEquals(testRequestId, found.getRequestId());
assertEquals(testTaskName, found.getName());
assertEquals(testTaskStatus, found.getStatus());
assertEquals(testIsManual, found.getIsManual());
}
use of org.onap.so.db.request.beans.OrchestrationTask in project so by onap.
the class OrchestrationTasks method UpdateOrchestrationTask.
@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;
}
}
Aggregations