fix healers
fix failing healers during resubmitAll
Issue - Id : SDC-480
Change-Id: Ie41c918d96271ff71f4dde00d22fdf3b23297044
Signed-off-by: talio <tali.orenbach@amdocs.com>
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 d061556..4dadb97 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
@@ -19,6 +19,7 @@
import java.util.Collection;
import java.util.Map;
+import java.util.Objects;
public class ComponentQuestionnaireHealer implements Healer {
@@ -59,8 +60,10 @@
Collection<ComponentEntity> componentEntities =
componentDao.list(new ComponentEntity(vspId, version, null));
componentEntities.forEach(componentEntity -> {
- String questionnaire = componentDao.getQuestionnaireData(vspId, version, componentEntity
- .getId()).getQuestionnaireData();
+ ComponentEntity componentQuestionnaireData =
+ componentDao.getQuestionnaireData(vspId, version, componentEntity.getId());
+ String questionnaire = Objects.isNull(componentQuestionnaireData) ? null
+ : componentQuestionnaireData.getQuestionnaireData();
if (questionnaire != null) {
JsonParser jsonParser = new JsonParser();
@@ -97,7 +100,6 @@
* Move Disk Atributes from genral/image/ to genral/disk in component questionnaire itself
* @param json
* @param diskAttrName
- * @param diskJsonObject
* @return
*/
private void processDiskAttribute(JsonObject json, String diskAttrName) {
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 130405b..9355eb0 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
@@ -55,6 +55,9 @@
private static NicDao nicDao = NicDaoFactory.getInstance().createInterface();
private static NetworkDao networkDao = NetworkDaoFactory.getInstance().createInterface();
+ private static String emptyString = "";
+ private static String emptyJson = "{}";
+
@Override
public Object heal(Map<String, Object> healingParams) throws Exception {
@@ -90,8 +93,7 @@
for (Object entity : compositionEntities) {
CompositionEntity compositionEntity = (CompositionEntity) entity;
- if (Objects.isNull(compositionEntity.getQuestionnaireData()) ||
- "".equals(compositionEntity.getQuestionnaireData())) {
+ if (isQuestionnaireNeedsToGetHealed(compositionEntity)) {
compositionEntity.setVersion(newVersion);
updateNullQuestionnaire(compositionEntity, type);
}
@@ -100,6 +102,12 @@
mdcDataDebugMessage.debugExitMessage(null);
}
+ private boolean isQuestionnaireNeedsToGetHealed(CompositionEntity compositionEntity) {
+ return Objects.isNull(compositionEntity.getQuestionnaireData())
+ || emptyString.equals(compositionEntity.getQuestionnaireData())
+ || emptyJson.equals(compositionEntity.getQuestionnaireData());
+ }
+
private void updateNullQuestionnaire(CompositionEntity entity,
CompositionEntityType type) {
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 58ba3b7..4bf7e18 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
@@ -48,6 +48,11 @@
UploadDataEntity orchestrationTemplate =
orchestrationTemplateDao.getOrchestrationTemplate(vspId, version);
+ if(Objects.isNull(orchestrationTemplate.getValidationData())
+ || !JsonUtil.isValidJson(orchestrationTemplate.getValidationData())){
+ return Optional.empty();
+ }
+
OldValidationStructureTree oldValidationStructureTree;
try{
oldValidationStructureTree =
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 4accd79..085923b 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,5 +1,6 @@
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;
@@ -15,6 +16,7 @@
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.types.VersionInfo;
import java.util.ArrayList;
import java.util.List;
@@ -60,7 +62,7 @@
VendorLicenseModelEntity vlm = vendorLicenseModel.getVendorLicenseModel();
String vlmId = vlm.getId();
- Version vlmVersion = vlm.getVersion();
+ Version vlmVersion = getLatestFinalVlmVersion(vendorLicenseModel.getVersionInfo());
List<LicenseAgreementEntity> laList =
new ArrayList<>(
@@ -68,12 +70,19 @@
vspDetails.setVlmVersion(vlmVersion);
- vspDetails.setLicenseAgreement(laList.get(0).getId());
- vspDetails.setFeatureGroups(new ArrayList<>(laList.get(0).getFeatureGroupIds()));
+
+ if(CollectionUtils.isNotEmpty(laList)) {
+ vspDetails.setLicenseAgreement(laList.get(0).getId());
+ vspDetails.setFeatureGroups(new ArrayList<>(laList.get(0).getFeatureGroupIds()));
+ }
vspInfoDao.update(vspDetails);
-
return vspDetails;
}
+
+ private Version getLatestFinalVlmVersion(VersionInfo versionInfo){
+ return versionInfo.getActiveVersion().isFinal() ? versionInfo.getActiveVersion()
+ : versionInfo.getLatestFinalVersion();
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
index 4c38bd9..640777e 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/filedatastructuremodule/CandidateServiceImpl.java
@@ -340,7 +340,8 @@
Optional<String> jsonFileDataStructure =
orchestrationTemplateCandidateDataDao.getStructure(vspId, version);
- if (jsonFileDataStructure.isPresent()) {
+ if (jsonFileDataStructure.isPresent()
+ && JsonUtil.isValidJson(jsonFileDataStructure.get())) {
mdcDataDebugMessage.debugExitMessage("VSP Id", vspId);
return Optional
.of(JsonUtil.json2Object(jsonFileDataStructure.get(), FilesDataStructure.class));