summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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/mapping/MapPackageInfoToPackageInfoDto.java2
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java4
-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
-rw-r--r--openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java11
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ToscaServiceModelHealer.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java6
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDao.java11
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ToscaServiceModelProperty.java35
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java3
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java62
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java8
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java4
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java3
-rw-r--r--openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaModelConverter.java133
-rw-r--r--openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java12
-rw-r--r--openecomp-be/tools/install/database/init_schemas.cql20
-rw-r--r--openecomp-be/tools/install/database/upgrade-scripts/20210729-dox.package_details.cql2
23 files changed, 339 insertions, 99 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/mapping/MapPackageInfoToPackageInfoDto.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/mapping/MapPackageInfoToPackageInfoDto.java
index c6faa0361b..3dce7a72af 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/mapping/MapPackageInfoToPackageInfoDto.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/mapping/MapPackageInfoToPackageInfoDto.java
@@ -34,6 +34,7 @@ public class MapPackageInfoToPackageInfoDto extends MappingBase<PackageInfo, Pac
target.setPackageId(source.getVspId());
target.setDescription(source.getVspDescription());
target.setVersion(source.getVersion());
+ target.setVersionId(source.getVersionId());
target.setPackageType(source.getPackageType());
target.setCategory(source.getCategory());
target.setSubCategory(source.getSubCategory());
@@ -41,5 +42,6 @@ public class MapPackageInfoToPackageInfoDto extends MappingBase<PackageInfo, Pac
target.setVendorRelease(source.getVendorRelease());
target.setVendorName(source.getVendorName());
target.setResourceType(source.getResourceType());
+ target.setModels(source.getModels());
}
}
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java
index 5650ac8670..8935349a4b 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/vendor-software-products-rest/vendor-software-products-rest-types/src/main/java/org/openecomp/sdcrests/vendorsoftwareproducts/types/PackageInfoDto.java
@@ -15,6 +15,7 @@
*/
package org.openecomp.sdcrests.vendorsoftwareproducts.types;
+import java.util.Set;
import lombok.Data;
/**
@@ -27,6 +28,7 @@ public class PackageInfoDto {
private String description;
private String vspName;
private String version;
+ private String versionId;
private String packageId;
private String category;
private String subCategory;
@@ -35,4 +37,6 @@ public class PackageInfoDto {
private String packageChecksum;
private String packageType;
private String resourceType;
+ private Set<String> models;
+
}
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
diff --git a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java
index 4ed85f939b..6540cc1eda 100644
--- a/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java
+++ b/openecomp-be/lib/openecomp-core-lib/openecomp-utilities-lib/src/main/java/org/openecomp/core/utilities/orchestration/OnboardingTypesEnum.java
@@ -16,21 +16,22 @@
package org.openecomp.core.utilities.orchestration;
import java.util.Arrays;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
+@AllArgsConstructor
public enum OnboardingTypesEnum {
CSAR("csar"), ZIP("zip"), MANUAL("manual"), NONE("none"), SIGNED_CSAR("signed-csar");
- private final String type;
- OnboardingTypesEnum(final String type) {
- this.type = type;
- }
+ @Getter
+ private final String type;
public static OnboardingTypesEnum getOnboardingTypesEnum(final String type) {
if (StringUtils.isEmpty(type)) {
return null;
}
- return Arrays.stream(OnboardingTypesEnum.values()).filter(onboardingTypesEnum -> onboardingTypesEnum.toString().equalsIgnoreCase(type))
+ return Arrays.stream(OnboardingTypesEnum.values()).filter(onboardingTypesEnum -> onboardingTypesEnum.type.equalsIgnoreCase(type))
.findAny().orElse(null);
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ToscaServiceModelHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ToscaServiceModelHealer.java
index b65629002a..34b436a4f4 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ToscaServiceModelHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ToscaServiceModelHealer.java
@@ -46,7 +46,7 @@ public class ToscaServiceModelHealer implements Healer {
private static final String VALIDATION_FAILURE_MESSAGE =
"Product was updated. Please " + "update the uploaded Heat file according to these validation errors: \n";
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
+ private ServiceModelDao<ToscaServiceModel> serviceModelDao;
private OrchestrationTemplateDao orchestrationTemplateDao;
public ToscaServiceModelHealer() {
@@ -54,7 +54,7 @@ public class ToscaServiceModelHealer implements Healer {
this.orchestrationTemplateDao = OrchestrationTemplateDaoFactory.getInstance().createInterface();
}
- public ToscaServiceModelHealer(ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao,
+ public ToscaServiceModelHealer(ServiceModelDao<ToscaServiceModel> serviceModelDao,
OrchestrationTemplateDao orchestrationTemplateDao) {
this.serviceModelDao = serviceModelDao;
this.orchestrationTemplateDao = orchestrationTemplateDao;
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java
index 033c4ee11c..685abb7109 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/EnrichedServiceModelDao.java
@@ -22,10 +22,8 @@ package org.openecomp.core.model.dao;
import org.openecomp.core.model.types.ServiceArtifact;
import org.openecomp.sdc.versioning.dao.VersionableDao;
-public interface EnrichedServiceModelDao<M, E> extends VersionableDao, ServiceModelDao<M, E> {
+public interface EnrichedServiceModelDao<M> extends VersionableDao, ServiceModelDao<M> {
void storeExternalArtifact(ServiceArtifact serviceArtifact);
- //List<ServiceArtifact> getExternalArtifacts(String vspId, Version version);
- //List<String> getServiceModelContentNames();
-}
+}
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDao.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDao.java
index 7908711023..d3c1b8b3e9 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDao.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/dao/ServiceModelDao.java
@@ -22,14 +22,19 @@ package org.openecomp.core.model.dao;
import org.openecomp.sdc.versioning.dao.VersionableDao;
import org.openecomp.sdc.versioning.dao.types.Version;
-public interface ServiceModelDao<M, E> extends VersionableDao {
+public interface ServiceModelDao<M> extends VersionableDao {
M getServiceModel(String vspId, Version version);
+ /**
+ * Store a service model.
+ *
+ * @param vspId the Vendor Software Product id
+ * @param version the Vendor Software Product version
+ * @param serviceModel the service model to store
+ */
void storeServiceModel(String vspId, Version version, M serviceModel);
- E getServiceModelInfo(String vspId, Version version, String name);
-
void deleteAll(String vspId, Version version);
/**
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ToscaServiceModelProperty.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ToscaServiceModelProperty.java
new file mode 100644
index 0000000000..e344bf63ff
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/types/ToscaServiceModelProperty.java
@@ -0,0 +1,35 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.model.types;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor
+public enum ToscaServiceModelProperty {
+ BASE("base"),
+ MODELS("models");
+
+ private final String name;
+}
+
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java
index 6f1492c163..0e736d945b 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/EnrichedServiceModelDaoZusammenImpl.java
@@ -36,8 +36,7 @@ import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
-public class EnrichedServiceModelDaoZusammenImpl extends ServiceModelDaoZusammenImpl implements
- EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> {
+public class EnrichedServiceModelDaoZusammenImpl extends ServiceModelDaoZusammenImpl implements EnrichedServiceModelDao<ToscaServiceModel> {
private static final Logger logger = LoggerFactory.getLogger(EnrichedServiceModelDaoZusammenImpl.class);
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
index 27ef113204..5368ec97dd 100644
--- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java
@@ -19,6 +19,8 @@
*/
package org.openecomp.sdc.model.impl.zusammen;
+import static org.openecomp.core.model.types.ToscaServiceModelProperty.BASE;
+import static org.openecomp.core.model.types.ToscaServiceModelProperty.MODELS;
import static org.openecomp.core.zusammen.api.ZusammenUtil.buildElement;
import static org.openecomp.core.zusammen.api.ZusammenUtil.buildStructuralElement;
@@ -32,6 +34,8 @@ import com.amdocs.zusammen.datatypes.item.ElementContext;
import com.amdocs.zusammen.datatypes.item.Info;
import java.io.ByteArrayInputStream;
import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@@ -41,7 +45,6 @@ import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
import org.onap.sdc.tosca.services.ToscaExtensionYamlUtil;
import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.errors.RetrieveServiceTemplateFromDbErrorBuilder;
-import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.zusammen.api.ZusammenAdaptor;
import org.openecomp.core.zusammen.api.ZusammenUtil;
@@ -53,9 +56,8 @@ import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.versioning.dao.types.Version;
import org.openecomp.types.ElementPropertyName;
-public class ServiceModelDaoZusammenImpl implements ServiceModelDao<ToscaServiceModel, ServiceElement> {
+public class ServiceModelDaoZusammenImpl implements ServiceModelDao<ToscaServiceModel> {
- private static final String BASE_PROPERTY = "base";
private static final Logger logger = LoggerFactory.getLogger(ServiceModelDaoZusammenImpl.class);
protected ZusammenAdaptor zusammenAdaptor;
protected ElementType elementType;
@@ -70,57 +72,57 @@ public class ServiceModelDaoZusammenImpl implements ServiceModelDao<ToscaService
}
@Override
- public ToscaServiceModel getServiceModel(String vspId, Version version) {
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
- Optional<ElementInfo> serviceModel = getServiceModelElementInfo(context, elementContext);
- if (!serviceModel.isPresent()) {
+ public ToscaServiceModel getServiceModel(final String vspId, final Version version) {
+ final var context = ZusammenUtil.createSessionContext();
+ final var elementContext = new ElementContext(vspId, version.getId());
+ final Optional<ElementInfo> serviceModelOpt = getServiceModelElementInfo(context, elementContext);
+ if (serviceModelOpt.isEmpty()) {
return null;
}
- Id serviceModelElementId = serviceModel.get().getId();
- Map<String, ServiceTemplate> serviceTemplates = getTemplates(context, elementContext, serviceModelElementId);
+ final var serviceModelElementInfo = serviceModelOpt.get();
+ final var serviceModelElementId = serviceModelElementInfo.getId();
+ final Map<String, ServiceTemplate> serviceTemplates = getTemplates(context, elementContext, serviceModelElementId);
if (serviceTemplates == null) {
return null;
}
- FileContentHandler artifacts = getArtifacts(context, elementContext, serviceModelElementId);
- String entryDefinitionServiceTemplate = serviceModel.get().getInfo().getProperty(BASE_PROPERTY);
- return new ToscaServiceModel(artifacts, serviceTemplates, entryDefinitionServiceTemplate);
+ final FileContentHandler artifacts = getArtifacts(context, elementContext, serviceModelElementId);
+ final String entryDefinitionServiceTemplate = serviceModelElementInfo.getInfo().getProperty(BASE.getName());
+ final List<String> modelList = serviceModelElementInfo.getInfo().getProperty(MODELS.getName());
+ return new ToscaServiceModel(modelList, artifacts, serviceTemplates, entryDefinitionServiceTemplate);
}
@Override
- public void storeServiceModel(String vspId, Version version, ToscaServiceModel serviceModel) {
- logger.info("Storing service model for VendorSoftwareProduct id -> {}", vspId);
- ZusammenElement templatesElement = buildStructuralElement(ElementType.Templates, Action.UPDATE);
+ public void storeServiceModel(final String vspId, final Version version, final ToscaServiceModel serviceModel) {
+ logger.info("Storing service model for VendorSoftwareProduct id '{}', version '{}', models '{}'", vspId, version,
+ String.join(",", serviceModel.getModelList() == null ? Collections.emptyList() : serviceModel.getModelList()));
+ final ZusammenElement templatesElement = buildStructuralElement(ElementType.Templates, Action.UPDATE);
serviceModel.getServiceTemplates().forEach((key, value) -> templatesElement
.addSubElement(buildServiceTemplateElement(key, value, serviceModel.getEntryDefinitionServiceTemplate(), Action.CREATE)));
- ZusammenElement artifactsElement = buildStructuralElement(ElementType.Artifacts, Action.UPDATE);
+ final ZusammenElement artifactsElement = buildStructuralElement(ElementType.Artifacts, Action.UPDATE);
if (Objects.nonNull(serviceModel.getArtifactFiles())) {
serviceModel.getArtifactFiles().getFiles()
.forEach((key, value) -> artifactsElement.addSubElement(buildArtifactElement(key, value, Action.CREATE)));
}
- ZusammenElement serviceModelElement = buildServiceModelElement(serviceModel.getEntryDefinitionServiceTemplate());
+ final ZusammenElement serviceModelElement = buildServiceModelElement(serviceModel.getEntryDefinitionServiceTemplate());
+ serviceModelElement.getInfo().addProperty(MODELS.getName(), serviceModel.getModelList());
serviceModelElement.addSubElement(templatesElement);
serviceModelElement.addSubElement(artifactsElement);
- ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ final ZusammenElement vspModel = buildStructuralElement(ElementType.VspModel, Action.IGNORE);
+ vspModel.getInfo().addProperty(MODELS.getName(), serviceModel.getModelList());
vspModel.addSubElement(serviceModelElement);
- SessionContext context = ZusammenUtil.createSessionContext();
- ElementContext elementContext = new ElementContext(vspId, version.getId());
+ final var context = ZusammenUtil.createSessionContext();
+ final var elementContext = new ElementContext(vspId, version.getId());
zusammenAdaptor.saveElement(context, elementContext, vspModel, "Store service model");
logger.info("Finished storing {} for VendorSoftwareProduct id -> {}", elementType.name(), vspId);
}
@Override
- public ServiceElement getServiceModelInfo(String vspId, Version version, String name) {
- return null;
- }
-
- @Override
public void deleteAll(String vspId, Version version) {
logger.info("Started deleting content of Templates and Artifacts of {} of vsp {} version {}", elementType.name(), vspId, version.getId());
SessionContext context = ZusammenUtil.createSessionContext();
ElementContext elementContext = new ElementContext(vspId, version.getId());
Optional<ElementInfo> serviceModel = getServiceModelElementInfo(context, elementContext);
- if (!serviceModel.isPresent()) {
+ if (serviceModel.isEmpty()) {
logger.info("{} of vsp {} version {} does not exist - nothing to delete", elementType.name(), vspId, version.getId());
return;
}
@@ -163,7 +165,7 @@ public class ServiceModelDaoZusammenImpl implements ServiceModelDao<ToscaService
ElementContext elementContext, ZusammenElement serviceModelElement) {
Optional<ElementInfo> elementInfo = zusammenAdaptor
.getElementInfoByName(context, elementContext, serviceModelElementId, ElementType.Templates.name());
- if (!elementInfo.isPresent()) {
+ if (elementInfo.isEmpty()) {
return;
}
ZusammenElement templateElement = buildStructuralElement(ElementType.Templates, Action.UPDATE);
@@ -203,7 +205,7 @@ public class ServiceModelDaoZusammenImpl implements ServiceModelDao<ToscaService
private ZusammenElement buildServiceModelElement(String entryDefinitionServiceTemplate) {
ZusammenElement serviceModelElement = buildStructuralElement(elementType, Action.UPDATE);
- serviceModelElement.getInfo().addProperty(BASE_PROPERTY, entryDefinitionServiceTemplate);
+ serviceModelElement.getInfo().addProperty(BASE.getName(), entryDefinitionServiceTemplate);
return serviceModelElement;
}
@@ -213,7 +215,7 @@ public class ServiceModelDaoZusammenImpl implements ServiceModelDao<ToscaService
info.setName(name);
info.setDescription(serviceTemplate.getDescription());
info.addProperty(ElementPropertyName.elementType.name(), ElementType.ServiceTemplate.name());
- info.addProperty(BASE_PROPERTY, entryDefinitionServiceTemplate);
+ info.addProperty(BASE.getName(), entryDefinitionServiceTemplate);
String yaml = new ToscaExtensionYamlUtil().objectToYaml(serviceTemplate);
zusammenElement.setData(new ByteArrayInputStream(yaml.getBytes()));
zusammenElement.setInfo(info);
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java
index 9c751a239d..ce918b9915 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/type/PackageInfo.java
@@ -23,6 +23,7 @@ import com.datastax.driver.mapping.annotations.Column;
import com.datastax.driver.mapping.annotations.PartitionKey;
import com.datastax.driver.mapping.annotations.Table;
import java.nio.ByteBuffer;
+import java.util.Set;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
@@ -38,6 +39,8 @@ public class PackageInfo {
private String vspId;
@PartitionKey(value = 1)
private String version;
+ @Column(name = "version_id")
+ private String versionId;
@Column(name = "display_name")
private String displayName;
@Column(name = "vsp_name")
@@ -59,9 +62,12 @@ public class PackageInfo {
private ByteBuffer translatedFile;
@Column(name = "resource_type")
private String resourceType = ResourceTypeEnum.VF.name();
+ @Column(name = "models")
+ private Set<String> models;
- public PackageInfo(String packageId, Version version) {
+ public PackageInfo(final String packageId, final Version version) {
this.vspId = packageId;
this.version = version.getName();
+ this.versionId = version.getId();
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java
index 591af3c8b9..f8b75496e5 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/dao/impl/PackageInfoDaoImpl.java
@@ -76,8 +76,8 @@ public class PackageInfoDaoImpl extends CassandraBaseDao<PackageInfo> implements
@Accessor
interface PackageInfoAccessor {
- @Query("SELECT vsp_id,version,display_name,vsp_name,vsp_description,vendor_name,category"
- + " ,sub_category, vendor_release,package_checksum,package_type, resource_type FROM package_details")
+ @Query("SELECT vsp_id, version, version_id, display_name, vsp_name, vsp_description, vendor_name, category"
+ + " , sub_category, vendor_release, package_checksum, package_type, resource_type, models FROM package_details")
Result<PackageInfo> listInfo();
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
index 1118260a16..4929668753 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/test/java/org/openecomp/sdc/vendorsoftwareproduct/dao/ServiceModelDaoFactoryTest.java
@@ -87,8 +87,8 @@ public class ServiceModelDaoFactoryTest {
zusammenAdaptor);
zusammenAdaptor.setItemVersion(itemVersionmock);
- ToscaServiceModel model = getToscaServiceModel();
- serviceModelDaoZusammen.storeServiceModel(vspId, version, model);
+ ToscaServiceModel toscaServiceModel = getToscaServiceModel();
+ serviceModelDaoZusammen.storeServiceModel(vspId, version, toscaServiceModel);
}
@Test
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java
index 1be85a5759..d19a05bfc8 100644
--- a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/AbstractToscaConverter.java
@@ -113,7 +113,8 @@ public abstract class AbstractToscaConverter implements ToscaConverter {
toscaServiceModel.setEntryDefinitionServiceTemplate(entryDefinitionServiceTemplateName);
externalFilesHandler.addFile(TOSCA_META_ORIG_PATH_FILE_NAME, csarFiles.get(TOSCA_META_ORIG_PATH_FILE_NAME));
toscaServiceModel.setArtifactFiles(externalFilesHandler);
- if (MapUtils.isNotEmpty(globalSubstitutionServiceTemplate.getNode_types())) {
+ if (MapUtils.isNotEmpty(globalSubstitutionServiceTemplate.getNode_types())
+ || MapUtils.isNotEmpty(globalSubstitutionServiceTemplate.getData_types())) {
serviceTemplates.put(GLOBAL_SUBSTITUTION_SERVICE_FILE_NAME, globalSubstitutionServiceTemplate);
}
}
diff --git a/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaModelConverter.java b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaModelConverter.java
new file mode 100644
index 0000000000..2656382972
--- /dev/null
+++ b/openecomp-be/lib/openecomp-tosca-converter-lib/openecomp-tosca-converter-core/src/main/java/org/openecomp/core/impl/ToscaModelConverter.java
@@ -0,0 +1,133 @@
+/*
+ * -
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.core.impl;
+
+import static org.openecomp.core.converter.datatypes.Constants.GLOBAL_ST_NAME;
+import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS;
+import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.io.FilenameUtils;
+import org.onap.sdc.tosca.datatypes.model.ServiceTemplate;
+import org.openecomp.core.converter.ServiceTemplateReaderService;
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
+import org.openecomp.sdc.tosca.csar.OnboardingToscaMetadata;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+
+public class ToscaModelConverter extends AbstractToscaConverter {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(ToscaModelConverter.class);
+
+ private final Set<String> handledDefinitionFilesList = new HashSet<>();
+ private ToscaServiceModel toscaServiceModel;
+ private Map<String, ServiceTemplate> serviceTemplateMap;
+ private FileContentHandler csarFileContentHandler;
+ private FileContentHandler artifactFileContentHandler;
+ private Map<String, byte[]> csarFileMap;
+ private GlobalSubstitutionServiceTemplate globalSubstitutionServiceTemplate;
+ private String mainDefinitionFilePath;
+
+ @Override
+ public ToscaServiceModel convert(final FileContentHandler fileContentHandler) throws IOException {
+ init(fileContentHandler);
+ handleMainServiceTemplate();
+ handleExternalArtifacts();
+ handleMetadataFile(csarFileMap);
+ updateToscaServiceModel();
+ return toscaServiceModel;
+ }
+
+ private void init(final FileContentHandler fileContentHandler) throws IOException {
+ csarFileContentHandler = fileContentHandler;
+ csarFileMap = new HashMap<>(fileContentHandler.getFiles());
+ toscaServiceModel = new ToscaServiceModel();
+ serviceTemplateMap = new HashMap<>();
+ artifactFileContentHandler = new FileContentHandler();
+ globalSubstitutionServiceTemplate = new GlobalSubstitutionServiceTemplate();
+ mainDefinitionFilePath = getMainServiceDefinitionFileName();
+ }
+
+ @Override
+ public void convertTopologyTemplate(final ServiceTemplate serviceTemplate, final ServiceTemplateReaderService readerService) {
+ new VnfTopologyTemplateConverter().convertTopologyTemplate(serviceTemplate, readerService);
+ }
+
+ private void handleMainServiceTemplate() {
+ if (mainDefinitionFilePath == null) {
+ return;
+ }
+ final String mainServiceTemplateFileName = FilenameUtils.getName(mainDefinitionFilePath);
+ handleServiceTemplate(mainServiceTemplateFileName, mainDefinitionFilePath, csarFileMap, serviceTemplateMap);
+ handleImportDefinitions(mainDefinitionFilePath);
+ }
+
+ private void handleExternalArtifacts() {
+ if (MapUtils.isEmpty(csarFileMap)) {
+ return;
+ }
+ csarFileMap.entrySet().stream()
+ .filter(fileEntry -> !handledDefinitionFilesList.contains(fileEntry.getKey()) && !isMetadataFile(fileEntry.getKey()))
+ .forEach(fileEntry -> {
+ if (isGlobalServiceTemplate(fileEntry.getKey())) {
+ handleServiceTemplate(GLOBAL_ST_NAME, fileEntry.getKey(), csarFileMap, serviceTemplateMap);
+ } else {
+ artifactFileContentHandler.addFile(getConcreteArtifactFileName(fileEntry.getKey()), fileEntry.getValue());
+ }
+ });
+ }
+
+ private void handleImportDefinitions(final String fileName) {
+ final var toscaDefinitionImportHandler = new ToscaDefinitionImportHandler(csarFileMap, fileName);
+ if (toscaDefinitionImportHandler.hasError()) {
+ throw new InvalidToscaDefinitionImportException(toscaDefinitionImportHandler.getErrors());
+ }
+ final Map<String, ServiceTemplateReaderService> handledImportDefinitionFileMap =
+ toscaDefinitionImportHandler.getHandledImportDefinitionFileMap();
+ handledDefinitionFilesList.addAll(handledImportDefinitionFileMap.keySet());
+ handledDefinitionFilesList.forEach(file -> handleDefinitionTemplate(file, csarFileMap, globalSubstitutionServiceTemplate));
+ }
+
+ private String getMainServiceDefinitionFileName() throws IOException {
+ try {
+ var toscaMetadata = OnboardingToscaMetadata
+ .parseToscaMetadataFile(csarFileContentHandler.getFileContentAsStream(TOSCA_META_PATH_FILE_NAME));
+ return toscaMetadata.getMetaEntries().get(ENTRY_DEFINITIONS.getName());
+ } catch (final IOException e) {
+ LOGGER.error(e.getMessage(), e);
+ throw new IOException(e.getMessage());
+ }
+ }
+
+ private void updateToscaServiceModel() {
+ final String mainDefinitionSimpleName = FilenameUtils.getName(mainDefinitionFilePath);
+ updateToscaServiceModel(toscaServiceModel, serviceTemplateMap, artifactFileContentHandler, globalSubstitutionServiceTemplate, csarFileMap,
+ mainDefinitionSimpleName);
+ }
+
+}
diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java
index 90e1d2e863..557056a588 100644
--- a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java
+++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java
@@ -21,6 +21,7 @@ package org.openecomp.sdc.tosca.datatypes;
import java.util.Collections;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
import lombok.AccessLevel;
@@ -43,11 +44,20 @@ import org.openecomp.sdc.tosca.services.DataModelUtil;
@Setter
public class ToscaServiceModel implements AsdcModel {
+ private List<String> modelList;
private FileContentHandler artifactFiles;
@Getter(AccessLevel.NONE)
private Map<String, ServiceTemplate> serviceTemplates;
private String entryDefinitionServiceTemplate;
+
+ public ToscaServiceModel(final FileContentHandler artifactFiles, final Map<String, ServiceTemplate> serviceTemplates,
+ final String entryDefinitionServiceTemplate) {
+ this.artifactFiles = artifactFiles;
+ this.serviceTemplates = serviceTemplates;
+ this.entryDefinitionServiceTemplate = entryDefinitionServiceTemplate;
+ }
+
/**
* Gets cloned service model.
*
@@ -55,7 +65,7 @@ public class ToscaServiceModel implements AsdcModel {
* @return the cloned service model
*/
public static ToscaServiceModel getClonedServiceModel(ToscaServiceModel toscaServiceModel) {
- return ToscaServiceModel.class.cast(DataModelUtil.getClonedObject(toscaServiceModel));
+ return (ToscaServiceModel) DataModelUtil.getClonedObject(toscaServiceModel);
}
/**
diff --git a/openecomp-be/tools/install/database/init_schemas.cql b/openecomp-be/tools/install/database/init_schemas.cql
index 0569a12f65..7e3bc0a0b2 100644
--- a/openecomp-be/tools/install/database/init_schemas.cql
+++ b/openecomp-be/tools/install/database/init_schemas.cql
@@ -4,7 +4,25 @@ CREATE TYPE IF NOT EXISTS user_candidate_version (version frozen<version>, user
CREATE TABLE IF NOT EXISTS version_info (entity_type text, entity_id text, active_version frozen<version>, status text, candidate frozen<user_candidate_version>, viewable_versions set<frozen<version>>, latest_final_version frozen<version>, PRIMARY KEY (entity_type, entity_id));
CREATE TABLE IF NOT EXISTS version_info_deleted (entity_type text, entity_id text, active_version frozen<version>, status text, candidate frozen<user_candidate_version>, viewable_versions set<frozen<version>>, latest_final_version frozen<version>, PRIMARY KEY (entity_type, entity_id));
CREATE TABLE IF NOT EXISTS unique_value (type text, value text, PRIMARY KEY ((type, value)));
-CREATE TABLE IF NOT EXISTS package_details (VSP_ID text, version text,DISPLAY_NAME text,vsp_name text,vsp_description text,VENDOR_NAME text,CATEGORY text,SUB_CATEGORY text,VENDOR_RELEASE text,PACKAGE_CHECKSUM text,PACKAGE_TYPE text, RESOURCE_TYPE text, TRANSLATE_CONTENT blob,PRIMARY KEY ((VSP_ID, version)));
+CREATE TABLE IF NOT EXISTS package_details
+(
+ VSP_ID text,
+ version text,
+ version_id text,
+ DISPLAY_NAME text,
+ vsp_name text,
+ vsp_description text,
+ VENDOR_NAME text,
+ CATEGORY text,
+ SUB_CATEGORY text,
+ VENDOR_RELEASE text,
+ PACKAGE_CHECKSUM text,
+ PACKAGE_TYPE text,
+ RESOURCE_TYPE text,
+ models set<text>,
+ TRANSLATE_CONTENT blob,
+ PRIMARY KEY ((VSP_ID, version))
+);
CREATE TABLE IF NOT EXISTS vsp_enriched_service_template (vsp_id text, version frozen<version>, base_name text static, name text, content_data blob, PRIMARY KEY ((vsp_id, version), name));
CREATE TABLE IF NOT EXISTS vsp_enriched_service_artifact (vsp_id text, version frozen<version>, name text, content_data blob, PRIMARY KEY ((vsp_id, version), name));
CREATE TABLE IF NOT EXISTS application_config (namespace text, key text, value text, PRIMARY KEY (namespace, key));
diff --git a/openecomp-be/tools/install/database/upgrade-scripts/20210729-dox.package_details.cql b/openecomp-be/tools/install/database/upgrade-scripts/20210729-dox.package_details.cql
new file mode 100644
index 0000000000..9836fa7616
--- /dev/null
+++ b/openecomp-be/tools/install/database/upgrade-scripts/20210729-dox.package_details.cql
@@ -0,0 +1,2 @@
+ALTER TABLE dox.package_details ADD models set<text>;
+ALTER TABLE dox.package_details ADD version_id text; \ No newline at end of file