summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main
diff options
context:
space:
mode:
authortalio <tali.orenbach@amdocs.com>2017-10-19 13:45:23 +0300
committertalio <tali.orenbach@amdocs.com>2017-10-19 13:45:23 +0300
commit7a39e9df5f809bafdaec56358d0bb391a928b25e (patch)
treec1baed6e1b331f50cb53287e34b858729156fac0 /openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main
parent371880722fa899f59c82b1a98b0e3d65ff250e41 (diff)
fix healers
fix failing healers during resubmitAll Issue - Id : SDC-480 Change-Id: Ie41c918d96271ff71f4dde00d22fdf3b23297044 Signed-off-by: talio <tali.orenbach@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main')
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java8
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java12
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ValidationStructureHealer.java5
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java17
4 files changed, 33 insertions, 9 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 d061556e4c..4dadb97f71 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 org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
import java.util.Map;
+import java.util.Objects;
public class ComponentQuestionnaireHealer implements Healer {
@@ -59,8 +60,10 @@ public class ComponentQuestionnaireHealer implements Healer {
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 @@ public class ComponentQuestionnaireHealer implements Healer {
* 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 130405be1d..9355eb076f 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 @@ public class SubEntitiesQuestionnaireHealer implements Healer {
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 @@ public class SubEntitiesQuestionnaireHealer implements Healer {
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 @@ public class SubEntitiesQuestionnaireHealer implements Healer {
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 58ba3b7c35..4bf7e18091 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 @@ public class ValidationStructureHealer implements Healer {
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 4accd790ab..085923b8a0 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.VendorSoftwareProductInfoDao;
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 @@ public class VlmVersionHealer implements Healer {
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 @@ public class VlmVersionHealer implements Healer {
vspDetails.setVlmVersion(vlmVersion);
- vspDetails.setLicenseAgreement(laList.get(0).getId());
- vspDetails.setFeatureGroups(new ArrayList<>(laList.get(0).getFeatureGroupIds()));
- vspInfoDao.update(vspDetails);
+ 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();
+ }
}
="n">sitePath}</url> </site> </distributionManagement> <build> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <executions> <execution> <id>pre-unit-test</id> <goals> <goal>prepare-agent</goal> </goals> <configuration> <destFile>${sonar.jacoco.reportPath}</destFile> <append>true</append> </configuration> </execution> <execution> <id>post-unit-test</id> <phase>test</phase> <goals> <goal>report</goal> </goals> <configuration> <dataFile>${sonar.jacoco.reportPath}</dataFile> </configuration> </execution> </executions> </plugin> </plugins> <pluginManagement> <plugins> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>${jacoco.version}</version> <configuration> <!-- Note: This exclusion list should match <sonar.exclusions> property above --> <excludes> <exclude>**/gen/**</exclude> <exclude>**/generated-sources/**</exclude> <exclude>**/yang-gen/**</exclude> <exclude>**/pax/**</exclude> </excludes> </configuration> <executions> <!-- Prepares the property pointing to the JaCoCo runtime agent which is passed as VM argument when Maven the Surefire plugin is executed. --> <execution> <id>pre-unit-test</id> <goals> <goal>prepare-agent</goal> </goals> <configuration> <destFile>${sonar.jacoco.reportPath}</destFile> </configuration> </execution> <!-- Ensures that the code coverage report for unit tests is created after unit tests have been run. --> <execution> <id>post-unit-test</id> <phase>test</phase> <goals> <goal>report</goal> </goals> <configuration> <dataFile>${sonar.jacoco.reportPath}</dataFile> </configuration> </execution> </executions> </plugin> </plugins> </pluginManagement> </build> </project>