aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java')
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java10
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java30
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java83
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealer.java6
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java29
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NicDataHealer.java10
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java47
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java15
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ValidationStructureHealer.java250
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java69
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java94
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspQuestionnaireHealer.java7
12 files changed, 308 insertions, 342 deletions
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java
index 50e76781b3..83395e015a 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java
@@ -4,7 +4,6 @@ import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.lang3.StringUtils;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
@@ -19,7 +18,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
-import java.util.Map;
import java.util.Objects;
@@ -57,11 +55,9 @@ public class ComponentQuestionnaireHealer implements Healer {
}
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
- mdcDataDebugMessage.debugEntryMessage("VSP ID",
- (String) healingParams.get(SdcCommon.VSP_ID));
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
+ public Object heal(String vspId, Version version) throws Exception {
+ mdcDataDebugMessage.debugEntryMessage("VSP ID", vspId);
+
Collection<ComponentEntity> componentEntities =
componentDao.list(new ComponentEntity(vspId, version, null));
componentEntities.forEach(componentEntity -> {
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
index 6fc8cfef61..e7a5e30f2d 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
@@ -31,7 +31,6 @@ import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -57,7 +56,7 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionDataExtractorFactory;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
@@ -69,7 +68,6 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.IOException;
import java.util.Collection;
-import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@@ -102,14 +100,10 @@ public class CompositionDataHealer implements Healer {
}
@Override
- public Optional<CompositionData> heal(Map<String, Object> healingParams) throws IOException {
+ public Optional<CompositionData> heal(String vspId,
+ Version version) throws IOException {
mdcDataDebugMessage.debugEntryMessage(null);
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = VERSION00.equals(healingParams.get(SdcCommon.VERSION))
- ? VERSION01
- : (Version) healingParams.get(SdcCommon.VERSION);
-
Collection<ComponentEntity> componentEntities =
componentDao.list(new ComponentEntity(vspId, version, null));
Collection<NicEntity> nicEntities = nicDao.listByVsp(vspId, version);
@@ -131,7 +125,7 @@ public class CompositionDataHealer implements Healer {
serviceModels.get()) : null;
}
- if(serviceModels.isPresent()) {
+ if (serviceModels.isPresent()) {
compositionData =
getCompositionDataForHealing(vspId, version, serviceModels.get());
HealNfodData(vspId, version, compositionData);
@@ -150,16 +144,16 @@ public class CompositionDataHealer implements Healer {
if (CollectionUtils.isEmpty(computeEntities) && CollectionUtils.isEmpty(imageEntities)) {
for (Component component : compositionData.getComponents()) {
String componentId = null;
- for (ComponentEntity componentEntity:componentEntities) {
+ for (ComponentEntity componentEntity : componentEntities) {
if (componentEntity.getComponentCompositionData().getName().equals(component.getData()
.getName())) {
componentId = componentEntity.getId();
break;
}
}
- compositionEntityDataManager.saveComputesFlavorByComponent(vspId,version,component,
+ compositionEntityDataManager.saveComputesFlavorByComponent(vspId, version, component,
componentId);
- compositionEntityDataManager.saveImagesByComponent(vspId,version,component,
+ compositionEntityDataManager.saveImagesByComponent(vspId, version, component,
componentId);
}
@@ -228,13 +222,15 @@ public class CompositionDataHealer implements Healer {
}
private Optional<Pair<ToscaServiceModel, ToscaServiceModel>> getServiceModelForHealing(String
- vspId, Version
+ vspId,
+ Version
version)
throws IOException {
mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
- UploadDataEntity uploadData =
- orchestrationTemplateDataDao.getOrchestrationTemplate(vspId, version);
+ /*OrchestrationTemplateEntity uploadData =
+ vendorSoftwareProductDao.getUploadData(new OrchestrationTemplateEntity(vspId, version));*/
+ OrchestrationTemplateEntity uploadData = orchestrationTemplateDataDao.get(vspId, version);
if (Objects.isNull(uploadData) || Objects.isNull(uploadData.getContentData())) {
return Optional.empty();
@@ -259,7 +255,7 @@ public class CompositionDataHealer implements Healer {
.getNonUnifiedToscaServiceModel()));
}
- private TranslatorOutput getTranslatorOutputForHealing(UploadDataEntity uploadData) {
+ private TranslatorOutput getTranslatorOutputForHealing(OrchestrationTemplateEntity uploadData) {
FileContentHandler fileContentHandler;
try {
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
index 4a0a5f9d63..6e49c9a6cf 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
@@ -24,33 +24,23 @@ import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
-import org.openecomp.sdc.common.utils.SdcCommon;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.healing.interfaces.Healer;
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.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.vendorsoftwareproduct.factory.CandidateServiceFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule.CandidateService;
import org.openecomp.sdc.vendorsoftwareproduct.services.utils.CandidateEntityBuilder;
import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
import java.util.Optional;
public class FileDataStructureHealer implements Healer {
- private static final OrchestrationTemplateDao orchestrationTemplateDataDao =
- OrchestrationTemplateDaoFactory.getInstance().createInterface();
- private static CandidateService candidateService =
- CandidateServiceFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
@@ -59,64 +49,55 @@ public class FileDataStructureHealer implements Healer {
}
@Override
- public Optional<FilesDataStructure> heal(Map<String, Object> healingParams) throws Exception {
-
-
+ public Optional<FilesDataStructure> heal(String vspId,
+ Version version) throws Exception {
mdcDataDebugMessage.debugEntryMessage(null);
- Optional<FilesDataStructure> healingResult = Optional.empty();
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
- String user = (String) healingParams.get(SdcCommon.USER);
+ OrchestrationTemplateCandidateDao candidateDao =
+ OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface();
+
+ OrchestrationTemplateCandidateData candidateData = candidateDao.get(vspId, version);
- UploadDataEntity uploadData =
- orchestrationTemplateDataDao.getOrchestrationTemplate(vspId,version);
- if (uploadData == null || uploadData.getContentData() == null) {
- FilesDataStructure emptyFilesDataStructure = new FilesDataStructure();
- return Optional.of(emptyFilesDataStructure);
+ if (candidateData == null || candidateData.getContentData() == null ||
+ candidateData.getFilesDataStructure() != null) {
+ return Optional.of(new FilesDataStructure());
}
- Optional<FilesDataStructure> candidateFileDataStructure =
- candidateService.getOrchestrationTemplateCandidateFileDataStructure(vspId, version);
+ Optional<FilesDataStructure> filesDataStructure =
+ healFilesDataStructure(vspId, version, candidateData);
- if (!candidateFileDataStructure.isPresent()) {
- healingResult = healFilesDataStructure(vspId, version, user, uploadData);
- }
+ filesDataStructure
+ .ifPresent(structure -> candidateDao.updateStructure(vspId, version, structure));
mdcDataDebugMessage.debugExitMessage(null);
- return healingResult;
+ return filesDataStructure;
}
- private Optional<FilesDataStructure> healFilesDataStructure(String vspId, Version version,
- String user,
- UploadDataEntity uploadData)
+ private Optional<FilesDataStructure> healFilesDataStructure(
+ String vspId, Version version, OrchestrationTemplateCandidateData candidateData)
throws Exception {
-
-
mdcDataDebugMessage.debugEntryMessage(null);
Optional<FilesDataStructure> healingResult;
- byte[] byteContentData = uploadData.getContentData().array();
+ byte[] byteContentData = candidateData.getContentData().array();
FileContentHandler fileContentHandler;
- try{
- fileContentHandler = CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, byteContentData);
- Map<String, List<ErrorMessage>> errors = new HashMap<>();
- OrchestrationTemplateCandidateData candidateDataEntity =
- new CandidateEntityBuilder(candidateService)
- .buildCandidateEntityFromZip(new VspDetails(vspId, version), byteContentData,
- fileContentHandler, errors, user);
-
- healingResult = getFileDataStructureFromJson(candidateDataEntity.getFilesDataStructure());
- }catch (Exception e){
+ try {
+ fileContentHandler =
+ CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, byteContentData);
+
+ String filesDataStructure =
+ new CandidateEntityBuilder(CandidateServiceFactory.getInstance().createInterface())
+ .buildCandidateEntityFromZip(new VspDetails(vspId, version), byteContentData,
+ fileContentHandler, new HashMap<>()).getFilesDataStructure();
+
+ healingResult =
+ Optional.of(JsonUtil.json2Object(filesDataStructure, FilesDataStructure.class));
+ } catch (Exception e) {
log.debug("", e);
- return Optional.empty();
+ healingResult = Optional.empty();
}
mdcDataDebugMessage.debugExitMessage(null);
return healingResult;
}
-
- private Optional<FilesDataStructure> getFileDataStructureFromJson(String fileDataStructureJson) {
- return Optional.of(JsonUtil.json2Object(fileDataStructureJson, FilesDataStructure.class));
- }
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealer.java
index c2d7c2c5e4..7991c5904e 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealer.java
@@ -5,7 +5,6 @@ import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.dao.ServiceModelDaoFactory;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.sdc.common.togglz.ToggleableFeature;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
@@ -46,10 +45,7 @@ public class ForwarderCapabilityHealer implements Healer {
}
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
-
+ public Object heal(String vspId, Version version) throws Exception {
if(!ToggleableFeature.FORWARDER_CAPABILITY.isActive()) {
return Optional.empty();
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
index 32cd8cbae3..ddae09fa01 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
@@ -3,14 +3,11 @@ package org.openecomp.sdc.healing.healers;
import org.openecomp.core.model.dao.ServiceModelDao;
import org.openecomp.core.model.dao.ServiceModelDaoFactory;
-import org.openecomp.core.model.dao.ServiceTemplateDaoFactory;
-import org.openecomp.core.model.dao.ServiceTemplateDaoInter;
import org.openecomp.core.model.types.ServiceElement;
import org.openecomp.core.translator.datatypes.TranslatorOutput;
import org.openecomp.core.utilities.file.FileContentHandler;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
import org.openecomp.sdc.common.utils.CommonUtil;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -19,37 +16,32 @@ import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Map;
import java.util.Objects;
import java.util.Optional;
-public class HeatToToscaTranslationHealer implements Healer {
+public class HeatToToscaTranslationHealer implements Healer {
private static final OrchestrationTemplateDao orchestrationTemplateDao =
OrchestrationTemplateDaoFactory.getInstance().createInterface();
private static final ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao =
ServiceModelDaoFactory.getInstance().createInterface();
- public static final ServiceTemplateDaoInter
- templateDao = ServiceTemplateDaoFactory.getInstance().createInterface();
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
private final Logger log = (Logger) LoggerFactory.getLogger(this.getClass().getName());
- public HeatToToscaTranslationHealer(){
+ public HeatToToscaTranslationHealer() {
}
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
- mdcDataDebugMessage.debugEntryMessage(null, null);
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
- String user = (String) healingParams.get(SdcCommon.USER);
- UploadDataEntity uploadData =
- orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
+ public Object heal(String vspId, Version version) throws Exception {
+ mdcDataDebugMessage.debugEntryMessage(null);;
+
+ OrchestrationTemplateEntity uploadData =
+ orchestrationTemplateDao.get(vspId, version);
if (Objects.isNull(uploadData) || Objects.isNull(uploadData.getContentData())) {
return Optional.empty();
@@ -58,8 +50,9 @@ public class HeatToToscaTranslationHealer implements Healer {
FileContentHandler fileContentHandler;
TranslatorOutput translatorOutput;
try {
- fileContentHandler = CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadData
- .getContentData().array());
+ fileContentHandler =
+ CommonUtil.validateAndUploadFileContent(OnboardingTypesEnum.ZIP, uploadData
+ .getContentData().array());
translatorOutput =
HeatToToscaUtil.loadAndTranslateTemplateData(fileContentHandler);
} catch (Exception e) {
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NicDataHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NicDataHealer.java
index 123a943785..b2ef965286 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NicDataHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/NicDataHealer.java
@@ -1,20 +1,16 @@
package org.openecomp.sdc.healing.healers;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Nic;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
-import java.util.Map;
public class NicDataHealer implements Healer {
/*private static final VendorSoftwareProductDao vendorSoftwareProductDao =
@@ -28,11 +24,9 @@ public class NicDataHealer implements Healer {
}
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
+ public Object heal(String vspId, Version version) throws Exception {
mdcDataDebugMessage.debugEntryMessage(null, null);
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
- String user = (String) healingParams.get(SdcCommon.USER);
+
Collection<NicEntity> nics = nicDao.listByVsp(vspId, version);
for (NicEntity nicEntity : nics) {
Nic nic = nicEntity.getNicCompositionData();
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java
new file mode 100644
index 0000000000..acc20c97e4
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/OwnerHealer.java
@@ -0,0 +1,47 @@
+package org.openecomp.sdc.healing.healers;
+
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDao;
+import org.openecomp.sdc.itempermissions.dao.ItemPermissionsDaoFactory;
+import org.openecomp.sdc.itempermissions.impl.types.PermissionTypes;
+import org.openecomp.sdc.itempermissions.type.ItemPermissionsEntity;
+import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+
+/**
+ * Created by ayalaben on 8/28/2017
+ */
+public class OwnerHealer implements Healer {
+ private static final String HEALING_USER_SUFFIX = "_healer";
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ private static final ItemPermissionsDao permissionsDao =
+ ItemPermissionsDaoFactory.getInstance().createInterface();
+
+ public Object heal(String itemId, Version version) {
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ Collection<ItemPermissionsEntity> itemPermissions = permissionsDao.listItemPermissions(itemId);
+
+ if (itemPermissions.stream().noneMatch(this::isOwnerPermission)) {
+ String currentUserId =
+ SessionContextProviderFactory.getInstance().createInterface().get().getUser().getUserId()
+ .replace(HEALING_USER_SUFFIX, "");
+
+ permissionsDao.updateItemPermissions(itemId, PermissionTypes.Owner.name(),
+ Collections.singleton(currentUserId), new HashSet<>());
+
+ return currentUserId;
+ }
+ return itemPermissions.stream().filter(this::isOwnerPermission).findFirst().get().getUserId();
+ }
+
+ private boolean isOwnerPermission(ItemPermissionsEntity permissionsEntity) {
+ return permissionsEntity.getPermission().equals(PermissionTypes.Owner.name());
+ }
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java
index 9355eb076f..a1dd80c307 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java
@@ -21,7 +21,6 @@
package org.openecomp.sdc.healing.healers;
import org.openecomp.core.utilities.json.JsonSchemaDataGenerator;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
@@ -30,8 +29,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NetworkDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.NicDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.CompositionEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NetworkEntity;
@@ -42,15 +39,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTempl
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
-import java.util.Map;
import java.util.Objects;
public class SubEntitiesQuestionnaireHealer implements Healer {
private static Version version00 = new Version(0, 0);
private MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
- private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();
private static ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface();
private static NicDao nicDao = NicDaoFactory.getInstance().createInterface();
private static NetworkDao networkDao = NetworkDaoFactory.getInstance().createInterface();
@@ -59,22 +53,17 @@ public class SubEntitiesQuestionnaireHealer implements Healer {
private static String emptyJson = "{}";
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
+ public Object heal(String vspId, Version version) throws Exception {
mdcDataDebugMessage.debugEntryMessage(null);
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = version00.equals(healingParams.get(SdcCommon.VERSION)) ? new Version
- (0, 1)
- : (Version) healingParams.get(SdcCommon.VERSION);
-
Collection<ComponentEntity> componentEntities =
componentDao.listCompositionAndQuestionnaire(vspId, version);
networkDao.list(new NetworkEntity(vspId, version, null));
- Collection<NicEntity> nicEntities = vendorSoftwareProductDao.listNicsByVsp(vspId, version);
+ Collection<NicEntity> nicEntities = nicDao.listByVsp(vspId, version);
healCompositionEntityQuestionnaire(componentEntities, version, CompositionEntityType.component);
healCompositionEntityQuestionnaire(nicEntities, version, CompositionEntityType.nic);
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ValidationStructureHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ValidationStructureHealer.java
index 4bf7e18091..d172432284 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ValidationStructureHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ValidationStructureHealer.java
@@ -2,7 +2,6 @@ package org.openecomp.sdc.healing.healers;
import org.apache.commons.collections4.CollectionUtils;
import org.openecomp.core.utilities.json.JsonUtil;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.datatypes.error.ErrorMessage;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.heat.datatypes.manifest.FileData;
@@ -13,16 +12,11 @@ import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadData;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
-import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
@@ -32,78 +26,55 @@ import java.util.Set;
*/
public class ValidationStructureHealer implements Healer {
- private static final VendorSoftwareProductInfoDao vspInfoDao =
- VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
+ private static final Logger logger = LoggerFactory.getLogger(JsonUtil.class);
private static final OrchestrationTemplateDao orchestrationTemplateDao =
OrchestrationTemplateDaoFactory.getInstance().createInterface();
- private static final Logger logger = LoggerFactory.getLogger(JsonUtil.class);
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
+ public Object heal(String vspId, Version version) throws Exception {
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
+ OrchestrationTemplateEntity orchestrationTemplate =
+ orchestrationTemplateDao.get(vspId, version);
- VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
- UploadDataEntity orchestrationTemplate =
- orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
-
- if(Objects.isNull(orchestrationTemplate.getValidationData())
- || !JsonUtil.isValidJson(orchestrationTemplate.getValidationData())){
+ if (Objects.isNull(orchestrationTemplate.getValidationData())
+ || !JsonUtil.isValidJson(orchestrationTemplate.getValidationData())) {
return Optional.empty();
}
OldValidationStructureTree oldValidationStructureTree;
- try{
- oldValidationStructureTree =
- JsonUtil.json2Object(orchestrationTemplate.getValidationData(), OldValidationStructureTree
- .class);
- } catch (Exception e){
- logger.debug("",e);
+ try {
+ oldValidationStructureTree = JsonUtil
+ .json2Object(orchestrationTemplate.getValidationData(), OldValidationStructureTree.class);
+ } catch (Exception e) {
+ logger.debug("", e);
return Optional.empty();
}
Optional<HeatStructureTree> newHeatStructureTreeFromOldStructureTree =
- createNewHeatStructureTreeFromOldStructureTree(oldValidationStructureTree.getImportStructure());
+ createNewHeatStructureTreeFromOldStructureTree(
+ oldValidationStructureTree.getImportStructure());
- if(newHeatStructureTreeFromOldStructureTree.isPresent()){
- ValidationStructureList validationData = new ValidationStructureList
- (newHeatStructureTreeFromOldStructureTree.get());
- vspDetails.setValidationDataStructure(validationData);
+ newHeatStructureTreeFromOldStructureTree.ifPresent(newStructure ->
+ updateValuesInDb(vspId, version, orchestrationTemplate,
+ new ValidationStructureList(newStructure)));
- updateValuesInDb(vspId, vspDetails, orchestrationTemplate, validationData);
- }
return newHeatStructureTreeFromOldStructureTree;
}
- private void updateValuesInDb(String vspId, VspDetails vspDetails,
- UploadDataEntity orchestrationTemplate,
+ private void updateValuesInDb(String vspId, Version version,
+ OrchestrationTemplateEntity orchestrationTemplate,
ValidationStructureList validationData) {
- vspInfoDao.update(vspDetails);
- UploadData uploadData = getUpdatedUploadData(orchestrationTemplate, validationData);
- orchestrationTemplateDao.updateOrchestrationTemplateData(vspId, uploadData);
+ orchestrationTemplate.setValidationDataStructure(validationData);
+ orchestrationTemplateDao.update(vspId, version, orchestrationTemplate);
}
- private UploadData getUpdatedUploadData(UploadDataEntity orchestrationTemplate,
- ValidationStructureList validationData) {
- UploadData uploadData = new UploadData();
- uploadData.setValidationDataStructure(validationData);
- uploadData.setValidationData(JsonUtil.object2Json(validationData));
- uploadData.setContentData(orchestrationTemplate.getContentData());
- uploadData.setId(orchestrationTemplate.getId());
- uploadData.setPackageName(orchestrationTemplate.getPackageName());
- uploadData.setPackageVersion(orchestrationTemplate.getPackageVersion());
- return uploadData;
- }
-
-
- private Optional<HeatStructureTree> createNewHeatStructureTreeFromOldStructureTree(OldHeatStructureTree
- oldHeatStructureTree){
+ private Optional<HeatStructureTree> createNewHeatStructureTreeFromOldStructureTree(
+ OldHeatStructureTree oldHeatStructureTree) {
HeatStructureTree heatStructureTree = new HeatStructureTree();
- if(Objects.isNull(oldHeatStructureTree)){
+ if (Objects.isNull(oldHeatStructureTree)) {
return Optional.empty();
}
@@ -112,11 +83,14 @@ public class ValidationStructureHealer implements Healer {
Set<OldHeatStructureTree> heat =
oldHeatStructureTree.getHeat() == null ? new HashSet<>() : oldHeatStructureTree.getHeat();
Set<OldHeatStructureTree> volume =
- oldHeatStructureTree.getVolume() == null ? new HashSet<>() : oldHeatStructureTree.getVolume();
+ oldHeatStructureTree.getVolume() == null ? new HashSet<>()
+ : oldHeatStructureTree.getVolume();
Set<OldHeatStructureTree> nested =
- oldHeatStructureTree.getNested() == null ? new HashSet<>() : oldHeatStructureTree.getNested();
+ oldHeatStructureTree.getNested() == null ? new HashSet<>()
+ : oldHeatStructureTree.getNested();
Set<OldHeatStructureTree> network =
- oldHeatStructureTree.getNetwork() == null ? new HashSet<>() : oldHeatStructureTree.getNetwork();
+ oldHeatStructureTree.getNetwork() == null ? new HashSet<>()
+ : oldHeatStructureTree.getNetwork();
heatStructureTree.setHeat(createHeatStructureTreeSetFromOld(heat));
@@ -124,57 +98,47 @@ public class ValidationStructureHealer implements Healer {
heatStructureTree.setNested(createHeatStructureTreeSetFromOld(nested));
heatStructureTree.setNetwork(createHeatStructureTreeSetFromOld(network));
-
return Optional.of(heatStructureTree);
-
}
- private void mapOldHeatStructureTreeValues(
- OldHeatStructureTree oldHeatStructureTree,
- HeatStructureTree heatStructureTree) {
+ private void mapOldHeatStructureTreeValues(OldHeatStructureTree oldHeatStructureTree,
+ HeatStructureTree heatStructureTree) {
heatStructureTree.setFileName(oldHeatStructureTree.getFileName());
heatStructureTree.setBase(oldHeatStructureTree.getBase());
heatStructureTree.setType(oldHeatStructureTree.getType());
heatStructureTree.setArtifacts(oldHeatStructureTree.getArtifacts());
heatStructureTree.setErrors(oldHeatStructureTree.getErrors());
- if(Objects.nonNull(oldHeatStructureTree.getEnv())) {
+ if (Objects.nonNull(oldHeatStructureTree.getEnv())) {
heatStructureTree.setEnv(new HeatStructureTree(oldHeatStructureTree.getEnv(), false));
}
}
private Set<HeatStructureTree> createHeatStructureTreeSetFromOld(Set<OldHeatStructureTree>
- oldHeatStructureTreeSet){
- if(CollectionUtils.isEmpty(oldHeatStructureTreeSet)){
+ oldHeatStructureTreeSet) {
+ if (CollectionUtils.isEmpty(oldHeatStructureTreeSet)) {
return null;
}
Set<HeatStructureTree> newHeatStructureSet = new HashSet<>();
- for(OldHeatStructureTree old : oldHeatStructureTreeSet){
+ for (OldHeatStructureTree old : oldHeatStructureTreeSet) {
Optional<HeatStructureTree> newHeatStructureTree =
createNewHeatStructureTreeFromOldStructureTree(old);
- if(newHeatStructureTree.isPresent()){
- newHeatStructureSet.add(newHeatStructureTree.get());
- }
+ newHeatStructureTree.ifPresent(newHeatStructureSet::add);
}
return newHeatStructureSet;
}
- private class OldValidationStructureTree{
+ private class OldValidationStructureTree {
private OldHeatStructureTree importStructure;
- public OldHeatStructureTree getImportStructure() {
+ OldHeatStructureTree getImportStructure() {
return importStructure;
}
-
- public void setImportStructure(
- OldHeatStructureTree importStructure) {
- this.importStructure = importStructure;
- }
}
- private class OldHeatStructureTree{
+ private class OldHeatStructureTree {
private String fileName;
private FileData.Type type;
private Boolean isBase;
@@ -190,93 +154,93 @@ public class ValidationStructureHealer implements Healer {
public OldHeatStructureTree() {
}
- public String getFileName() {
- return fileName;
- }
+ public String getFileName() {
+ return fileName;
+ }
- public void setFileName(String fileName) {
- this.fileName = fileName;
- }
+ public void setFileName(String fileName) {
+ this.fileName = fileName;
+ }
- public FileData.Type getType() {
- return type;
- }
+ public FileData.Type getType() {
+ return type;
+ }
- public void setType(FileData.Type type) {
- this.type = type;
- }
+ public void setType(FileData.Type type) {
+ this.type = type;
+ }
- public Boolean getBase() {
- return isBase;
- }
+ public Boolean getBase() {
+ return isBase;
+ }
- public void setBase(Boolean base) {
- isBase = base;
- }
+ public void setBase(Boolean base) {
+ isBase = base;
+ }
- public String getEnv() {
- return env;
- }
+ public String getEnv() {
+ return env;
+ }
- public void setEnv(String env) {
- this.env = env;
- }
+ public void setEnv(String env) {
+ this.env = env;
+ }
- public List<ErrorMessage> getErrors() {
- return errors;
- }
+ public List<ErrorMessage> getErrors() {
+ return errors;
+ }
- public void setErrors(List<ErrorMessage> errors) {
- this.errors = errors;
- }
+ public void setErrors(List<ErrorMessage> errors) {
+ this.errors = errors;
+ }
- public Set<OldHeatStructureTree> getHeat() {
- return heat;
- }
+ public Set<OldHeatStructureTree> getHeat() {
+ return heat;
+ }
- public void setHeat(Set<OldHeatStructureTree> heat) {
- this.heat = heat;
- }
+ public void setHeat(Set<OldHeatStructureTree> heat) {
+ this.heat = heat;
+ }
- public Set<OldHeatStructureTree> getVolume() {
- return volume;
- }
+ public Set<OldHeatStructureTree> getVolume() {
+ return volume;
+ }
- public void setVolume(Set<OldHeatStructureTree> volume) {
- this.volume = volume;
- }
+ public void setVolume(Set<OldHeatStructureTree> volume) {
+ this.volume = volume;
+ }
- public Set<OldHeatStructureTree> getNetwork() {
- return network;
- }
+ public Set<OldHeatStructureTree> getNetwork() {
+ return network;
+ }
- public void setNetwork(
- Set<OldHeatStructureTree> network) {
- this.network = network;
- }
+ public void setNetwork(
+ Set<OldHeatStructureTree> network) {
+ this.network = network;
+ }
- public Set<OldHeatStructureTree> getNested() {
- return nested;
- }
+ public Set<OldHeatStructureTree> getNested() {
+ return nested;
+ }
- public void setNested(Set<OldHeatStructureTree> nested) {
- this.nested = nested;
- }
+ public void setNested(Set<OldHeatStructureTree> nested) {
+ this.nested = nested;
+ }
- public Set<OldHeatStructureTree> getOther() {
- return other;
- }
+ public Set<OldHeatStructureTree> getOther() {
+ return other;
+ }
- public void setOther(Set<OldHeatStructureTree> other) {
- this.other = other;
- }
+ public void setOther(Set<OldHeatStructureTree> other) {
+ this.other = other;
+ }
- public Set<Artifact> getArtifacts() {
- return artifacts;
- }
+ public Set<Artifact> getArtifacts() {
+ return artifacts;
+ }
- public void setArtifacts(Set<Artifact> artifacts) {
- this.artifacts = artifacts;
+ public void setArtifacts(Set<Artifact> artifacts) {
+ this.artifacts = artifacts;
+ }
}
}
-}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java
index 085923b8a0..a57ac74350 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java
@@ -1,26 +1,21 @@
package org.openecomp.sdc.healing.healers;
-import org.apache.commons.collections4.CollectionUtils;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDao;
import org.openecomp.sdc.vendorlicense.dao.LicenseAgreementDaoFactory;
import org.openecomp.sdc.vendorlicense.dao.types.LicenseAgreementEntity;
-import org.openecomp.sdc.vendorlicense.dao.types.VendorLicenseModelEntity;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacade;
-import org.openecomp.sdc.vendorlicense.facade.VendorLicenseFacadeFactory;
-import org.openecomp.sdc.vendorlicense.types.VersionedVendorLicenseModel;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
import org.openecomp.sdc.versioning.dao.types.Version;
-import org.openecomp.sdc.versioning.types.VersionInfo;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
@@ -28,8 +23,8 @@ import java.util.Optional;
* Created by TALIO on 7/3/2017.
*/
public class VlmVersionHealer implements Healer {
- private static final VendorLicenseFacade vendorLicenseFacade =
- VendorLicenseFacadeFactory.getInstance().createInterface();
+ private VersioningManager versioningManager =
+ VersioningManagerFactory.getInstance().createInterface();
private static final VendorSoftwareProductInfoDao vspInfoDao =
VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
private static final LicenseAgreementDao licenseAgreementDao =
@@ -38,51 +33,35 @@ public class VlmVersionHealer implements Healer {
LoggerFactory.getLogger(VlmVersionHealer.class);
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
- String user = (String) healingParams.get(SdcCommon.USER);
-
+ public Object heal(String vspId, Version version) throws Exception {
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
- VersionedVendorLicenseModel vendorLicenseModel;
-
- if(!Objects.isNull(vspDetails.getVlmVersion())) {
+
+ if (!Objects.isNull(vspDetails.getVlmVersion())) {
return Optional.empty();
}
-
- try{
- vendorLicenseModel =
- vendorLicenseFacade.getVendorLicenseModel(vspDetails.getVendorId(), null, user);
- } catch (Exception e){
- logger.debug("" + e);
+ // get the certified vlm version with the highest number in its name
+ Optional<Version> certifiedVlmVersion =
+ versioningManager.list(vspDetails.getVendorId()).stream()
+ .filter(ver -> VersionStatus.Certified == ver.getStatus())
+ .max((o1, o2) -> ((Double) Double.parseDouble(o1.getName()))
+ .compareTo(Double.parseDouble(o2.getName())));
+ if (!certifiedVlmVersion.isPresent()) {
logger.debug("No Vlm was found for Vsp " + vspDetails.getName());
return Optional.empty();
}
+ vspDetails.setVlmVersion(certifiedVlmVersion.get());
- VendorLicenseModelEntity vlm = vendorLicenseModel.getVendorLicenseModel();
- String vlmId = vlm.getId();
- Version vlmVersion = getLatestFinalVlmVersion(vendorLicenseModel.getVersionInfo());
-
- List<LicenseAgreementEntity> laList =
- new ArrayList<>(
- licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, vlmVersion, null)));
-
-
- vspDetails.setVlmVersion(vlmVersion);
-
- if(CollectionUtils.isNotEmpty(laList)) {
- vspDetails.setLicenseAgreement(laList.get(0).getId());
- vspDetails.setFeatureGroups(new ArrayList<>(laList.get(0).getFeatureGroupIds()));
+ Collection<LicenseAgreementEntity> licenseAgreements = licenseAgreementDao.list(
+ new LicenseAgreementEntity(vspDetails.getVendorId(), certifiedVlmVersion.get(), null));
+ if (!licenseAgreements.isEmpty()) {
+ LicenseAgreementEntity licenseAgreement = licenseAgreements.iterator().next();
+ vspDetails.setLicenseAgreement(licenseAgreement.getId());
+ vspDetails.setFeatureGroups(new ArrayList<>(licenseAgreement.getFeatureGroupIds()));
}
vspInfoDao.update(vspDetails);
- return vspDetails;
- }
-
- private Version getLatestFinalVlmVersion(VersionInfo versionInfo){
- return versionInfo.getActiveVersion().isFinal() ? versionInfo.getActiveVersion()
- : versionInfo.getLatestFinalVersion();
+ return vspDetails;
}
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
index ddcd31453c..d5c082bdae 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealer.java
@@ -2,55 +2,91 @@ package org.openecomp.sdc.healing.healers;
import org.openecomp.core.utilities.orchestration.OnboardingTypesEnum;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OnboardingMethod;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateCandidateData;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.OrchestrationTemplateEntity;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Map;
import java.util.Objects;
public class VspOnboardingMethodHealer implements Healer {
- private static VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+
+ private static final String DEFAULT_FILE_NAME = "Upload File";
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+ private OrchestrationTemplateDao orchestrationTemplateDao;
+ private OrchestrationTemplateCandidateDao candidateDao;
public VspOnboardingMethodHealer(){
- this(VendorSoftwareProductInfoDaoFactory.getInstance().createInterface());
+ this(VendorSoftwareProductInfoDaoFactory.getInstance().createInterface(),
+ OrchestrationTemplateDaoFactory.getInstance().createInterface(),
+ OrchestrationTemplateCandidateDaoFactory.getInstance().createInterface());
}
- public VspOnboardingMethodHealer( VendorSoftwareProductInfoDao inVendorSoftwareProductInfoDao){
- vendorSoftwareProductInfoDao = inVendorSoftwareProductInfoDao;
+ public VspOnboardingMethodHealer(VendorSoftwareProductInfoDao vspInfoDao,
+ OrchestrationTemplateDao orchestrationTemplateDao,
+ OrchestrationTemplateCandidateDao candidateDao) {
+ this.vendorSoftwareProductInfoDao = vspInfoDao;
+ this.orchestrationTemplateDao = orchestrationTemplateDao;
+ this.candidateDao = candidateDao;
}
-
@Override
- public Object heal(Map<String, Object> healingParams) throws Exception {
- mdcDataDebugMessage.debugEntryMessage(null, null);
-
- String onboardingMethod=null;
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
- VspDetails vendorSoftwareProductInfo =
- vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version));
- String onboardingValue = vendorSoftwareProductInfo.getOnboardingMethod();
-
- if(Objects.isNull(onboardingValue)) {
- onboardingMethod="NetworkPackage";
-
- updateVSPInfo(OnboardingTypesEnum.ZIP.toString(), onboardingMethod, vendorSoftwareProductInfo);
- } else if (onboardingValue.equals("HEAT")){
- onboardingMethod="NetworkPackage";
- updateVSPInfo(OnboardingTypesEnum.ZIP.toString(),onboardingMethod, vendorSoftwareProductInfo);
+ public Object heal(String vspId, Version version) throws Exception {
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ VspDetails vsp = vendorSoftwareProductInfoDao.get(new VspDetails(vspId, version));
+ healOnboardingMethod(vsp);
+
+ if (!OnboardingMethod.Manual.name().equals(vsp.getOnboardingMethod())) {
+ healOrchestrationTemplateFileName(vspId, version);
+ healOrchestrationTemplateCandidateFileName(vspId, version);
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return null;
+ }
+
+ private void healOnboardingMethod(VspDetails vsp) {
+ if (Objects.isNull(vsp.getOnboardingMethod()) || "HEAT".equals(vsp.getOnboardingMethod())) {
+ vsp.setOnboardingMethod(OnboardingMethod.NetworkPackage.name());
+ vendorSoftwareProductInfoDao.update(vsp);
}
- return onboardingMethod;
}
- private void updateVSPInfo(String onboardingOrigin, String onboardingMethod, VspDetails vendorSoftwareProductInfo) {
- vendorSoftwareProductInfo.setOnboardingMethod(onboardingMethod);
- vendorSoftwareProductInfo.setOnboardingOrigin(onboardingOrigin);
- vendorSoftwareProductInfoDao.update(vendorSoftwareProductInfo);
+ private void healOrchestrationTemplateFileName(String vspId, Version version) {
+ OrchestrationTemplateEntity orchestrationTemplate =
+ orchestrationTemplateDao.get(vspId, version);
+
+ if (orchestrationTemplate == null || orchestrationTemplate.getContentData() == null ||
+ orchestrationTemplate.getFileSuffix() != null) {
+ return;
+ }
+ orchestrationTemplate.setFileSuffix(OnboardingTypesEnum.ZIP.toString());
+ orchestrationTemplate.setFileName(DEFAULT_FILE_NAME);
+
+ orchestrationTemplateDao.update(vspId, version, orchestrationTemplate);
+ }
+
+ private void healOrchestrationTemplateCandidateFileName(String vspId, Version version) {
+ OrchestrationTemplateCandidateData candidate = candidateDao.get(vspId, version);
+
+ if (candidate == null || candidate.getContentData() == null ||
+ candidate.getFileSuffix() != null) {
+ return;
+ }
+ candidate.setFileSuffix(OnboardingTypesEnum.ZIP.toString());
+ candidate.setFileName(DEFAULT_FILE_NAME);
+
+ candidateDao.update(vspId, version, candidate);
}
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspQuestionnaireHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspQuestionnaireHealer.java
index 0952a4c88f..b45ce30a3e 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspQuestionnaireHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspQuestionnaireHealer.java
@@ -21,7 +21,6 @@
package org.openecomp.sdc.healing.healers;
import org.openecomp.core.utilities.json.JsonSchemaDataGenerator;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
@@ -35,7 +34,6 @@ import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTempl
import org.openecomp.sdc.versioning.dao.types.Version;
import java.io.IOException;
-import java.util.Map;
import java.util.Objects;
import java.util.Optional;
@@ -50,15 +48,12 @@ public class VspQuestionnaireHealer implements Healer {
}
@Override
- public Object heal(Map<String, Object> healingParams) throws IOException {
+ public Object heal(String vspId, Version version) throws IOException {
mdcDataDebugMessage.debugEntryMessage(null, null);
Optional<String> questionnaireData = null;
- String vspId = (String) healingParams.get(SdcCommon.VSP_ID);
- Version version = (Version) healingParams.get(SdcCommon.VERSION);
-
VspQuestionnaireEntity vspQuestionnaireEntity =
vspInfoDao.getQuestionnaire(vspId, version);