aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src/main/java
diff options
context:
space:
mode:
authorPlummer, Brittany <brittany.plummer@att.com>2019-10-24 14:32:07 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-10-24 14:32:07 -0400
commitbe613b48ac1da8f3820c647390978e62ec35da5d (patch)
tree2175747fe5b5c4e3de220a7b30fdf7459fea4486 /mso-api-handlers/mso-api-handler-infra/src/main/java
parent86f62530f1813152efbcc3d61f85e1fa6c943e36 (diff)
refactor repeated duplicate check code to RequestHandlerUtils
Moved repeated code used when checking for duplicate requests to a new method in RequestHandlerUtils. Issue-ID: SO-2488 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: I523bbb0823f384a458f098c349d8c4b17e782469
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java16
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java41
2 files changed, 21 insertions, 36 deletions
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 e4ae80da97..f68af63591 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
@@ -306,6 +306,22 @@ public class RequestHandlerUtils extends AbstractRestHandler {
return requestUri;
}
+ public void checkForDuplicateRequests(Actions action, HashMap<String, String> instanceIdMap, String requestScope,
+ InfraActiveRequests currentActiveReq, String instanceName) throws ApiException {
+ InfraActiveRequests dup = null;
+ boolean inProgress = false;
+
+ dup = duplicateCheck(action, instanceIdMap, instanceName, requestScope, currentActiveReq);
+
+ if (dup != null) {
+ inProgress = camundaHistoryCheck(dup, currentActiveReq);
+ }
+
+ if (dup != null && inProgress) {
+ buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, instanceName, requestScope, dup);
+ }
+ }
+
public InfraActiveRequests duplicateCheck(Actions action, HashMap<String, String> instanceIdMap,
String instanceName, String requestScope, InfraActiveRequests currentActiveReq) throws ApiException {
InfraActiveRequests dup = null;
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
index 91c62180fc..bb5013085b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java
@@ -846,19 +846,9 @@ public class ServiceInstances extends AbstractRestHandler {
currentActiveReq.setNetworkType(networkType);
}
- InfraActiveRequests dup = null;
- boolean inProgress = false;
-
- dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, instanceName, requestScope, currentActiveReq);
-
- if (dup != null) {
- inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq);
- }
+ requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq,
+ instanceName);
- if (dup != null && inProgress) {
- requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, instanceName,
- requestScope, dup);
- }
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
RequestReferences referencesResponse = new RequestReferences();
@@ -1006,18 +996,7 @@ public class ServiceInstances extends AbstractRestHandler {
throw validateException;
}
- InfraActiveRequests dup =
- requestHandlerUtils.duplicateCheck(action, instanceIdMap, null, requestScope, currentActiveReq);
- boolean inProgress = false;
-
- if (dup != null) {
- inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq);
- }
-
- if (dup != null && inProgress) {
- requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, null, requestScope,
- dup);
- }
+ requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq, null);
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
@@ -1077,18 +1056,8 @@ public class ServiceInstances extends AbstractRestHandler {
requestHandlerUtils.setInstanceId(currentActiveReq, requestScope, null, instanceIdMap);
String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
- InfraActiveRequests dup = null;
-
- dup = requestHandlerUtils.duplicateCheck(action, instanceIdMap, instanceName, requestScope, currentActiveReq);
-
- if (dup != null) {
- inProgress = requestHandlerUtils.camundaHistoryCheck(dup, currentActiveReq);
- }
-
- if (instanceIdMap != null && dup != null && inProgress) {
- requestHandlerUtils.buildErrorOnDuplicateRecord(currentActiveReq, action, instanceIdMap, instanceName,
- requestScope, dup);
- }
+ requestHandlerUtils.checkForDuplicateRequests(action, instanceIdMap, requestScope, currentActiveReq,
+ instanceName);
ServiceInstancesResponse serviceResponse = new ServiceInstancesResponse();
RequestReferences referencesResponse = new RequestReferences();