aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-healing-lib
diff options
context:
space:
mode:
authortalig <talig@amdocs.com>2017-12-20 14:30:43 +0200
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2017-12-21 11:12:33 +0000
commit8e9c0653dd6c6862123c9609ae34e1206d86456e (patch)
tree5eeef00ec0677133baa439ca8d7ffd7aca4804b6 /openecomp-be/lib/openecomp-healing-lib
parent785ebcc95de3e064e843bec04ba7a209d854fc7c (diff)
Add collaboration feature
Issue-ID: SDC-767 Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795 Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-healing-lib')
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml22
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java14
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/dao/HealingDao.java13
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/factory/HealingManagerFactory.java2
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/interfaces/Healer.java4
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/ConfigConstants.java5
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealerType.java6
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealingContext.java41
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java46
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java6
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java189
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json12
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/healingConfiguration.json28
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml5
-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
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealerTest.java16
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealerTest.java8
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java108
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/data/TestDescriptionHealer.java16
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/structure/TestNewEntityInVspHealer.java16
31 files changed, 718 insertions, 489 deletions
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml
index 2900785b55..fa3533fde9 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml
@@ -14,6 +14,23 @@
<dependencies>
<dependency>
+ <groupId>org.openecomp.sdc.common</groupId>
+ <artifactId>openecomp-configuration-management-core</artifactId>
+ <version>${openecomp.sdc.common.version}</version>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc.common</groupId>
+ <artifactId>openecomp-configuration-management-api</artifactId>
+ <version>${openecomp.sdc.common.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.openecomp.sdc.core</groupId>
<artifactId>openecomp-facade-core</artifactId>
<version>${project.version}</version>
@@ -33,6 +50,11 @@
<artifactId>openecomp-sdc-versioning-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java
index 211d9a21b2..ca0a3c79d7 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java
@@ -20,16 +20,24 @@
package org.openecomp.sdc.healing.api;
+import org.openecomp.sdc.datatypes.model.ItemType;
import org.openecomp.sdc.healing.types.HealCode;
+import org.openecomp.sdc.healing.types.HealerType;
+import org.openecomp.sdc.versioning.dao.types.Version;
-import java.util.Map;
import java.util.Optional;
/**
* Created by Talio on 11/29/2016.
*/
public interface HealingManager {
- Object heal(HealCode code, Map<String, Object> healParameters);
- Optional<String> healAll(Map<String, Object> healParameters);
+ /**
+ * @return healed version, if healing was not performed - Optional.empty.
+ */
+ Optional<Version> healItemVersion(String itemId, Version version, ItemType itemType,
+ boolean force);
+
+ Object heal(String itemId, Version version, HealerType healerType, HealCode code,
+ ItemType itemType);
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/dao/HealingDao.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/dao/HealingDao.java
new file mode 100644
index 0000000000..b766bd8d88
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/dao/HealingDao.java
@@ -0,0 +1,13 @@
+package org.openecomp.sdc.healing.dao;
+
+import java.util.Optional;
+
+/**
+ * Created by ayalaben on 10/17/2017
+ */
+public interface HealingDao {
+
+ Optional<Boolean> getItemHealingFlag(String space, String itemId, String versionId);
+
+ void setItemHealingFlag(boolean healingNeededFlag, String space, String itemId, String versionId);
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/factory/HealingManagerFactory.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/factory/HealingManagerFactory.java
index 8e8d633b42..5e375ee046 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/factory/HealingManagerFactory.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/factory/HealingManagerFactory.java
@@ -20,9 +20,9 @@
package org.openecomp.sdc.healing.factory;
-import org.openecomp.sdc.healing.api.HealingManager;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
+import org.openecomp.sdc.healing.api.HealingManager;
/**
* Created by Talio on 11/29/2016.
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/interfaces/Healer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/interfaces/Healer.java
index eb2f9a74d2..38afd1342a 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/interfaces/Healer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/interfaces/Healer.java
@@ -20,11 +20,11 @@
package org.openecomp.sdc.healing.interfaces;
-import java.util.Map;
+import org.openecomp.sdc.versioning.dao.types.Version;
/**
* Created by Talio on 11/29/2016.
*/
public interface Healer {
- Object heal(Map<String, Object> healingParams) throws Exception;
+ Object heal(String itemId, Version version) throws Exception;
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/ConfigConstants.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/ConfigConstants.java
new file mode 100644
index 0000000000..06301279a9
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/ConfigConstants.java
@@ -0,0 +1,5 @@
+package org.openecomp.sdc.healing.types;
+
+public class ConfigConstants {
+ public static final String HEALING_NAMESPACE = "healing";
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealerType.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealerType.java
new file mode 100644
index 0000000000..3355a3cd92
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealerType.java
@@ -0,0 +1,6 @@
+package org.openecomp.sdc.healing.types;
+
+public enum HealerType {
+ data,
+ structure
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealingContext.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealingContext.java
deleted file mode 100644
index 2ad143a0ec..0000000000
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealingContext.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package org.openecomp.sdc.healing.types;
-import org.openecomp.sdc.versioning.dao.types.Version;
-
-/**
- * Created by TALIO on 7/3/2017.
- */
-public class HealingContext {
- private String vspId;
- private Version version;
- private String user;
-
- public HealingContext(String vspId, Version version, String user) {
- this.vspId = vspId;
- this.version = version;
- this.user = user;
- }
-
- public String getVspId() {
- return vspId;
- }
-
- public void setVspId(String vspId) {
- this.vspId = vspId;
- }
-
- public Version getVersion() {
- return version;
- }
-
- public void setVersion(Version version) {
- this.version = version;
- }
-
- public String getUser() {
- return user;
- }
-
- public void setUser(String user) {
- this.user = user;
- }
-}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java
new file mode 100644
index 0000000000..921f418118
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/dao/impl/HealingDaoImpl.java
@@ -0,0 +1,46 @@
+package org.openecomp.sdc.healing.dao.impl;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.mapping.annotations.Accessor;
+import com.datastax.driver.mapping.annotations.Query;
+import org.openecomp.core.nosqldb.api.NoSqlDb;
+import org.openecomp.core.nosqldb.factory.NoSqlDbFactory;
+import org.openecomp.sdc.healing.dao.HealingDao;
+
+import java.util.Optional;
+
+/**
+ * Created by ayalaben on 10/17/2017
+ */
+public class HealingDaoImpl implements HealingDao {
+
+ private static final NoSqlDb noSqlDb = NoSqlDbFactory.getInstance().createInterface();
+ private static HealingAccessor accessor =
+ noSqlDb.getMappingManager().createAccessor(HealingAccessor.class);
+
+ @Override
+ public Optional<Boolean> getItemHealingFlag(String space, String itemId, String versionId) {
+ ResultSet result = accessor.getItemHealingFlag(space, itemId, versionId);
+ return result.getAvailableWithoutFetching() < 1
+ ? Optional.empty()
+ : Optional.of(result.one().getBool("healing_needed"));
+ }
+
+ @Override
+ public void setItemHealingFlag(boolean healingNeededFlag, String space, String itemId,
+ String versionId) {
+ accessor.setItemHealingFlag(healingNeededFlag, space, itemId, versionId);
+ }
+
+
+ @Accessor
+ interface HealingAccessor {
+
+ @Query("SELECT healing_needed FROM healing WHERE space=? AND item_id=? AND version_id=?")
+ ResultSet getItemHealingFlag(String space, String itemId, String versionId);
+
+ @Query("UPDATE healing SET healing_needed=? WHERE space=? AND item_id=? AND version_id=?")
+ void setItemHealingFlag(boolean flag, String space, String itemId, String versionId);
+
+ }
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java
index 84aff4327d..5a283f954b 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java
@@ -21,15 +21,17 @@
package org.openecomp.sdc.healing.impl;
import org.openecomp.sdc.healing.api.HealingManager;
+import org.openecomp.sdc.healing.dao.impl.HealingDaoImpl;
import org.openecomp.sdc.healing.factory.HealingManagerFactory;
+import org.openecomp.sdc.versioning.VersioningManagerFactory;
/**
* Created by Talio on 11/29/2016.
*/
public class HealingManagerFactoryImpl extends HealingManagerFactory {
-
@Override
public HealingManager createInterface() {
- return new HealingManagerImpl();
+ return new HealingManagerImpl(
+ VersioningManagerFactory.getInstance().createInterface(), new HealingDaoImpl());
}
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
index 1c895ffc6f..59c6732cab 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
@@ -24,34 +24,147 @@ import org.openecomp.core.utilities.CommonMethods;
import org.openecomp.core.utilities.file.FileUtils;
import org.openecomp.core.utilities.json.JsonUtil;
import org.openecomp.sdc.common.errors.Messages;
+import org.openecomp.sdc.common.session.SessionContextProviderFactory;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.model.ItemType;
import org.openecomp.sdc.healing.api.HealingManager;
+import org.openecomp.sdc.healing.dao.HealingDao;
import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.healing.types.HealCode;
+import org.openecomp.sdc.healing.types.HealerType;
import org.openecomp.sdc.logging.context.impl.MdcDataErrorMessage;
import org.openecomp.sdc.logging.types.LoggerConstants;
import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
+import org.openecomp.sdc.versioning.VersioningManager;
+import org.openecomp.sdc.versioning.dao.types.Version;
+import org.openecomp.sdc.versioning.dao.types.VersionStatus;
+import org.openecomp.sdc.versioning.types.VersionCreationMethod;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
+import java.util.stream.Collectors;
/**
* Created by Talio on 11/29/2016.
*/
public class HealingManagerImpl implements HealingManager {
- private static String HEALING_CONF_FILE = "healingConfiguration.json";
- private static Map<String, String> healerCodeToImplClass = initHealers();
+
+ private static final String HEALERS_BY_ENTITY_TYPE_FILE = "entityHealingConfiguration.json";
+ private static final String HEALING_USER_SUFFIX = "_healer";
+ private static final String PUBLIC_USER = "public";
+
+ private HealingDao healingDao;
+ private VersioningManager versioningManager;
+
+ public HealingManagerImpl(VersioningManager versioningManager, HealingDao healingDao) {
+ this.versioningManager = versioningManager;
+ this.healingDao = healingDao;
+ }
+
+ @Override
+ public Optional<Version> healItemVersion(String itemId, Version version, ItemType itemType,
+ boolean force) {
+ String user = getUser();
+ if (force || isPrivateHealingNeededByFlag(itemId, version.getId(), user)) {
+ version = versioningManager.get(itemId, version);
+ Version origVersion = version;
+ if (version.getStatus() == VersionStatus.Certified) {
+ Optional<Version> newVersion = createNewVersion(itemId, version);
+ if (!newVersion.isPresent()) {
+ // do NOT turn off flag here (in thought of saving version calculate performance next
+ // time) because maybe next time the next version will be available (due to deletion of
+ // the taken one)
+ return Optional.empty();
+ }
+ version = newVersion.get();
+ }
+
+ doHeal(itemId, version, origVersion, itemType, user, force);
+ return Optional.of(version);
+ }
+ return Optional.empty();
+ }
+
+ private void doHeal(String itemId, Version version, Version origVersion,
+ ItemType itemType, String user, boolean force) {
+ Optional<String> privateFailureMessages =
+ healPrivate(itemId, version, origVersion, getItemHealers(itemType), user);
+
+ Optional<String> publicFailureMessages =
+ force || origVersion.getStatus() == VersionStatus.Certified ||
+ isPublicHealingNeededByFlag(itemId, origVersion.getId())
+ ? healPublic(itemId, version, origVersion, getItemHealers(itemType), user)
+ : Optional.empty();
+
+ if (privateFailureMessages.isPresent() || publicFailureMessages.isPresent()) {
+ throw new RuntimeException(
+ publicFailureMessages.orElse("") + " " + privateFailureMessages.orElse(""));
+ }
+ }
+
+ private Optional<String> healPrivate(String itemId, Version version, Version origVersion,
+ Map<String, Map<String, String>> itemHealers, String user) {
+ if (origVersion.getStatus() != VersionStatus.Certified) {
+ itemHealers.remove(HealerType.structure.name());
+ }
+
+ Optional<String> privateHealingFailureMessages = executeHealers(itemId, version, itemHealers);
+ markAsHealed(itemId, origVersion.getId(), user);
+ return privateHealingFailureMessages;
+ }
+
+ private Optional<String> healPublic(String itemId, Version version, Version origVersion,
+ Map<String, Map<String, String>> itemHealers, String user) {
+ Optional<String> healingFailureMessages = origVersion.getStatus() == VersionStatus.Certified
+ ? Optional.empty()
+ : healPublic(itemId, version, itemHealers, user);
+
+ markAsHealed(itemId, origVersion.getId(), PUBLIC_USER);
+ return healingFailureMessages;
+ }
+
+ private Optional<String> healPublic(String itemId, Version version,
+ Map<String, Map<String, String>> itemHealers, String user) {
+ SessionContextProviderFactory.getInstance().createInterface()
+ .create(user + HEALING_USER_SUFFIX);
+
+ versioningManager.sync(itemId, version);
+
+ Optional<String> healingFailureMessages = executeHealers(itemId, version, itemHealers);
+ Version publicVersion = versioningManager.get(itemId, version);
+
+ if (Objects.nonNull(publicVersion.getState()) && publicVersion.getState().isDirty()) {
+ versioningManager.publish(itemId, version, "Healing vsp");
+ }
+
+ SessionContextProviderFactory.getInstance().createInterface().create(user);
+ return healingFailureMessages;
+ }
+
+ private Optional<Version> createNewVersion(String itemId, Version version) {
+ Version newVersion = new Version();
+ newVersion.setBaseId(version.getId());
+ try {
+ return Optional.of(versioningManager.create(itemId, newVersion, VersionCreationMethod.major));
+ } catch (Exception e) {
+ return Optional.empty();
+ }
+ }
@Override
- public Object heal(HealCode code, Map<String, Object> healParameters) {
+ public Object heal(String itemId, Version version, HealerType healerType, HealCode code,
+ ItemType itemType) {
+ String healerClassName = getItemHealers(itemType).get(healerType.name()).get(code.name());
ArrayList<String> healingFailureMessages = new ArrayList<>();
- Object result =
- heal(healParameters, healerCodeToImplClass.get(code.name()), healingFailureMessages);
+ Object result = executeHealer(itemId, version, healerClassName, healingFailureMessages);
if (!healingFailureMessages.isEmpty()) {
throw new RuntimeException(CommonMethods.listToSeparatedString(healingFailureMessages, '\n'));
@@ -59,46 +172,77 @@ public class HealingManagerImpl implements HealingManager {
return result;
}
- @Override
- public Optional<String> healAll(Map<String, Object> healParameters) {
- ArrayList<String> healingFailureMessages = new ArrayList<>();
+ private Optional<String> executeHealers(String itemId, Version version,
+ Map<String, Map<String, String>> itemHealers) {
+ List<String> healers = itemHealers.values().stream()
+ .map(Map::values)
+ .flatMap(Collection::stream)
+ .collect(Collectors.toList());
- for (String implClassName : healerCodeToImplClass.values()) {
- heal(healParameters, implClassName, healingFailureMessages);
+ List<String> healingFailureMessages = new ArrayList<>();
+ for (String implClassName : healers) {
+ executeHealer(itemId, version, implClassName, healingFailureMessages);
}
- return healingFailureMessages.isEmpty() ? Optional.empty()
+ return healingFailureMessages.isEmpty()
+ ? Optional.empty()
: Optional.of(CommonMethods.listToSeparatedString(healingFailureMessages, '\n'));
}
- private Object heal(Map<String, Object> healParameters, String healerImplClassName,
- ArrayList<String> healingFailureMessages) {
- Healer healerImpl;
+
+ private Object executeHealer(String itemId, Version version, String healerClassName,
+ List<String> healingFailureMessages) {
+ Healer healer;
try {
- healerImpl = getHealerImplInstance(healerImplClassName);
+ healer = getHealerImplInstance(healerClassName);
} catch (Exception e) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(), LoggerErrorCode
.DATA_ERROR.getErrorCode(), LoggerErrorDescription.CANT_HEAL);
healingFailureMessages
.add(String.format(Messages.CANT_LOAD_HEALING_CLASS.getErrorMessage(),
- healerImplClassName));
+ healerClassName));
return null;
}
try {
- return healerImpl.heal(healParameters);
+ return healer.heal(itemId, version);
} catch (Exception e) {
MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(), LoggerErrorCode
.DATA_ERROR.getErrorCode(), LoggerErrorDescription.CANT_HEAL);
- healingFailureMessages.add(e.getMessage() + " ,healer name :" + healerImplClassName);
+ healingFailureMessages.add(e.getMessage() + " ,healer name :" + healerClassName);
}
return null;
}
- private static Map<String, String> initHealers() {
- return FileUtils.readViaInputStream(HEALING_CONF_FILE, stream -> JsonUtil.json2Object(stream, Map.class));
+ private boolean isPrivateHealingNeededByFlag(String itemId, String version, String user) {
+ Optional<Boolean> userHealingFlag = getHealingFlag(itemId, version, user);
+ return userHealingFlag.isPresent()
+ ? userHealingFlag.get()
+ : isPublicHealingNeededByFlag(itemId, version);
+ }
+
+ private boolean isPublicHealingNeededByFlag(String itemId, String versionId) {
+ Optional<Boolean> publicHealingFlag = getHealingFlag(itemId, versionId, PUBLIC_USER);
+ return publicHealingFlag.isPresent() && publicHealingFlag.get();
+ }
+
+ private Optional<Boolean> getHealingFlag(String itemId, String version, String user) {
+ return healingDao.getItemHealingFlag(user, itemId, version);
+ }
+
+ private void markAsHealed(String itemId, String versionId, String user) {
+ healingDao.setItemHealingFlag(false, user, itemId, versionId);
+ }
+
+ private Map<String, Map<String, String>> getItemHealers(ItemType itemType) {
+ // TODO: 11/29/2017 create objects to hold this configuration +
+ // load once from the json file and use the relevant healers (by itemType, healerType) as needed.
+ Map healingConfig = FileUtils
+ .readViaInputStream(HEALERS_BY_ENTITY_TYPE_FILE,
+ stream -> JsonUtil.json2Object(stream, Map.class));
+ return (Map<String, Map<String, String>>) healingConfig.get(itemType.name());
}
private Healer getHealerImplInstance(String implClassName)
@@ -106,4 +250,9 @@ public class HealingManagerImpl implements HealingManager {
NoSuchMethodException, ClassNotFoundException {
return (Healer) Class.forName(implClassName).getConstructor().newInstance();
}
+
+ private String getUser() {
+ return SessionContextProviderFactory.getInstance().createInterface().get().getUser()
+ .getUserId();
+ }
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json
new file mode 100644
index 0000000000..ab8a1dfb4f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/entityHealingConfiguration.json
@@ -0,0 +1,12 @@
+{
+ "vsp": {
+ "structure": {
+ "ownerHealer": "org.openecomp.sdc.healing.healers.OwnerHealer"
+ }
+ },
+ "vlm": {
+ "structure": {
+ "ownerHealer": "org.openecomp.sdc.healing.healers.OwnerHealer"
+ }
+ }
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/healingConfiguration.json b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/healingConfiguration.json
index 4e1b0df97a..85eec77c56 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/healingConfiguration.json
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/healingConfiguration.json
@@ -1,13 +1,19 @@
{
- "FILE_DATA_STRUCTURE_HEALER" : "org.openecomp.sdc.healing.healers.FileDataStructureHealer",
- "QUESTIONNAIRE_HEALER" : "org.openecomp.sdc.healing.healers.VspQuestionnaireHealer",
- "COMPOSITION_DATA_HEALER" : "org.openecomp.sdc.healing.healers.CompositionDataHealer",
- "SUB_ENTITIES_HEALER" : "org.openecomp.sdc.healing.healers.SubEntitiesQuestionnaireHealer",
- "ONBOARDING_METHOD_HEALER" : "org.openecomp.sdc.healing.healers.VspOnboardingMethodHealer",
- "NIC_DATA_HEALER" : "org.openecomp.sdc.healing.healers.NicDataHealer",
- "COMPONENT_QUESTIONNAIRE_HEALER" : "org.openecomp.sdc.healing.healers.ComponentQuestionnaireHealer",
- "HEAT_TOSCA_TRANSLATION_HEALER" : "org.openecomp.sdc.healing.healers.HeatToToscaTranslationHealer",
- "VLM_VERSION_HEALER" : "org.openecomp.sdc.healing.healers.VlmVersionHealer",
- "VALIDATION_STRUCTURE_HEALER" : "org.openecomp.sdc.healing.healers.ValidationStructureHealer",
- "FORWARDER_CAPABILITY_HEALER" : "org.openecomp.sdc.healing.healers.ForwarderCapabilityHealer"
+ "VendorSoftwareProduct" : {
+ "VSP_OWNER_HEALER" : "org.openecomp.sdc.healing.healers.VspOwnerHealer",
+ "FILE_DATA_STRUCTURE_HEALER" : "org.openecomp.sdc.healing.healers.FileDataStructureHealer",
+ "QUESTIONNAIRE_HEALER" : "org.openecomp.sdc.healing.healers.VspQuestionnaireHealer",
+ "COMPOSITION_DATA_HEALER" : "org.openecomp.sdc.healing.healers.CompositionDataHealer",
+ "SUB_ENTITIES_HEALER" : "org.openecomp.sdc.healing.healers.SubEntitiesQuestionnaireHealer",
+ "ONBOARDING_METHOD_HEALER" : "org.openecomp.sdc.healing.healers.VspOnboardingMethodHealer",
+ "NIC_DATA_HEALER" : "org.openecomp.sdc.healing.healers.NicDataHealer",
+ "COMPONENT_QUESTIONNAIRE_HEALER" : "org.openecomp.sdc.healing.healers.ComponentQuestionnaireHealer",
+ "HEAT_TOSCA_TRANSLATION_HEALER" : "org.openecomp.sdc.healing.healers.HeatToToscaTranslationHealer",
+ "VLM_VERSION_HEALER" : "org.openecomp.sdc.healing.healers.VlmVersionHealer",
+ "VALIDATION_STRUCTURE_HEALER" : "org.openecomp.sdc.healing.healers.ValidationStructureHealer",
+ "FORWARDER_CAPABILITY_HEALER" : "org.openecomp.sdc.healing.healers.ForwarderCapabilityHealer"
+ },
+ "VendorLicenseModel" : {
+ "VLM_OWNER_HEALER" : "org.openecomp.sdc.healing.healers.VlmOwnerHealer"
+ }
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
index c54f724b9a..1359e6921d 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
@@ -39,6 +39,11 @@
<artifactId>openecomp-sdc-vendor-license-api</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-item-permissions-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
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);
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealerTest.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealerTest.java
index 69f4287cd1..688d1d4236 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealerTest.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealerTest.java
@@ -8,7 +8,6 @@ import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import org.openecomp.sdc.common.utils.SdcCommon;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
@@ -20,10 +19,7 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.doNothing;
@@ -47,7 +43,6 @@ public class ComponentQuestionnaireHealerTest {
private static final String DUMMY_COMPONENT_ID = "2495ef442f964cbfb00d82bd54292f89";
private static final String DUMMY_COMPUTE_ID = "3495ef442f964cbfb00d82bd54292f89";
private static final String DUMMY_IMAGE_ID = "4495ef442f964cbfb00d82bd54292f89";
- private static Map<String, Object> healingParams = new HashMap<>();
private static final String componentQuestionnaireData = "{\"compute\": {" +
"\"guestOS\": {\"bitSize\": 64},\"vmSizing\": {\"IOOperationsPerSec\": \"0\"}," +
"\"numOfVMs\": {\"CpuOverSubscriptionRatio\": \"1:1\",\"MemoryRAM\": \"2 GB\"}}," +
@@ -131,16 +126,13 @@ public class ComponentQuestionnaireHealerTest {
@Before
public void init() throws Exception {
MockitoAnnotations.initMocks(ComponentQuestionnaireHealerTest.this);
-
- healingParams.put(SdcCommon.VSP_ID, DUMMY_VSP_ID);
- healingParams.put(SdcCommon.VERSION, VERSION);
}
@Test
public void healQuestionnaireNullTest() throws Exception {
prepareHealingData();
componentEntity.setQuestionnaireData(null);
- Object returnObject = componentQuestionnaireHealer.heal(healingParams);
+ Object returnObject = componentQuestionnaireHealer.heal(DUMMY_VSP_ID, VERSION);
Assert.assertTrue(returnObject instanceof Collection);
Collection<ComponentEntity> componentEntities = (Collection<ComponentEntity>) returnObject;
componentEntities.forEach(componentEntity -> {
@@ -152,7 +144,7 @@ public class ComponentQuestionnaireHealerTest {
public void healAllCasesTest() throws Exception {
prepareHealingData();
- Object returnObject = componentQuestionnaireHealer.heal(healingParams);
+ Object returnObject = componentQuestionnaireHealer.heal(DUMMY_VSP_ID, VERSION);
Assert.assertTrue(returnObject instanceof Collection);
Collection<ComponentEntity> componentEntities = (Collection<ComponentEntity>) returnObject;
componentEntities.forEach(componentEntity -> {
@@ -177,7 +169,7 @@ public class ComponentQuestionnaireHealerTest {
public void healDiskAttrMissingTest() throws Exception {
prepareHealingData();
componentEntity.setQuestionnaireData(componentQuestionnaireMissingDiskAttrData);
- Object returnObject = componentQuestionnaireHealer.heal(healingParams);
+ Object returnObject = componentQuestionnaireHealer.heal(DUMMY_VSP_ID, VERSION);
Assert.assertTrue(returnObject instanceof Collection);
Collection<ComponentEntity> componentEntities = (Collection<ComponentEntity>) returnObject;
componentEntities.forEach(componentEntity -> {
@@ -238,7 +230,7 @@ public class ComponentQuestionnaireHealerTest {
.getDeclaredMethod(methodName, JsonObject.class, JsonObject.class);
method.setAccessible(true);
- method.invoke(componentQuestionnaireHealer,jsonObject.getAsJsonObject(COMPUTE), null);
+ method.invoke(componentQuestionnaireHealer, jsonObject.getAsJsonObject(COMPUTE), null);
}
private void prepareHealingData() {
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealerTest.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealerTest.java
index 406d039178..a07ace683f 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealerTest.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/ForwarderCapabilityHealerTest.java
@@ -13,7 +13,6 @@ import org.mockito.MockitoAnnotations;
import org.openecomp.core.model.dao.ServiceModelDao;
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.healers.util.TestUtil;
import org.openecomp.sdc.tosca.datatypes.ToscaNodeType;
import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
@@ -32,13 +31,14 @@ import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.eq;
public class ForwarderCapabilityHealerTest {
+ private static final String vspId = "1";
+ private static final Version version = new Version(1, 1);
private static final String IN_SUFFIX = "/in";
private static final String OUT_SUFFIX = "/out";
private static final String BASE_DIRECTORY = "/mock/healers/forwarder";
private static final String ENTRY_DEFINITION_SERVICE_TEMPLATE = "MainServiceTemplate.yaml";
private static TestFeatureManager manager;
- private Map<String,Object> params = new HashMap<>();
@Mock
private ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao;
@@ -65,8 +65,6 @@ public class ForwarderCapabilityHealerTest {
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(ForwarderCapabilityHealerTest.this);
- params.put(SdcCommon.VSP_ID,"1");
- params.put(SdcCommon.VERSION, new Version(1,1));
}
@@ -127,7 +125,7 @@ public class ForwarderCapabilityHealerTest {
private void validateServiceModelAfterHealing(String testDirectory) throws Exception {
Optional<ToscaServiceModel> serviceModelObject =
- (Optional<ToscaServiceModel>) forwarderCapabilityHealer.heal(params);
+ (Optional<ToscaServiceModel>) forwarderCapabilityHealer.heal(vspId, version);
Assert.assertTrue(serviceModelObject.isPresent());
TestUtil
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java
index b732cb03b6..5584a5fe77 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/VspOnboardingMethodHealerTest.java
@@ -2,69 +2,77 @@ package org.openecomp.sdc.healing.healers;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
-import org.openecomp.sdc.common.utils.SdcCommon;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateCandidateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+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.HashMap;
-import java.util.Map;
-
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
-public class VspOnboardingMethodHealerTest{
+public class VspOnboardingMethodHealerTest {
+ private static final String vspId = "1";
+ private static final Version version = new Version(1, 1);
+
+ @Mock
+ private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+ @Mock
+ private OrchestrationTemplateDao orchestrationTemplateDao;
+ @Mock
+ private OrchestrationTemplateCandidateDao candidateDao;
+ @InjectMocks
+ private VspOnboardingMethodHealer vspOnboardingMethodHealer;
+
+ private OrchestrationTemplateEntity orchestrationTemplateEntity = new OrchestrationTemplateEntity();
+ private OrchestrationTemplateCandidateData candidateData = new OrchestrationTemplateCandidateData();
+ private static final String NETWORK_PACKAGE = "NetworkPackage";
+ private static final String HEAT = "HEAT";
+ private static final String MANUAL = "Manual";
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(VspOnboardingMethodHealerTest.this);
+ }
+
+ @Test
+ public void checkHealingWithNullOnboarding() throws Exception {
+ VspDetails vspDetails = initAndExecuteHealer(null);
+ assertEquals(vspDetails.getOnboardingMethod(), NETWORK_PACKAGE);
+ }
- @Mock
- private VendorSoftwareProductInfoDao vendorSoftwareProductInfoDao;
+ @Test
+ public void checkHealingWithHEATOnboarding() throws Exception {
+ VspDetails vspDetails = initAndExecuteHealer(HEAT);
+ assertEquals(vspDetails.getOnboardingMethod(), NETWORK_PACKAGE);
+ }
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(VspOnboardingMethodHealerTest.this);
- }
+ @Test
+ public void checkHealingWithManualOnboarding() throws Exception {
+ VspDetails vspDetails = initAndExecuteHealer(MANUAL);
+ assertEquals(vspDetails.getOnboardingMethod(), MANUAL);
+ }
- @Test
- public void checkHealingWithNullOnboarding() throws Exception{
- VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
- Map<String,Object> params = new HashMap<>();
- params.put(SdcCommon.VSP_ID,"1");
- params.put(SdcCommon.VERSION, new Version(1,1));
- VspDetails vspDetails = new VspDetails();
- vspDetails.setOnboardingMethod(null);
- Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
- vspOnboardingMethodHealer.heal(params);
- assertEquals(vspDetails.getOnboardingMethod(),"NetworkPackage");
- assertEquals(vspDetails.getOnboardingOrigin(),"zip");
- }
+ private VspDetails initAndExecuteHealer(String onboardingMethod) throws Exception {
+ VspDetails vspDetails = new VspDetails();
+ vspDetails.setOnboardingMethod(onboardingMethod);
- @Test
- public void checkHealingWithHEATOnboarding() throws Exception{
- VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
- Map<String,Object> params = new HashMap<>();
- params.put(SdcCommon.VSP_ID,"1");
- params.put(SdcCommon.VERSION, new Version(1,1));
- VspDetails vspDetails = new VspDetails();
- vspDetails.setOnboardingMethod("HEAT");
- Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
- vspOnboardingMethodHealer.heal(params);
- assertEquals(vspDetails.getOnboardingMethod(),"NetworkPackage");
- assertEquals(vspDetails.getOnboardingOrigin(),"zip");
- }
+ setMockActions(vspDetails);
+ vspOnboardingMethodHealer.heal(vspId, version);
+ return vspDetails;
+ }
- @Test
- public void checkHealingWithManualOnboarding() throws Exception{
- VspOnboardingMethodHealer vspOnboardingMethodHealer = new VspOnboardingMethodHealer(vendorSoftwareProductInfoDao);
- Map<String,Object> params = new HashMap<>();
- params.put(SdcCommon.VSP_ID,"1");
- params.put(SdcCommon.VERSION, new Version(1,1));
- VspDetails vspDetails = new VspDetails();
- vspDetails.setOnboardingMethod("Manual");
- Mockito.when(vendorSoftwareProductInfoDao.get(any())).thenReturn(vspDetails);
- vspOnboardingMethodHealer.heal(params);
- assertEquals(vspDetails.getOnboardingMethod(),"Manual");
- assertEquals(vspDetails.getOnboardingOrigin(),null);
- }
+ private void setMockActions(VspDetails vspDetails) {
+ Mockito.doReturn(vspDetails).when(vendorSoftwareProductInfoDao).get(any());
+ Mockito.doReturn(orchestrationTemplateEntity).when(orchestrationTemplateDao).get(any(), any());
+ Mockito.doNothing().when(orchestrationTemplateDao).update(any(), any(), any());
+ Mockito.doReturn(candidateData).when(candidateDao).get(any(), any());
+ Mockito.doNothing().when(candidateDao).update(any(), any(), any());
+ }
} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/data/TestDescriptionHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/data/TestDescriptionHealer.java
new file mode 100644
index 0000000000..aac1a502ef
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/data/TestDescriptionHealer.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.healing.healers.testHealers.data;
+
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public class TestDescriptionHealer implements Healer {
+
+ @Override
+ public Object heal(String vspId, Version version) throws Exception {
+ VspDetails vspDetails = new VspDetails(vspId, version);
+ vspDetails.setDescription("This is a data healer");
+
+ return vspDetails;
+ }
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/structure/TestNewEntityInVspHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/structure/TestNewEntityInVspHealer.java
new file mode 100644
index 0000000000..7d71c0319b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/test/java/org/openecomp/sdc/healing/healers/testHealers/structure/TestNewEntityInVspHealer.java
@@ -0,0 +1,16 @@
+package org.openecomp.sdc.healing.healers.testHealers.structure;
+
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+public class TestNewEntityInVspHealer implements Healer {
+
+ @Override
+ public Object heal(String vspId, Version version) throws Exception {
+ VspDetails vspDetails = new VspDetails(vspId, version);
+ vspDetails.setDescription("This is a structure healer");
+
+ return vspDetails;
+ }
+}