2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.vendorsoftwareproduct.impl;
22 import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.GENERAL_COMPONENT_ID;
23 import static org.openecomp.sdc.vendorsoftwareproduct.VendorSoftwareProductConstants.UniqueValues
25 import org.apache.commons.collections4.CollectionUtils;
26 import org.apache.commons.collections4.MapUtils;
27 import org.apache.xalan.xslt.Process;
28 import org.openecomp.core.model.dao.ServiceModelDao;
29 import org.openecomp.core.model.types.ServiceElement;
30 import org.openecomp.core.util.UniqueValueUtil;
31 import org.openecomp.core.utilities.file.FileContentHandler;
32 import org.openecomp.core.utilities.file.FileUtils;
33 import org.openecomp.core.utilities.json.JsonUtil;
34 import org.openecomp.sdc.activityLog.ActivityLogManager;
35 import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
36 import org.openecomp.sdc.common.errors.CoreException;
37 import org.openecomp.sdc.common.errors.Messages;
38 import org.openecomp.sdc.common.utils.CommonUtil;
39 import org.openecomp.sdc.common.utils.SdcCommon;
40 import org.openecomp.sdc.datatypes.error.ErrorLevel;
41 import org.openecomp.sdc.datatypes.error.ErrorMessage;
42 import org.openecomp.sdc.healing.api.HealingManager;
43 import org.openecomp.sdc.healing.types.HealCode;
44 import org.openecomp.sdc.heat.datatypes.structure.HeatStructureTree;
45 import org.openecomp.sdc.heat.datatypes.structure.ValidationStructureList;
46 import org.openecomp.sdc.heat.services.tree.HeatTreeManager;
47 import org.openecomp.sdc.heat.services.tree.HeatTreeManagerUtil;
48 import org.openecomp.sdc.logging.api.Logger;
49 import org.openecomp.sdc.logging.api.LoggerFactory;
50 import org.openecomp.sdc.logging.api.annotations.Metrics;
51 import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
52 import org.openecomp.sdc.logging.types.LoggerServiceName;
53 import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
54 import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
55 import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
56 import org.openecomp.sdc.validation.util.ValidationManagerUtil;
57 import org.openecomp.sdc.vendorsoftwareproduct.OrchestrationTemplateCandidateManager;
58 import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
59 import org.openecomp.sdc.vendorsoftwareproduct.dao.MibDao;
60 import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
61 import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
62 import org.openecomp.sdc.vendorsoftwareproduct.dao.ProcessDao;
63 import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
64 import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
65 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.MibEntity;
66 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
67 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ProcessEntity;
68 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
69 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
70 import org.openecomp.sdc.vendorsoftwareproduct.errors.OrchestrationTemplateNotFoundErrorBuilder;
71 import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
72 import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
73 import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
74 import org.openecomp.sdc.vendorsoftwareproduct.services.utils.CandidateEntityBuilder;
75 import org.openecomp.sdc.vendorsoftwareproduct.types.OrchestrationTemplateActionResponse;
76 import org.openecomp.sdc.vendorsoftwareproduct.types.UploadFileResponse;
77 import org.openecomp.sdc.vendorsoftwareproduct.types.ValidationResponse;
78 import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
79 import org.openecomp.sdc.vendorsoftwareproduct.utils.VendorSoftwareProductUtils;
80 import org.openecomp.sdc.versioning.dao.types.Version;
81 import org.openecomp.sdcrests.activitylog.types.ActivityType;
82 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
83 import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
84 import java.io.ByteArrayInputStream;
85 import java.io.IOException;
86 import java.io.InputStream;
87 import java.nio.ByteBuffer;
88 import java.util.HashMap;
89 import java.util.List;
91 import java.util.Optional;
92 import java.util.Collection;
94 public class OrchestrationTemplateCandidateManagerImpl
95 implements OrchestrationTemplateCandidateManager {
96 private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
97 private static final Logger logger =
98 LoggerFactory.getLogger(OrchestrationTemplateCandidateManagerImpl.class);
100 private VendorSoftwareProductDao vendorSoftwareProductDao;
101 private VendorSoftwareProductInfoDao vspInfoDao;
102 private OrchestrationTemplateDao orchestrationTemplateDataDao;
103 private CandidateService candidateService;
104 private HealingManager healingManager;
105 private CompositionDataExtractor compositionDataExtractor;
106 private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
107 private CompositionEntityDataManager compositionEntityDataManager;
108 private NicDao nicDao;
109 private ComponentDao componentDao;
110 private MibDao mibDao;
111 private ActivityLogManager activityLogManager;
112 private ProcessDao processDao;
114 public OrchestrationTemplateCandidateManagerImpl(
115 VendorSoftwareProductDao vendorSoftwareProductDao, VendorSoftwareProductInfoDao
117 OrchestrationTemplateDao orchestrationTemplateDataDao,
118 CandidateService candidateService, HealingManager healingManager,
119 CompositionDataExtractor compositionDataExtractor,
120 ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao,
121 CompositionEntityDataManager compositionEntityDataManager,
123 ComponentDao componentDao,
125 ProcessDao processDao,
126 ActivityLogManager activityLogManager) {
127 this.vendorSoftwareProductDao = vendorSoftwareProductDao;
128 this.vspInfoDao = vspInfoDao;
129 this.orchestrationTemplateDataDao = orchestrationTemplateDataDao;
130 this.candidateService = candidateService;
131 this.healingManager = healingManager;
132 this.compositionDataExtractor = compositionDataExtractor;
133 this.serviceModelDao = serviceModelDao;
134 this.compositionEntityDataManager = compositionEntityDataManager;
135 this.nicDao = nicDao;
136 this.componentDao = componentDao;
137 this.mibDao = mibDao;
138 this.processDao = processDao;
139 this.activityLogManager = activityLogManager;
144 public UploadFileResponse upload(String vspId, Version version, InputStream heatFileToUpload,
146 mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
148 VspDetails vspDetails = getVspDetails(vspId, version);
150 UploadFileResponse uploadFileResponse = new UploadFileResponse();
151 if (isNotEmptyFileToUpload(heatFileToUpload, uploadFileResponse)) {
152 return uploadFileResponse;
155 byte[] uploadedFileData = FileUtils.toByteArray(heatFileToUpload);
156 if (isInvalidRawZipData(uploadFileResponse, uploadedFileData)) {
157 return uploadFileResponse;
160 Optional<FileContentHandler> optionalContentMap =
161 getZipContentMap(uploadFileResponse, uploadedFileData);
162 if (!optionalContentMap.isPresent()) {
163 logger.error(Messages.ZIP_CONTENT_MAP.getErrorMessage());
166 SdcCommon.UPLOAD_FILE,
167 new ErrorMessage(ErrorLevel.ERROR, Messages.ZIP_CONTENT_MAP.getErrorMessage()));
169 mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
170 return uploadFileResponse;
173 if (!MapUtils.isEmpty(uploadFileResponse.getErrors())) {
175 mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
176 return uploadFileResponse;
179 OrchestrationTemplateCandidateData candidateData =
180 new CandidateEntityBuilder(candidateService)
181 .buildCandidateEntityFromZip(vspDetails, uploadedFileData, optionalContentMap.get(),
182 uploadFileResponse.getErrors(), user);
183 candidateService.updateCandidateUploadData(candidateData, vspDetails.getId());
184 } catch (Exception exception) {
185 logger.error(Messages.ZIP_CONTENT_MAP.getErrorMessage());
188 SdcCommon.UPLOAD_FILE,
189 new ErrorMessage(ErrorLevel.ERROR, exception.getMessage()));
191 mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
192 return uploadFileResponse;
195 mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
196 return uploadFileResponse;
200 public OrchestrationTemplateActionResponse process(String vspId,
201 Version version, String user) {
202 mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
204 Optional<OrchestrationTemplateCandidateData> candidate =
205 fetchCandidateDataEntity(vspId, version);
206 if (!candidate.isPresent()) {
207 throw new CoreException(new OrchestrationTemplateNotFoundErrorBuilder(vspId).build());
210 OrchestrationTemplateActionResponse response = new OrchestrationTemplateActionResponse();
211 UploadFileResponse uploadFileResponse = new UploadFileResponse();
212 OrchestrationTemplateCandidateData candidateDataEntity = candidate.get();
213 Optional<FileContentHandler> fileContent =
214 getZipContentMap(uploadFileResponse, candidateDataEntity.getContentData().array());
215 if (!fileContent.isPresent()) {
216 response.addStructureErrors(uploadFileResponse.getErrors());
217 mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
221 Map<String, List<ErrorMessage>> uploadErrors = uploadFileResponse.getErrors();
222 FileContentHandler fileContentMap = fileContent.get();
223 FilesDataStructure structure =
224 JsonUtil.json2Object(candidateDataEntity.getFilesDataStructure(), FilesDataStructure.class);
226 if (CollectionUtils.isNotEmpty(structure.getUnassigned())) {
227 response.addErrorMessageToMap(SdcCommon.UPLOAD_FILE,
228 Messages.FOUND_UNASSIGNED_FILES.getErrorMessage(), ErrorLevel.ERROR);
230 mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
234 VspDetails vspDetails =
235 getVspDetails(vspId, version);
237 String manifest = candidateService.createManifest(vspDetails, structure);
238 fileContentMap.addFile(SdcCommon.MANIFEST_NAME, manifest.getBytes());
240 HeatStructureTree tree = createAndValidateHeatTree(response, fileContentMap);
242 Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
243 .fetchZipFileByteArrayInputStream(vspId, candidateDataEntity, manifest, uploadErrors);
244 if (!zipByteArrayInputStream.isPresent()) {
247 Map<String,String> componentsQustanniare = new HashMap<>();
248 Map<String, Map<String, String>> componentNicsQustanniare = new HashMap<>();
249 Map<String, Collection<MibEntity>> componentMIBList = new HashMap<>();
250 Map<String, Collection<ProcessEntity>> processes = new HashMap<>();
251 Map<String, ProcessEntity> processArtifact = new HashMap<>();
253 backupComponentsQuestionnaireBeforeDelete(vspId, version, componentsQustanniare,
254 componentNicsQustanniare, componentMIBList, processes, processArtifact);
256 deleteUploadDataAndContent(vspId, version);
257 saveHotData(vspId, version, zipByteArrayInputStream.get(), fileContentMap, tree);
259 ToscaServiceModel toscaServiceModel =
260 HeatToToscaUtil.loadAndTranslateTemplateData(fileContentMap)
261 .getToscaServiceModel();
262 if (toscaServiceModel != null) {
263 serviceModelDao.storeServiceModel(vspId, version, toscaServiceModel);
264 compositionEntityDataManager.saveCompositionData(vspId, version,
265 compositionDataExtractor.extractServiceCompositionData(toscaServiceModel));
266 retainComponentQuestionnaireData(vspId, version, componentsQustanniare,
267 componentNicsQustanniare, componentMIBList, processes, processArtifact);
269 uploadFileResponse.addStructureErrors(uploadErrors);
271 ActivityLogEntity activityLogEntity = new ActivityLogEntity(vspId, String.valueOf(version.getMajor()+1),
272 ActivityType.UPLOAD_HEAT.toString(), user, true, "", "");
273 activityLogManager.addActionLog(activityLogEntity, user);
275 mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
281 public Optional<FilesDataStructure> getFilesDataStructure(
282 String vspId, Version version, String user) {
283 mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
285 Optional<FilesDataStructure> candidateFileDataStructure =
286 candidateService.getOrchestrationTemplateCandidateFileDataStructure(vspId, version);
287 if (candidateFileDataStructure.isPresent()) {
288 return candidateFileDataStructure;
290 Map<String, Object> healingParams = getHealingParamsAsMap(vspId, version, user);
293 .debugExitMessage("VSP id", vspId);
294 return (Optional<FilesDataStructure>) healingManager
295 .heal(HealCode.FILE_DATA_STRUCTURE_HEALER, healingParams);
301 public ValidationResponse updateFilesDataStructure(String vspId,
302 Version version, String user,
303 FilesDataStructure fileDataStructure) {
304 mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
306 ValidationResponse response = new ValidationResponse();
307 Optional<List<ErrorMessage>> validateErrors =
308 candidateService.validateFileDataStructure(fileDataStructure);
309 if (validateErrors.isPresent()) {
310 List<ErrorMessage> errorMessages = validateErrors.get();
311 if (CollectionUtils.isNotEmpty(errorMessages)) {
312 Map<String, List<ErrorMessage>> errorsMap = new HashMap<>();
313 errorsMap.put(SdcCommon.UPLOAD_FILE, errorMessages);
314 response.setUploadDataErrors(errorsMap, LoggerServiceName.Update_Manifest,
315 LoggerTragetServiceName.VALIDATE_FILE_DATA_STRUCTURE);
318 .debugExitMessage("VSP id", vspId);
322 candidateService.updateOrchestrationTemplateCandidateFileDataStructure(vspId, version,
326 .debugExitMessage("VSP id", vspId);
332 public Optional<byte[]> get(String vspId, Version version, String user)
334 mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
336 VspDetails vspDetails =
337 getVspDetails(vspId, version);
339 Optional<OrchestrationTemplateCandidateData> candidateDataEntity =
340 fetchCandidateDataEntity(vspId, version);
342 if (!candidateDataEntity.isPresent()) {
343 ErrorMessage errorMessage = new ErrorMessage(ErrorLevel.ERROR,
344 Messages.NO_ZIP_FILE_WAS_UPLOADED_OR_ZIP_NOT_EXIST.getErrorMessage());
345 logger.error(errorMessage.getMessage());
348 .debugExitMessage("VSP id", vspId);
349 return Optional.empty();
352 FilesDataStructure structure = JsonUtil
353 .json2Object(candidateDataEntity.get().getFilesDataStructure(), FilesDataStructure.class);
354 String manifest = candidateService.createManifest(vspDetails, structure);
357 .debugExitMessage("VSP id", vspId);
358 return Optional.ofNullable(candidateService
359 .replaceManifestInZip(candidateDataEntity.get().getContentData(), manifest, vspId));
362 private Optional<OrchestrationTemplateCandidateData> fetchCandidateDataEntity(
363 String vspId, Version version) {
365 .ofNullable(candidateService.getOrchestrationTemplateCandidate(vspId, version));
368 private void retainComponentQuestionnaireData(String vspId, Version activeVersion,
369 Map<String, String> componentsQustanniare,
370 Map<String, Map<String, String>> componentNicsQustanniare,
371 Map<String, Collection<MibEntity>> componentMIBList,
372 Map<String,Collection<ProcessEntity>> processes,
373 Map<String, ProcessEntity> processArtifact) {
375 restoreProcess(vspId, activeVersion, GENERAL_COMPONENT_ID, GENERAL_COMPONENT_ID, processes,
377 Collection<ComponentEntity>
378 components = vendorSoftwareProductDao.listComponents(vspId, activeVersion);
379 components.forEach(componentEntity -> {
380 String componentName = componentEntity.getComponentCompositionData().getName();
381 if( componentsQustanniare.containsKey(componentName) ){
382 componentDao.updateQuestionnaireData(vspId, activeVersion,
383 componentEntity.getId(),componentsQustanniare.get(componentEntity.getComponentCompositionData()
385 if( componentNicsQustanniare.containsKey(componentName) ){
386 Map<String, String> nicsQustanniare=componentNicsQustanniare.get(componentName);
387 Collection<NicEntity>
388 nics=nicDao.list(new NicEntity(vspId, activeVersion, componentEntity.getId(), null));
389 nics.forEach(nicEntity -> {
390 if(nicsQustanniare.containsKey(nicEntity.getNicCompositionData().getName())){
391 nicDao.updateQuestionnaireData(vspId, activeVersion,componentEntity.getId
392 (),nicEntity.getId(),nicsQustanniare.get(nicEntity.getNicCompositionData().getName()));
397 if(componentMIBList.containsKey(componentName)) {
398 Collection<MibEntity> mibList = componentMIBList.get(componentName);
399 mibList.forEach(mib -> {
400 mib.setComponentId(componentEntity.getId());
405 restoreProcess(vspId, activeVersion, componentEntity.getId(), componentName, processes,
411 private void backupComponentsQuestionnaireBeforeDelete(String vspId, Version activeVersion,
412 Map<String, String> componentsQustanniare,
413 Map<String, Map<String, String>>
414 componentNicsQustanniare,
415 Map<String, Collection<MibEntity>>
417 Map<String, Collection<ProcessEntity>> componentProcesses,
418 Map<String, ProcessEntity> processArtifact) {
419 //backup VSP processes
420 backupProcess(vspId, activeVersion, GENERAL_COMPONENT_ID, GENERAL_COMPONENT_ID,
421 componentProcesses,processArtifact);
422 Collection<ComponentEntity> componentsCompositionAndQuestionnaire= vendorSoftwareProductDao
423 .listComponentsCompositionAndQuestionnaire(vspId,
425 componentsCompositionAndQuestionnaire.forEach(componentEntity ->{
426 String componentName=componentEntity.getComponentCompositionData().getName();
427 componentsQustanniare.put(componentName,componentEntity
428 .getQuestionnaireData());
429 Collection<NicEntity>
430 nics=nicDao.list(new NicEntity(vspId, activeVersion,componentEntity.getId(),null));
432 Collection<MibEntity> componentMIB = mibDao.listArtifacts(new
433 MibEntity(vspId, activeVersion, componentEntity.getId(), null));
434 if(CollectionUtils.isNotEmpty(componentMIB)){
435 componentMIBList.put(componentName,componentMIB);
438 //backup component processes
439 backupProcess(vspId, activeVersion, componentEntity.getId(), componentName,
440 componentProcesses,processArtifact);
441 if(CollectionUtils.isNotEmpty(nics)) {
442 Map<String, String> nicsQustanniare = new HashMap<>();
443 nics.forEach(nicEntity -> {
444 NicEntity nic = nicDao.get(new NicEntity(vspId, activeVersion, componentEntity.getId(),
446 NicEntity nicQuestionnaire = nicDao.getQuestionnaireData(vspId,activeVersion,
447 componentEntity.getId(),nicEntity.getId());
450 .put(nicEntity.getNicCompositionData().getName(), nicQuestionnaire.getQuestionnaireData());
452 componentNicsQustanniare.put(componentName, nicsQustanniare);
457 private void backupProcess(String vspId, Version activeVersion, String componentId,
458 String componentName, Map<String,
459 Collection<ProcessEntity>> processes,
460 Map<String,ProcessEntity> processArtifact){
461 Collection<ProcessEntity> processList = vendorSoftwareProductDao.listProcesses(vspId,
462 activeVersion, componentId);
463 if(!processList.isEmpty()){
464 processes.put(componentName,processList);
465 processList.forEach(process -> {
466 //ProcessArtifactEntity artifact = vendorSoftwareProductDao.getProcessArtifact(vspId,
467 // activeVersion, componentId, process.getId());
468 ProcessEntity artifact = processDao.get(new ProcessEntity(vspId,activeVersion,componentId,process.getId()));
469 if(artifact.getArtifact()!=null) {
470 processArtifact.put(process.getId(), artifact);
476 private void restoreProcess(String vspId, Version activeVersion, String componentId,
477 String componentName, Map<String, Collection<ProcessEntity>> processes,
478 Map<String, ProcessEntity> processArtifact){
479 if(processes.containsKey(componentName)) {
480 Collection<ProcessEntity> processList = processes.get(componentName);
481 processList.forEach(process -> {
483 if (!GENERAL_COMPONENT_ID.equals(componentId) && processArtifact.containsKey(process.getId
485 ProcessEntity artifact = processArtifact.get(process.getId());
486 artifact.setComponentId(componentId);
487 UniqueValueUtil.createUniqueValue(PROCESS_NAME, vspId, activeVersion.toString(),
488 componentId, process.getName());
489 vendorSoftwareProductDao.createProcess(artifact);
495 private HeatStructureTree createAndValidateHeatTree(OrchestrationTemplateActionResponse response,
496 FileContentHandler fileContentMap) {
497 VendorSoftwareProductUtils.addFileNamesToUploadFileResponse(fileContentMap, response);
498 Map<String, List<ErrorMessage>> validationErrors =
499 ValidationManagerUtil.initValidationManager(fileContentMap).validate();
500 response.getErrors().putAll(validationErrors);
502 HeatTreeManager heatTreeManager = HeatTreeManagerUtil.initHeatTreeManager(fileContentMap);
503 heatTreeManager.createTree();
504 heatTreeManager.addErrors(validationErrors);
505 return heatTreeManager.getTree();
508 private void saveHotData(String vspId, Version activeVersion, InputStream uploadedFileData,
509 FileContentHandler fileContentMap, HeatStructureTree tree) {
510 Map<String, Object> manifestAsMap =
511 (Map<String, Object>) JsonUtil.json2Object(fileContentMap.getFileContent(
512 SdcCommon.MANIFEST_NAME), Map.class);
514 UploadData uploadData = new UploadData();
515 uploadData.setPackageName((String) manifestAsMap.get("name"));
516 uploadData.setPackageVersion((String) manifestAsMap.get("version"));
517 uploadData.setContentData(ByteBuffer.wrap(FileUtils.toByteArray(uploadedFileData)));
518 uploadData.setValidationDataStructure(new ValidationStructureList(tree));
519 orchestrationTemplateDataDao.updateOrchestrationTemplateData(vspId, uploadData);
522 private void deleteUploadDataAndContent(String vspId, Version version) {
523 //fixme change this when more tables are zusammenized
524 vendorSoftwareProductDao.deleteUploadData(vspId, version);
527 private boolean isInvalidRawZipData(UploadFileResponse uploadFileResponse,
528 byte[] uploadedFileData) {
529 Optional<ErrorMessage> errorMessage;
530 errorMessage = candidateService.validateRawZipData(uploadedFileData);
531 if (errorMessage.isPresent()) {
532 uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
538 private boolean isNotEmptyFileToUpload(InputStream heatFileToUpload,
539 UploadFileResponse uploadFileResponse) {
540 Optional<ErrorMessage> errorMessage =
541 candidateService.validateNonEmptyFileToUpload(heatFileToUpload);
542 if (errorMessage.isPresent()) {
543 uploadFileResponse.addStructureError(SdcCommon.UPLOAD_FILE, errorMessage.get());
549 private Optional<FileContentHandler> getZipContentMap(UploadFileResponse uploadFileResponse,
550 byte[] uploadedFileData) {
551 FileContentHandler contentMap = null;
553 contentMap = CommonUtil.loadUploadFileContent(uploadedFileData);
554 } catch (IOException exception) {
555 uploadFileResponse.addStructureError(
556 SdcCommon.UPLOAD_FILE,
557 new ErrorMessage(ErrorLevel.ERROR, Messages.INVALID_ZIP_FILE.getErrorMessage()));
558 } catch (CoreException coreException) {
559 uploadFileResponse.addStructureError(
560 SdcCommon.UPLOAD_FILE, new ErrorMessage(ErrorLevel.ERROR, coreException.getMessage()));
562 return Optional.ofNullable(contentMap);
565 // todo *************************** move to reusable place! *************************
567 private Map<String, Object> getHealingParamsAsMap(String vspId, Version version, String user) {
568 Map<String, Object> healingParams = new HashMap<>();
570 healingParams.put(SdcCommon.VSP_ID, vspId);
571 healingParams.put(SdcCommon.VERSION, version);
572 healingParams.put(SdcCommon.USER, user);
574 return healingParams;
577 public VspDetails getVspDetails(String vspId, Version version) {
578 VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
579 vspDetails.setValidationData(orchestrationTemplateDataDao.getValidationData(vspId, version));