summaryrefslogtreecommitdiffstats
path: root/mso-api-handlers
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2018-08-06 14:55:00 -0400
committerMarcus Williams <marcus.williams@intel.com>2018-08-06 20:33:50 +0000
commit459c5c9ecfb1bec41b6e82022ff7887d16f5a7af (patch)
treef052b8b97fe33290f4dabb7a46f66faa52950c45 /mso-api-handlers
parentd6f2d23cea31bef057154b1ad3ab147f4acd1223 (diff)
issue while persisting data
Fixing issue while persisting data into the infra active requests table Changing a URL to make it more consistent Removing MSORequest Dependency from all classes but E2EServiceInstance rename the yaml configuration key to something which is already present in d2d Issue-ID: SO-790 Change-Id: I4535a13e2b86ee0eb8c4b0e34aa02f522c0c1a3a Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'mso-api-handlers')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java14
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java8
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java62
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java1
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml6
6 files changed, 56 insertions, 37 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
index 42ad5fc3d5..a93feb6cd9 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java
@@ -479,20 +479,6 @@ public class MsoRequest {
return 0;
}
}
-
- public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage){
- if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
- aq.setStatusMessage (errorMessage);
- aq.setProgress(new Long(100));
- aq.setRequestStatus(status.toString());
- Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
- aq.setEndTime (endTimeStamp);
- iarRepo.save(aq);
- }
- }
-
-
-
public static String domToStr (Document doc) {
if (doc == null) {
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java
index 721fe2fe6b..466de0aa0e 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestsDbClient.java
@@ -55,13 +55,13 @@ public class RequestsDbClient {
private Client<InfraActiveRequests> infraActiveRequestClient;
- @Value("${mso.adapters.db.spring.endpoint:}")
+ @Value("${mso.adapters.requestDb.endpoint}")
private String endpoint;
-
- @Value("${mso.db.auth:}")
+
+ @Value("${mso.adapters.requestDb.auth}")
private String msoAdaptersAuth;
- private String getOrchestrationFilterURI = "/getOrchestrationFiltersFromInfraActive/";
+ private String getOrchestrationFilterURI = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive/";
private String checkVnfIdStatus = "/infraActiveRequests/checkVnfIdStatus/";
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 ba6635e737..e259839d6e 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
@@ -23,6 +23,7 @@ package org.onap.so.apihandlerinfra;
import java.io.IOException;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -712,7 +713,7 @@ public class ServiceInstances {
String errorMessage = "VnfType " + vnfType + " and VF Module Model Name " + modelInfo.getModelName() + serviceVersionText + " not found in MSO Catalog DB";
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
VfModuleNotFoundException vfModuleException = new VfModuleNotFoundException.Builder(errorMessage, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, vfModuleException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, vfModuleException.getMessage());
throw vfModuleException;
}
@@ -829,7 +830,7 @@ public class ServiceInstances {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.AvailabilityError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
String url = requestClient != null ? requestClient.getUrl() : "";
ClientConnectionException clientException = new ClientConnectionException.Builder(url, HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).cause(e).errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
throw clientException;
}
@@ -839,7 +840,7 @@ public class ServiceInstances {
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build();
ClientConnectionException clientException = new ClientConnectionException.Builder(requestClient.getUrl(), HttpStatus.SC_BAD_GATEWAY, ErrorNumbers.SVC_NO_SERVER_RESOURCES).errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, clientException.getMessage());
throw clientException;
}
@@ -883,7 +884,7 @@ public class ServiceInstances {
BPMNFailureException bpmnException = new BPMNFailureException.Builder(String.valueOf(bpelStatus) + camundaJSONResponseBody, bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
.errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, bpmnException.getMessage());
throw bpmnException;
} else {
@@ -893,7 +894,7 @@ public class ServiceInstances {
BPMNFailureException servException = new BPMNFailureException.Builder(String.valueOf(bpelStatus), bpelStatus, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
.errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, servException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, servException.getMessage());
throw servException;
}
@@ -968,7 +969,7 @@ public class ServiceInstances {
DuplicateRequestException dupException = new DuplicateRequestException.Builder(requestScope,instance,dup.getRequestStatus(),dup.getRequestId(), HttpStatus.SC_CONFLICT, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR)
.errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, dupException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, dupException.getMessage());
throw dupException;
}
@@ -987,7 +988,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder("Duplicate Check Request", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e)
.errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
@@ -1008,12 +1009,32 @@ public class ServiceInstances {
.errorInfo(errorLoggerInfo).build();
String requestScope = requestScopeFromUri(requestUri);
- msoRequest.createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON);
+ createErrorRequestRecord(Status.FAILED, requestId, validateException.getMessage(), action, requestScope, requestJSON);
throw validateException;
}
}
-
+ //TODO MSO-4177 -- remove this and call the msoRequest instead
+ public void createErrorRequestRecord (Status status, String requestId, String errorMessage, Actions action, String requestScope, String requestJSON) {
+ try {
+ InfraActiveRequests request = new InfraActiveRequests(requestId);
+ Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
+ request.setStartTime (startTimeStamp);
+ request.setRequestStatus(status.toString());
+ request.setStatusMessage(errorMessage);
+ request.setProgress((long) 100);
+ request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ request.setRequestAction(action.toString());
+ request.setRequestScope(requestScope);
+ request.setRequestBody(requestJSON);
+ Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
+ request.setEndTime(endTimeStamp);
+ iar.save(request);
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB");
+ msoLogger.debug ("Exception: ", e);
+ }
+ }
private void parseRequest(ServiceInstancesRequest sir, HashMap<String, String> instanceIdMap, Actions action, String version,
String requestJSON, Boolean aLaCarte, String requestId, InfraActiveRequests currentActiveReq) throws ValidateException {
int reqVersion = Integer.parseInt(version.substring(1));
@@ -1024,7 +1045,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
@@ -1049,7 +1070,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
@@ -1064,7 +1085,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
@@ -1078,7 +1099,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e)
.errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
}
@@ -1091,7 +1112,7 @@ public class ServiceInstances {
RecipeNotFoundException recipeNotFoundExceptionException = new RecipeNotFoundException.Builder("Recipe could not be retrieved from catalog DB.", HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR)
.errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, recipeNotFoundExceptionException.getMessage());
throw recipeNotFoundExceptionException;
}
return recipeLookupResult;
@@ -1611,7 +1632,7 @@ public class ServiceInstances {
ValidateException validateException = new ValidateException.Builder(error, HttpStatus.SC_NOT_FOUND, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR)
.errorInfo(errorLoggerInfo).build();
- msoRequest.updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
+ updateStatus(currentActiveReq, Status.FAILED, validateException.getMessage());
throw validateException;
@@ -1658,4 +1679,15 @@ public class ServiceInstances {
throw validateException;
}
}
+ //TODO MSO-4177 -- remove this and call the msoRequest instead
+ public void updateStatus(InfraActiveRequests aq, Status status, String errorMessage){
+ if ((status == Status.FAILED) || (status == Status.COMPLETE)) {
+ aq.setStatusMessage (errorMessage);
+ aq.setProgress(new Long(100));
+ aq.setRequestStatus(status.toString());
+ Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
+ aq.setEndTime (endTimeStamp);
+ iar.save(aq);
+ }
+ }
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
index 746f5a57b3..a9cf35796b 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java
@@ -124,6 +124,7 @@ public class CloudResourcesOrchestration {
if(status.equalsIgnoreCase("IN_PROGRESS") || status.equalsIgnoreCase("PENDING") || status.equalsIgnoreCase("PENDING_MANUAL_TASK")){
infraActiveRequest.setRequestStatus("UNLOCKED");
infraActiveRequest.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER);
+ infraActiveRequest.setRequestId(requestId);
requestDbClient.save(infraActiveRequest);
}else{
ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND,MsoLogger.ErrorCode.DataError).build();
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
index cc3fd14e70..de7f560020 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/OrchestrationRequestsTest.java
@@ -374,7 +374,7 @@ public class OrchestrationRequestsTest extends BaseTest {
private void setupTestGetOrchestrationRequestFilter() throws Exception{
//for testGetOrchestrationRequestFilter();
- stubFor(any(urlPathEqualTo("/getOrchestrationFiltersFromInfraActive/")).withRequestBody(equalToJson("{\"modelType\":[\"EQUALS\",\"vfModule\"]}")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
+ stubFor(any(urlPathEqualTo("/infraActiveRequests/getOrchestrationFiltersFromInfraActive/")).withRequestBody(equalToJson("{\"modelType\":[\"EQUALS\",\"vfModule\"]}")).willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.withBody(new String(Files.readAllBytes(Paths.get("src/test/resources/OrchestrationRequest/getRequestDetailsFilter.json"))))
.withStatus(HttpStatus.SC_OK)));
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
index 1f1f859eeb..c5b3b70723 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml
@@ -21,9 +21,9 @@ mso:
archived:
period: 180
adapters:
- db:
- spring:
- endpoint: http://localhost:${wiremock.server.port}
+ requestDb:
+ endpoint: http://localhost:${wiremock.server.port}
+ auth: Basic YnBlbDptc28tZGItMTUwNyE=
logPath: logs
site-name: mtanj
catalog: