-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
* 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
+ * 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.
- * ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.vendorsoftwareproduct.impl;
+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;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.openecomp.core.converter.datatypes.Constants;
+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;
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;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.core.validation.api.ValidationManager;
import org.openecomp.core.validation.util.MessageContainerUtil;
-import org.openecomp.sdc.activityLog.ActivityLogManager;
-import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.ValidationErrorBuilder;
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.generator.datatypes.tosca.VspModelInfo;
-import org.openecomp.sdc.healing.api.HealingManager;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
-import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
-import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
-import org.openecomp.sdc.logging.messages.AuditMessages;
-import org.openecomp.sdc.logging.types.LoggerConstants;
-import org.openecomp.sdc.logging.types.LoggerErrorCode;
-import org.openecomp.sdc.logging.types.LoggerServiceName;
-import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.tosca.csar.Manifest;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
import org.openecomp.sdc.validation.util.ValidationManagerUtil;
import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
+import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
+import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.VendorSoftwareProductNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
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.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.CreatePackageForNonFinalVendorSoftwareProductErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.DeploymentFlavorErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.FileCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.InformationArtifactCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.NicInternalNetworkErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.errors.OnboardingMethodErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageInvalidErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.TranslationFileCreationErrorBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder;
-import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
-import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+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.services.schemagenerator.SchemaGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult;
import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
-import org.openecomp.sdc.vendorsoftwareproduct.types.VersionedVendorSoftwareProductInfo;
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
import org.openecomp.sdc.vendorsoftwareproduct.utils.ComponentDependencyTracker;
import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.VersioningUtil;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.dao.types.VersionStatus;
-import org.openecomp.sdc.versioning.errors.RequestedVersionInvalidErrorBuilder;
-import org.openecomp.sdc.versioning.types.VersionInfo;
-import org.openecomp.sdc.versioning.types.VersionableEntityAction;
-import org.openecomp.sdcrests.activitylog.types.ActivityType;
-import org.slf4j.MDC;
-
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager {
- private static String VALIDATION_VSP_ID = "validationOnlyVspId";
- private static final String VALIDATION_VSP_NAME = "validationOnlyVspName";
- //private static final String VALIDATION_VSP_USER = "validationOnlyVspUser";
-
- private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private static final Logger logger =
- LoggerFactory.getLogger(VendorSoftwareProductManagerImpl.class);
-
- private OrchestrationTemplateDao orchestrationTemplateDao;
- private VendorSoftwareProductInfoDao vspInfoDao;
- private VersioningManager versioningManager;
- private VendorSoftwareProductDao vendorSoftwareProductDao;
- private VendorLicenseFacade vendorLicenseFacade;
- private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
- private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
- private HealingManager healingManager;
- private VendorLicenseArtifactsService licenseArtifactsService;
- private InformationArtifactGenerator informationArtifactGenerator;
- private PackageInfoDao packageInfoDao;
- private ActivityLogManager activityLogManager;
- private DeploymentFlavorDao deploymentFlavorDao;
- private NicDao nicDao;
- private ManualVspToscaManager manualVspToscaManager;
-
- /**
- * Instantiates a new Vendor software product manager.
- *
- * @param versioningManager the versioning manager
- * @param vendorSoftwareProductDao the vendor software product dao
- * @param orchestrationTemplateDataDao the orchestration template data dao
- * @param vspInfoDao the vsp info dao
- * @param vendorLicenseFacade the vendor license facade
- * @param serviceModelDao the service model dao
- * @param enrichedServiceModelDao the enriched service model dao
- * @param healingManager the healing manager
- * @param licenseArtifactsService the license artifacts service
- * @param informationArtifactGenerator the information artifact generator
- * @param packageInfoDao the package info dao
- * @param activityLogManager the activity log manager
- * @param deploymentFlavorDao the deployment flavor dao
- * @param nicDao the nic dao
- */
- public VendorSoftwareProductManagerImpl(
- VersioningManager versioningManager,
- VendorSoftwareProductDao vendorSoftwareProductDao,
- OrchestrationTemplateDao orchestrationTemplateDataDao,
- VendorSoftwareProductInfoDao vspInfoDao,
- VendorLicenseFacade vendorLicenseFacade,
- ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao,
- EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao,
- HealingManager healingManager,
- VendorLicenseArtifactsService licenseArtifactsService,
- InformationArtifactGenerator informationArtifactGenerator,
- PackageInfoDao packageInfoDao,
- ActivityLogManager activityLogManager,
- DeploymentFlavorDao deploymentFlavorDao,
- NicDao nicDao,
- ManualVspToscaManager manualVspToscaManager) {
- this.versioningManager = versioningManager;
- this.vendorSoftwareProductDao = vendorSoftwareProductDao;
- this.orchestrationTemplateDao = orchestrationTemplateDataDao;
- this.vspInfoDao = vspInfoDao;
- this.vendorLicenseFacade = vendorLicenseFacade;
- this.serviceModelDao = serviceModelDao;
- this.enrichedServiceModelDao = enrichedServiceModelDao;
- this.healingManager = healingManager;
- this.licenseArtifactsService = licenseArtifactsService;
- this.informationArtifactGenerator = informationArtifactGenerator;
- this.packageInfoDao = packageInfoDao;
- this.activityLogManager = activityLogManager;
- this.deploymentFlavorDao = deploymentFlavorDao;
- this.nicDao = nicDao;
- this.manualVspToscaManager = manualVspToscaManager;
-
- registerToVersioning();
- }
-
- private void registerToVersioning() {
- vendorSoftwareProductDao.registerVersioning(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
- serviceModelDao.registerVersioning(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
- enrichedServiceModelDao.registerVersioning(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
- }
-
- @Override
- public Version checkout(String vendorSoftwareProductId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vendorSoftwareProductId);
- MDC.put(LoggerConstants.SERVICE_NAME, LoggerServiceName.Checkout_Entity.toString());
-
- Version newVersion = versioningManager
- .checkout(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user);
-
- if (newVersion != null) {
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(newVersion.getMajor() + 1),
- ActivityType.CHECKOUT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
- }
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vendorSoftwareProductId);
- return newVersion;
- }
-
-
- @Override
- public Version undoCheckout(String vendorSoftwareProductId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vendorSoftwareProductId);
-
- Version version =
- getVersionInfo(vendorSoftwareProductId, VersionableEntityAction.Read, user)
- .getActiveVersion();
- String preVspName = vspInfoDao
- .get(new VspDetails(vendorSoftwareProductId, version)).getName();
-
- Version newVersion = versioningManager.undoCheckout(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user);
-
- String postVspName = vspInfoDao
- .get(new VspDetails(vendorSoftwareProductId, newVersion))
- .getName();
- updateUniqueName(preVspName, postVspName);
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vendorSoftwareProductId);
-
- return newVersion;
- }
-
- @Override
- public Version checkin(String vendorSoftwareProductId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vendorSoftwareProductId);
-
- Version newVersion = versioningManager.checkin(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user, null);
-
- if (newVersion != null) {
- ActivityLogEntity activityLogEntity =
- new ActivityLogEntity(vendorSoftwareProductId, String.valueOf(newVersion.getMajor() + 1),
- ActivityType.CHECKIN.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
+ private static final Logger LOGGER = LoggerFactory.getLogger(VendorSoftwareProductManager.class);
+ private VspMergeDao vspMergeDao;
+ private OrchestrationTemplateDao orchestrationTemplateDao;
+ private OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager;
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private VendorLicenseFacade vendorLicenseFacade;
+ private ServiceModelDao<ToscaServiceModel> serviceModelDao;
+ private EnrichedServiceModelDao<ToscaServiceModel> enrichedServiceModelDao;
+ private VendorLicenseArtifactsService licenseArtifactsService;
+ private InformationArtifactGenerator informationArtifactGenerator;
+ private PackageInfoDao packageInfoDao;
+ private DeploymentFlavorDao deploymentFlavorDao;
+ private ComponentDao componentDao;
+ private ComponentDependencyModelDao componentDependencyModelDao;
+ private NicDao nicDao;
+ private ComputeDao computeDao;
+ private ImageDao imageDao;
+ private ManualVspToscaManager manualVspToscaManager;
+ private UniqueValueUtil uniqueValueUtil;
+ private CandidateService candidateService;
+
+ private static ErrorCode createMissingMandatoryFieldError(String fieldName) {
+ return new ValidationErrorBuilder("must be supplied", fieldName).build();
+ }
+
+ @Override
+ public ValidationResponse validate(VspDetails vspDetails) throws IOException {
+ List<ErrorCode> vspErrors = new ArrayList<>(validateVspFields(vspDetails));
+ ValidationResponse validationResponse = new ValidationResponse();
+ if (Objects.nonNull(vspDetails.getOnboardingMethod()) && OnboardingMethod.Manual.name().equals(vspDetails.getOnboardingMethod())) {
+ validateManualOnboardingMethod(vspDetails, validationResponse, vspErrors);
+ } else {
+ validateOrchestrationTemplateCandidate(validationResponse, vspErrors, vspDetails.getId(), vspDetails.getVersion());
+ if (!validationResponse.isValid()) {
+ return validationResponse;
+ }
+ validateLicense(vspDetails, vspErrors);
+ OrchestrationTemplateEntity orchestrationTemplate = orchestrationTemplateDao.get(vspDetails.getId(), vspDetails.getVersion());
+ ToscaServiceModel serviceModel = serviceModelDao.getServiceModel(vspDetails.getId(), vspDetails.getVersion());
+ if (isOrchestrationTemplateMissing(orchestrationTemplate) || isServiceModelMissing(serviceModel)) {
+ vspErrors.add(VendorSoftwareProductInvalidErrorBuilder
+ .vendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(), vspDetails.getVersion()));
+ }
+ validationResponse.setUploadDataErrors(validateOrchestrationTemplate(orchestrationTemplate));
+ }
+ QuestionnaireValidationResult questionnaireValidationResult = validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(),
+ vspDetails.getOnboardingMethod());
+ if (Objects.nonNull(questionnaireValidationResult)) {
+ if (validationResponse.getQuestionnaireValidationResult() == null
+ || validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
+ validationResponse.setQuestionnaireValidationResult(questionnaireValidationResult);
+ } else {
+ validationResponse.getQuestionnaireValidationResult().getValidationData().addAll(questionnaireValidationResult.getValidationData());
+ }
+ }
+ Collection<ComponentDependencyModelEntity> componentDependencies = componentDependencyModelDao
+ .list(new ComponentDependencyModelEntity(vspDetails.getId(), vspDetails.getVersion(), null));
+ if (validateComponentDependencies(componentDependencies)) {
+ vspErrors.add(ComponentDependencyModelErrorBuilder.getCyclicDependencyComponentErrorBuilder());
+ }
+ validationResponse.setVspErrors(vspErrors);
+ validationResponse.setLicensingDataErrors(validateLicensingData(vspDetails));
+ return validationResponse;
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vendorSoftwareProductId);
-
- return newVersion;
- }
-
- @Override
- public ValidationResponse submit(String vspId, String user) throws IOException {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
-
- Version version = getVersionInfo(vspId, VersionableEntityAction.Read, user).getActiveVersion();
- VspDetails vspDetails = getVsp(vspId, version, user);
- UploadDataEntity uploadData = orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
- ToscaServiceModel serviceModel =
- serviceModelDao.getServiceModel(vspId, vspDetails.getVersion());
-
- ValidationResponse validationResponse = new ValidationResponse();
- validationResponse
- .setVspErrors(validateCompletedVendorSoftwareProduct(vspDetails, uploadData, serviceModel),
- LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
-
- if (isCyclicDependencyInComponents(vspId, vspDetails.getVersion())) {
- Collection<ErrorCode> vspErrors = validationResponse.getVspErrors() == null
- ? new ArrayList<>()
- : validationResponse.getVspErrors();
- vspErrors.add(ComponentDependencyModelErrorBuilder
- .getcyclicDependencyComponentErrorBuilder());
- validationResponse.setVspErrors(vspErrors, LoggerServiceName.Submit_VSP,
- LoggerTragetServiceName.SUBMIT_VSP);
+ private void validateLicense(VspDetails vspDetails, List<ErrorCode> vspErrors) {
+ if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null || vspDetails.getFeatureGroups() != null) {
+ vspErrors.addAll(validateMandatoryLicenseFields(vspDetails));
+ }
}
- validationResponse.setLicensingDataErrors(validateLicensingData(vspDetails));
- validationResponse
- .setUploadDataErrors(validateUploadData(uploadData,vspDetails), LoggerServiceName.Submit_VSP,
- LoggerTragetServiceName.SUBMIT_VSP);
-
- validationResponse.setQuestionnaireValidationResult(
- validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(), vspDetails
- .getOnboardingMethod()));
-
- if (vspDetails.getOnboardingMethod().equals("Manual")) {
- Collection<ErrorCode> deploymentFlavourValidationErrList = deploymentFlavorValidation(vspDetails.getId(), vspDetails.getVersion());
- if (validationResponse.getVspErrors() != null) {
- if(deploymentFlavourValidationErrList != null)
- validationResponse.getVspErrors().addAll(deploymentFlavourValidationErrList);
- } else {
- validationResponse.setVspErrors(deploymentFlavourValidationErrList, LoggerServiceName.Submit_VSP,
- LoggerTragetServiceName.SUBMIT_VSP);
- }
-
- Set<CompositionEntityValidationData> compositionEntityValidationData = componentValidation(vspDetails.getId(), vspDetails.getVersion());
- if (validationResponse.getQuestionnaireValidationResult() != null) {
- if(!CollectionUtils.isEmpty(compositionEntityValidationData))
- validationResponse.getQuestionnaireValidationResult().getValidationData().addAll(compositionEntityValidationData);
- } else {
- validationResponse.setQuestionnaireValidationResult(CollectionUtils.isEmpty(compositionEntityValidationData) ? null :
- new QuestionnaireValidationResult(compositionEntityValidationData));
- }
-
- //Generate Tosca service model for Manual Onboarding flow
- VspModelInfo vspModelInfo = manualVspToscaManager.gatherVspInformation(vspId, version, user);
- serviceModel = manualVspToscaManager.generateToscaModel(vspModelInfo);
- }
- validationResponse.setCompilationErrors(
- compile(vspId, vspDetails.getVersion(), serviceModel),
- LoggerServiceName.Submit_VSP, LoggerTragetServiceName.SUBMIT_VSP);
-
- if (validationResponse.isValid()) {
- Version newVersion = versioningManager.submit(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vspId, user, null);
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspDetails.getId(), String
- .valueOf(newVersion.getMajor()),
- ActivityType.SUBMIT.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
+ private void validateOrchestrationTemplateCandidate(ValidationResponse validationResponse, List<ErrorCode> vspErrors, String vspId,
+ Version version) {
+ orchestrationTemplateCandidateManager.getInfo(vspId, version).ifPresent(candidateInfo -> {
+ String fileName = candidateInfo.getFileName();
+ vspErrors.add(candidateInfo.getValidationData().isEmpty() ? candidateDataNotProcessedOrAbortedErrorBuilder(fileName)
+ : invalidProcessedCandidate(fileName));
+ validationResponse.setVspErrors(vspErrors);
+ });
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return validationResponse;
- }
-
- private boolean isCyclicDependencyInComponents(String vendorSoftwareProductId,
- Version version) {
- final Collection<ComponentDependencyModelEntity> componentDependencyModelEntities =
- vendorSoftwareProductDao.listComponentDependencies(vendorSoftwareProductId, version);
- ComponentDependencyTracker dependencyTracker = new ComponentDependencyTracker();
+ private void validateManualOnboardingMethod(VspDetails vspDetails, ValidationResponse validationResponse, List<ErrorCode> vspErrors) {
+ vspErrors.addAll(validateMandatoryLicenseFields(vspDetails));
+ Collection<DeploymentFlavorEntity> deploymentFlavors = deploymentFlavorDao
+ .list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails.getVersion(), null));
+ if (CollectionUtils.isEmpty(deploymentFlavors)) {
+ vspErrors.add(vspMissingDeploymentFlavorErrorBuilder());
+ }
+ vspErrors.addAll(validateDeploymentFlavors(deploymentFlavors));
+ Set<CompositionEntityValidationData> componentValidationResult = componentValidation(vspDetails.getId(), vspDetails.getVersion());
+ if (!CollectionUtils.isEmpty(componentValidationResult)) {
+ if (validationResponse.getQuestionnaireValidationResult() == null
+ || validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
+ validationResponse.setQuestionnaireValidationResult(new QuestionnaireValidationResult(componentValidationResult));
+ } else {
+ validationResponse.getQuestionnaireValidationResult().getValidationData().addAll(componentValidationResult);
+ }
+ }
+ }
- for (ComponentDependencyModelEntity entity : componentDependencyModelEntities) {
- dependencyTracker.addDependency(entity.getSourceComponentId(), entity.getTargetComponentId());
+ @Override
+ public Map<String, List<ErrorMessage>> compile(String vspId, Version version) {
+ ToscaServiceModel serviceModel = OnboardingMethod.Manual.name().equals(getValidatedVsp(vspId, version).getOnboardingMethod())
+ //Generate Tosca service model for Manual Onboarding flow
+ ? manualVspToscaManager.generateToscaModel(manualVspToscaManager.gatherVspInformation(vspId, version))
+ : serviceModelDao.getServiceModel(vspId, version);
+ return compile(vspId, version, serviceModel);
}
- return dependencyTracker.isCyclicDependencyPresent();
- }
-
- private Collection<ErrorCode> deploymentFlavorValidation(String vspId,
- Version version) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- Set<CompositionEntityValidationData> validationData = new HashSet<>();
- Collection<ErrorCode> errorCodeList = new ArrayList<>();
- Collection<DeploymentFlavorEntity> deploymentFlavors =
- vendorSoftwareProductDao.listDeploymentFlavors(vspId, version);
- if (!CollectionUtils.isEmpty(deploymentFlavors)) {
- deploymentFlavors.forEach(deploymentFlavor -> {
- DeploymentFlavorEntity deployment = vendorSoftwareProductDao.getDeploymentFlavor(vspId,
- version, deploymentFlavor.getId());
- DeploymentFlavor deploymentlocalFlavor = deployment.getDeploymentFlavorCompositionData();
- if (deploymentlocalFlavor != null) {
- if (deploymentlocalFlavor.getFeatureGroupId() == null ) {
- ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder.
- getFeatureGroupMandatoryErrorBuilder(deploymentlocalFlavor.getModel());
- errorCodeList.add(deploymentFlavorErrorBuilder);
- }
- List<ComponentComputeAssociation> componetComputeAssociations = new ArrayList<>();
- componetComputeAssociations = deploymentlocalFlavor.getComponentComputeAssociations();
- if (CollectionUtils.isEmpty(componetComputeAssociations)) {
- CompositionEntityValidationData compositionEntityValidationData = new
- CompositionEntityValidationData(CompositionEntityType.deployment,deploymentFlavor
- .getId());
- compositionEntityValidationData.setEntityName(deployment
- .getDeploymentFlavorCompositionData().getModel());
- ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
- .getInvalidComponentComputeAssociationErrorBuilder(deploymentlocalFlavor.getModel());
-
- errorCodeList.add(deploymentFlavorErrorBuilder);
- } else {
- componetComputeAssociations.forEach(componetComputeAssociation -> {
- if (componetComputeAssociation == null
- || !(componetComputeAssociation.getComponentId() != null
- && componetComputeAssociation.getComputeFlavorId() != null)) {
- CompositionEntityValidationData compositionEntityValidationData = new
- CompositionEntityValidationData(CompositionEntityType.deployment,
- deploymentFlavor.getId());
- compositionEntityValidationData.setEntityName(deployment
- .getDeploymentFlavorCompositionData().getModel());
- ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
- .getInvalidComponentComputeAssociationErrorBuilder(deploymentlocalFlavor.getModel());
-
- errorCodeList.add(deploymentFlavorErrorBuilder);
- }
+
+ private boolean validateComponentDependencies(Collection<ComponentDependencyModelEntity> componentDependencies) {
+ ComponentDependencyTracker dependencyTracker = new ComponentDependencyTracker();
+ for (ComponentDependencyModelEntity componentDependency : componentDependencies) {
+ dependencyTracker.addDependency(componentDependency.getSourceComponentId(), componentDependency.getTargetComponentId());
+ }
+ return dependencyTracker.isCyclicDependencyPresent();
+ }
+
+ private Collection<ErrorCode> validateDeploymentFlavors(Collection<DeploymentFlavorEntity> deploymentFlavors) {
+ Collection<ErrorCode> errorCodeList = new ArrayList<>();
+ if (!CollectionUtils.isEmpty(deploymentFlavors)) {
+ deploymentFlavors.forEach(deploymentFlavor -> {
+ DeploymentFlavorEntity deployment = deploymentFlavorDao.get(deploymentFlavor);
+ DeploymentFlavor deploymentLocalFlavor = deployment.getDeploymentFlavorCompositionData();
+ if (deploymentLocalFlavor != null) {
+ if (deploymentLocalFlavor.getFeatureGroupId() == null) {
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
+ .getFeatureGroupMandatoryErrorBuilder(deploymentLocalFlavor.getModel());
+ errorCodeList.add(deploymentFlavorErrorBuilder);
+ }
+ validateComponentComputeAssociations(errorCodeList, deploymentFlavor, deployment, deploymentLocalFlavor);
+ }
+ });
+ }
+ return errorCodeList;
+ }
+
+ private void validateComponentComputeAssociations(Collection<ErrorCode> errorCodeList, DeploymentFlavorEntity deploymentFlavor,
+ DeploymentFlavorEntity deployment, DeploymentFlavor deploymentlocalFlavor) {
+ List<ComponentComputeAssociation> componentComputeAssociations = deploymentlocalFlavor.getComponentComputeAssociations();
+ if (CollectionUtils.isEmpty(componentComputeAssociations)) {
+ validateCompositionEntity(errorCodeList, deploymentFlavor, deployment, deploymentlocalFlavor);
+ } else {
+ componentComputeAssociations.forEach(componentComputeAssociation -> {
+ if (componentComputeAssociation == null || !(componentComputeAssociation.getComponentId() != null
+ && componentComputeAssociation.getComputeFlavorId() != null)) {
+ validateCompositionEntity(errorCodeList, deploymentFlavor, deployment, deploymentlocalFlavor);
+ }
});
- }
}
- });
}
- return errorCodeList;
- }
-
- private Set<CompositionEntityValidationData> componentValidation(String vspId, Version version) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
-
- Set<CompositionEntityValidationData> validationData = new HashSet<>();
- Collection<ComponentEntity> components = vendorSoftwareProductDao.listComponents(vspId,version);
- if (!CollectionUtils.isEmpty(components)) {
- components.forEach(component -> {
- validateImage(vspId, version, validationData, component);
- validateNic(vspId, version, validationData, component);
- });
+ private void validateCompositionEntity(Collection<ErrorCode> errorCodeList, DeploymentFlavorEntity deploymentFlavor,
+ DeploymentFlavorEntity deployment, DeploymentFlavor deploymentlocalFlavor) {
+ CompositionEntityValidationData compositionEntityValidationData = new CompositionEntityValidationData(CompositionEntityType.deployment,
+ deploymentFlavor.getId());
+ compositionEntityValidationData.setEntityName(deployment.getDeploymentFlavorCompositionData().getModel());
+ ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
+ .getInvalidComponentComputeAssociationErrorBuilder(deploymentlocalFlavor.getModel());
+ errorCodeList.add(deploymentFlavorErrorBuilder);
}
- return validationData;
- }
-
- private void validateNic(String vspId, Version version,
- Set<CompositionEntityValidationData> validationData,
- ComponentEntity component) {
- Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId,version, component.getId(),null));
- if (CollectionUtils.isNotEmpty(nics)) {
- nics.forEach(nicEntity -> {
- NicEntity nic = nicDao.get(new NicEntity(vspId, version, component.getId(),
- nicEntity.getId()));
- NetworkType networkType = nic.getNicCompositionData().getNetworkType();
- String networkId = nic.getNicCompositionData().getNetworkId();
- if (networkType.equals(NetworkType.Internal) && networkId == null) {
- CompositionEntityValidationData compositionEntityValidationData = new
- CompositionEntityValidationData(CompositionEntityType.nic, nic.getId());
- compositionEntityValidationData.setEntityName(nic.getNicCompositionData().getName());
- ErrorCode nicInternalNetworkErrorBuilder = NicInternalNetworkErrorBuilder
- .getNicNullNetworkIdInternalNetworkIdErrorBuilder();
- List<String> errors = new ArrayList<>();
- errors.add(nicInternalNetworkErrorBuilder.message());
- compositionEntityValidationData.setErrors(errors);
- validationData.add(compositionEntityValidationData);
- }
- });
- }
- }
-
- private void validateImage(String vspId, Version version,
- Set<CompositionEntityValidationData> validationData,
- ComponentEntity component) {
- Collection<ImageEntity> images = vendorSoftwareProductDao.listImages(vspId,version,
- component.getId());
- if (CollectionUtils.isEmpty(images)) {
- CompositionEntityValidationData compositionEntityValidationData = new
- CompositionEntityValidationData(component.getType(),component.getId());
- compositionEntityValidationData.setEntityName(component.getComponentCompositionData()
- .getDisplayName());
- ErrorCode vfcMissingImageErrorBuilder =
- ComponentErrorBuilder.VfcMissingImageErrorBuilder();
- List<String> errors = new ArrayList<>();
- errors.add(vfcMissingImageErrorBuilder.message());
- compositionEntityValidationData.setErrors(errors);
- validationData.add(compositionEntityValidationData);
+ private Set<CompositionEntityValidationData> componentValidation(String vspId, Version version) {
+ Set<CompositionEntityValidationData> validationData = new HashSet<>();
+ Collection<ComponentEntity> components = componentDao.list(new ComponentEntity(vspId, version, null));
+ if (!CollectionUtils.isEmpty(components)) {
+ components.forEach(component -> {
+ validateImage(vspId, version, validationData, component);
+ validateNic(vspId, version, validationData, component);
+ });
+ }
+ return validationData;
+ }
+
+ private void validateNic(String vspId, Version version, Set<CompositionEntityValidationData> validationData, ComponentEntity component) {
+ Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, component.getId(), null));
+ if (CollectionUtils.isNotEmpty(nics)) {
+ nics.forEach(nicEntity -> {
+ NicEntity nic = nicDao.get(new NicEntity(vspId, version, component.getId(), nicEntity.getId()));
+ NetworkType networkType = nic.getNicCompositionData().getNetworkType();
+ String networkId = nic.getNicCompositionData().getNetworkId();
+ if (networkType.equals(NetworkType.Internal) && networkId == null) {
+ CompositionEntityValidationData compositionEntityValidationData = new CompositionEntityValidationData(CompositionEntityType.nic,
+ nic.getId());
+ compositionEntityValidationData.setEntityName(nic.getNicCompositionData().getName());
+ ErrorCode nicInternalNetworkErrorBuilder = NicInternalNetworkErrorBuilder.getNicNullNetworkIdInternalNetworkIdErrorBuilder();
+ List<String> errors = new ArrayList<>();
+ errors.add(nicInternalNetworkErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ }
+ });
+ }
}
- }
-
-
-
- private List<ErrorCode> validateCompletedVendorSoftwareProduct(
- VspDetails vspDetails, UploadDataEntity uploadData, Object serviceModel) {
-
- List<ErrorCode> errors = new ArrayList<>();
- if (vspDetails.getName() == null) {
- errors.add(createMissingMandatoryFieldError("name"));
- }
- if (vspDetails.getDescription() == null) {
- errors.add(createMissingMandatoryFieldError("description"));
- }
- if (vspDetails.getVendorId() == null) {
- errors.add(createMissingMandatoryFieldError("vendor Id"));
- }
- if (vspDetails.getCategory() == null) {
- errors.add(createMissingMandatoryFieldError("category"));
- }
- if (vspDetails.getSubCategory() == null) {
- errors.add(createMissingMandatoryFieldError("sub category"));
- }
- if (vspDetails.getOnboardingMethod().equals("Manual")) {
- //Manual Onboarding specific validations
- Collection<DeploymentFlavorEntity> deploymentFlavorEntities = vendorSoftwareProductDao
- .listDeploymentFlavors(vspDetails.getId(), vspDetails.getVersion());
- if (CollectionUtils.isEmpty(deploymentFlavorEntities) ) {
- ErrorCode vspMissingDeploymentFlavorErrorBuilder =
- VendorSoftwareProductInvalidErrorBuilder.VspMissingDeploymentFlavorErrorBuilder();
- errors.add(vspMissingDeploymentFlavorErrorBuilder);
- }
- errors.addAll(validateMandatoryLicenseFields(vspDetails));
- } else {
- //Heat flow specific VSP validations
- if (uploadData == null || uploadData.getContentData() == null || serviceModel == null) {
- errors.add(VendorSoftwareProductInvalidErrorBuilder
- .VendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(),
- vspDetails.getVersion()));
- }
- if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null
- || vspDetails.getFeatureGroups() != null) {
- errors.addAll(validateMandatoryLicenseFields(vspDetails));
- }
- }
- return errors.isEmpty() ? null : errors;
- }
-
- private List<ErrorCode> validateMandatoryLicenseFields(VspDetails vspDetails) {
- List<ErrorCode> errors = new ArrayList<>();
- if (vspDetails.getVlmVersion() == null) {
- errors.add(createMissingMandatoryFieldError(
- "licensing version (in the format of: {integer}.{integer})"));
- }
- if (vspDetails.getLicenseAgreement() == null) {
- errors.add(createMissingMandatoryFieldError("license agreement"));
- }
- if (CollectionUtils.isEmpty(vspDetails.getFeatureGroups())) {
- errors.add(createMissingMandatoryFieldError("feature groups"));
- }
- return errors;
- }
-
- private static ErrorCode createMissingMandatoryFieldError(String fieldName) {
- return new ValidationErrorBuilder("must be supplied", fieldName).build();
- }
-
- String getVspQuestionnaireSchema(SchemaTemplateInput schemaInput) {
- mdcDataDebugMessage.debugEntryMessage(null);
- mdcDataDebugMessage.debugExitMessage(null);
- return SchemaGenerator
- .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, schemaInput);
- }
-
- private static void sortVspListByModificationTimeDescOrder(
- List<VersionedVendorSoftwareProductInfo> vsps) {
- vsps.sort((o1, o2) -> o2.getVspDetails().getWritetimeMicroSeconds()
- .compareTo(o1.getVspDetails().getWritetimeMicroSeconds()));
- }
-
-
- private Map<String, List<ErrorMessage>> compile(String vendorSoftwareProductId, Version version,
- ToscaServiceModel serviceModel) {
- if (serviceModel == null) {
- return null;
+ private void validateImage(String vspId, Version version, Set<CompositionEntityValidationData> validationData, ComponentEntity component) {
+ Collection<ImageEntity> images = imageDao.list(new ImageEntity(vspId, version, component.getId(), null));
+ if (CollectionUtils.isEmpty(images)) {
+ CompositionEntityValidationData compositionEntityValidationData = new CompositionEntityValidationData(component.getType(),
+ component.getId());
+ compositionEntityValidationData.setEntityName(component.getComponentCompositionData().getDisplayName());
+ ErrorCode vfcMissingImageErrorBuilder = ComponentErrorBuilder.vfcMissingImageErrorBuilder();
+ List<String> errors = new ArrayList<>();
+ errors.add(vfcMissingImageErrorBuilder.message());
+ compositionEntityValidationData.setErrors(errors);
+ validationData.add(compositionEntityValidationData);
+ }
}
- enrichedServiceModelDao.deleteAll(vendorSoftwareProductId, version);
-
- EnrichmentManager<ToscaServiceModel> enrichmentManager =
- EnrichmentManagerFactory.getInstance().createInterface();
- enrichmentManager.init(vendorSoftwareProductId, version);
- enrichmentManager.setModel(serviceModel);
- Map<String, List<ErrorMessage>> enrichErrors = enrichmentManager.enrich();
-
- if (MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, enrichErrors))) {
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.ENRICHMENT_COMPLETED
- + vendorSoftwareProductId);
- } else {
- enrichErrors.values().forEach(errorList ->
- auditIfContainsErrors(errorList,vendorSoftwareProductId,AuditMessages.ENRICHMENT_ERROR));
+ private List<ErrorCode> validateVspFields(VspDetails vspDetails) {
+ List<ErrorCode> errors = new ArrayList<>();
+ if (vspDetails.getName() == null) {
+ errors.add(createMissingMandatoryFieldError("name"));
+ }
+ if (vspDetails.getDescription() == null) {
+ errors.add(createMissingMandatoryFieldError("description"));
+ }
+ if (vspDetails.getVendorId() == null) {
+ errors.add(createMissingMandatoryFieldError("vendor Id"));
+ }
+ if (vspDetails.getCategory() == null) {
+ errors.add(createMissingMandatoryFieldError("category"));
+ }
+ if (vspDetails.getSubCategory() == null) {
+ errors.add(createMissingMandatoryFieldError("sub category"));
+ }
+ return errors;
}
- enrichedServiceModelDao
- .storeServiceModel(vendorSoftwareProductId, version, enrichmentManager.getModel());
-
- return enrichErrors;
- }
-
- private Collection<ErrorCode> validateLicensingData(VspDetails vspDetails) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspDetails.getId());
-
- if (vspDetails.getVendorId() == null || vspDetails.getVlmVersion() == null
- || vspDetails.getLicenseAgreement() == null
- || CollectionUtils.isEmpty(vspDetails.getFeatureGroups())) {
- return null;
+ private List<ErrorCode> validateMandatoryLicenseFields(VspDetails vspDetails) {
+ List<ErrorCode> errors = new ArrayList<>();
+ if (vspDetails.getVlmVersion() == null) {
+ errors.add(createMissingMandatoryFieldError("licensing version"));
+ }
+ if (vspDetails.getLicenseAgreement() == null) {
+ errors.add(createMissingMandatoryFieldError("license agreement"));
+ }
+ if (CollectionUtils.isEmpty(vspDetails.getFeatureGroups())) {
+ errors.add(createMissingMandatoryFieldError("feature groups"));
+ }
+ return errors;
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
- return vendorLicenseFacade
- .validateLicensingData(vspDetails.getVendorId(), vspDetails.getVlmVersion(),
- vspDetails.getLicenseAgreement(), vspDetails.getFeatureGroups());
- }
-
- @Override
- public String fetchValidationVsp(String user) {
- try {
- validateUniqueName(VALIDATION_VSP_NAME);
- } catch (Exception ignored) {
- return VALIDATION_VSP_ID;
+ private Map<String, List<ErrorMessage>> compile(String vendorSoftwareProductId, Version version, ToscaServiceModel serviceModel) {
+ if (isServiceModelMissing(serviceModel)) {
+ return null;
+ }
+ enrichedServiceModelDao.deleteAll(vendorSoftwareProductId, version);
+ 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);
+ final Map<String, List<ErrorMessage>> enrichErrors = enrichmentManager.enrich();
+ enrichedServiceModelDao.storeServiceModel(vendorSoftwareProductId, version, enrichmentManager.getModel());
+ return enrichErrors;
+ }
+
+ private Collection<ErrorCode> validateLicensingData(VspDetails vspDetails) {
+ if (vspDetails.getVendorId() != null) {
+ Optional<ErrorCode> errorCode = vendorLicenseFacade.validateVendorForUsage(vspDetails.getVendorId(), vspDetails.getVlmVersion());
+ if (errorCode.isPresent()) {
+ return Collections.singleton(errorCode.get());
+ }
+ }
+ if (vspDetails.getVendorId() == null || vspDetails.getVlmVersion() == null || vspDetails.getLicenseAgreement() == null || CollectionUtils
+ .isEmpty(vspDetails.getFeatureGroups())) {
+ return Collections.emptyList();
+ }
+ return vendorLicenseFacade.validateLicensingData(vspDetails.getVendorId(), vspDetails.getVlmVersion(), vspDetails.getLicenseAgreement(),
+ vspDetails.getFeatureGroups());
}
- VspDetails validationVsp = new VspDetails();
- validationVsp.setName(VALIDATION_VSP_NAME);
-
- vspInfoDao.create(validationVsp);
- Version version = versioningManager.create(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- validationVsp.getId(), user);
- validationVsp.setVersion(version);
-
- createUniqueName(VALIDATION_VSP_NAME);
- VALIDATION_VSP_ID = validationVsp.getId();
- return VALIDATION_VSP_ID;
- }
- @Override
- public VspDetails createVsp(VspDetails vspDetails, String user) {
- mdcDataDebugMessage.debugEntryMessage(null);
-
- validateUniqueName(vspDetails.getName());
-
- vspDetails.setOnboardingOrigin(OnboardingTypesEnum.NONE.toString());
-
- vspInfoDao.create(vspDetails);//id will be set in the dao
- vspInfoDao.updateQuestionnaireData(vspDetails.getId(), null,
+ @Override
+ public VspDetails createVsp(VspDetails vspDetails) {
+ vspInfoDao.create(vspDetails);
+ vspInfoDao.updateQuestionnaireData(vspDetails.getId(), vspDetails.getVersion(),
new JsonSchemaDataGenerator(getVspQuestionnaireSchema(null)).generateData());
-
- Version version = versioningManager
- .create(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vspDetails.getId(), user);
- vspDetails.setVersion(version);
- ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspDetails.getId(), String
- .valueOf(vspDetails.getVersion().getMajor() + 1),
- ActivityType.CREATE_NEW.toString(), user, true, "", "");
- activityLogManager.addActionLog(activityLogEntity, user);
- String vspName = vspDetails.getName();
- createUniqueName(vspName);
- mdcDataDebugMessage.debugExitMessage(null);
- return vspDetails;
- }
-
- @Override
- public List<VersionedVendorSoftwareProductInfo> listVsps(String versionFilter, String user) {
- mdcDataDebugMessage.debugEntryMessage(null);
-
- Map<String, VersionInfo> idToVersionsInfo = versioningManager.listEntitiesVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE, user,
- VersionableEntityAction.Read);
-
- List<VersionedVendorSoftwareProductInfo> vsps = new ArrayList<>();
- for (Map.Entry<String, VersionInfo> entry : idToVersionsInfo.entrySet()) {
- VersionInfo versionInfo = entry.getValue();
- if (versionFilter != null && versionFilter.equals(VersionStatus.Final.name())) {
- if (versionInfo.getLatestFinalVersion() == null) {
- continue;
- }
- versionInfo.setActiveVersion(versionInfo.getLatestFinalVersion());
- versionInfo.setStatus(VersionStatus.Final);
- versionInfo.setLockingUser(null);
- }
-
- Version version = versionInfo.getActiveVersion();
- if (user.equals(versionInfo.getLockingUser())) {
- version.setStatus(VersionStatus.Locked);
- }
- try {
- VspDetails vsp = vspInfoDao.get(new VspDetails(entry.getKey(), version));
- if (vsp != null && !vsp.getId().equals(VALIDATION_VSP_ID)) {
- vsp.setValidationDataStructure(null);
- vsps.add(new VersionedVendorSoftwareProductInfo(vsp, versionInfo));
- }
- } catch (RuntimeException rte) {
- logger.error(
- "Error trying to retrieve vsp[" + entry.getKey() + "] version[" + version.toString
- () + "] " +
- "message:" + rte
- .getMessage());
- }
+ return vspDetails;
}
- sortVspListByModificationTimeDescOrder(vsps);
-
- mdcDataDebugMessage.debugExitMessage(null);
-
- return vsps;
- }
-
- @Override
- public void updateVsp(VspDetails vspDetails, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspDetails.getId());
-
- VspDetails retrieved = vspInfoDao.get(vspDetails);
- if (!retrieved.getOnboardingMethod().equals(vspDetails.getOnboardingMethod())) {
- final ErrorCode onboardingMethodUpdateErrorCode = OnboardingMethodErrorBuilder
- .getOnboardingUpdateError();
-
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.UPDATE_VSP, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), onboardingMethodUpdateErrorCode.message());
-
- throw new CoreException(onboardingMethodUpdateErrorCode);
+ @Override
+ public void updateVsp(VspDetails vspDetails) {
+ VspDetails retrieved = vspInfoDao.get(vspDetails);
+ if (retrieved == null) {
+ throw new CoreException((new ErrorCode.ErrorCodeBuilder()
+ .withMessage(String.format("Vsp with id %s and version %s does not exist.", vspDetails.getId(), vspDetails.getVersion().getId())))
+ .build());
+ }
+ vspDetails.setOnboardingMethod(retrieved.getOnboardingMethod());
+ //If any existing feature group is removed from VSP which is also associated in DF then
+
+ //update DF to remove feature group associations.
+ updateDeploymentFlavor(vspDetails);
+ updateUniqueName(retrieved.getName(), vspDetails.getName());
+ vspInfoDao.update(vspDetails);
+ }
+
+ private void updateDeploymentFlavor(VspDetails vspDetails) {
+ final List<String> featureGroups = vspDetails.getFeatureGroups();
+ if (featureGroups != null) {
+ final Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao
+ .list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails.getVersion(), null));
+ if (Objects.nonNull(deploymentFlavorEntities)) {
+ for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
+ updateDeploymentFlavourEntity(featureGroups, deploymentFlavorEntity);
+ }
+ }
+ }
}
- //If any existing feature group is removed from VSP which is also associated in DF then
- //update DF to remove feature group associations.
- updateDeploymentFlavor(vspDetails, user);
-
- updateUniqueName(retrieved.getName(), vspDetails.getName());
- vspDetails.setOldVersion(retrieved.getOldVersion());
-
- vspInfoDao.update(vspDetails);
- //vendorSoftwareProductDao.updateVspLatestModificationTime(vspDetails.getId(), activeVersion);
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspDetails.getId());
- }
-
- private void updateDeploymentFlavor(VspDetails vspDetails, String user) {
- final List<String> featureGroups = vspDetails.getFeatureGroups();
- if (featureGroups != null) {
- final Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao
- .list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails
- .getVersion(), null));
- if (Objects.nonNull(deploymentFlavorEntities)) {
- deploymentFlavorEntities.forEach(deploymentFlavorEntity -> {
- final String featureGroupId =
- deploymentFlavorEntity.getDeploymentFlavorCompositionData().getFeatureGroupId();
- if ( !featureGroups.contains(featureGroupId)) {
- DeploymentFlavor deploymentFlavorCompositionData =
- deploymentFlavorEntity.getDeploymentFlavorCompositionData();
+ private void updateDeploymentFlavourEntity(List<String> featureGroups, DeploymentFlavorEntity deploymentFlavorEntity) {
+ final String featureGroupId = deploymentFlavorEntity.getDeploymentFlavorCompositionData().getFeatureGroupId();
+ if (!featureGroups.contains(featureGroupId)) {
+ DeploymentFlavor deploymentFlavorCompositionData = deploymentFlavorEntity.getDeploymentFlavorCompositionData();
deploymentFlavorCompositionData.setFeatureGroupId(null);
- deploymentFlavorEntity.setDeploymentFlavorCompositionData
- (deploymentFlavorCompositionData);
- vendorSoftwareProductDao.updateDeploymentFlavor(deploymentFlavorEntity);
- }
- });
- }
+ deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavorCompositionData);
+ deploymentFlavorDao.update(deploymentFlavorEntity);
+ }
}
- }
-
- @Override
- public VspDetails getVsp(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ @Override
+ public VspDetails getVsp(String vspId, Version version) {
+ return getValidatedVsp(vspId, version);
+ }
- VspDetails vsp = vspInfoDao.get(new VspDetails(vspId, version));
- if (vsp == null) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.GET_VSP, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), "Requested VSP not found");
- throw new CoreException(new VendorSoftwareProductNotFoundErrorBuilder(vspId).build());
+ private VspDetails getValidatedVsp(String vspId, Version version) {
+ VspDetails vsp = vspInfoDao.get(new VspDetails(vspId, version));
+ if (vsp == null) {
+ throw new CoreException(new VendorSoftwareProductNotFoundErrorBuilder(vspId).build());
+ }
+ return vsp;
}
- vsp.setValidationData(orchestrationTemplateDao.getValidationData(vspId, version));
- if(Objects.isNull(vsp.getOnboardingOrigin())){
- vsp.setOnboardingOrigin(OnboardingTypesEnum.ZIP.toString());
+ @Override
+ public void deleteVsp(String vspId, Version version) {
+ vspMergeDao.deleteHint(vspId, version);
}
- if(Objects.isNull(vsp.getNetworkPackageName())){
- vsp.setNetworkPackageName("Upload File");
+ @Override
+ public List<PackageInfo> listPackages(String category, String subCategory) {
+ return packageInfoDao.listByCategory(category, subCategory);
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return vsp;
- }
-
- @Override
- public Version callAutoHeal(String vspId, VersionInfo versionInfo,
- VspDetails vendorSoftwareProductInfo, String user)
- throws Exception {
- switch (versionInfo.getStatus()) {
- case Locked:
- if (user.equals(versionInfo.getLockingUser())) {
- autoHeal(vspId, versionInfo.getActiveVersion(), vendorSoftwareProductInfo,
- versionInfo.getLockingUser());
- }
- return versionInfo.getActiveVersion();
- case Available:
- Version checkoutVersion = checkout(vspId, user);
- autoHeal(vspId, checkoutVersion, vendorSoftwareProductInfo, user);
- return checkin(vspId, user);
- case Final:
- Version checkoutFinalVersion = checkout(vspId, user);
- autoHeal(vspId, checkoutFinalVersion, vendorSoftwareProductInfo, user);
- Version checkinFinalVersion = checkin(vspId, user);
- ValidationResponse response = submit(vspId, user);
- if (!response.isValid()) {
- return checkout(vspId, user);
+ @Override
+ public File getTranslatedFile(String vspId, Version version) {
+ PackageInfo packageInfo = packageInfoDao.get(new PackageInfo(vspId, version));
+ if (packageInfo == null) {
+ throw new CoreException(new PackageNotFoundErrorBuilder(vspId, version).build());
}
-
- try {
- Version finalVersion = checkinFinalVersion.calculateNextFinal();
- createPackage(vspId, finalVersion, user);
- return finalVersion;
- } catch (IOException ex) {
- throw new Exception(ex.getMessage());
+ ByteBuffer translatedFileBuffer = packageInfo.getTranslatedFile();
+ if (translatedFileBuffer == null) {
+ throw new CoreException(new PackageInvalidErrorBuilder(vspId, version).build());
}
- default:
- //do nothing
- break;
- }
- return versionInfo.getActiveVersion();
- }
-
- @Override
-
- public void deleteVsp(String vspId, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
-
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.DELETE_VSP, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Unsupported operation");
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
-
- throw new UnsupportedOperationException(
- VendorSoftwareProductConstants.UNSUPPORTED_OPERATION_ERROR);
- }
-
- @Override
- public void heal(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
-
- VersionInfo versionInfo = getVersionInfo(vspId, VersionableEntityAction.Read, user);
-
- version = VersionStatus.Locked.equals(versionInfo.getStatus())
- ? versionInfo.getActiveVersion()
- : checkout(vspId, user);
- version.setStatus(VersionStatus.Locked);
-
- healingManager.healAll(getHealingParamsAsMap(vspId, version, user));
-
- VspDetails vspDetails = new VspDetails(vspId, version);
- vspDetails.setOldVersion(null);
- vspInfoDao.updateOldVersionIndication(vspDetails);
-
- logger.audit("Healed VSP " + vspDetails.getId());
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- }
-
- private void autoHeal(String vspId, Version checkoutVersion, VspDetails vspDetails, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
-
- checkoutVersion.setStatus(VersionStatus.Locked);
- Map<String, Object> healingParams = getHealingParamsAsMap(vspId, checkoutVersion, user);
- healingManager.healAll(healingParams);
- vspDetails.setVersion(checkoutVersion);
- vspDetails.setOldVersion(null);
- vspInfoDao.updateOldVersionIndication(vspDetails);
-
- logger.audit("Healed VSP " + vspDetails.getName());
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- }
-
- private Map<String, Object> getHealingParamsAsMap(String vspId, Version version, String user) {
- Map<String, Object> healingParams = new HashMap<>();
-
- healingParams.put(SdcCommon.VSP_ID, vspId);
- healingParams.put(SdcCommon.VERSION, version);
- healingParams.put(SdcCommon.USER, user);
-
- return healingParams;
- }
-
- @Override
- public List<PackageInfo> listPackages(String category, String subCategory) {
- return packageInfoDao.listByCategory(category, subCategory);
- }
-
- @Override
- public File getTranslatedFile(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- String errorMessage;
- if (version == null) {
- errorMessage = "Package not found";
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.GET_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
- throw new CoreException(new PackageNotFoundErrorBuilder(vspId).build());
- } else if (!version.isFinal()) {
- errorMessage = "Invalid requested version";
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.GET_VERSION_INFO, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
- throw new CoreException(new RequestedVersionInvalidErrorBuilder().build());
+ File translatedFile = new File(VendorSoftwareProductConstants.VSP_PACKAGE_ZIP);
+ try (FileOutputStream fos = new FileOutputStream(translatedFile)) {
+ fos.write(translatedFileBuffer.array());
+ } catch (IOException exception) {
+ throw new CoreException(new TranslationFileCreationErrorBuilder(vspId, version).build(), exception);
+ }
+ return translatedFile;
}
- PackageInfo packageInfo =
- packageInfoDao.get(new PackageInfo(vspId, version));
- if (packageInfo == null) {
- errorMessage = "Package not found";
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.GET_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
- throw new CoreException(new PackageNotFoundErrorBuilder(vspId, version).build());
+ @Override
+ public byte[] getOrchestrationTemplateFile(String vspId, Version version) {
+ OrchestrationTemplateEntity uploadData = orchestrationTemplateDao.get(vspId, version);
+ ByteBuffer contentData = uploadData.getContentData();
+ if (contentData == null) {
+ return new byte[0];
+ }
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (final ZipOutputStream zos = new ZipOutputStream(baos); ZipInputStream ignored = new ZipInputStream(
+ new ByteArrayInputStream(contentData.array()))) {
+ zos.write(contentData.array());
+ } catch (IOException exception) {
+ throw new CoreException(new FileCreationErrorBuilder(vspId).build(), exception);
+ }
+ return baos.toByteArray();
}
- ByteBuffer translatedFileBuffer = packageInfo.getTranslatedFile();
- if (translatedFileBuffer == null) {
- errorMessage = "Package not found";
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.GET_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
- throw new CoreException(new PackageInvalidErrorBuilder(vspId, version).build());
+ @Override
+ public OrchestrationTemplateEntity getOrchestrationTemplateInfo(String vspId, Version version) {
+ return orchestrationTemplateDao.getInfo(vspId, version);
}
- File translatedFile = new File(VendorSoftwareProductConstants.VSP_PACKAGE_ZIP);
-
- try {
- FileOutputStream fos = new FileOutputStream(translatedFile);
- fos.write(translatedFileBuffer.array());
- fos.close();
- } catch (IOException exception) {
- errorMessage = "Can't create package";
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_TRANSLATED_FILE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), errorMessage);
- throw new CoreException(new TranslationFileCreationErrorBuilder(vspId, version).build(),
- exception);
+ @Override
+ public Optional<FilesDataStructure> getOrchestrationTemplateStructure(String vspId, Version version) {
+ Optional<String> jsonFileDataStructure = orchestrationTemplateDao.getOrchestrationTemplateStructure(vspId, version);
+ if (jsonFileDataStructure.isPresent() && JsonUtil.isValidJson(jsonFileDataStructure.get())) {
+ return Optional.of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class));
+ } else {
+ return Optional.empty();
+ }
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ @Override
+ public PackageInfo createPackage(final String vspId, final Version version) throws IOException {
+ final ToscaServiceModel toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version);
+ final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
+ final Version vlmVersion = vspDetails.getVlmVersion();
+ if (vlmVersion != null) {
+ populateVersionsForVlm(vspDetails.getVendorId(), vlmVersion);
+ }
+ final PackageInfo packageInfo = createPackageInfo(vspDetails);
+ final ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar = new ToscaFileOutputServiceCsarImpl();
+ final FileContentHandler licenseArtifacts = licenseArtifactsService
+ .createLicenseArtifacts(vspDetails.getId(), vspDetails.getVendorId(), vlmVersion, vspDetails.getFeatureGroups());
+ final ETSIService etsiService = new ETSIServiceImpl();
+ if (etsiService.hasEtsiSol261Metadata(toscaServiceModel.getArtifactFiles())) {
+ final FileContentHandler handler = toscaServiceModel.getArtifactFiles();
+ final Manifest manifest = etsiService.getManifest(handler);
+ final Optional<Map<String, Path>> fromToMovedPaths = etsiService.moveNonManoFileToArtifactFolder(handler);
+ fromToMovedPaths.ifPresent(it -> etsiService.updateMainDescriptorPaths(toscaServiceModel, it));
+ packageInfo.setResourceType(etsiService.getResourceType(manifest).name());
+ if (CollectionUtils.isEmpty(vspDetails.getModelIdList())) {
+ packageInfo.setVendorRelease(etsiService.getHighestCompatibleSpecificationVersion(handler).getOriginalValue());
+ }
+ }
+ packageInfo.setTranslatedFile(ByteBuffer.wrap(toscaServiceTemplateServiceCsar.createOutputFile(toscaServiceModel, licenseArtifacts)));
+ packageInfoDao.create(packageInfo);
+ return packageInfo;
+ }
- return translatedFile;
- }
+ void populateVersionsForVlm(String vlmId, Version vlmVersion) {
+ VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface();
+ versioningManager.list(vlmId).stream().filter(version -> version.getId().equalsIgnoreCase(vlmVersion.getId())).findAny()
+ .ifPresent(version -> {
+ vlmVersion.setMinor(version.getMinor());
+ vlmVersion.setMajor(version.getMajor());
+ });
+ }
- @Override
+ 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());
+ packageInfo.setSubCategory(vspDetails.getSubCategory());
+ 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;
+ }
- public byte[] getOrchestrationTemplateFile(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ @Override
+ public QuestionnaireResponse getVspQuestionnaire(String vspId, Version version) {
+ VspQuestionnaireEntity retrieved = vspInfoDao.getQuestionnaire(vspId, version);
+ VersioningUtil.validateEntityExistence(retrieved, new VspQuestionnaireEntity(vspId, version), VspDetails.ENTITY_TYPE);
+ String questionnaireData = retrieved.getQuestionnaireData();
+ QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
+ questionnaireResponse.setData(questionnaireData);
+ questionnaireResponse.setSchema(getVspQuestionnaireSchema(null));
+ return questionnaireResponse;
+ }
- UploadDataEntity uploadData = orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
- ByteBuffer contentData = uploadData.getContentData();
- if (contentData == null) {
- return null;
+ @Override
+ public void updateVspQuestionnaire(String vspId, Version version, String questionnaireData) {
+ vspInfoDao.updateQuestionnaireData(vspId, version, questionnaireData);
}
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- try (final ZipOutputStream zos = new ZipOutputStream(baos);
- ZipInputStream zipStream = new ZipInputStream(
- new ByteArrayInputStream(contentData.array()))) {
- zos.write(contentData.array());
- } catch (IOException exception) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.GET_UPLOADED_HEAT, ErrorLevel.ERROR.name(),
- LoggerErrorCode.DATA_ERROR.getErrorCode(), "Can't get uploaded HEAT");
- throw new CoreException(new FileCreationErrorBuilder(vspId).build(), exception);
+ private Map<String, List<ErrorMessage>> validateOrchestrationTemplate(OrchestrationTemplateEntity orchestrationTemplate) throws IOException {
+ if (isOrchestrationTemplateMissing(orchestrationTemplate)) {
+ return null;
+ }
+ Map<String, List<ErrorMessage>> validationErrors = new HashMap<>();
+ FileContentHandler fileContentMap = CommonUtil
+ .validateAndUploadFileContent(OnboardingTypesEnum.getOnboardingTypesEnum(orchestrationTemplate.getFileSuffix()),
+ orchestrationTemplate.getContentData().array());
+ try (InputStream zipFileManifest = fileContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
+ addDummyHeatBase(zipFileManifest, fileContentMap);
+ } catch (Exception e) {
+ LOGGER.error("Invalid package content", e);
+ }
+ if (CommonUtil.isFileOriginFromZip(orchestrationTemplate.getFileSuffix())) {
+ ValidationManager validationManager = ValidationManagerUtil.initValidationManager(fileContentMap);
+ validationErrors.putAll(validationManager.validate());
+ }
+ return MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, validationErrors)) ? null : validationErrors;
+ }
+
+ private FileContentHandler addDummyHeatBase(InputStream zipFileManifest, FileContentHandler fileContentMap) {
+ ManifestContent manifestContent = JsonUtil.json2Object(zipFileManifest, ManifestContent.class);
+ for (FileData fileData : manifestContent.getData()) {
+ if ((fileData.getFile()).contains("dummy_ignore.yaml")) {
+ String filePath = new File("").getAbsolutePath() + "/resources";
+ File envFilePath = new File(filePath + "/base_template.env");
+ File baseFilePath = new File(filePath + "/base_template.yaml");
+ try (InputStream envStream = new FileInputStream(envFilePath); InputStream baseStream = new FileInputStream(baseFilePath);) {
+ fileContentMap.addFile("base_template_dummy_ignore.env", envStream);
+ fileContentMap.addFile("base_template_dummy_ignore.yaml", baseStream);
+ } catch (Exception e) {
+ LOGGER.error("File not found error {}", e);
+ }
+ }
+ }
+ return fileContentMap;
+ }
+
+ private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version, String onboardingMethod) {
+ // The apis of CompositionEntityDataManager used here are stateful!
+
+ // so, it must be re-created from scratch when it is used!
+ CompositionEntityDataManager compositionEntityDataManager = CompositionEntityDataManagerFactory.getInstance().createInterface();
+ compositionEntityDataManager.addEntity(vspInfoDao.getQuestionnaire(vspId, version), null);
+ Collection<NicEntity> nics = nicDao.listByVsp(vspId, version);
+ Map<String, List<String>> nicNamesByComponent = new HashMap<>();
+ for (NicEntity nicEntity : nics) {
+ compositionEntityDataManager.addEntity(nicEntity, null);
+ Nic nic = nicEntity.getNicCompositionData();
+ if (nic != null && nic.getName() != null) {
+ List<String> nicNames = nicNamesByComponent.computeIfAbsent(nicEntity.getComponentId(), k -> new ArrayList<>());
+ nicNames.add(nic.getName());
+ }
+ }
+ Collection<ComponentEntity> components = componentDao.listCompositionAndQuestionnaire(vspId, version);
+ components.forEach(component -> compositionEntityDataManager.addEntity(component,
+ new ComponentQuestionnaireSchemaInput(nicNamesByComponent.get(component.getId()),
+ JsonUtil.json2Object(component.getQuestionnaireData(), Map.class), null, OnboardingMethod.Manual.name().equals(onboardingMethod))));
+ Collection<ComputeEntity> computes = computeDao.listByVsp(vspId, version);
+ computes.forEach(compute -> compositionEntityDataManager.addEntity(compute, null));
+ if (OnboardingMethod.Manual.name().equals(onboardingMethod)) {
+ Collection<ImageEntity> images = imageDao.listByVsp(vspId, version);
+ images.forEach(image -> compositionEntityDataManager.addEntity(image, null));
+ }
+ Map<CompositionEntityId, Collection<String>> errorsByEntityId = compositionEntityDataManager.validateEntitiesQuestionnaire();
+ if (MapUtils.isNotEmpty(errorsByEntityId)) {
+ compositionEntityDataManager.buildTrees();
+ compositionEntityDataManager.addErrorsToTrees(errorsByEntityId);
+ return new QuestionnaireValidationResult(compositionEntityDataManager.getAllErrorsByVsp(vspId));
+ }
+ return null;
}
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return baos.toByteArray();
- }
-
- @Override
- public PackageInfo createPackage(String vspId, Version version, String user) throws IOException {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
-
- if (!version.isFinal()) {
- MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
- LoggerTragetServiceName.CREATE_PACKAGE, ErrorLevel.ERROR.name(),
- LoggerErrorCode.PERMISSION_ERROR.getErrorCode(), "Can't create package");
- throw new CoreException(
- new CreatePackageForNonFinalVendorSoftwareProductErrorBuilder(vspId, version)
- .build());
+ @Override
+ public File getInformationArtifact(String vspId, Version version) {
+ VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
+ if (vspDetails == null) {
+ return null;
+ }
+ String vspName = vspDetails.getName();
+ ByteBuffer infoArtifactAsByteBuffer;
+ File infoArtifactFile;
+ try {
+ infoArtifactAsByteBuffer = ByteBuffer.wrap(informationArtifactGenerator.generate(vspId, version).getBytes());
+ infoArtifactFile = new File(String.format(VendorSoftwareProductConstants.INFORMATION_ARTIFACT_NAME, vspName));
+ try (OutputStream out = new BufferedOutputStream(new FileOutputStream(infoArtifactFile))) {
+ out.write(infoArtifactAsByteBuffer.array());
+ }
+ } catch (IOException ex) {
+ throw new CoreException(new InformationArtifactCreationErrorBuilder(vspId).build(), ex);
+ }
+ return infoArtifactFile;
}
- ToscaServiceModel toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version);
- VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
- Version vlmVersion = vspDetails.getVlmVersion();
+ String getVspQuestionnaireSchema(SchemaTemplateInput schemaInput) {
+ return SchemaGenerator.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, schemaInput);
+ }
- PackageInfo packageInfo = createPackageInfo(vspId, vspDetails);
+ @Override
+ public Optional<Pair<String, byte[]>> 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()));
+ }
- ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar =
- new ToscaFileOutputServiceCsarImpl();
- FileContentHandler licenseArtifacts = licenseArtifactsService
- .createLicenseArtifacts(vspDetails.getId(), vspDetails.getVendorId(), vlmVersion,
- vspDetails.getFeatureGroups(), user);
- //todo add tosca validation here
- packageInfo.setTranslatedFile(ByteBuffer.wrap(
- toscaServiceTemplateServiceCsar.createOutputFile(toscaServiceModel, licenseArtifacts)));
+ void updateUniqueName(String oldVspName, String newVspName) {
+ uniqueValueUtil.updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, oldVspName, newVspName);
+ }
- packageInfoDao.create(packageInfo);
+ @Override
+ public Collection<ComputeEntity> getComputeByVsp(String vspId, Version version) {
+ return computeDao.listByVsp(vspId, version);
+ }
- logger.audit(AuditMessages.AUDIT_MSG + AuditMessages.CREATE_PACKAGE + vspId);
+ private boolean isOrchestrationTemplateMissing(OrchestrationTemplateEntity orchestrationTemplate) {
+ return orchestrationTemplate == null || orchestrationTemplate.getContentData() == null || orchestrationTemplate.getFileSuffix() == null
+ || orchestrationTemplate.getFileName() == null;
+ }
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return packageInfo;
- }
+ private boolean isServiceModelMissing(ToscaServiceModel serviceModel) {
+ return serviceModel == null || serviceModel.getEntryDefinitionServiceTemplate() == null;
+ }
- private PackageInfo createPackageInfo(String vspId, VspDetails vspDetails) {
- PackageInfo packageInfo = new PackageInfo();
- packageInfo.setVspId(vspId);
- packageInfo.setVersion(vspDetails.getVersion());
- packageInfo.setVspName(vspDetails.getName());
- packageInfo.setVspDescription(vspDetails.getDescription());
- packageInfo.setCategory(vspDetails.getCategory());
- packageInfo.setSubCategory(vspDetails.getSubCategory());
- packageInfo.setVendorName(vspDetails.getVendorName());
- packageInfo.setPackageType(VendorSoftwareProductConstants.CSAR);
- packageInfo.setVendorRelease("1.0"); //todo TBD
- return packageInfo;
- }
+ public static class Builder {
- @Override
+ private VspMergeDao vspMergeDao;
+ private OrchestrationTemplateDao orchestrationTemplateDao;
+ private OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager;
+ private VendorSoftwareProductInfoDao vspInfoDao;
+ private VendorLicenseFacade vendorLicenseFacade;
+ private ServiceModelDao<ToscaServiceModel> serviceModelDao;
+ private EnrichedServiceModelDao<ToscaServiceModel> enrichedServiceModelDao;
+ private VendorLicenseArtifactsService licenseArtifactsService;
+ private InformationArtifactGenerator informationArtifactGenerator;
+ private PackageInfoDao packageInfoDao;
+ private DeploymentFlavorDao deploymentFlavorDao;
+ private ComponentDao componentDao;
+ private ComponentDependencyModelDao componentDependencyModelDao;
+ private NicDao nicDao;
+ private ComputeDao computeDao;
+ private ImageDao imageDao;
+ private ManualVspToscaManager manualVspToscaManager;
+ private UniqueValueDao uniqueValueDao;
+ private CandidateService candidateService;
- public QuestionnaireResponse getVspQuestionnaire(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ public Builder vspMerge(VspMergeDao vspMergeDao) {
+ this.vspMergeDao = vspMergeDao;
+ return this;
+ }
- VspQuestionnaireEntity retrieved = vspInfoDao.getQuestionnaire(vspId, version);
- VersioningUtil.validateEntityExistence(retrieved, new VspQuestionnaireEntity(vspId, version),
- VspDetails.ENTITY_TYPE);
+ public Builder orchestrationTemplate(OrchestrationTemplateDao orchestrationTemplateDao) {
+ this.orchestrationTemplateDao = orchestrationTemplateDao;
+ return this;
+ }
- String questionnaireData = retrieved.getQuestionnaireData();
+ public Builder orchestrationTemplateCandidateManager(OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager) {
+ this.orchestrationTemplateCandidateManager = orchestrationTemplateCandidateManager;
+ return this;
+ }
- QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
- questionnaireResponse.setData(questionnaireData);
- questionnaireResponse.setSchema(getVspQuestionnaireSchema(null));
+ public Builder vspInfo(VendorSoftwareProductInfoDao vspInfoDao) {
+ this.vspInfoDao = vspInfoDao;
+ return this;
+ }
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ public Builder vendorLicenseFacade(VendorLicenseFacade vendorLicenseFacade) {
+ this.vendorLicenseFacade = vendorLicenseFacade;
+ return this;
+ }
- return questionnaireResponse;
- }
+ public Builder serviceModel(ServiceModelDao<ToscaServiceModel> serviceModelDao) {
+ this.serviceModelDao = serviceModelDao;
+ return this;
+ }
- @Override
- public void updateVspQuestionnaire(String vspId, Version version, String questionnaireData,
- String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+ public Builder enrichedServiceModel(EnrichedServiceModelDao<ToscaServiceModel> enrichedServiceModelDao) {
+ this.enrichedServiceModelDao = enrichedServiceModelDao;
+ return this;
+ }
- vspInfoDao.updateQuestionnaireData(vspId, version, questionnaireData);
+ public Builder licenseArtifactsService(VendorLicenseArtifactsService licenseArtifactsService) {
+ this.licenseArtifactsService = licenseArtifactsService;
+ return this;
+ }
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- }
+ public Builder informationArtifactGenerator(InformationArtifactGenerator informationArtifactGenerator) {
+ this.informationArtifactGenerator = informationArtifactGenerator;
+ return this;
+ }
+ public Builder packageInfo(PackageInfoDao packageInfoDao) {
+ this.packageInfoDao = packageInfoDao;
+ return this;
+ }
- private Map<String, List<ErrorMessage>> validateUploadData(UploadDataEntity uploadData,
- VspDetails vspDetails)
- throws IOException {
+ public Builder deploymentFlavor(DeploymentFlavorDao deploymentFlavorDao) {
+ this.deploymentFlavorDao = deploymentFlavorDao;
+ return this;
+ }
- Map<String, List<ErrorMessage>> validationErrors = new HashMap<>();
- if (uploadData == null || uploadData.getContentData() == null) {
- return null;
- }
+ public Builder component(ComponentDao componentDao) {
+ this.componentDao = componentDao;
+ return this;
+ }
- FileContentHandler fileContentMap =
- CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.getOnboardingTypesEnum
- (vspDetails.getOnboardingOrigin()),
- uploadData.getContentData().array());
- //todo - check
- ValidationManager validationManager =
- ValidationManagerUtil.initValidationManager(fileContentMap);
- validationErrors.putAll(validationManager.validate());
-
- return
- MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, validationErrors))
- ? null : validationErrors;
- }
-
- private VersionInfo getVersionInfo(String vendorSoftwareProductId, VersionableEntityAction action,
- String user) {
- return versioningManager.getEntityVersionInfo(
- VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE,
- vendorSoftwareProductId, user, action);
- }
-
-
- private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version,
- String onboardingMethod) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
-
- // The apis of CompositionEntityDataManager used here are stateful!
- // so, it must be re-created from scratch when it is used!
- CompositionEntityDataManager compositionEntityDataManager =
- CompositionEntityDataManagerFactory.getInstance().createInterface();
- compositionEntityDataManager
- .addEntity(vspInfoDao.getQuestionnaire(vspId, version), null);
-
- Collection<NicEntity> nics = vendorSoftwareProductDao.listNicsByVsp(vspId, version);
-
- Map<String, List<String>> nicNamesByComponent = new HashMap<>();
- for (NicEntity nicEntity : nics) {
- compositionEntityDataManager.addEntity(nicEntity, null);
-
- Nic nic = nicEntity.getNicCompositionData();
- if (nic != null && nic.getName() != null) {
- List<String> nicNames =
- nicNamesByComponent.computeIfAbsent(nicEntity.getComponentId(), k -> new ArrayList<>());
- nicNames.add(nic.getName());
- }
- }
+ public Builder componentDependencyModel(ComponentDependencyModelDao componentDependencyModelDao) {
+ this.componentDependencyModelDao = componentDependencyModelDao;
+ return this;
+ }
- Collection<ComponentEntity> components =
- vendorSoftwareProductDao.listComponentsCompositionAndQuestionnaire(vspId, version);
- components.forEach(component -> compositionEntityDataManager.addEntity(component,
- new ComponentQuestionnaireSchemaInput(nicNamesByComponent.get(component.getId()),
- JsonUtil.json2Object(component.getQuestionnaireData(), Map.class))));
+ public Builder nic(NicDao nicDao) {
+ this.nicDao = nicDao;
+ return this;
+ }
- Collection<ComputeEntity> computes = vendorSoftwareProductDao.listComputesByVsp(vspId, version);
- computes.forEach(compute -> compositionEntityDataManager.addEntity(compute, null));
+ public Builder compute(ComputeDao computeDao) {
+ this.computeDao = computeDao;
+ return this;
+ }
- if ("Manual".equals(onboardingMethod) ) {
- Collection<ImageEntity> images = vendorSoftwareProductDao.listImagesByVsp(vspId, version);
- images.forEach(image -> compositionEntityDataManager.addEntity(image, null));
- }
+ public Builder image(ImageDao imageDao) {
+ this.imageDao = imageDao;
+ return this;
+ }
- Map<CompositionEntityId, Collection<String>> errorsByEntityId =
- compositionEntityDataManager.validateEntitiesQuestionnaire();
- if (MapUtils.isNotEmpty(errorsByEntityId)) {
- compositionEntityDataManager.buildTrees();
- compositionEntityDataManager.addErrorsToTrees(errorsByEntityId);
-/* Set<CompositionEntityValidationData> entitiesWithValidationErrors =
- compositionEntityDataManager.getEntityListWithErrors();*/
- //Collection<CompositionEntityValidationData> roots = compositionEntityDataManager.getTrees();
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return new QuestionnaireValidationResult(
- compositionEntityDataManager.getAllErrorsByVsp(vspId));
- }
+ public Builder manualVspToscaManager(ManualVspToscaManager manualVspToscaManager) {
+ this.manualVspToscaManager = manualVspToscaManager;
+ return this;
+ }
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return null;
- }
+ public Builder uniqueValue(UniqueValueDao uniqueValueDao) {
+ this.uniqueValueDao = uniqueValueDao;
+ return this;
+ }
- @Override
- public File getInformationArtifact(String vspId, Version version, String user) {
- mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
+ public Builder candidateService(CandidateService candidateService) {
+ this.candidateService = candidateService;
+ return this;
+ }
- if (vspDetails == null) {
- return null;
- }
+ private void registerToVersioning() {
+ if (serviceModelDao != null) {
+ serviceModelDao.registerVersioning(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
+ }
+ if (enrichedServiceModelDao != null) {
+ enrichedServiceModelDao.registerVersioning(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
+ }
+ }
- String vspName = vspDetails.getName();
- ByteBuffer infoArtifactAsByteBuffer;
- File infoArtifactFile;
- try {
- infoArtifactAsByteBuffer = ByteBuffer.wrap(informationArtifactGenerator.generate(vspId,
- version).getBytes());
-
- infoArtifactFile =
- new File(
- String.format(VendorSoftwareProductConstants.INFORMATION_ARTIFACT_NAME, vspName));
- OutputStream out = new BufferedOutputStream(new FileOutputStream(infoArtifactFile));
- out.write(infoArtifactAsByteBuffer.array());
- out.close();
- } catch (IOException ex) {
- throw new CoreException(new InformationArtifactCreationErrorBuilder(vspId).build(), ex);
+ public VendorSoftwareProductManager build() {
+ VendorSoftwareProductManagerImpl vendorSoftwareProductManager = new VendorSoftwareProductManagerImpl();
+ vendorSoftwareProductManager.vspMergeDao = this.vspMergeDao;
+ vendorSoftwareProductManager.orchestrationTemplateDao = this.orchestrationTemplateDao;
+ vendorSoftwareProductManager.orchestrationTemplateCandidateManager = this.orchestrationTemplateCandidateManager;
+ vendorSoftwareProductManager.vspInfoDao = this.vspInfoDao;
+ vendorSoftwareProductManager.vendorLicenseFacade = this.vendorLicenseFacade;
+ vendorSoftwareProductManager.serviceModelDao = this.serviceModelDao;
+ vendorSoftwareProductManager.enrichedServiceModelDao = this.enrichedServiceModelDao;
+ vendorSoftwareProductManager.licenseArtifactsService = this.licenseArtifactsService;
+ vendorSoftwareProductManager.informationArtifactGenerator = this.informationArtifactGenerator;
+ vendorSoftwareProductManager.packageInfoDao = this.packageInfoDao;
+ vendorSoftwareProductManager.deploymentFlavorDao = this.deploymentFlavorDao;
+ vendorSoftwareProductManager.componentDao = this.componentDao;
+ vendorSoftwareProductManager.componentDependencyModelDao = this.componentDependencyModelDao;
+ vendorSoftwareProductManager.nicDao = this.nicDao;
+ vendorSoftwareProductManager.computeDao = this.computeDao;
+ vendorSoftwareProductManager.imageDao = this.imageDao;
+ vendorSoftwareProductManager.manualVspToscaManager = this.manualVspToscaManager;
+ vendorSoftwareProductManager.uniqueValueUtil = new UniqueValueUtil(this.uniqueValueDao);
+ vendorSoftwareProductManager.candidateService = candidateService;
+ this.registerToVersioning();
+ return vendorSoftwareProductManager;
+ }
}
-
- mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
- return infoArtifactFile;
- }
-
- void validateUniqueName(String vspName) {
- UniqueValueUtil.validateUniqueValue(
- VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, vspName);
- }
-
- void createUniqueName(String vspName) {
- UniqueValueUtil.createUniqueValue(
- VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, vspName);
- }
-
- void updateUniqueName(String oldVspName, String newVspName) {
- UniqueValueUtil.updateUniqueValue(
- VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME,
- oldVspName, newVspName);
- }
-
- @Override
- public Collection<ComputeEntity> getComputeByVsp(String vspId, Version version,
- String user) {
- return vendorSoftwareProductDao.listComputesByVsp(vspId, version);
- }
-
- private void auditIfContainsErrors(List<ErrorMessage> errorList, String vspId,String auditType) {
-
- errorList.forEach(errorMessage -> {
- if (errorMessage.getLevel().equals(ErrorLevel.ERROR)) {
- logger.audit(AuditMessages.AUDIT_MSG + String.format(auditType, errorMessage.getMessage(),
- vspId));
- }
- });
- }
}