summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-common/pom.xml2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/pom.xml2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationTasks.java91
-rw-r--r--mso-api-handlers/mso-requests-db-repositories/pom.xml2
-rw-r--r--mso-api-handlers/mso-requests-db/pom.xml2
-rw-r--r--mso-api-handlers/pom.xml2
6 files changed, 96 insertions, 5 deletions
diff --git a/mso-api-handlers/mso-api-handler-common/pom.xml b/mso-api-handlers/mso-api-handler-common/pom.xml
index a3fd37ce2b..865de7998f 100644
--- a/mso-api-handlers/mso-api-handler-common/pom.xml
+++ b/mso-api-handlers/mso-api-handler-common/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.onap.so</groupId>
<artifactId>mso-api-handlers</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
diff --git a/mso-api-handlers/mso-api-handler-infra/pom.xml b/mso-api-handlers/mso-api-handler-infra/pom.xml
index 9944984d33..3a7c7ad477 100644
--- a/mso-api-handlers/mso-api-handler-infra/pom.xml
+++ b/mso-api-handlers/mso-api-handler-infra/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.onap.so</groupId>
<artifactId>mso-api-handlers</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
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 21129d7c2d..90cf50262b 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
@@ -206,4 +206,95 @@ public class OrchestrationTasks {
}
}
+ @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;
+ }
+
+ }
+
+ @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;
+ }
+
+ }
+
+ private JSONObject createMessageBody(String taskId, String taskName, Map<String, ?> variables) {
+ JSONObject msgJson = new JSONObject();
+ msgJson.put("messageName", taskName);
+ msgJson.put("businessKey", taskId);
+ JSONObject processVariables = new JSONObject();
+ for (Map.Entry<String, ?> entry : variables.entrySet()) {
+ JSONObject valueInfo = new JSONObject();
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ valueInfo.put("value", value.toString());
+ valueInfo.put("type", value.getClass().getSimpleName());
+ processVariables.put(key, valueInfo);
+ }
+ msgJson.put("processVariables", processVariables);
+ return msgJson;
+ }
+
}
diff --git a/mso-api-handlers/mso-requests-db-repositories/pom.xml b/mso-api-handlers/mso-requests-db-repositories/pom.xml
index 4dbf22cd87..efc81384d4 100644
--- a/mso-api-handlers/mso-requests-db-repositories/pom.xml
+++ b/mso-api-handlers/mso-requests-db-repositories/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.onap.so</groupId>
<artifactId>mso-api-handlers</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<artifactId>mso-requests-db-repositories</artifactId>
diff --git a/mso-api-handlers/mso-requests-db/pom.xml b/mso-api-handlers/mso-requests-db/pom.xml
index 031f86282a..37bb4175a5 100644
--- a/mso-api-handlers/mso-requests-db/pom.xml
+++ b/mso-api-handlers/mso-requests-db/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.onap.so</groupId>
<artifactId>mso-api-handlers</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<artifactId>mso-requests-db</artifactId>
diff --git a/mso-api-handlers/pom.xml b/mso-api-handlers/pom.xml
index b4d5c7070a..5c84ab1d77 100644
--- a/mso-api-handlers/pom.xml
+++ b/mso-api-handlers/pom.xml
@@ -5,7 +5,7 @@
<parent>
<groupId>org.onap.so</groupId>
<artifactId>so</artifactId>
- <version>1.4.0-SNAPSHOT</version>
+ <version>1.6.0-SNAPSHOT</version>
</parent>
<artifactId>mso-api-handlers</artifactId>