summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java33
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java11
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml4
3 files changed, 30 insertions, 18 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
index e9f17c42d0..17377d881a 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/CamundaRequestHandler.java
@@ -2,10 +2,10 @@ package org.onap.so.apihandlerinfra;
import java.security.GeneralSecurityException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import javax.ws.rs.core.UriBuilder;
import javax.xml.bind.DatatypeConverter;
import org.camunda.bpm.engine.impl.persistence.entity.HistoricActivityInstanceEntity;
import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity;
@@ -42,10 +42,29 @@ public class CamundaRequestHandler {
@Autowired
private Environment env;
+ private String buildCamundaUrlString(boolean historyLookup, boolean sort, boolean active, String lookupId) {
+ UriBuilder uriBuilder = UriBuilder.fromUri(env.getProperty("mso.camundaURL"));
+ if (historyLookup) {
+ uriBuilder.path(env.getProperty("mso.camunda.rest.history.uri"));
+ uriBuilder.queryParam("processInstanceBusinessKey", lookupId);
+ if (active) {
+ uriBuilder.queryParam("active", true);
+ }
+ if (sort) {
+ uriBuilder.queryParam("sortBy", "startTime");
+ uriBuilder.queryParam("sortOrder", "desc");
+ }
+ } else {
+ uriBuilder.path(env.getProperty("mso.camunda.rest.activity.uri"));
+ uriBuilder.queryParam("processInstanceId", lookupId);
+ }
+ uriBuilder.queryParam("maxResults", 1);
+ return uriBuilder.build().toString();
+ }
+
public ResponseEntity<List<HistoricProcessInstanceEntity>> getCamundaProcessInstanceHistory(String requestId,
- boolean retry) {
- String path = env.getProperty("mso.camunda.rest.history.uri") + requestId;
- String targetUrl = env.getProperty("mso.camundaURL") + path;
+ boolean retry, boolean activeOnly, boolean sort) {
+ String targetUrl = buildCamundaUrlString(true, sort, activeOnly, requestId);
HttpHeaders headers =
setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
@@ -77,8 +96,7 @@ public class CamundaRequestHandler {
protected ResponseEntity<List<HistoricActivityInstanceEntity>> getCamundaActivityHistory(String processInstanceId) {
RestTemplate restTemplate = getRestTemplate(false);
- String path = env.getProperty("mso.camunda.rest.activity.uri") + processInstanceId;
- String targetUrl = env.getProperty("mso.camundaURL") + path;
+ String targetUrl = buildCamundaUrlString(false, false, false, processInstanceId);
HttpHeaders headers =
setCamundaHeaders(env.getRequiredProperty("mso.camundaAuth"), env.getRequiredProperty("mso.msoKey"));
HttpEntity<?> requestEntity = new HttpEntity<>(headers);
@@ -92,7 +110,7 @@ public class CamundaRequestHandler {
String taskInformation = null;
try {
- response = getCamundaProcessInstanceHistory(requestId, false);
+ response = getCamundaProcessInstanceHistory(requestId, false, false, true);
} catch (RestClientException e) {
logger.warn("Error querying Camunda for process-instance history for requestId: {}, exception: {}",
requestId, e.getMessage());
@@ -112,7 +130,6 @@ public class CamundaRequestHandler {
String taskInformation = null;
if (historicProcessInstanceList != null && !historicProcessInstanceList.isEmpty()) {
- Collections.reverse(historicProcessInstanceList);
processInstanceId = historicProcessInstanceList.get(0).getId();
} else {
logger.warn("No processInstances returned for requestId: {} to get TaskInformation", requestId);
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
index 0c6ad0ba22..75b7e74d49 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java
@@ -356,7 +356,7 @@ public class RequestHandlerUtils extends AbstractRestHandler {
String requestId = duplicateRecord.getRequestId();
ResponseEntity<List<HistoricProcessInstanceEntity>> response = null;
try {
- response = camundaRequestHandler.getCamundaProcessInstanceHistory(requestId, true);
+ response = camundaRequestHandler.getCamundaProcessInstanceHistory(requestId, true, true, false);
} catch (RestClientException e) {
logger.error("Error querying Camunda for process-instance history for requestId: {}, exception: {}",
requestId, e.getMessage());
@@ -370,13 +370,8 @@ public class RequestHandlerUtils extends AbstractRestHandler {
if (response.getBody().isEmpty()) {
updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
- }
- for (HistoricProcessInstance instance : response.getBody()) {
- if (("ACTIVE").equals(instance.getState())) {
- return true;
- } else {
- updateStatus(duplicateRecord, Status.COMPLETE, "Request Completed");
- }
+ } else {
+ return true;
}
return false;
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
index babefd9478..baa7af77a5 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml
@@ -25,9 +25,9 @@ mso:
task:
uri: /sobpmnengine/task
history:
- uri: /sobpmnengine/history/process-instance?variables=mso-request-id_eq_
+ uri: /sobpmnengine/history/process-instance
activity:
- uri: /sobpmnengine/history/activity-instance?processInstanceId=
+ uri: /sobpmnengine/history/activity-instance
camundaURL: http://localhost:8089
camundaAuth: E8E19DD16CC90D2E458E8FF9A884CC0452F8F3EB8E321F96038DE38D5C1B0B02DFAE00B88E2CF6E2A4101AB2C011FC161212EE