summaryrefslogtreecommitdiffstats
path: root/openecomp-be/backend
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/backend')
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java28
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java5
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java72
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java3
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java4
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java2
6 files changed, 69 insertions, 45 deletions
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 82b1d0a64c..175ba3df7d 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
@@ -51,7 +51,6 @@ import org.openecomp.core.enrichment.api.EnrichmentManager;
import org.openecomp.core.enrichment.factory.EnrichmentManagerFactory;
import org.openecomp.core.model.dao.EnrichedServiceModelDao;
import org.openecomp.core.model.dao.ServiceModelDao;
-import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.util.UniqueValueUtil;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonSchemaDataGenerator;
@@ -147,8 +146,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager;
private VendorSoftwareProductInfoDao vspInfoDao;
private VendorLicenseFacade vendorLicenseFacade;
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
- private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
+ private ServiceModelDao<ToscaServiceModel> serviceModelDao;
+ private EnrichedServiceModelDao<ToscaServiceModel> enrichedServiceModelDao;
private VendorLicenseArtifactsService licenseArtifactsService;
private InformationArtifactGenerator informationArtifactGenerator;
private PackageInfoDao packageInfoDao;
@@ -388,10 +387,14 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return null;
}
enrichedServiceModelDao.deleteAll(vendorSoftwareProductId, version);
- EnrichmentManager<ToscaServiceModel> enrichmentManager = EnrichmentManagerFactory.getInstance().createInterface();
+ if (CollectionUtils.isNotEmpty(serviceModel.getModelList())) {
+ enrichedServiceModelDao.storeServiceModel(vendorSoftwareProductId, version, serviceModel);
+ return Collections.emptyMap();
+ }
+ final EnrichmentManager<ToscaServiceModel> enrichmentManager = EnrichmentManagerFactory.getInstance().createInterface();
enrichmentManager.init(vendorSoftwareProductId, version);
enrichmentManager.setModel(serviceModel);
- Map<String, List<ErrorMessage>> enrichErrors = enrichmentManager.enrich();
+ final Map<String, List<ErrorMessage>> enrichErrors = enrichmentManager.enrich();
enrichedServiceModelDao.storeServiceModel(vendorSoftwareProductId, version, enrichmentManager.getModel());
return enrichErrors;
}
@@ -568,8 +571,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
});
}
- private PackageInfo createPackageInfo(VspDetails vspDetails) {
- PackageInfo packageInfo = new PackageInfo(vspDetails.getId(), vspDetails.getVersion());
+ private PackageInfo createPackageInfo(final VspDetails vspDetails) {
+ final var packageInfo = new PackageInfo(vspDetails.getId(), vspDetails.getVersion());
packageInfo.setVspName(vspDetails.getName());
packageInfo.setVspDescription(vspDetails.getDescription());
packageInfo.setCategory(vspDetails.getCategory());
@@ -577,6 +580,9 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
packageInfo.setVendorName(vspDetails.getVendorName());
packageInfo.setPackageType(VendorSoftwareProductConstants.CSAR);
packageInfo.setVendorRelease("1.0"); //todo TBD
+ if (CollectionUtils.isNotEmpty(vspDetails.getModelIdList())) {
+ packageInfo.setModels(new HashSet<>(vspDetails.getModelIdList()));
+ }
return packageInfo;
}
@@ -732,8 +738,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
private OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager;
private VendorSoftwareProductInfoDao vspInfoDao;
private VendorLicenseFacade vendorLicenseFacade;
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
- private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
+ private ServiceModelDao<ToscaServiceModel> serviceModelDao;
+ private EnrichedServiceModelDao<ToscaServiceModel> enrichedServiceModelDao;
private VendorLicenseArtifactsService licenseArtifactsService;
private InformationArtifactGenerator informationArtifactGenerator;
private PackageInfoDao packageInfoDao;
@@ -772,12 +778,12 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
return this;
}
- public Builder serviceModel(ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao) {
+ public Builder serviceModel(ServiceModelDao<ToscaServiceModel> serviceModelDao) {
this.serviceModelDao = serviceModelDao;
return this;
}
- public Builder enrichedServiceModel(EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao) {
+ public Builder enrichedServiceModel(EnrichedServiceModelDao<ToscaServiceModel> enrichedServiceModelDao) {
this.enrichedServiceModelDao = enrichedServiceModelDao;
return this;
}
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
index bc84e89e74..9b5c798c5f 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/OrchestrationUtil.java
@@ -90,7 +90,7 @@ public class OrchestrationUtil {
private final ProcessDao processDao;
private final OrchestrationTemplateDao orchestrationTemplateDataDao;
private final ComponentDao componentDao;
- private final ServiceModelDao serviceModelDao;
+ private final ServiceModelDao<ToscaServiceModel> serviceModelDao;
private final ComponentDependencyModelDao componentDependencyModelDao;
private final CompositionEntityDataManager compositionEntityDataManager;
private final CompositionDataExtractor compositionDataExtractor;
@@ -275,7 +275,8 @@ public class OrchestrationUtil {
VspMergeDaoFactory.getInstance().createInterface().updateHint(vspDetails.getId(), vspDetails.getVersion());
}
- public void saveServiceModel(String vspId, Version version, ToscaServiceModel serviceModelToExtract, ToscaServiceModel serviceModelToStore) {
+ public void saveServiceModel(String vspId, Version version, ToscaServiceModel serviceModelToExtract,
+ ToscaServiceModel serviceModelToStore) {
if (serviceModelToExtract != null) {
serviceModelDao.storeServiceModel(vspId, version, serviceModelToStore);
//Extracting the compostion data from the output service model of the first phase of
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
index 8778e0b56b..144c8fcf8c 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessCsarHandler.java
@@ -18,14 +18,15 @@ package org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.process;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.openecomp.core.impl.AbstractToscaSolConverter;
import org.openecomp.core.impl.ToscaConverterImpl;
+import org.openecomp.core.impl.ToscaModelConverter;
import org.openecomp.core.impl.ToscaSolConverterVnf;
import org.openecomp.core.impl.ToscaSolModelDrivenConverterPnf;
import org.openecomp.core.utilities.file.FileContentHandler;
@@ -43,14 +44,11 @@ import org.openecomp.sdc.heat.services.tree.ToscaTreeManager;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentMonitoringUploadEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
import org.openecomp.sdc.vendorsoftwareproduct.impl.orchestration.OrchestrationUtil;
import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
-import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIService;
import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIServiceImpl;
import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
@@ -101,37 +99,55 @@ public class OrchestrationTemplateProcessCsarHandler implements OrchestrationTem
return;
}
HeatStructureTree tree = toscaTreeManager.getTree();
- Map<String, String> componentsQuestionnaire = new HashMap<>();
- Map<String, Map<String, String>> componentNicsQuestionnaire = new HashMap<>();
- Map<String, Collection<ComponentMonitoringUploadEntity>> componentMibList = new HashMap<>();
- Map<String, Collection<ProcessEntity>> processes = new HashMap<>();
- Map<String, ProcessEntity> processArtifact = new HashMap<>();
- OrchestrationUtil orchestrationUtil = new OrchestrationUtil();
- orchestrationUtil.backupComponentsQuestionnaireBeforeDelete(vspDetails.getId(), vspDetails.getVersion(), componentsQuestionnaire,
- componentNicsQuestionnaire, componentMibList, processes, processArtifact);
+ final var orchestrationUtil = new OrchestrationUtil();
+ orchestrationUtil.backupComponentsQuestionnaireBeforeDelete(vspDetails.getId(), vspDetails.getVersion(),
+ new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>(), new HashMap<>());
Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
.fetchZipFileByteArrayInputStream(vspDetails.getId(), candidateData, null, OnboardingTypesEnum.CSAR, errors);
orchestrationUtil.deleteUploadDataAndContent(vspDetails.getId(), vspDetails.getVersion());
zipByteArrayInputStream.ifPresent(
byteArrayInputStream -> orchestrationUtil.saveUploadData(vspDetails, candidateData, byteArrayInputStream, fileContentHandler, tree));
- ETSIService etsiService = new ETSIServiceImpl();
- ToscaServiceModel toscaServiceModel;
- if (etsiService.isSol004WithToscaMetaDirectory(fileContentHandler)) {
- if (OnboardingTypesEnum.CSAR.toString().equalsIgnoreCase(candidateData.getFileSuffix())) {
- fileContentHandler
- .addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getOriginalFileName() + EXT_SEPARATOR + candidateData.getOriginalFileSuffix(),
- candidateData.getOriginalFileContentData().array());
- } else {
- fileContentHandler.addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getFileName() + EXT_SEPARATOR + candidateData.getFileSuffix(),
- candidateData.getContentData().array());
- }
- final ResourceTypeEnum resourceType = etsiService.getResourceType(fileContentHandler);
- toscaServiceModel = instantiateToscaConverterFor(resourceType).convert(fileContentHandler);
+ final var toscaServiceModel = convertToToscaServiceModel(vspDetails.getModelIdList(), fileContentHandler, candidateData);
+ orchestrationUtil
+ .saveServiceModel(vspDetails.getId(), vspDetails.getVersion(), toscaServiceModel, toscaServiceModel);
+ candidateService.deleteOrchestrationTemplateCandidate(vspDetails.getId(), vspDetails.getVersion());
+ }
+
+ private ToscaServiceModel convertToToscaServiceModel(final List<String> modelList, final FileContentHandler fileContentHandler,
+ final OrchestrationTemplateCandidateData candidateData) throws IOException {
+ if (CollectionUtils.isNotEmpty(modelList)) {
+ return handleToscaModelConversion(modelList, fileContentHandler, candidateData);
+ }
+ if (new ETSIServiceImpl().isSol004WithToscaMetaDirectory(fileContentHandler)) {
+ return getToscaServiceModelSol004(fileContentHandler, candidateData);
+ }
+ return new ToscaConverterImpl().convert(fileContentHandler);
+ }
+
+ private ToscaServiceModel handleToscaModelConversion(final List<String> modelList, final FileContentHandler fileContentHandler,
+ final OrchestrationTemplateCandidateData candidateData) throws IOException {
+ addOriginalOnboardedPackage(fileContentHandler, candidateData);
+ final var toscaServiceModel = new ToscaModelConverter().convert(fileContentHandler);
+ toscaServiceModel.setModelList(modelList);
+ return toscaServiceModel;
+ }
+
+ private ToscaServiceModel getToscaServiceModelSol004(final FileContentHandler fileContentHandler,
+ final OrchestrationTemplateCandidateData candidateData) throws IOException {
+ addOriginalOnboardedPackage(fileContentHandler, candidateData);
+ final ResourceTypeEnum resourceType = new ETSIServiceImpl().getResourceType(fileContentHandler);
+ return instantiateToscaConverterFor(resourceType).convert(fileContentHandler);
+ }
+
+ private void addOriginalOnboardedPackage(final FileContentHandler fileContentHandler, final OrchestrationTemplateCandidateData candidateData) {
+ if (OnboardingTypesEnum.CSAR.getType().equalsIgnoreCase(candidateData.getFileSuffix())) {
+ fileContentHandler
+ .addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getOriginalFileName() + EXT_SEPARATOR + candidateData.getOriginalFileSuffix(),
+ candidateData.getOriginalFileContentData().array());
} else {
- toscaServiceModel = new ToscaConverterImpl().convert(fileContentHandler);
+ fileContentHandler.addFile(SDC_ONBOARDED_PACKAGE_DIR + candidateData.getFileName() + EXT_SEPARATOR + candidateData.getFileSuffix(),
+ candidateData.getContentData().array());
}
- orchestrationUtil.saveServiceModel(vspDetails.getId(), vspDetails.getVersion(), toscaServiceModel, toscaServiceModel);
- candidateService.deleteOrchestrationTemplateCandidate(vspDetails.getId(), vspDetails.getVersion());
}
private AbstractToscaSolConverter instantiateToscaConverterFor(ResourceTypeEnum resourceType) {
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
index 5f18cb2faa..4754a2d384 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/orchestration/process/OrchestrationTemplateProcessZipHandler.java
@@ -125,7 +125,8 @@ public class OrchestrationTemplateProcessZipHandler implements OrchestrationTemp
orchestrationUtil.saveUploadData(vspDetails, candidateData, zipByteArrayInputStream.get(), fileContentMap, tree);
TranslatorOutput translatorOutput = HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap);
ToscaServiceModel toscaServiceModel = translatorOutput.getToscaServiceModel();
- orchestrationUtil.saveServiceModel(vspId, version, translatorOutput.getNonUnifiedToscaServiceModel(), toscaServiceModel);
+ orchestrationUtil
+ .saveServiceModel(vspId, version, translatorOutput.getNonUnifiedToscaServiceModel(), toscaServiceModel);
orchestrationUtil
.retainComponentQuestionnaireData(vspId, version, componentsQuestionnaire, componentNicsQuestionnaire, componentMibList, processes,
processArtifact);
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
index 654fb1a1af..f49e8f98cb 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImplTest.java
@@ -106,9 +106,9 @@ public class VendorSoftwareProductManagerImplTest {
@Mock
private VendorLicenseFacade vendorLicenseFacadeMock;
@Mock
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
+ private ServiceModelDao<ToscaServiceModel> serviceModelDaoMock;
@Mock
- private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDaoMock;
+ private EnrichedServiceModelDao<ToscaServiceModel> enrichedServiceModelDaoMock;
@Mock
private HealingManager healingManagerMock;
@Mock
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java
index cc73bd766f..4adb1e1b5a 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/tree/UploadFileTest.java
@@ -74,7 +74,7 @@ public class UploadFileTest {
@Mock
private CompositionDataExtractor compositionDataExtractorMock;
@Mock
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDaoMock;
+ private ServiceModelDao<ToscaServiceModel> serviceModelDaoMock;
@Mock
private CompositionEntityDataManager compositionEntityDataManagerMock;
@Mock