From 2b60bd08c6b209c0817fac84970c35df4abca6ed Mon Sep 17 00:00:00 2001 From: shrikantawachar Date: Thu, 8 Mar 2018 13:33:17 +0530 Subject: Download processed file Download processed file Change-Id: Ieaaea0ce231bc0418d9d997d652f85f1743031f0 Issue-ID: SDC-1087 Signed-off-by: shrikantawachar --- .../VendorSoftwareProductManager.java | 2 ++ .../OrchestrationTemplateCandidateManagerImpl.java | 8 ------- .../impl/VendorSoftwareProductManagerImpl.java | 26 +++++++++++++++++++++- .../impl/VspManagerFactoryImpl.java | 4 +++- 4 files changed, 30 insertions(+), 10 deletions(-) (limited to 'openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org') diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java index 423f9a51bb..1b07f681ac 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/VendorSoftwareProductManager.java @@ -16,6 +16,7 @@ package org.openecomp.sdc.vendorsoftwareproduct; +import org.apache.commons.lang3.tuple.Pair; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity; import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity; @@ -68,6 +69,7 @@ public interface VendorSoftwareProductManager { File getInformationArtifact(String vspId, Version version); + public Optional> get(String vspId, Version version) throws IOException; Collection getComputeByVsp(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 97a4a213af..cfb4c9dbfd 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 @@ -22,10 +22,8 @@ import org.apache.commons.lang3.tuple.Pair; import org.openecomp.core.utilities.json.JsonUtil; import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.common.errors.Messages; import org.openecomp.sdc.common.utils.CommonUtil; import org.openecomp.sdc.common.utils.SdcCommon; -import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.datatypes.error.ErrorMessage; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; @@ -52,8 +50,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; -import static org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder.getErrorWithParameters; - public class OrchestrationTemplateCandidateManagerImpl implements OrchestrationTemplateCandidateManager { private static final Logger LOGGER = @@ -128,10 +124,6 @@ public class OrchestrationTemplateCandidateManagerImpl fetchCandidateDataEntity(vspId, version); if (!candidateDataEntity.isPresent()) { - ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR, - getErrorWithParameters(Messages.NO_FILE_WAS_UPLOADED_OR_FILE_NOT_EXIST.getErrorMessage(), - "")); - LOGGER.error(errorMessage.getMessage()); return Optional.empty(); } OnboardingTypesEnum type = 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 ada88b8e1b..f116abef16 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 @@ -18,6 +18,8 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; import org.openecomp.core.dao.UniqueValueDao; import org.openecomp.core.enrichment.api.EnrichmentManager; import org.openecomp.core.enrichment.factory.EnrichmentManagerFactory; @@ -82,6 +84,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilde import org.openecomp.sdc.vendorsoftwareproduct.errors.TranslationFileCreationErrorBuilder; import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder; import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator; +import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService; import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse; import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult; @@ -144,6 +147,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa private final ImageDao imageDao; private final ManualVspToscaManager manualVspToscaManager; private final UniqueValueUtil uniqueValueUtil; + private final CandidateService candidateService; public VendorSoftwareProductManagerImpl( VspMergeDao vspMergeDao, @@ -163,7 +167,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa ComputeDao computeDao, ImageDao imageDao, ManualVspToscaManager manualVspToscaManager, - UniqueValueDao uniqueValueDao) { + UniqueValueDao uniqueValueDao, + CandidateService candidateService) { this.vspMergeDao = vspMergeDao; this.orchestrationTemplateDao = orchestrationTemplateDataDao; this.orchestrationTemplateCandidateManager = orchestrationTemplateCandidateManager; @@ -182,6 +187,7 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa this.imageDao = imageDao; this.manualVspToscaManager = manualVspToscaManager; this.uniqueValueUtil = new UniqueValueUtil(uniqueValueDao); + this.candidateService = candidateService; registerToVersioning(); } @@ -817,6 +823,24 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, schemaInput); } + @Override + public Optional> get(String vspId, Version version) throws IOException { + + OrchestrationTemplateEntity orchestrationTemplateEntity = + orchestrationTemplateDao.get(vspId, version); + + if (isOrchestrationTemplateMissing(orchestrationTemplateEntity)) { + return Optional.empty(); + } + + if (CommonUtil.isFileOriginFromZip(orchestrationTemplateEntity.getFileSuffix())) { + return Optional.of(new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(), candidateService + .getZipData(orchestrationTemplateEntity.getContentData()))); + } + return Optional.of(new ImmutablePair<>(orchestrationTemplateEntity.getFileSuffix(), + orchestrationTemplateEntity.getContentData().array())); + } + void updateUniqueName(String oldVspName, String newVspName) { uniqueValueUtil.updateUniqueValue( VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java index da4328dd91..75351e2fc5 100644 --- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java +++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VspManagerFactoryImpl.java @@ -25,6 +25,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateMan import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager; import org.openecomp.sdc.vendorsoftwareproduct.VspManagerFactory; import org.openecomp.sdc.vendorsoftwareproduct.dao.*; +import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory; import org.openecomp.sdc.vendorsoftwareproduct.factory.InformationArtifactGeneratorFactory; public class VspManagerFactoryImpl extends VspManagerFactory { @@ -47,7 +48,8 @@ public class VspManagerFactoryImpl extends VspManagerFactory { ComputeDaoFactory.getInstance().createInterface(), ImageDaoFactory.getInstance().createInterface(), new ManualVspToscaManagerImpl(), - UniqueValueDaoFactory.getInstance().createInterface()); + UniqueValueDaoFactory.getInstance().createInterface(), CandidateServiceFactory + .getInstance().createInterface()); @Override public VendorSoftwareProductManager createInterface() { -- cgit 1.2.3-korg