summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main
diff options
context:
space:
mode:
authorPlummer, Brittany <brittany.plummer@att.com>2020-03-12 19:23:27 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2020-03-12 19:23:27 -0400
commit7a7e6e39b0c1426ad5e107ca22e526ff565ceec2 (patch)
tree21048bda6948ac6c0beb59c6aa63153604ba710a /mso-api-handlers/mso-api-handler-infra/src/main
parentdf40976f9f92f24096021144f7618e8779fe5f1c (diff)
Added check to prevent camunda history lookup on
Added check to prevent camunda history lookup on older requests Issue-ID: SO-2726 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ie8513626f942404241c351313a791098a0708db4
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/OrchestrationRequests.java35
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/resources/application.yaml1
2 files changed, 30 insertions, 6 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
index 33c2ac80be..c43a050500 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java
@@ -28,6 +28,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import javax.transaction.Transactional;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@@ -73,6 +74,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
@@ -105,6 +107,9 @@ public class OrchestrationRequests {
@Autowired
private CamundaRequestHandler camundaRequestHandler;
+ @Autowired
+ private Environment env;
+
@GET
@Path("/{version:[vV][4-8]}/{requestId}")
@Operation(description = "Find Orchestrated Requests for a given requestId", responses = @ApiResponse(
@@ -436,12 +441,14 @@ public class OrchestrationRequests {
String retryStatusMessage = iar.getRetryStatusMessage();
String taskName = null;
- if (format == null || !format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLENOTASKINFO.toString())) {
- if (flowStatusMessage != null && !flowStatusMessage.equals("Successfully completed all Building Blocks")
- && !flowStatusMessage.equals("All Rollback flows have completed successfully")) {
- taskName = camundaRequestHandler.getTaskName(iar.getRequestId());
- if (taskName != null) {
- flowStatusMessage = flowStatusMessage + " TASK INFORMATION: " + taskName;
+ if (daysSinceRequest(iar) <= camundaCleanupInterval()) {
+ if (format == null || !format.equalsIgnoreCase(OrchestrationRequestFormat.SIMPLENOTASKINFO.toString())) {
+ if (flowStatusMessage != null && !flowStatusMessage.equals("Successfully completed all Building Blocks")
+ && !flowStatusMessage.equals("All Rollback flows have completed successfully")) {
+ taskName = camundaRequestHandler.getTaskName(iar.getRequestId());
+ if (taskName != null) {
+ flowStatusMessage = flowStatusMessage + " TASK INFORMATION: " + taskName;
+ }
}
}
}
@@ -594,4 +601,20 @@ public class OrchestrationRequests {
}
return infraActiveRequest;
}
+
+ protected long daysSinceRequest(InfraActiveRequests request) {
+ long startTime = request.getStartTime().getTime();
+ long now = System.currentTimeMillis();
+
+ return TimeUnit.MILLISECONDS.toDays(now - startTime);
+ }
+
+ protected int camundaCleanupInterval() {
+ String cleanupInterval = env.getProperty("mso.camundaCleanupInterval");
+ int days = 30;
+ if (cleanupInterval != null) {
+ days = Integer.parseInt(cleanupInterval);
+ }
+ return days;
+ }
}
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 baa7af77a5..b46690f2a7 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
@@ -30,6 +30,7 @@ mso:
uri: /sobpmnengine/history/activity-instance
camundaURL: http://localhost:8089
camundaAuth: E8E19DD16CC90D2E458E8FF9A884CC0452F8F3EB8E321F96038DE38D5C1B0B02DFAE00B88E2CF6E2A4101AB2C011FC161212EE
+ camundaCleanupInterval: 30
spring:
datasource: