diff options
Diffstat (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp')
3 files changed, 29 insertions, 45 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java index a28e2c8144..238dbc08d0 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/OrchestrationTemplateCandidateManager.java @@ -41,7 +41,7 @@ public interface OrchestrationTemplateCandidateManager { Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException; - OrchestrationTemplateCandidateData getInfo(String vspId, Version version); + Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version); void abort(String vspId, Version version); } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java index e5b953ffda..57f6b672be 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/OrchestrationTemplateCandidateManagerImpl.java @@ -45,7 +45,6 @@ import java.io.InputStream; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Optional; public class OrchestrationTemplateCandidateManagerImpl @@ -78,9 +77,10 @@ public class OrchestrationTemplateCandidateManagerImpl @Override public OrchestrationTemplateActionResponse process(String vspId, Version version) { - OrchestrationTemplateCandidateData candidate = fetchCandidateDataEntity(vspId, version) - .orElseThrow( - () -> new CoreException(new OrchestrationTemplateNotFoundErrorBuilder(vspId).build())); + OrchestrationTemplateCandidateData candidate = + candidateService.getOrchestrationTemplateCandidate(vspId, version) + .orElseThrow(() -> new CoreException( + new OrchestrationTemplateNotFoundErrorBuilder(vspId).build())); return OrchestrationProcessFactory.getInstance(candidate.getFileSuffix()) .map(processor -> processor.process(getVspDetails(vspId, version), candidate)) @@ -117,27 +117,22 @@ public class OrchestrationTemplateCandidateManagerImpl VspDetails vspDetails = getVspDetails(vspId, version); Optional<OrchestrationTemplateCandidateData> candidateDataEntity = - fetchCandidateDataEntity(vspId, version); + candidateService.getOrchestrationTemplateCandidate(vspId, version); if (!candidateDataEntity.isPresent()) { return Optional.empty(); } - if(Objects.isNull(candidateDataEntity.get().getFileSuffix())) { - return Optional.empty(); - } - - OnboardingTypesEnum type = - OnboardingTypesEnum.getOnboardingTypesEnum(candidateDataEntity.get().getFileSuffix()); - if (CommonUtil.isFileOriginFromZip(candidateDataEntity.get().getFileSuffix())) { FilesDataStructure structure = JsonUtil .json2Object(candidateDataEntity.get().getFilesDataStructure(), FilesDataStructure.class); String manifest = candidateService.createManifest(vspDetails, structure); + OnboardingTypesEnum type = + OnboardingTypesEnum.getOnboardingTypesEnum(candidateDataEntity.get().getFileSuffix()); return Optional.of( new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(), candidateService .replaceManifestInZip(candidateDataEntity.get().getContentData(), - manifest, vspId, type))); + manifest, type))); } return Optional.of( @@ -146,7 +141,7 @@ public class OrchestrationTemplateCandidateManagerImpl } @Override - public OrchestrationTemplateCandidateData getInfo(String vspId, Version version) { + public Optional<OrchestrationTemplateCandidateData> getInfo(String vspId, Version version) { return candidateService.getOrchestrationTemplateCandidateInfo(vspId, version); } @@ -155,16 +150,7 @@ public class OrchestrationTemplateCandidateManagerImpl candidateService.deleteOrchestrationTemplateCandidate(vspId, version); } - private Optional<OrchestrationTemplateCandidateData> fetchCandidateDataEntity( - String vspId, Version version) { - return Optional - .ofNullable(candidateService.getOrchestrationTemplateCandidate(vspId, version)); - } - private VspDetails getVspDetails(String vspId, Version version) { - return vspInfoDao.get(new VspDetails(vspId, version)); } - - } diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java index f116abef16..5874394e96 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java @@ -68,7 +68,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod; -import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails; @@ -127,6 +126,10 @@ import java.util.Set; import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; +import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.candidateDataNotProcessedOrAbortedErrorBuilder; +import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.invalidProcessedCandidate; +import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.vspMissingDeploymentFlavorErrorBuilder; + public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager { private final VspMergeDao vspMergeDao; @@ -258,19 +261,14 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa private void validateOrchestrationTemplateCandidate(ValidationResponse validationResponse, List<ErrorCode> vspErrors, String vspId, Version version) { - OrchestrationTemplateCandidateData orchestrationTemplateCandidateData = - orchestrationTemplateCandidateManager.getInfo(vspId, version); - String validationData = orchestrationTemplateCandidateData.getValidationData(); - String fileName = orchestrationTemplateCandidateData.getFileName(); - if (Objects.nonNull(orchestrationTemplateCandidateData.getFileSuffix())) { - if (validationData.isEmpty()) { - vspErrors.add(VendorSoftwareProductInvalidErrorBuilder - .candidateDataNotProcessedOrAbortedErrorBuilder(fileName)); - } else { - vspErrors.add(VendorSoftwareProductInvalidErrorBuilder.invalidProcessedCandidate(fileName)); - } - validationResponse.setVspErrors(vspErrors); - } + orchestrationTemplateCandidateManager.getInfo(vspId, version) + .ifPresent(candidateInfo -> { + String fileName = candidateInfo.getFileName(); + vspErrors.add(candidateInfo.getValidationData().isEmpty() + ? candidateDataNotProcessedOrAbortedErrorBuilder(fileName) + : invalidProcessedCandidate(fileName)); + validationResponse.setVspErrors(vspErrors); + }); } private void validateManualOnboardingMethod(VspDetails vspDetails, @@ -281,8 +279,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa Collection<DeploymentFlavorEntity> deploymentFlavors = deploymentFlavorDao .list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails.getVersion(), null)); if (CollectionUtils.isEmpty(deploymentFlavors)) { - vspErrors - .add(VendorSoftwareProductInvalidErrorBuilder.vspMissingDeploymentFlavorErrorBuilder()); + vspErrors.add(vspMissingDeploymentFlavorErrorBuilder()); } vspErrors.addAll(validateDeploymentFlavors(deploymentFlavors)); @@ -675,7 +672,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa return packageInfo; } - protected void populateVersionsForVlm(String vlmId, Version vlmVersion) { + void populateVersionsForVlm(String vlmId, Version vlmVersion) { VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface(); versioningManager.list(vlmId).stream() .filter(version -> version.getId().equalsIgnoreCase(vlmVersion.getId())) @@ -852,11 +849,12 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa return computeDao.listByVsp(vspId, version); } - private boolean isOrchestrationTemplateMissing(OrchestrationTemplateEntity orchestrationTemplate) { + private boolean isOrchestrationTemplateMissing( + OrchestrationTemplateEntity orchestrationTemplate) { return orchestrationTemplate == null - || orchestrationTemplate.getContentData() == null - || orchestrationTemplate.getFileSuffix() == null - || orchestrationTemplate.getFileName() == null; + || orchestrationTemplate.getContentData() == null + || orchestrationTemplate.getFileSuffix() == null + || orchestrationTemplate.getFileName() == null; } private boolean isServiceModelMissing(ToscaServiceModel serviceModel) { |