Unique identifier for test execution
[sdc.git] / openecomp-be / backend / openecomp-sdc-vendor-software-product-manager / src / main / java / org / openecomp / sdc / vendorsoftwareproduct / impl / VendorSoftwareProductManagerImpl.java
1 /*
2  * Copyright © 2016-2018 European Support Limited
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.openecomp.sdc.vendorsoftwareproduct.impl;
18
19 import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.candidateDataNotProcessedOrAbortedErrorBuilder;
20 import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.invalidProcessedCandidate;
21 import static org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder.vspMissingDeploymentFlavorErrorBuilder;
22
23 import java.io.BufferedOutputStream;
24 import java.io.ByteArrayInputStream;
25 import java.io.ByteArrayOutputStream;
26 import java.io.File;
27 import java.io.FileOutputStream;
28 import java.io.IOException;
29 import java.io.OutputStream;
30 import java.nio.ByteBuffer;
31 import java.nio.file.Path;
32 import java.util.ArrayList;
33 import java.util.Collection;
34 import java.util.Collections;
35 import java.util.HashMap;
36 import java.util.HashSet;
37 import java.util.List;
38 import java.util.Map;
39 import java.util.Objects;
40 import java.util.Optional;
41 import java.util.Set;
42 import java.util.zip.ZipInputStream;
43 import java.util.zip.ZipOutputStream;
44 import org.apache.commons.collections4.CollectionUtils;
45 import org.apache.commons.collections4.MapUtils;
46 import org.apache.commons.lang3.tuple.ImmutablePair;
47 import org.apache.commons.lang3.tuple.Pair;
48 import org.openecomp.core.dao.UniqueValueDao;
49 import org.openecomp.core.enrichment.api.EnrichmentManager;
50 import org.openecomp.core.enrichment.factory.EnrichmentManagerFactory;
51 import org.openecomp.core.model.dao.EnrichedServiceModelDao;
52 import org.openecomp.core.model.dao.ServiceModelDao;
53 import org.openecomp.core.model.types.ServiceElement;
54 import org.openecomp.core.util.UniqueValueUtil;
55 import org.openecomp.core.utilities.file.FileContentHandler;
56 import org.openecomp.core.utilities.json.JsonSchemaDataGenerator;
57 import org.openecomp.core.utilities.json.JsonUtil;
58 import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
59 import org.openecomp.core.validation.api.ValidationManager;
60 import org.openecomp.core.validation.util.MessageContainerUtil;
61 import org.openecomp.sdc.common.errors.CoreException;
62 import org.openecomp.sdc.common.errors.ErrorCode;
63 import org.openecomp.sdc.common.errors.ValidationErrorBuilder;
64 import org.openecomp.sdc.common.utils.CommonUtil;
65 import org.openecomp.sdc.datatypes.error.ErrorLevel;
66 import org.openecomp.sdc.datatypes.error.ErrorMessage;
67 import org.openecomp.sdc.tosca.csar.Manifest;
68 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
69 import org.openecomp.sdc.tosca.services.impl.ToscaFileOutputServiceCsarImpl;
70 import org.openecomp.sdc.validation.util.ValidationManagerUtil;
71 import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
72 import org.openecomp.sdc.vendorlicense.licenseartifacts.VendorLicenseArtifactsService;
73 import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManager;
74 import org.openecomp.sdc.vendorsoftwareproduct.CompositionEntityDataManagerFactory;
75 import org.openecomp.sdc.vendorsoftwareproduct.ManualVspToscaManager;
76 import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
77 import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants;
78 import org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductManager;
79 import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
80 import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDependencyModelDao;
81 import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
82 import org.openecomp.sdc.vendorsoftwareproduct.dao.DeploymentFlavorDao;
83 import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
84 import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
85 import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
86 import org.openecomp.sdc.vendorsoftwareproduct.dao.PackageInfoDao;
87 import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
88 import org.openecomp.sdc.vendorsoftwareproduct.dao.VspMergeDao;
89 import org.openecomp.sdc.vendorsoftwareproduct.dao.errors.VendorSoftwareProductNotFoundErrorBuilder;
90 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentDependencyModelEntity;
91 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
92 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
93 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.DeploymentFlavorEntity;
94 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
95 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
96 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod;
97 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
98 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.PackageInfo;
99 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
100 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
101 import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentDependencyModelErrorBuilder;
102 import org.openecomp.sdc.vendorsoftwareproduct.errors.ComponentErrorBuilder;
103 import org.openecomp.sdc.vendorsoftwareproduct.errors.DeploymentFlavorErrorBuilder;
104 import org.openecomp.sdc.vendorsoftwareproduct.errors.FileCreationErrorBuilder;
105 import org.openecomp.sdc.vendorsoftwareproduct.errors.InformationArtifactCreationErrorBuilder;
106 import org.openecomp.sdc.vendorsoftwareproduct.errors.NicInternalNetworkErrorBuilder;
107 import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageInvalidErrorBuilder;
108 import org.openecomp.sdc.vendorsoftwareproduct.errors.PackageNotFoundErrorBuilder;
109 import org.openecomp.sdc.vendorsoftwareproduct.errors.TranslationFileCreationErrorBuilder;
110 import org.openecomp.sdc.vendorsoftwareproduct.errors.VendorSoftwareProductInvalidErrorBuilder;
111 import org.openecomp.sdc.vendorsoftwareproduct.informationArtifact.InformationArtifactGenerator;
112 import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
113 import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIService;
114 import org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi.ETSIServiceImpl;
115 import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
116 import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireResponse;
117 import org.openecomp.sdc.vendorsoftwareproduct.types.QuestionnaireValidationResult;
118 import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
119 import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
120 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
121 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
122 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
123 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
124 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
125 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
126 import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
127 import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.ComponentQuestionnaireSchemaInput;
128 import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
129 import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateInput;
130 import org.openecomp.sdc.vendorsoftwareproduct.utils.ComponentDependencyTracker;
131 import org.openecomp.sdc.versioning.VersioningManager;
132 import org.openecomp.sdc.versioning.VersioningManagerFactory;
133 import org.openecomp.sdc.versioning.VersioningUtil;
134 import org.openecomp.sdc.versioning.dao.types.Version;
135
136 public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductManager {
137
138     private VspMergeDao vspMergeDao;
139     private OrchestrationTemplateDao orchestrationTemplateDao;
140     private OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager;
141     private VendorSoftwareProductInfoDao vspInfoDao;
142     private VendorLicenseFacade vendorLicenseFacade;
143     private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
144     private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
145     private VendorLicenseArtifactsService licenseArtifactsService;
146     private InformationArtifactGenerator informationArtifactGenerator;
147     private PackageInfoDao packageInfoDao;
148     private DeploymentFlavorDao deploymentFlavorDao;
149     private ComponentDao componentDao;
150     private ComponentDependencyModelDao componentDependencyModelDao;
151     private NicDao nicDao;
152     private ComputeDao computeDao;
153     private ImageDao imageDao;
154     private ManualVspToscaManager manualVspToscaManager;
155     private UniqueValueUtil uniqueValueUtil;
156     private CandidateService candidateService;
157
158     @Override
159     public ValidationResponse validate(VspDetails vspDetails) throws IOException {
160         List<ErrorCode> vspErrors = new ArrayList<>(validateVspFields(vspDetails));
161         ValidationResponse validationResponse = new ValidationResponse();
162         if (Objects.nonNull(vspDetails.getOnboardingMethod()) && OnboardingMethod.Manual.name()
163                                                                          .equals(vspDetails.getOnboardingMethod())) {
164             validateManualOnboardingMethod(vspDetails, validationResponse, vspErrors);
165         } else {
166             validateOrchestrationTemplateCandidate(validationResponse, vspErrors, vspDetails.getId(),
167                     vspDetails.getVersion());
168             if (!validationResponse.isValid()) {
169                 return validationResponse;
170             }
171             validateLicense(vspDetails, vspErrors);
172             OrchestrationTemplateEntity orchestrationTemplate =
173                     orchestrationTemplateDao.get(vspDetails.getId(), vspDetails.getVersion());
174             ToscaServiceModel serviceModel =
175                     serviceModelDao.getServiceModel(vspDetails.getId(), vspDetails.getVersion());
176             if (isOrchestrationTemplateMissing(orchestrationTemplate) || isServiceModelMissing(serviceModel)) {
177                 vspErrors.add(VendorSoftwareProductInvalidErrorBuilder
178                                       .vendorSoftwareProductMissingServiceModelErrorBuilder(vspDetails.getId(),
179                                               vspDetails.getVersion()));
180             }
181             validationResponse.setUploadDataErrors(validateOrchestrationTemplate(orchestrationTemplate));
182         }
183
184         QuestionnaireValidationResult questionnaireValidationResult =
185                 validateQuestionnaire(vspDetails.getId(), vspDetails.getVersion(), vspDetails.getOnboardingMethod());
186
187         if (Objects.nonNull(questionnaireValidationResult)) {
188             if (validationResponse.getQuestionnaireValidationResult() == null
189                         || validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
190                 validationResponse.setQuestionnaireValidationResult(questionnaireValidationResult);
191             } else {
192                 validationResponse.getQuestionnaireValidationResult().getValidationData()
193                         .addAll(questionnaireValidationResult.getValidationData());
194             }
195         }
196
197         Collection<ComponentDependencyModelEntity> componentDependencies = componentDependencyModelDao
198                                                                                    .list(new ComponentDependencyModelEntity(
199                                                                                            vspDetails.getId(),
200                                                                                            vspDetails.getVersion(),
201                                                                                            null));
202
203         if (validateComponentDependencies(componentDependencies)) {
204             vspErrors.add(ComponentDependencyModelErrorBuilder.getCyclicDependencyComponentErrorBuilder());
205         }
206         validationResponse.setVspErrors(vspErrors);
207         validationResponse.setLicensingDataErrors(validateLicensingData(vspDetails));
208         return validationResponse;
209     }
210
211     private void validateLicense(VspDetails vspDetails, List<ErrorCode> vspErrors) {
212         if (vspDetails.getVlmVersion() != null || vspDetails.getLicenseAgreement() != null
213                     || vspDetails.getFeatureGroups() != null) {
214             vspErrors.addAll(validateMandatoryLicenseFields(vspDetails));
215         }
216     }
217
218     private void validateOrchestrationTemplateCandidate(ValidationResponse validationResponse,
219             List<ErrorCode> vspErrors, String vspId, Version version) {
220         orchestrationTemplateCandidateManager.getInfo(vspId, version).ifPresent(candidateInfo -> {
221             String fileName = candidateInfo.getFileName();
222             vspErrors.add(candidateInfo.getValidationData().isEmpty() ? candidateDataNotProcessedOrAbortedErrorBuilder(
223                     fileName) : invalidProcessedCandidate(fileName));
224             validationResponse.setVspErrors(vspErrors);
225         });
226     }
227
228     private void validateManualOnboardingMethod(VspDetails vspDetails, ValidationResponse validationResponse,
229             List<ErrorCode> vspErrors) {
230         vspErrors.addAll(validateMandatoryLicenseFields(vspDetails));
231
232         Collection<DeploymentFlavorEntity> deploymentFlavors =
233                 deploymentFlavorDao.list(new DeploymentFlavorEntity(vspDetails.getId(), vspDetails.getVersion(), null));
234         if (CollectionUtils.isEmpty(deploymentFlavors)) {
235             vspErrors.add(vspMissingDeploymentFlavorErrorBuilder());
236         }
237         vspErrors.addAll(validateDeploymentFlavors(deploymentFlavors));
238
239         Set<CompositionEntityValidationData> componentValidationResult =
240                 componentValidation(vspDetails.getId(), vspDetails.getVersion());
241         if (!CollectionUtils.isEmpty(componentValidationResult)) {
242             if (validationResponse.getQuestionnaireValidationResult() == null
243                         || validationResponse.getQuestionnaireValidationResult().getValidationData() == null) {
244                 validationResponse
245                         .setQuestionnaireValidationResult(new QuestionnaireValidationResult(componentValidationResult));
246             } else {
247                 validationResponse.getQuestionnaireValidationResult().getValidationData()
248                         .addAll(componentValidationResult);
249             }
250         }
251     }
252
253     @Override
254     public Map<String, List<ErrorMessage>> compile(String vspId, Version version) {
255         ToscaServiceModel serviceModel =
256                 OnboardingMethod.Manual.name().equals(getValidatedVsp(vspId, version).getOnboardingMethod())
257                         //Generate Tosca service model for Manual Onboarding flow
258                         ? manualVspToscaManager
259                                   .generateToscaModel(manualVspToscaManager.gatherVspInformation(vspId, version))
260                         : serviceModelDao.getServiceModel(vspId, version);
261
262         return compile(vspId, version, serviceModel);
263     }
264
265     private boolean validateComponentDependencies(Collection<ComponentDependencyModelEntity> componentDependencies) {
266         ComponentDependencyTracker dependencyTracker = new ComponentDependencyTracker();
267
268         for (ComponentDependencyModelEntity componentDependency : componentDependencies) {
269             dependencyTracker.addDependency(componentDependency.getSourceComponentId(),
270                     componentDependency.getTargetComponentId());
271         }
272         return dependencyTracker.isCyclicDependencyPresent();
273     }
274
275     private Collection<ErrorCode> validateDeploymentFlavors(Collection<DeploymentFlavorEntity> deploymentFlavors) {
276
277         Collection<ErrorCode> errorCodeList = new ArrayList<>();
278         if (!CollectionUtils.isEmpty(deploymentFlavors)) {
279             deploymentFlavors.forEach(deploymentFlavor -> {
280                 DeploymentFlavorEntity deployment = deploymentFlavorDao.get(deploymentFlavor);
281                 DeploymentFlavor deploymentLocalFlavor = deployment.getDeploymentFlavorCompositionData();
282                 if (deploymentLocalFlavor != null) {
283                     if (deploymentLocalFlavor.getFeatureGroupId() == null) {
284                         ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder.
285                                                                                                      getFeatureGroupMandatoryErrorBuilder(
286                                                                                                              deploymentLocalFlavor
287                                                                                                                      .getModel());
288                         errorCodeList.add(deploymentFlavorErrorBuilder);
289                     }
290                     validateComponentComputeAssociations(errorCodeList, deploymentFlavor, deployment,
291                             deploymentLocalFlavor);
292                 }
293             });
294         }
295         return errorCodeList;
296     }
297
298     private void validateComponentComputeAssociations(Collection<ErrorCode> errorCodeList,
299             DeploymentFlavorEntity deploymentFlavor, DeploymentFlavorEntity deployment,
300             DeploymentFlavor deploymentlocalFlavor) {
301         List<ComponentComputeAssociation> componentComputeAssociations =
302                 deploymentlocalFlavor.getComponentComputeAssociations();
303         if (CollectionUtils.isEmpty(componentComputeAssociations)) {
304             validateCompositionEntity(errorCodeList, deploymentFlavor, deployment, deploymentlocalFlavor);
305         } else {
306             componentComputeAssociations.forEach(componentComputeAssociation -> {
307                 if (componentComputeAssociation == null || !(componentComputeAssociation.getComponentId() != null
308                                                                      && componentComputeAssociation.getComputeFlavorId()
309                                                                                 != null)) {
310                     validateCompositionEntity(errorCodeList, deploymentFlavor, deployment, deploymentlocalFlavor);
311                 }
312             });
313         }
314     }
315
316     private void validateCompositionEntity(Collection<ErrorCode> errorCodeList, DeploymentFlavorEntity deploymentFlavor,
317             DeploymentFlavorEntity deployment, DeploymentFlavor deploymentlocalFlavor) {
318         CompositionEntityValidationData compositionEntityValidationData =
319                 new CompositionEntityValidationData(CompositionEntityType.deployment, deploymentFlavor.getId());
320         compositionEntityValidationData.setEntityName(deployment.getDeploymentFlavorCompositionData().getModel());
321         ErrorCode deploymentFlavorErrorBuilder = DeploymentFlavorErrorBuilder
322                                                          .getInvalidComponentComputeAssociationErrorBuilder(
323                                                                  deploymentlocalFlavor.getModel());
324         errorCodeList.add(deploymentFlavorErrorBuilder);
325     }
326
327     private Set<CompositionEntityValidationData> componentValidation(String vspId, Version version) {
328         Set<CompositionEntityValidationData> validationData = new HashSet<>();
329         Collection<ComponentEntity> components = componentDao.list(new ComponentEntity(vspId, version, null));
330         if (!CollectionUtils.isEmpty(components)) {
331             components.forEach(component -> {
332                 validateImage(vspId, version, validationData, component);
333                 validateNic(vspId, version, validationData, component);
334
335             });
336         }
337
338         return validationData;
339     }
340
341     private void validateNic(String vspId, Version version, Set<CompositionEntityValidationData> validationData,
342             ComponentEntity component) {
343         Collection<NicEntity> nics = nicDao.list(new NicEntity(vspId, version, component.getId(), null));
344         if (CollectionUtils.isNotEmpty(nics)) {
345             nics.forEach(nicEntity -> {
346                 NicEntity nic = nicDao.get(new NicEntity(vspId, version, component.getId(), nicEntity.getId()));
347                 NetworkType networkType = nic.getNicCompositionData().getNetworkType();
348                 String networkId = nic.getNicCompositionData().getNetworkId();
349                 if (networkType.equals(NetworkType.Internal) && networkId == null) {
350                     CompositionEntityValidationData compositionEntityValidationData =
351                             new CompositionEntityValidationData(CompositionEntityType.nic, nic.getId());
352                     compositionEntityValidationData.setEntityName(nic.getNicCompositionData().getName());
353                     ErrorCode nicInternalNetworkErrorBuilder =
354                             NicInternalNetworkErrorBuilder.getNicNullNetworkIdInternalNetworkIdErrorBuilder();
355                     List<String> errors = new ArrayList<>();
356                     errors.add(nicInternalNetworkErrorBuilder.message());
357                     compositionEntityValidationData.setErrors(errors);
358                     validationData.add(compositionEntityValidationData);
359                 }
360             });
361         }
362     }
363
364     private void validateImage(String vspId, Version version, Set<CompositionEntityValidationData> validationData,
365             ComponentEntity component) {
366         Collection<ImageEntity> images = imageDao.list(new ImageEntity(vspId, version, component.getId(), null));
367         if (CollectionUtils.isEmpty(images)) {
368             CompositionEntityValidationData compositionEntityValidationData =
369                     new CompositionEntityValidationData(component.getType(), component.getId());
370             compositionEntityValidationData.setEntityName(component.getComponentCompositionData().getDisplayName());
371             ErrorCode vfcMissingImageErrorBuilder = ComponentErrorBuilder.vfcMissingImageErrorBuilder();
372             List<String> errors = new ArrayList<>();
373             errors.add(vfcMissingImageErrorBuilder.message());
374             compositionEntityValidationData.setErrors(errors);
375             validationData.add(compositionEntityValidationData);
376         }
377     }
378
379     private List<ErrorCode> validateVspFields(VspDetails vspDetails) {
380         List<ErrorCode> errors = new ArrayList<>();
381
382         if (vspDetails.getName() == null) {
383             errors.add(createMissingMandatoryFieldError("name"));
384         }
385         if (vspDetails.getDescription() == null) {
386             errors.add(createMissingMandatoryFieldError("description"));
387         }
388         if (vspDetails.getVendorId() == null) {
389             errors.add(createMissingMandatoryFieldError("vendor Id"));
390         }
391         if (vspDetails.getCategory() == null) {
392             errors.add(createMissingMandatoryFieldError("category"));
393         }
394         if (vspDetails.getSubCategory() == null) {
395             errors.add(createMissingMandatoryFieldError("sub category"));
396         }
397         return errors;
398     }
399
400     private List<ErrorCode> validateMandatoryLicenseFields(VspDetails vspDetails) {
401         List<ErrorCode> errors = new ArrayList<>();
402         if (vspDetails.getVlmVersion() == null) {
403             errors.add(createMissingMandatoryFieldError("licensing version"));
404         }
405         if (vspDetails.getLicenseAgreement() == null) {
406             errors.add(createMissingMandatoryFieldError("license agreement"));
407         }
408         if (CollectionUtils.isEmpty(vspDetails.getFeatureGroups())) {
409             errors.add(createMissingMandatoryFieldError("feature groups"));
410         }
411         return errors;
412     }
413
414     private static ErrorCode createMissingMandatoryFieldError(String fieldName) {
415         return new ValidationErrorBuilder("must be supplied", fieldName).build();
416     }
417
418     private Map<String, List<ErrorMessage>> compile(String vendorSoftwareProductId, Version version,
419             ToscaServiceModel serviceModel) {
420         if (isServiceModelMissing(serviceModel)) {
421             return null;
422         }
423
424         enrichedServiceModelDao.deleteAll(vendorSoftwareProductId, version);
425
426         EnrichmentManager<ToscaServiceModel> enrichmentManager =
427                 EnrichmentManagerFactory.getInstance().createInterface();
428         enrichmentManager.init(vendorSoftwareProductId, version);
429         enrichmentManager.setModel(serviceModel);
430         Map<String, List<ErrorMessage>> enrichErrors = enrichmentManager.enrich();
431
432         enrichedServiceModelDao.storeServiceModel(vendorSoftwareProductId, version, enrichmentManager.getModel());
433
434         return enrichErrors;
435     }
436
437     private Collection<ErrorCode> validateLicensingData(VspDetails vspDetails) {
438         if (vspDetails.getVendorId() != null) {
439             Optional<ErrorCode> errorCode =
440                     vendorLicenseFacade.validateVendorForUsage(vspDetails.getVendorId(), vspDetails.getVlmVersion());
441             if (errorCode.isPresent()) {
442                 return Collections.singleton(errorCode.get());
443             }
444         }
445
446         if (vspDetails.getVendorId() == null || vspDetails.getVlmVersion() == null
447                     || vspDetails.getLicenseAgreement() == null || CollectionUtils
448                                                                            .isEmpty(vspDetails.getFeatureGroups())) {
449             return Collections.emptyList();
450         }
451         return vendorLicenseFacade.validateLicensingData(vspDetails.getVendorId(), vspDetails.getVlmVersion(),
452                 vspDetails.getLicenseAgreement(), vspDetails.getFeatureGroups());
453     }
454
455     @Override
456     public VspDetails createVsp(VspDetails vspDetails) {
457         vspInfoDao.create(vspDetails);
458         vspInfoDao.updateQuestionnaireData(vspDetails.getId(), vspDetails.getVersion(),
459                 new JsonSchemaDataGenerator(getVspQuestionnaireSchema(null)).generateData());
460         return vspDetails;
461     }
462
463     @Override
464     public void updateVsp(VspDetails vspDetails) {
465         VspDetails retrieved = vspInfoDao.get(vspDetails);
466         if (retrieved == null) {
467             throw new CoreException((new ErrorCode.ErrorCodeBuilder().withMessage(
468                     String.format("Vsp with id %s and version %s does not exist.", vspDetails.getId(),
469                             vspDetails.getVersion().getId()))).build());
470         }
471         vspDetails.setOnboardingMethod(retrieved.getOnboardingMethod());
472
473         //If any existing feature group is removed from VSP which is also associated in DF then
474         //update DF to remove feature group associations.
475         updateDeploymentFlavor(vspDetails);
476
477         updateUniqueName(retrieved.getName(), vspDetails.getName());
478         vspInfoDao.update(vspDetails);
479     }
480
481     private void updateDeploymentFlavor(VspDetails vspDetails) {
482         final List<String> featureGroups = vspDetails.getFeatureGroups();
483         if (featureGroups != null) {
484             final Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deploymentFlavorDao
485                                                                                         .list(new DeploymentFlavorEntity(
486                                                                                                 vspDetails.getId(),
487                                                                                                 vspDetails.getVersion(),
488                                                                                                 null));
489             if (Objects.nonNull(deploymentFlavorEntities)) {
490                 for (DeploymentFlavorEntity deploymentFlavorEntity : deploymentFlavorEntities) {
491                     updateDeploymentFlavourEntity(featureGroups, deploymentFlavorEntity);
492                 }
493             }
494         }
495     }
496
497     private void updateDeploymentFlavourEntity(List<String> featureGroups,
498             DeploymentFlavorEntity deploymentFlavorEntity) {
499         final String featureGroupId = deploymentFlavorEntity.getDeploymentFlavorCompositionData().getFeatureGroupId();
500         if (!featureGroups.contains(featureGroupId)) {
501             DeploymentFlavor deploymentFlavorCompositionData =
502                     deploymentFlavorEntity.getDeploymentFlavorCompositionData();
503             deploymentFlavorCompositionData.setFeatureGroupId(null);
504             deploymentFlavorEntity.setDeploymentFlavorCompositionData(deploymentFlavorCompositionData);
505             deploymentFlavorDao.update(deploymentFlavorEntity);
506         }
507     }
508
509
510     @Override
511     public VspDetails getVsp(String vspId, Version version) {
512         return getValidatedVsp(vspId, version);
513     }
514
515     private VspDetails getValidatedVsp(String vspId, Version version) {
516         VspDetails vsp = vspInfoDao.get(new VspDetails(vspId, version));
517         if (vsp == null) {
518             throw new CoreException(new VendorSoftwareProductNotFoundErrorBuilder(vspId).build());
519         }
520         return vsp;
521     }
522
523     @Override
524     public void deleteVsp(String vspId, Version version) {
525         vspMergeDao.deleteHint(vspId, version);
526     }
527
528     @Override
529     public List<PackageInfo> listPackages(String category, String subCategory) {
530         return packageInfoDao.listByCategory(category, subCategory);
531     }
532
533     @Override
534     public File getTranslatedFile(String vspId, Version version) {
535         PackageInfo packageInfo = packageInfoDao.get(new PackageInfo(vspId, version));
536         if (packageInfo == null) {
537             throw new CoreException(new PackageNotFoundErrorBuilder(vspId, version).build());
538         }
539
540         ByteBuffer translatedFileBuffer = packageInfo.getTranslatedFile();
541         if (translatedFileBuffer == null) {
542             throw new CoreException(new PackageInvalidErrorBuilder(vspId, version).build());
543         }
544
545         File translatedFile = new File(VendorSoftwareProductConstants.VSP_PACKAGE_ZIP);
546
547         try (FileOutputStream fos = new FileOutputStream(translatedFile)) {
548             fos.write(translatedFileBuffer.array());
549         } catch (IOException exception) {
550             throw new CoreException(new TranslationFileCreationErrorBuilder(vspId, version).build(), exception);
551         }
552         return translatedFile;
553     }
554
555     @Override
556     public byte[] getOrchestrationTemplateFile(String vspId, Version version) {
557         OrchestrationTemplateEntity uploadData = orchestrationTemplateDao.get(vspId, version);
558         ByteBuffer contentData = uploadData.getContentData();
559         if (contentData == null) {
560             return new byte[0];
561         }
562
563         ByteArrayOutputStream baos = new ByteArrayOutputStream();
564
565         try (final ZipOutputStream zos = new ZipOutputStream(baos);
566              ZipInputStream ignored = new ZipInputStream(new ByteArrayInputStream(contentData.array()))) {
567             zos.write(contentData.array());
568         } catch (IOException exception) {
569             throw new CoreException(new FileCreationErrorBuilder(vspId).build(), exception);
570         }
571         return baos.toByteArray();
572     }
573
574     @Override
575     public OrchestrationTemplateEntity getOrchestrationTemplateInfo(String vspId, Version version) {
576         return orchestrationTemplateDao.getInfo(vspId, version);
577     }
578
579     @Override
580     public Optional<FilesDataStructure> getOrchestrationTemplateStructure(String vspId, Version version) {
581         Optional<String> jsonFileDataStructure =
582                 orchestrationTemplateDao.getOrchestrationTemplateStructure(vspId, version);
583
584         if (jsonFileDataStructure.isPresent() && JsonUtil.isValidJson(jsonFileDataStructure.get())) {
585             return Optional.of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class));
586         } else {
587             return Optional.empty();
588         }
589     }
590
591     @Override
592     public PackageInfo createPackage(final String vspId, final Version version) throws IOException {
593         final ToscaServiceModel toscaServiceModel = enrichedServiceModelDao.getServiceModel(vspId, version);
594         final VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
595         final Version vlmVersion = vspDetails.getVlmVersion();
596         if (vlmVersion != null) {
597             populateVersionsForVlm(vspDetails.getVendorId(), vlmVersion);
598         }
599         final PackageInfo packageInfo = createPackageInfo(vspDetails);
600
601         final ToscaFileOutputServiceCsarImpl toscaServiceTemplateServiceCsar = new ToscaFileOutputServiceCsarImpl();
602         final FileContentHandler licenseArtifacts = licenseArtifactsService.createLicenseArtifacts(vspDetails.getId(),
603                 vspDetails.getVendorId(), vlmVersion, vspDetails.getFeatureGroups());
604         final ETSIService etsiService = new ETSIServiceImpl();
605         if (etsiService.isSol004WithToscaMetaDirectory(toscaServiceModel.getArtifactFiles())) {
606             final FileContentHandler handler = toscaServiceModel.getArtifactFiles();
607             final Manifest manifest = etsiService.getManifest(handler);
608             final Optional<Map<String, Path>> fromToMovedPaths = etsiService.moveNonManoFileToArtifactFolder(handler);
609             fromToMovedPaths.ifPresent(it -> etsiService.updateMainDescriptorPaths(toscaServiceModel, it));
610             packageInfo.setResourceType(etsiService.getResourceType(manifest).name());
611         }
612         packageInfo.setTranslatedFile(
613                 ByteBuffer.wrap(toscaServiceTemplateServiceCsar.createOutputFile(toscaServiceModel, licenseArtifacts)));
614
615         packageInfoDao.create(packageInfo);
616         return packageInfo;
617     }
618
619     void populateVersionsForVlm(String vlmId, Version vlmVersion) {
620         VersioningManager versioningManager = VersioningManagerFactory.getInstance().createInterface();
621         versioningManager.list(vlmId).stream().filter(version -> version.getId().equalsIgnoreCase(vlmVersion.getId()))
622                 .findAny().ifPresent(version -> {
623             vlmVersion.setMinor(version.getMinor());
624             vlmVersion.setMajor(version.getMajor());
625         });
626     }
627
628     private PackageInfo createPackageInfo(VspDetails vspDetails) {
629         PackageInfo packageInfo = new PackageInfo(vspDetails.getId(), vspDetails.getVersion());
630         packageInfo.setVspName(vspDetails.getName());
631         packageInfo.setVspDescription(vspDetails.getDescription());
632         packageInfo.setCategory(vspDetails.getCategory());
633         packageInfo.setSubCategory(vspDetails.getSubCategory());
634         packageInfo.setVendorName(vspDetails.getVendorName());
635         packageInfo.setPackageType(VendorSoftwareProductConstants.CSAR);
636         packageInfo.setVendorRelease("1.0"); //todo TBD
637         return packageInfo;
638     }
639
640     @Override
641
642     public QuestionnaireResponse getVspQuestionnaire(String vspId, Version version) {
643         VspQuestionnaireEntity retrieved = vspInfoDao.getQuestionnaire(vspId, version);
644         VersioningUtil
645                 .validateEntityExistence(retrieved, new VspQuestionnaireEntity(vspId, version), VspDetails.ENTITY_TYPE);
646
647         String questionnaireData = retrieved.getQuestionnaireData();
648
649         QuestionnaireResponse questionnaireResponse = new QuestionnaireResponse();
650         questionnaireResponse.setData(questionnaireData);
651         questionnaireResponse.setSchema(getVspQuestionnaireSchema(null));
652         return questionnaireResponse;
653     }
654
655     @Override
656     public void updateVspQuestionnaire(String vspId, Version version, String questionnaireData) {
657         vspInfoDao.updateQuestionnaireData(vspId, version, questionnaireData);
658     }
659
660
661     private Map<String, List<ErrorMessage>> validateOrchestrationTemplate(
662             OrchestrationTemplateEntity orchestrationTemplate) throws IOException {
663
664         if (isOrchestrationTemplateMissing(orchestrationTemplate)) {
665             return null;
666         }
667         Map<String, List<ErrorMessage>> validationErrors = new HashMap<>();
668
669         FileContentHandler fileContentMap = CommonUtil.validateAndUploadFileContent(
670                 OnboardingTypesEnum.getOnboardingTypesEnum(orchestrationTemplate.getFileSuffix()),
671                 orchestrationTemplate.getContentData().array());
672
673         if (CommonUtil.isFileOriginFromZip(orchestrationTemplate.getFileSuffix())) {
674             ValidationManager validationManager = ValidationManagerUtil.initValidationManager(fileContentMap);
675             validationErrors.putAll(validationManager.validate());
676         }
677
678         return MapUtils.isEmpty(MessageContainerUtil.getMessageByLevel(ErrorLevel.ERROR, validationErrors)) ? null
679                        : validationErrors;
680     }
681
682     private QuestionnaireValidationResult validateQuestionnaire(String vspId, Version version,
683             String onboardingMethod) {
684         // The apis of CompositionEntityDataManager used here are stateful!
685         // so, it must be re-created from scratch when it is used!
686         CompositionEntityDataManager compositionEntityDataManager =
687                 CompositionEntityDataManagerFactory.getInstance().createInterface();
688         compositionEntityDataManager.addEntity(vspInfoDao.getQuestionnaire(vspId, version), null);
689
690         Collection<NicEntity> nics = nicDao.listByVsp(vspId, version);
691
692         Map<String, List<String>> nicNamesByComponent = new HashMap<>();
693         for (NicEntity nicEntity : nics) {
694             compositionEntityDataManager.addEntity(nicEntity, null);
695
696             Nic nic = nicEntity.getNicCompositionData();
697             if (nic != null && nic.getName() != null) {
698                 List<String> nicNames =
699                         nicNamesByComponent.computeIfAbsent(nicEntity.getComponentId(), k -> new ArrayList<>());
700                 nicNames.add(nic.getName());
701             }
702         }
703
704         Collection<ComponentEntity> components = componentDao.listCompositionAndQuestionnaire(vspId, version);
705         components.forEach(component -> compositionEntityDataManager.addEntity(component,
706                 new ComponentQuestionnaireSchemaInput(nicNamesByComponent.get(component.getId()),
707                         JsonUtil.json2Object(component.getQuestionnaireData(), Map.class), null,
708                         OnboardingMethod.Manual.name().equals(onboardingMethod))));
709
710         Collection<ComputeEntity> computes = computeDao.listByVsp(vspId, version);
711         computes.forEach(compute -> compositionEntityDataManager.addEntity(compute, null));
712
713         if (OnboardingMethod.Manual.name().equals(onboardingMethod)) {
714             Collection<ImageEntity> images = imageDao.listByVsp(vspId, version);
715             images.forEach(image -> compositionEntityDataManager.addEntity(image, null));
716         }
717
718         Map<CompositionEntityId, Collection<String>> errorsByEntityId =
719                 compositionEntityDataManager.validateEntitiesQuestionnaire();
720         if (MapUtils.isNotEmpty(errorsByEntityId)) {
721             compositionEntityDataManager.buildTrees();
722             compositionEntityDataManager.addErrorsToTrees(errorsByEntityId);
723             return new QuestionnaireValidationResult(compositionEntityDataManager.getAllErrorsByVsp(vspId));
724         }
725         return null;
726     }
727
728     @Override
729     public File getInformationArtifact(String vspId, Version version) {
730         VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
731
732         if (vspDetails == null) {
733             return null;
734         }
735
736         String vspName = vspDetails.getName();
737         ByteBuffer infoArtifactAsByteBuffer;
738         File infoArtifactFile;
739         try {
740             infoArtifactAsByteBuffer =
741                     ByteBuffer.wrap(informationArtifactGenerator.generate(vspId, version).getBytes());
742
743             infoArtifactFile =
744                     new File(String.format(VendorSoftwareProductConstants.INFORMATION_ARTIFACT_NAME, vspName));
745             try (OutputStream out = new BufferedOutputStream(new FileOutputStream(infoArtifactFile))) {
746                 out.write(infoArtifactAsByteBuffer.array());
747             }
748
749         } catch (IOException ex) {
750             throw new CoreException(new InformationArtifactCreationErrorBuilder(vspId).build(), ex);
751         }
752         return infoArtifactFile;
753     }
754
755     String getVspQuestionnaireSchema(SchemaTemplateInput schemaInput) {
756         return SchemaGenerator.generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, schemaInput);
757     }
758
759     @Override
760     public Optional<Pair<String, byte[]>> get(String vspId, Version version) throws IOException {
761
762         OrchestrationTemplateEntity orchestrationTemplateEntity = orchestrationTemplateDao.get(vspId, version);
763
764         if (isOrchestrationTemplateMissing(orchestrationTemplateEntity)) {
765             return Optional.empty();
766         }
767
768         if (CommonUtil.isFileOriginFromZip(orchestrationTemplateEntity.getFileSuffix())) {
769             return Optional.of(new ImmutablePair<>(OnboardingTypesEnum.ZIP.toString(),
770                     candidateService.getZipData(orchestrationTemplateEntity.getContentData())));
771         }
772         return Optional.of(new ImmutablePair<>(orchestrationTemplateEntity.getFileSuffix(),
773                 orchestrationTemplateEntity.getContentData().array()));
774     }
775
776     void updateUniqueName(String oldVspName, String newVspName) {
777         uniqueValueUtil
778                 .updateUniqueValue(VendorSoftwareProductConstants.UniqueValues.VENDOR_SOFTWARE_PRODUCT_NAME, oldVspName,
779                         newVspName);
780     }
781
782     @Override
783     public Collection<ComputeEntity> getComputeByVsp(String vspId, Version version) {
784         return computeDao.listByVsp(vspId, version);
785     }
786
787     private boolean isOrchestrationTemplateMissing(OrchestrationTemplateEntity orchestrationTemplate) {
788         return orchestrationTemplate == null || orchestrationTemplate.getContentData() == null
789                        || orchestrationTemplate.getFileSuffix() == null || orchestrationTemplate.getFileName() == null;
790     }
791
792     private boolean isServiceModelMissing(ToscaServiceModel serviceModel) {
793         return serviceModel == null || serviceModel.getEntryDefinitionServiceTemplate() == null;
794     }
795
796     public static class Builder {
797
798         private VspMergeDao vspMergeDao;
799         private OrchestrationTemplateDao orchestrationTemplateDao;
800         private OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager;
801         private VendorSoftwareProductInfoDao vspInfoDao;
802         private VendorLicenseFacade vendorLicenseFacade;
803         private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
804         private EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao;
805         private VendorLicenseArtifactsService licenseArtifactsService;
806         private InformationArtifactGenerator informationArtifactGenerator;
807         private PackageInfoDao packageInfoDao;
808         private DeploymentFlavorDao deploymentFlavorDao;
809         private ComponentDao componentDao;
810         private ComponentDependencyModelDao componentDependencyModelDao;
811         private NicDao nicDao;
812         private ComputeDao computeDao;
813         private ImageDao imageDao;
814         private ManualVspToscaManager manualVspToscaManager;
815         private UniqueValueDao uniqueValueDao;
816         private CandidateService candidateService;
817
818         public Builder vspMerge(VspMergeDao vspMergeDao) {
819             this.vspMergeDao = vspMergeDao;
820             return this;
821         }
822
823         public Builder orchestrationTemplate(OrchestrationTemplateDao orchestrationTemplateDao) {
824             this.orchestrationTemplateDao = orchestrationTemplateDao;
825             return this;
826         }
827
828         public Builder orchestrationTemplateCandidateManager(
829                 OrchestrationTemplateCandidateManager orchestrationTemplateCandidateManager) {
830             this.orchestrationTemplateCandidateManager = orchestrationTemplateCandidateManager;
831             return this;
832         }
833
834         public Builder vspInfo(VendorSoftwareProductInfoDao vspInfoDao) {
835             this.vspInfoDao = vspInfoDao;
836             return this;
837         }
838
839         public Builder vendorLicenseFacade(VendorLicenseFacade vendorLicenseFacade) {
840             this.vendorLicenseFacade = vendorLicenseFacade;
841             return this;
842         }
843
844         public Builder serviceModel(ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao) {
845             this.serviceModelDao = serviceModelDao;
846             return this;
847         }
848
849         public Builder enrichedServiceModel(
850                 EnrichedServiceModelDao<ToscaServiceModel, ServiceElement> enrichedServiceModelDao) {
851             this.enrichedServiceModelDao = enrichedServiceModelDao;
852             return this;
853         }
854
855         public Builder licenseArtifactsService(VendorLicenseArtifactsService licenseArtifactsService) {
856             this.licenseArtifactsService = licenseArtifactsService;
857             return this;
858         }
859
860         public Builder informationArtifactGenerator(InformationArtifactGenerator informationArtifactGenerator) {
861             this.informationArtifactGenerator = informationArtifactGenerator;
862             return this;
863         }
864
865         public Builder packageInfo(PackageInfoDao packageInfoDao) {
866             this.packageInfoDao = packageInfoDao;
867             return this;
868         }
869
870         public Builder deploymentFlavor(DeploymentFlavorDao deploymentFlavorDao) {
871             this.deploymentFlavorDao = deploymentFlavorDao;
872             return this;
873         }
874
875         public Builder component(ComponentDao componentDao) {
876             this.componentDao = componentDao;
877             return this;
878         }
879
880         public Builder componentDependencyModel(ComponentDependencyModelDao componentDependencyModelDao) {
881             this.componentDependencyModelDao = componentDependencyModelDao;
882             return this;
883         }
884
885         public Builder nic(NicDao nicDao) {
886             this.nicDao = nicDao;
887             return this;
888         }
889
890         public Builder compute(ComputeDao computeDao) {
891             this.computeDao = computeDao;
892             return this;
893         }
894
895         public Builder image(ImageDao imageDao) {
896             this.imageDao = imageDao;
897             return this;
898         }
899
900         public Builder manualVspToscaManager(ManualVspToscaManager manualVspToscaManager) {
901             this.manualVspToscaManager = manualVspToscaManager;
902             return this;
903         }
904
905         public Builder uniqueValue(UniqueValueDao uniqueValueDao) {
906             this.uniqueValueDao = uniqueValueDao;
907             return this;
908         }
909
910         public Builder candidateService(CandidateService candidateService) {
911             this.candidateService = candidateService;
912             return this;
913         }
914
915         private void registerToVersioning() {
916             if (serviceModelDao != null) {
917                 serviceModelDao
918                         .registerVersioning(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
919             }
920             if (enrichedServiceModelDao != null) {
921                 enrichedServiceModelDao
922                         .registerVersioning(VendorSoftwareProductConstants.VENDOR_SOFTWARE_PRODUCT_VERSIONABLE_TYPE);
923             }
924         }
925
926         public VendorSoftwareProductManager build() {
927             VendorSoftwareProductManagerImpl vendorSoftwareProductManager = new VendorSoftwareProductManagerImpl();
928             vendorSoftwareProductManager.vspMergeDao = this.vspMergeDao;
929             vendorSoftwareProductManager.orchestrationTemplateDao = this.orchestrationTemplateDao;
930             vendorSoftwareProductManager.orchestrationTemplateCandidateManager =
931                     this.orchestrationTemplateCandidateManager;
932             vendorSoftwareProductManager.vspInfoDao = this.vspInfoDao;
933             vendorSoftwareProductManager.vendorLicenseFacade = this.vendorLicenseFacade;
934             vendorSoftwareProductManager.serviceModelDao = this.serviceModelDao;
935             vendorSoftwareProductManager.enrichedServiceModelDao = this.enrichedServiceModelDao;
936             vendorSoftwareProductManager.licenseArtifactsService = this.licenseArtifactsService;
937             vendorSoftwareProductManager.informationArtifactGenerator = this.informationArtifactGenerator;
938             vendorSoftwareProductManager.packageInfoDao = this.packageInfoDao;
939             vendorSoftwareProductManager.deploymentFlavorDao = this.deploymentFlavorDao;
940             vendorSoftwareProductManager.componentDao = this.componentDao;
941             vendorSoftwareProductManager.componentDependencyModelDao = this.componentDependencyModelDao;
942             vendorSoftwareProductManager.nicDao = this.nicDao;
943             vendorSoftwareProductManager.computeDao = this.computeDao;
944             vendorSoftwareProductManager.imageDao = this.imageDao;
945             vendorSoftwareProductManager.manualVspToscaManager = this.manualVspToscaManager;
946             vendorSoftwareProductManager.uniqueValueUtil = new UniqueValueUtil(this.uniqueValueDao);
947             vendorSoftwareProductManager.candidateService = candidateService;
948             this.registerToVersioning();
949             return vendorSoftwareProductManager;
950         }
951     }
952
953 }