diff options
Diffstat (limited to 'mso-api-handlers')
14 files changed, 154 insertions, 45 deletions
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 2dab494b07..ec1c4cb362 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 @@ -1125,12 +1125,16 @@ public class ServiceInstances { mapper.setSerializationInclusion(Include.NON_NULL); if(msoRawRequest != null){ ServiceInstancesRequest sir = mapper.readValue(msoRawRequest, ServiceInstancesRequest.class); - if( !isAlaCarte && Action.createInstance.equals(action) && serviceInstRequest != null && + if( serviceInstRequest != null && serviceInstRequest.getRequestDetails() != null && serviceInstRequest.getRequestDetails().getRequestParameters() != null) { - sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration()); - sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams()); + if( !isAlaCarte && Action.createInstance.equals(action)) { + sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration()); + sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams()); + } + sir.getRequestDetails().getRequestParameters().setUsePreload(serviceInstRequest.getRequestDetails().getRequestParameters().getUsePreload()); } + logger.debug("Value as string: {}", mapper.writeValueAsString(sir)); return mapper.writeValueAsString(sir); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java index 31c65e1bd2..9303e12071 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java @@ -82,7 +82,6 @@ public class SDCClientHelper { try { String urlString = this.buildUriBuilder(serviceModelVersionId, operationalEnvironmentId); - logger.debug("Url ASDC Activate request: {}", urlString); String jsonPayload = this.buildJsonWorkloadContext(workloadContext); String basicAuthCred = getBasicAuth(); @@ -158,7 +157,6 @@ public class SDCClientHelper { enhancedAsdcResponseJsonObj.put("statusCode", Integer.toString(statusCode)); enhancedAsdcResponseJsonObj.put("messageId", ""); enhancedAsdcResponseJsonObj.put("message", "Success"); - logger.debug("Url ASDC Activate response: {} {}", "distributionId ", sdcResponseJsonObj.get("distributionId")); } else { // error if (sdcResponseJsonObj.has("requestError") ) { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java index 219a2efcac..352bf8fb0b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java @@ -86,26 +86,31 @@ public class ActivateVnfStatusOperationalEnvironment { */ public void execute(String requestId, CloudOrchestrationRequest request) throws ApiException { - - String operationalEnvironmentId = ""; + try { + + String operationalEnvironmentId = ""; String sdcDistributionId = request.getDistributionId(); Distribution sdcStatus = request.getDistribution(); - // Distribution, Query for operationalEnvironmentId, serviceModelVersionId + // Distribution, Query for operationalEnvironmentId, serviceModelVersionId, origRequestId this.queryDistributionDbResponse = client.getDistributionStatusById(sdcDistributionId); operationalEnvironmentId = this.queryDistributionDbResponse.getOperationalEnvId(); + this.origRequestId = this.queryDistributionDbResponse.getRequestId(); - // ServiceModel, Query for dbRequestId, recoveryAction, retryCountString - this.queryServiceModelResponse = client.findOneByOperationalEnvIdAndServiceModelVersionId(operationalEnvironmentId, queryDistributionDbResponse.getServiceModelVersionId()); - this.origRequestId = this.queryServiceModelResponse.getRequestId(); - + // ServiceModel, Query for recoveryAction, retryCountString + this.queryServiceModelResponse = client.findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId(operationalEnvironmentId, queryDistributionDbResponse.getServiceModelVersionId(), this.origRequestId); + processActivateSDCStatus(sdcDistributionId, sdcStatus, this.queryDistributionDbResponse, this.queryServiceModelResponse); // After EVERY status processed, need to query the status of all service modelId // to determine the OVERALL status if "COMPLETE" or "FAILURE": checkOrUpdateOverallStatus(operationalEnvironmentId, this.origRequestId); - + + } catch(Exception e) { + requestDb.updateInfraFailureCompletion(e.getMessage(), this.origRequestId, this.queryDistributionDbResponse.getOperationalEnvId()); + } + } /** @@ -161,13 +166,11 @@ public class ActivateVnfStatusOperationalEnvironment { } sdcStatusValue = modifiedStatus; - // should update 1 row, modified status & retryCount set 0 OperationalEnvServiceModelStatus updateRetryCountZeroAndStatus = dbHelper.updateRetryCountAndStatusInOperationalEnvServiceModelStatus(queryServiceModelResponse, modifiedStatus, - RETRY_COUNT_ZERO); + RETRY_COUNT_ZERO); client.save(updateRetryCountZeroAndStatus); - // should update 1 row, modified status OperationalEnvDistributionStatus updateDistStatus = dbHelper.updateStatusInOperationalEnvDistributionStatus(queryDistributionDbResponse, modifiedStatus, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java index 7ef712e124..6fd765b76f 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolationbeans/RequestStatus.java @@ -38,7 +38,7 @@ public class RequestStatus implements Serializable { protected String statusMessage; @JsonProperty("percentProgress") protected String percentProgress; - @JsonProperty("timeStamp") + @JsonProperty("timestamp") protected String timeStamp; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java index edb92ef68b..8e1a6f5d35 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidation.java @@ -73,6 +73,23 @@ public class RequestParametersValidation implements ValidationRule{ if(action == Action.createInstance || action == Action.updateInstance){ if(requestParameters.isUsePreload() == null){ if(reqVersion >= 4){ + if (requestParameters.getALaCarte() == null || requestParameters.getALaCarte() == true) { + requestParameters.setUsePreload(true); + } + else { + requestParameters.setUsePreload(false); + } + } + else { + requestParameters.setUsePreload(true); + } + } + } + } + if(requestScope.equalsIgnoreCase(ModelType.service.name())){ + if(action == Action.createInstance){ + if(requestParameters.isUsePreload() == null){ + if(reqVersion >= 4){ if (requestParameters.getALaCarte() == null || requestParameters.getALaCarte() == false) { requestParameters.setUsePreload(false); } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java index 23974ef1fa..d6c794ef2e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/ServiceInstancesTest.java @@ -194,6 +194,24 @@ public class ServiceInstancesTest extends BaseTest{ assertEquals("10",modelInfo.getModelUuid()); } + + + @Test + public void test_mapJSONtoMSOStyleUsePreload() throws IOException{ + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(Include.NON_NULL); + String testRequest= inputStream("/ServiceInstanceDefault.json"); + ServiceInstancesRequest sir = new ServiceInstancesRequest(); + RequestDetails rd = new RequestDetails(); + RequestParameters rp = new RequestParameters(); + rp.setUsePreload(true); + rd.setRequestParameters(rp); + sir.setRequestDetails(rd); + String resultString = servInstances.mapJSONtoMSOStyle(testRequest, sir, false, null); + ServiceInstancesRequest sir1 = mapper.readValue(resultString, ServiceInstancesRequest.class); + assertTrue(sir1.getRequestDetails().getRequestParameters().getUsePreload()); + } + @Test public void createServiceInstanceVIDDefault() throws IOException{ TestAppender.events.clear(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java index 29fa1a34b3..a26848bf21 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironmentTest.java @@ -109,7 +109,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(serviceModelDb)) .withStatus(HttpStatus.SC_OK))); @@ -134,7 +134,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountZero); serviceModelDb.setServiceModelVersionDistrStatus(statusError); - stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(serviceModelDb)) .withStatus(HttpStatus.SC_OK))); @@ -169,7 +169,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountTwo); serviceModelDb.setServiceModelVersionDistrStatus(statusError); - stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(serviceModelDb)) .withStatus(HttpStatus.SC_OK))); @@ -208,7 +208,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(serviceModelDb)) .withStatus(HttpStatus.SC_OK))); @@ -244,7 +244,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ serviceModelDb.setOperationalEnvId(operationalEnvironmentId); serviceModelDb.setRetryCount(retryCountThree); serviceModelDb.setServiceModelVersionDistrStatus(statusError); - stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(serviceModelDb)) .withStatus(HttpStatus.SC_OK))); @@ -276,7 +276,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ stubFor(post(urlPathMatching("/sdc/v1/catalog/services/.*")) .willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(jsonObject.toString()).withStatus(HttpStatus.SC_ACCEPTED))); - stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(serviceModelDb)) .withStatus(HttpStatus.SC_OK))); @@ -339,7 +339,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(serviceModelDb)) .withStatus(HttpStatus.SC_OK))); @@ -415,7 +415,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ InfraActiveRequests iar = new InfraActiveRequests(); iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(serviceModelDb)) .withStatus(HttpStatus.SC_OK))); @@ -477,7 +477,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(serviceModelDb)) .withStatus(HttpStatus.SC_OK))); @@ -536,7 +536,7 @@ public class ActivateVnfStatusOperationalEnvironmentTest extends BaseTest{ iar.setRequestId(requestIdOrig); iar.setRequestStatus("PENDING"); - stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionId")) + stubFor(get(urlPathEqualTo("/operationalEnvServiceModelStatus/search/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId")) .willReturn(aResponse().withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .withBody(mapper.writeValueAsString(serviceModelDb)) .withStatus(HttpStatus.SC_OK))); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java index 2813ef7b70..bd9b95dc12 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/validation/RequestParametersValidationTest.java @@ -50,7 +50,7 @@ public class RequestParametersValidationTest extends BaseTest{ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b"); RequestParametersValidation validation = new RequestParametersValidation(); validation.validate(info); - + assertFalse(sir.getRequestDetails().getRequestParameters().getUsePreload()); assertFalse(info.getReqParameters().getUsePreload()); } @@ -66,7 +66,8 @@ public class RequestParametersValidationTest extends BaseTest{ RequestParametersValidation validation = new RequestParametersValidation(); validation.validate(info); - assertFalse(info.getReqParameters().getUsePreload()); + assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload()); + assertTrue(info.getReqParameters().getUsePreload()); } @Test @@ -82,6 +83,7 @@ public class RequestParametersValidationTest extends BaseTest{ RequestParametersValidation validation = new RequestParametersValidation(); validation.validate(info); + assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload()); assertTrue(info.getReqParameters().getUsePreload()); } @@ -97,7 +99,71 @@ public class RequestParametersValidationTest extends BaseTest{ sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b"); RequestParametersValidation validation = new RequestParametersValidation(); validation.validate(info); - + assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload()); + assertTrue(info.getReqParameters().getUsePreload()); + } + + @Test + public void testServiceWithFalseALaCarte() throws IOException, ValidationException { + String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleModelVersionId.json"))); + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class); + sir.getRequestDetails().getRequestParameters().setUsePreload(null); + ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, + 6, false, sir.getRequestDetails().getRequestParameters()); + sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b"); + info.setRequestScope("service"); + RequestParametersValidation validation = new RequestParametersValidation(); + validation.validate(info); + assertFalse(sir.getRequestDetails().getRequestParameters().getUsePreload()); + assertFalse(info.getReqParameters().getUsePreload()); + } + + @Test + public void testServiceWithNoALaCarte() throws IOException, ValidationException { + String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersNoALaCarte.json"))); + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class); + ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, + 6, false, sir.getRequestDetails().getRequestParameters()); + sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b"); + sir.getRequestDetails().getRequestParameters().setSubscriptionServiceType("subscriptionServiceType"); + info.setRequestScope("service"); + RequestParametersValidation validation = new RequestParametersValidation(); + validation.validate(info); + assertFalse(sir.getRequestDetails().getRequestParameters().getUsePreload()); + assertFalse(info.getReqParameters().getUsePreload()); + } + + @Test + public void testServiceWithTrueALaCarte() throws IOException, ValidationException { + String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleRequestParametersIsALaCarte.json"))); + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class); + sir.getRequestDetails().getRequestParameters().setUsePreload(null); + ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, + 6, true, sir.getRequestDetails().getRequestParameters()); + sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b"); + info.setRequestScope("service"); + RequestParametersValidation validation = new RequestParametersValidation(); + validation.validate(info); + assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload()); assertTrue(info.getReqParameters().getUsePreload()); } + + @Test + public void testServiceWithReqVersionBelow4() throws IOException, ValidationException { + String requestJson = new String(Files.readAllBytes(Paths.get("src/test/resources/MsoRequestTest/RequestParameters/VfModuleModelVersionId.json"))); + ObjectMapper mapper = new ObjectMapper(); + ServiceInstancesRequest sir = mapper.readValue(requestJson, ServiceInstancesRequest.class); + sir.getRequestDetails().getRequestParameters().setUsePreload(null); + ValidationInformation info = new ValidationInformation(sir, new HashMap<String, String>(), Action.createInstance, + 3, false, sir.getRequestDetails().getRequestParameters()); + sir.setServiceInstanceId("0fd90c0c-0e3a-46e2-abb5-4c4820d5985b"); + info.setRequestScope("service"); + RequestParametersValidation validation = new RequestParametersValidation(); + validation.validate(info); + assertTrue(sir.getRequestDetails().getRequestParameters().getUsePreload()); + assertTrue(info.getReqParameters().getUsePreload()); + } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json index dde4392c38..3b2eca7ce2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationFilterResponse.json @@ -29,7 +29,7 @@ "requestState": "COMPLETE", "statusMessage": "STATUS: COMPLETED", "percentProgress": 100, - "timeStamp": "Fri, 01 Jul 2016 04:41:42 GMT" + "timestamp": "Fri, 01 Jul 2016 04:41:42 GMT" } } }, @@ -63,7 +63,7 @@ "requestState": "COMPLETE", "statusMessage": "STATUS: Vf Module has been deleted successfully. FLOW STATUS: Building blocks 1 of 3 completed. ROLLBACK STATUS: Rollback has been completed successfully.", "percentProgress": 100, - "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT" + "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT" } } }, @@ -97,7 +97,7 @@ "requestState": "PENDING", "statusMessage": "STATUS: Vf Module deletion pending.", "percentProgress": 0, - "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT" + "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT" } } }, @@ -181,7 +181,7 @@ "requestState": "UNLOCKED", "statusMessage": "STATUS: Vf Module deletion pending.", "percentProgress": 0, - "timeStamp": "Mon, 30 Jul 2018 06:09:01 GMT" + "timestamp": "Mon, 30 Jul 2018 06:09:01 GMT" } } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json index ecbf7a92a4..90089c0c7e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/OrchestrationRequest/OrchestrationList.json @@ -28,7 +28,7 @@ "requestState":"COMPLETE", "statusMessage":"STATUS: Vf Module has been deleted successfully.", "percentProgress":100, - "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT" + "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT" } } }, @@ -60,7 +60,7 @@ "requestState":"PENDING", "statusMessage":"FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.", "percentProgress":0, - "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT" + "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT" } } }, @@ -323,7 +323,7 @@ "requestState":"PENDING", "statusMessage":"STATUS: Adding members. FLOW STATUS: Building blocks 1 of 3 completed. RETRY STATUS: Retry 2/5 will be started in 8 min. ROLLBACK STATUS: Rollback has been completed successfully.", "percentProgress":0, - "timeStamp": "Thu, 22 Dec 2016 08:30:28 GMT" + "timestamp": "Thu, 22 Dec 2016 08:30:28 GMT" } } } diff --git a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java index bcad9ce6d5..ecf1dcb183 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/main/java/org/onap/so/db/request/data/repository/OperationalEnvServiceModelStatusRepository.java @@ -37,7 +37,8 @@ public interface OperationalEnvServiceModelStatusRepository extends JpaRepositor public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndRequestId(String operationalEnvId, String requestId); public List<OperationalEnvServiceModelStatus> findAllByOperationalEnvIdAndRequestId(@Param("OPERATIONAL_ENV_ID") String operationalEnvId, @Param("REQUEST_ID") String requestId); - public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionId(@Param("OPERATIONAL_ENV_ID") String operationalEnvId, - @Param("SERVICE_MODEL_VERSION_ID") String serviceModelVersionId); + public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId(@Param("OPERATIONAL_ENV_ID") String operationalEnvId, + @Param("SERVICE_MODEL_VERSION_ID") String serviceModelVersionId, + @Param("REQUEST_ID") String requestId); } diff --git a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java index ef3466278e..9eec860cc9 100644 --- a/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java +++ b/mso-api-handlers/mso-requests-db-repositories/src/test/java/org/onap/so/db/request/OperationalEnvServiceModelStatusTest.java @@ -54,8 +54,9 @@ public class OperationalEnvServiceModelStatusTest { status.setRetryCount(0); repository.saveAndFlush(status); - OperationalEnvServiceModelStatus status2 = repository.findOneByOperationalEnvIdAndServiceModelVersionId("oper-env-id-1", "service-model-ver-id-1"); + OperationalEnvServiceModelStatus status2 = repository.findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId("oper-env-id-1", "service-model-ver-id-1", "request-id-1"); status2.setRetryCount(1); + assertEquals("request-id-1", status2.getRequestId()); repository.saveAndFlush(status2); diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java index 69d84b7679..c8ad5f1843 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/beans/WatchdogDistributionStatus.java @@ -56,7 +56,6 @@ public class WatchdogDistributionStatus implements Serializable { @Column(name = "MODIFY_TIME") @Temporal(TemporalType.TIMESTAMP) private Date modifyTime; - @Version @Column(name = "LOCK_VERSION") private int version; diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index b809691b31..5958397851 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -96,7 +96,7 @@ public class RequestsDbClient { private String findOneByServiceIdAndOperationIdURI = "/findOneByServiceIdAndOperationId"; - private String findOneByOperationalEnvIdAndServiceModelVersionIdURI = "/findOneByOperationalEnvIdAndServiceModelVersionId"; + private String findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI = "/findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId"; private String findAllByOperationalEnvIdAndRequestIdURI = "/findAllByOperationalEnvIdAndRequestId"; @@ -123,7 +123,7 @@ public class RequestsDbClient { findOneByServiceIdAndOperationIdURI = endpoint + OPERATION_STATUS_SEARCH + findOneByServiceIdAndOperationIdURI; requestProcessingDataURI = endpoint + requestProcessingDataURI; operationalEnvDistributionStatusURI = endpoint + operationalEnvDistributionStatusURI; - findOneByOperationalEnvIdAndServiceModelVersionIdURI = endpoint + OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH + findOneByOperationalEnvIdAndServiceModelVersionIdURI; + findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI = endpoint + OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH + findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI; findAllByOperationalEnvIdAndRequestIdURI = endpoint + OPERATIONAL_ENV_SERVICE_MODEL_STATUS_SEARCH + findAllByOperationalEnvIdAndRequestIdURI; } @@ -227,16 +227,18 @@ public class RequestsDbClient { } } - public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionId(String operationalEnvironmentId, String serviceModelVersionId) { + public OperationalEnvServiceModelStatus findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestId(String operationalEnvironmentId, String serviceModelVersionId, String requestId) { try { HttpEntity<?> entity = getHttpEntity(); - OperationalEnvServiceModelStatus modelStatus = restTemplate.exchange(getUri(UriBuilder.fromUri(findOneByOperationalEnvIdAndServiceModelVersionIdURI) + OperationalEnvServiceModelStatus modelStatus = restTemplate.exchange(getUri(UriBuilder.fromUri(findOneByOperationalEnvIdAndServiceModelVersionIdAndRequestIdURI) .queryParam(OPERATIONAL_ENVIRONMENT_ID, operationalEnvironmentId) .queryParam(SERVICE_MODEL_VERSION_ID, serviceModelVersionId) + .queryParam(REQUEST_ID, requestId) .build().toString()), HttpMethod.GET, entity, OperationalEnvServiceModelStatus.class).getBody(); if (null != modelStatus) { modelStatus.setOperationalEnvId(operationalEnvironmentId); modelStatus.setServiceModelVersionId(serviceModelVersionId); + modelStatus.setRequestId(requestId); } return modelStatus; }catch(HttpClientErrorException e){ |