summaryrefslogtreecommitdiffstats
path: root/openecomp-be/api/openecomp-sdc-rest-webapp
diff options
context:
space:
mode:
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>2021-04-21 13:59:12 +0200
committerMichael Morris <michael.morris@est.tech>2021-05-14 14:58:14 +0000
commite3de4c9d214983d38a7d66e89dae5d4bba170ca3 (patch)
tree9f92e5fc15d06051ffff254588bbcc1e85214d3f /openecomp-be/api/openecomp-sdc-rest-webapp
parentdf353be353e1ec25ac2a0e64a9eb617dcbc87703 (diff)
Integrate helm validator with SDC-BE
- Read helm validator configuration - Add call to helm validator during Helm validation - Add JUnit tests - Fix display message when CNF upload is unsuccessful - Show warning messages from validation after CNF upload Issue-ID: SDC-3185 Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com> Change-Id: If197d557e6ddef4a07bef986d7cf133aedcb2cc5 Signed-off-by: Piotr Marcinkiewicz <piotr.marcinkiewicz@nokia.com>
Diffstat (limited to 'openecomp-be/api/openecomp-sdc-rest-webapp')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java24
1 files changed, 17 insertions, 7 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
index 48ad75d09c..cd18cf973b 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-services/src/main/java/org/openecomp/sdcrests/vsp/rest/services/OrchestrationTemplateCandidateImpl.java
@@ -52,6 +52,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding.OnboardingPackageProcessor;
+import org.openecomp.sdc.vendorsoftwareproduct.impl.onboarding.validation.CnfPackageValidator;
import org.openecomp.sdc.vendorsoftwareproduct.types.OnboardPackageInfo;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
@@ -98,10 +99,12 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
final byte[] fileToUploadBytes = fileToUpload.getObject(byte[].class);
final DataHandler dataHandler = fileToUpload.getDataHandler();
final String filename = ValidationUtils.sanitizeInputString(dataHandler.getName());
- final OnboardingPackageProcessor onboardingPackageProcessor = new OnboardingPackageProcessor(filename, fileToUploadBytes);
+ final OnboardingPackageProcessor onboardingPackageProcessor =
+ new OnboardingPackageProcessor(filename, fileToUploadBytes, new CnfPackageValidator());
+ final ErrorMessage[] errorMessages = onboardingPackageProcessor.getErrorMessages().toArray(new ErrorMessage[0]);
if (onboardingPackageProcessor.hasErrors()) {
final UploadFileResponseDto uploadFileResponseDto = buildUploadResponseWithError(
- onboardingPackageProcessor.getErrorMessages().toArray(new ErrorMessage[0]));
+ errorMessages);
return Response.status(Status.NOT_ACCEPTABLE).entity(uploadFileResponseDto).build();
}
final OnboardPackageInfo onboardPackageInfo = onboardingPackageProcessor.getOnboardPackageInfo().orElse(null);
@@ -112,23 +115,30 @@ public class OrchestrationTemplateCandidateImpl implements OrchestrationTemplate
}
final VspDetails vspDetails = new VspDetails(ValidationUtils.sanitizeInputString(vspId),
new Version(ValidationUtils.sanitizeInputString(versionId)));
- return processOnboardPackage(onboardPackageInfo, vspDetails);
+ return processOnboardPackage(onboardPackageInfo, vspDetails, errorMessages);
}
- private Response processOnboardPackage(final OnboardPackageInfo onboardPackageInfo, final VspDetails vspDetails) {
+ private Response processOnboardPackage(final OnboardPackageInfo onboardPackageInfo, final VspDetails vspDetails, final ErrorMessage... errorMessages) {
final UploadFileResponse uploadFileResponse = candidateManager.upload(vspDetails, onboardPackageInfo);
final UploadFileResponseDto uploadFileResponseDto = new MapUploadFileResponseToUploadFileResponseDto()
.applyMapping(uploadFileResponse, UploadFileResponseDto.class);
+ if (errorMessages.length > 0) {
+ uploadFileResponseDto.setErrors(getErrorMap(errorMessages));
+ }
return Response.ok(uploadFileResponseDto).build();
}
- private UploadFileResponseDto buildUploadResponseWithError(final ErrorMessage... errorMessages) {
- final UploadFileResponseDto uploadFileResponseDto = new UploadFileResponseDto();
+ private Map<String, List<ErrorMessage>> getErrorMap(ErrorMessage[] errorMessages) {
final Map<String, List<ErrorMessage>> errorMap = new HashMap<>();
final List<ErrorMessage> errorMessageList = new ArrayList<>();
Collections.addAll(errorMessageList, errorMessages);
errorMap.put(SdcCommon.UPLOAD_FILE, errorMessageList);
- uploadFileResponseDto.setErrors(errorMap);
+ return errorMap;
+ }
+
+ private UploadFileResponseDto buildUploadResponseWithError(final ErrorMessage... errorMessages) {
+ final UploadFileResponseDto uploadFileResponseDto = new UploadFileResponseDto();
+ uploadFileResponseDto.setErrors(getErrorMap(errorMessages));
return uploadFileResponseDto;
}