aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-healing-lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-healing-lib')
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml33
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml.versionsBackup35
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java34
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/factory/HealingManagerFactory.java34
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/interfaces/Healer.java30
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealCode.java31
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/resources/factoryConfiguration.json3
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/pom.xml33
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/pom.xml.versionsBackup35
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java35
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java91
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingConfiguration.java27
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingUtil.java27
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/healingConfiguration.json7
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml34
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml.versionsBackup36
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java224
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java116
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java82
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java129
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspQuestionnaireHealer.java88
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/pom.xml23
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/pom.xml.versionsBackup23
23 files changed, 1210 insertions, 0 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
new file mode 100644
index 0000000000..a3969f983b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-healing-api</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-healing-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-facade-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-validation-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml.versionsBackup
new file mode 100644
index 0000000000..c9d100dd50
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/pom.xml.versionsBackup
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-facade-core</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.core</groupId>
+ <artifactId>openecomp-facade-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-validation-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-healing-lib</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-healing-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+
+</project> \ No newline at end of file
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
new file mode 100644
index 0000000000..a2ce153a82
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.healing.api;
+
+import org.openecomp.sdc.healing.types.HealCode;
+
+import java.util.Map;
+
+/**
+ * Created by Talio on 11/29/2016.
+ */
+public interface HealingManager {
+ Object heal(HealCode code, Map<String, Object> healParameters);
+
+ void healAll(Map<String, Object> healParameters);
+}
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
new file mode 100644
index 0000000000..8e8d633b42
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/factory/HealingManagerFactory.java
@@ -0,0 +1,34 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+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;
+
+/**
+ * Created by Talio on 11/29/2016.
+ */
+public abstract class HealingManagerFactory extends AbstractComponentFactory<HealingManager> {
+ public static HealingManagerFactory getInstance(){
+ return AbstractFactory.getInstance(HealingManagerFactory.class);
+ }
+}
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
new file mode 100644
index 0000000000..eb2f9a74d2
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/interfaces/Healer.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.healing.interfaces;
+
+import java.util.Map;
+
+/**
+ * Created by Talio on 11/29/2016.
+ */
+public interface Healer {
+ Object heal(Map<String, Object> healingParams) throws Exception;
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealCode.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealCode.java
new file mode 100644
index 0000000000..420d75621f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/types/HealCode.java
@@ -0,0 +1,31 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.healing.types;
+
+/**
+ * Created by Talio on 11/29/2016.
+ */
+public enum HealCode {
+ FILE_DATA_STRUCTURE_HEALER,
+ QUESTIONNAIRE_HEALER,
+ COMPOSITION_DATA_HEALER,
+ SUB_ENTITIES_QUESTIONNAIRE_HEALER;
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/resources/factoryConfiguration.json b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/resources/factoryConfiguration.json
new file mode 100644
index 0000000000..e05e00e075
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/resources/factoryConfiguration.json
@@ -0,0 +1,3 @@
+{
+ "org.openecomp.sdc.healing.factory.HealingManagerFactory" : "org.openecomp.sdc.healing.impl.HealingManagerFactoryImpl"
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/pom.xml b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/pom.xml
new file mode 100644
index 0000000000..a01d79e937
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/pom.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-healing-core</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-healing-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-healing-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-validation-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/pom.xml.versionsBackup
new file mode 100644
index 0000000000..c48c3259e1
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/pom.xml.versionsBackup
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-healing-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-validation-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-healing-lib</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-healing-core</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+
+</project> \ No newline at end of file
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
new file mode 100644
index 0000000000..84aff4327d
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerFactoryImpl.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.healing.impl;
+
+import org.openecomp.sdc.healing.api.HealingManager;
+import org.openecomp.sdc.healing.factory.HealingManagerFactory;
+
+/**
+ * Created by Talio on 11/29/2016.
+ */
+public class HealingManagerFactoryImpl extends HealingManagerFactory {
+
+ @Override
+ public HealingManager createInterface() {
+ return new HealingManagerImpl();
+ }
+}
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
new file mode 100644
index 0000000000..0d4cb9c0ba
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java
@@ -0,0 +1,91 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.healing.impl;
+
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.healing.interfaces.Healer;
+import org.openecomp.core.utilities.file.FileUtils;
+import org.openecomp.sdc.healing.types.HealCode;
+import org.openecomp.core.utilities.json.JsonUtil;
+import org.openecomp.sdc.healing.api.HealingManager;
+import org.openecomp.sdc.common.errors.Messages;
+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 java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.util.Map;
+
+/**
+ * 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();
+
+ @Override
+ public Object heal(HealCode code, Map<String, Object> healParameters) {
+ String implClassName = healerCodeToImplClass.get(code.name());
+ try {
+ Healer healerImpl = getHealerImplInstance(implClassName);
+ return healerImpl.heal(healParameters);
+
+ } catch (Exception e) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(), LoggerErrorCode
+ .DATA_ERROR.getErrorCode(), LoggerErrorDescription.CANT_HEAL);
+ throw new RuntimeException(String.format(Messages.CANT_LOAD_CLASS.getErrorMessage(),
+ implClassName, e.getMessage()));
+ }
+ }
+
+ @Override
+ public void healAll(Map<String, Object> healParameters) {
+ for (String implClassName : healerCodeToImplClass.values()) {
+ try {
+ Healer healerImpl = getHealerImplInstance(implClassName);
+ healerImpl.heal(healParameters);
+ } catch (Exception e) {
+ MdcDataErrorMessage.createErrorMessageAndUpdateMdc(LoggerConstants.TARGET_ENTITY_DB,
+ LoggerTragetServiceName.SELF_HEALING, ErrorLevel.ERROR.name(), LoggerErrorCode
+ .DATA_ERROR.getErrorCode(), LoggerErrorDescription.CANT_HEAL);
+ throw new RuntimeException(String.format(Messages.CANT_LOAD_CLASS.getErrorMessage(),
+ implClassName, e.getMessage()));
+ }
+ }
+ }
+
+ private static Map<String, String> initHealers() {
+ InputStream healingConfigurationJson = FileUtils.getFileInputStream(HEALING_CONF_FILE);
+ return JsonUtil.json2Object(healingConfigurationJson, Map.class);
+ }
+
+ private Healer getHealerImplInstance(String implClassName)
+ throws ClassNotFoundException, NoSuchMethodException, InstantiationException,
+ IllegalAccessException, java.lang.reflect.InvocationTargetException {
+ Class<?> clazz = Class.forName(implClassName);
+ Constructor<?> constructor = clazz.getConstructor();
+ return (Healer) constructor.newInstance();
+ }
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingConfiguration.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingConfiguration.java
new file mode 100644
index 0000000000..7767277444
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingConfiguration.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.healing.utils;
+
+/**
+ * Created by Talio on 11/29/2016.
+ */
+public class HealingConfiguration {
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingUtil.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingUtil.java
new file mode 100644
index 0000000000..e955c83b79
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/utils/HealingUtil.java
@@ -0,0 +1,27 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.healing.utils;
+
+/**
+ * Created by Talio on 11/29/2016.
+ */
+public class HealingUtil {
+}
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
new file mode 100644
index 0000000000..23427ceb6a
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/resources/healingConfiguration.json
@@ -0,0 +1,7 @@
+{
+ "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",
+ "HEAT_TOSCA_TRANSLATION_HEALER" : "org.openecomp.sdc.healing.healers.HeatToToscaTranslationHealer"
+} \ 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
new file mode 100644
index 0000000000..70d40be2a6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-healing-impl</artifactId>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-healing-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-healing-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-core</artifactId>
+ <version>${project.version}</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml.versionsBackup
new file mode 100644
index 0000000000..c5f936366b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/pom.xml.versionsBackup
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <dependencies>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-healing-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-vendor-software-product-core</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-healing-lib</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-healing-impl</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+
+</project> \ No newline at end of file
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
new file mode 100644
index 0000000000..283f6c83b6
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
@@ -0,0 +1,224 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.healing.healers;
+
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.core.model.dao.ServiceModelDao;
+import org.openecomp.core.model.dao.ServiceModelDaoFactory;
+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.json.JsonUtil;
+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.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel;
+import org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+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.OrchestrationTemplateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+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.factory.CompositionDataExtractorFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.factory.CompositionEntityDataManagerFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionDataExtractor;
+import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData;
+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;
+
+public class CompositionDataHealer implements Healer {
+ private static final Version VERSION00 = new Version(0, 0);
+ private static final Version VERSION01 = new Version(0, 1);
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ private static final OrchestrationTemplateDao orchestrationTemplateDataDao =
+ OrchestrationTemplateDaoFactory.getInstance().createInterface();
+
+ private static ComponentDao componentDao = ComponentDaoFactory.getInstance().createInterface();
+ private static NicDao nicDao = NicDaoFactory.getInstance().createInterface();
+ private static NetworkDao networkDao = NetworkDaoFactory.getInstance().createInterface();
+
+ private static final ServiceModelDao<ToscaServiceModel, ServiceElement> serviceModelDao =
+ ServiceModelDaoFactory.getInstance().createInterface();
+ private static CompositionDataExtractor compositionDataExtractor =
+ CompositionDataExtractorFactory.getInstance().createInterface();
+ private static CompositionEntityDataManager compositionEntityDataManager =
+ CompositionEntityDataManagerFactory.getInstance().createInterface();
+
+ public CompositionDataHealer() {
+ }
+
+ @Override
+ public Optional<CompositionData> heal(Map<String, Object> healingParams) 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);
+ Collection<NetworkEntity> networkEntities =
+ networkDao.list(new NetworkEntity(vspId, version, null));
+
+ Optional<ToscaServiceModel> serviceModelForHealing = getServiceModelForHealing(vspId, version);
+
+ if (!doesVspNeedCompositionDataHealing(componentEntities, networkEntities,
+ nicEntities)) {
+ updateComponentsDisplayNames(componentEntities);
+ mdcDataDebugMessage.debugExitMessage(null);
+ return Optional.empty();
+ }
+
+
+ if (!serviceModelForHealing.isPresent()) {
+ mdcDataDebugMessage.debugExitMessage(null);
+ return Optional.empty();
+ }
+
+ CompositionData compositionData = healCompositionData(vspId, version, serviceModelForHealing);
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return Optional.of(compositionData);
+ }
+
+ private CompositionData healCompositionData(String vspId, Version version,
+ Optional<ToscaServiceModel> serviceModelForHealing) {
+ ToscaServiceModel toscaServiceModel = serviceModelForHealing.get();
+ CompositionData compositionData =
+ getCompositionDataForHealing(vspId, version, toscaServiceModel);
+ compositionEntityDataManager.saveCompositionData(vspId, version, compositionData);
+ return compositionData;
+ }
+
+ private boolean doesVspNeedCompositionDataHealing(Collection<ComponentEntity> componentEntities,
+ Collection<NetworkEntity> networkEntities,
+ Collection<NicEntity> nicEntities) {
+
+ return (CollectionUtils.isEmpty(componentEntities) && CollectionUtils.isEmpty(nicEntities) &&
+ CollectionUtils.isEmpty(networkEntities));
+ }
+
+ private CompositionData getCompositionDataForHealing(String vspId, Version version,
+ ToscaServiceModel toscaServiceModel) {
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ if (Objects.isNull(toscaServiceModel)) {
+ return null;
+ }
+
+ CompositionData compositionData = new CompositionData();
+ if (Objects.nonNull(toscaServiceModel)) {
+ compositionData = compositionDataExtractor
+ .extractServiceCompositionData(toscaServiceModel);
+ serviceModelDao.storeServiceModel(vspId, version, toscaServiceModel);
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return compositionData;
+ }
+
+ private void updateComponentsDisplayNames(Collection<ComponentEntity> componentEntities) {
+ if (CollectionUtils.isEmpty(componentEntities)) {
+ return;
+ }
+
+ for (ComponentEntity component : componentEntities) {
+ updateComponentName(component);
+ componentDao.update(component);
+ }
+ }
+
+ private void updateComponentName(ComponentEntity component) {
+ mdcDataDebugMessage.debugEntryMessage("VSP id, component id", component.getVspId(), component
+ .getId());
+
+ ComponentData componentData =
+ JsonUtil.json2Object(component.getCompositionData(), ComponentData.class);
+ componentData
+ .setDisplayName(compositionDataExtractor.getComponentDisplayName(componentData.getName()));
+ componentData.setVfcCode(componentData.getDisplayName());
+ component.setCompositionData(JsonUtil.object2Json(componentData));
+
+ mdcDataDebugMessage.debugExitMessage("VSP id, component id", component.getVspId(), component
+ .getId());
+
+ }
+
+ private Optional<ToscaServiceModel> getServiceModelForHealing(String vspId, Version version)
+ throws IOException {
+ mdcDataDebugMessage.debugEntryMessage("VSP id", vspId);
+
+ /*UploadDataEntity uploadData =
+ vendorSoftwareProductDao.getUploadData(new UploadDataEntity(vspId, version));*/
+ UploadDataEntity uploadData =
+ orchestrationTemplateDataDao.getOrchestrationTemplate(vspId, version);
+
+ if (Objects.isNull(uploadData) || Objects.isNull(uploadData.getContentData())) {
+ return Optional.empty();
+ }
+
+ TranslatorOutput translatorOutput = getTranslatorOutputForHealing(uploadData);
+
+ if (Objects.isNull(translatorOutput)) {
+ return Optional.empty();
+ }
+
+ try {
+ serviceModelDao.storeServiceModel(vspId, version,
+ translatorOutput.getToscaServiceModel());
+ }catch (Exception e){
+ return Optional.empty();
+ }
+
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+ return Optional.of(translatorOutput.getToscaServiceModel());
+ }
+
+ private TranslatorOutput getTranslatorOutputForHealing(UploadDataEntity uploadData){
+
+ FileContentHandler fileContentHandler;
+ try {
+ fileContentHandler =
+ CommonUtil.loadUploadFileContent(uploadData.getContentData().array());
+ return HeatToToscaUtil.loadAndTranslateTemplateData(fileContentHandler);
+ }catch (Exception e){
+ return null;
+ }
+ }
+}
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
new file mode 100644
index 0000000000..14fe885d53
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/FileDataStructureHealer.java
@@ -0,0 +1,116 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.healing.healers;
+
+import org.openecomp.core.utilities.file.FileContentHandler;
+import org.openecomp.core.utilities.json.JsonUtil;
+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.context.impl.MdcDataDebugMessage;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.OrchestrationTemplateDaoFactory;
+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();
+
+ public FileDataStructureHealer() {
+ }
+
+ @Override
+ public Optional<FilesDataStructure> heal(Map<String, Object> healingParams) 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);
+
+ UploadDataEntity uploadData =
+ orchestrationTemplateDataDao.getOrchestrationTemplate(vspId,version);
+ if (uploadData == null || uploadData.getContentData() == null) {
+ FilesDataStructure emptyFilesDataStructure = new FilesDataStructure();
+ return Optional.of(emptyFilesDataStructure);
+ }
+
+ Optional<FilesDataStructure> candidateFileDataStructure =
+ candidateService.getOrchestrationTemplateCandidateFileDataStructure(vspId, version);
+
+ if (!candidateFileDataStructure.isPresent()) {
+ healingResult = healFilesDataStructure(vspId, version, user, uploadData);
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return healingResult;
+ }
+
+ private Optional<FilesDataStructure> healFilesDataStructure(String vspId, Version version,
+ String user,
+ UploadDataEntity uploadData)
+ throws Exception {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ Optional<FilesDataStructure> healingResult;
+ byte[] byteContentData = uploadData.getContentData().array();
+ FileContentHandler fileContentHandler;
+ try{
+ fileContentHandler = CommonUtil.loadUploadFileContent(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){
+ return 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/HeatToToscaTranslationHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
new file mode 100644
index 0000000000..fb9dfe7e4f
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/HeatToToscaTranslationHealer.java
@@ -0,0 +1,82 @@
+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.sdc.common.utils.CommonUtil;
+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.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.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.UploadDataEntity;
+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 {
+
+ 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();
+
+ 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);
+
+ if (Objects.isNull(uploadData) || Objects.isNull(uploadData.getContentData())) {
+ return Optional.empty();
+ }
+
+ FileContentHandler fileContentHandler;
+ TranslatorOutput translatorOutput;
+ try {
+ fileContentHandler = CommonUtil.loadUploadFileContent(uploadData
+ .getContentData().array());
+ translatorOutput =
+ HeatToToscaUtil.loadAndTranslateTemplateData(fileContentHandler);
+ }catch (Exception e){
+ return Optional.empty();
+ }
+
+ if(Objects.isNull(translatorOutput)){
+ return Optional.empty();
+ }
+
+ if (translatorOutput != null && translatorOutput.getToscaServiceModel() == null) {
+ return Optional.empty();
+ }
+ //templateDao.deleteAll(vspId, version);
+ serviceModelDao.deleteAll(vspId,version);
+ serviceModelDao.storeServiceModel(vspId, version,
+ translatorOutput.getToscaServiceModel());
+ mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+
+ return translatorOutput;
+
+ }
+}
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
new file mode 100644
index 0000000000..4e8de71ea3
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java
@@ -0,0 +1,129 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+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;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+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;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.NicEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
+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();
+
+ @Override
+ public Object heal(Map<String, Object> healingParams) 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);
+
+ healCompositionEntityQuestionnaire(componentEntities, version, CompositionEntityType.component);
+ healCompositionEntityQuestionnaire(nicEntities, version, CompositionEntityType.nic);
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ return new Object();
+ }
+
+
+ private void healCompositionEntityQuestionnaire(Collection
+ compositionEntities,
+ Version newVersion, CompositionEntityType type) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ for (Object entity : compositionEntities) {
+ CompositionEntity compositionEntity = (CompositionEntity) entity;
+ if (Objects.isNull(compositionEntity.getQuestionnaireData())) {
+ compositionEntity.setVersion(newVersion);
+ updateNullQuestionnaire(compositionEntity, type);
+ }
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null);
+ }
+
+ private void updateNullQuestionnaire(CompositionEntity entity,
+ CompositionEntityType type) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null);
+
+ entity.setQuestionnaireData(
+ new JsonSchemaDataGenerator(SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, type,
+ null)).generateData());
+
+ switch (type) {
+ case component:
+ ComponentEntity component = (ComponentEntity) entity;
+ componentDao.updateQuestionnaireData(component.getVspId(), component
+ .getVersion(), component.getId(), component.getQuestionnaireData());
+ break;
+
+ case nic:
+ NicEntity nic = (NicEntity) entity;
+ nicDao.updateQuestionnaireData(nic.getVspId(), nic.getVersion(), nic.getComponentId(),
+ nic.getId(), nic.getQuestionnaireData());
+ break;
+ }
+ mdcDataDebugMessage.debugExitMessage(null);
+ }
+
+}
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
new file mode 100644
index 0000000000..4d2b26df8b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VspQuestionnaireHealer.java
@@ -0,0 +1,88 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+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.VendorSoftwareProductDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductInfoDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
+import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
+import org.openecomp.sdc.vendorsoftwareproduct.types.schemagenerator.SchemaTemplateContext;
+import org.openecomp.sdc.versioning.dao.types.Version;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+
+public class VspQuestionnaireHealer implements Healer {
+ private static final VendorSoftwareProductInfoDao vspInfoDao =
+ VendorSoftwareProductInfoDaoFactory.getInstance().createInterface();
+ private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+
+ public VspQuestionnaireHealer() {
+ }
+
+ @Override
+ public Object heal(Map<String, Object> healingParams) 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);
+
+ if(Objects.isNull(vspQuestionnaireEntity.getQuestionnaireData())) {
+ questionnaireData = healQuestionnaire(vspId, version);
+ }
+
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return questionnaireData;
+ }
+
+ private Optional<String> healQuestionnaire(String vspId, Version version) {
+
+
+ mdcDataDebugMessage.debugEntryMessage(null, null);
+
+ String questionnaireData;
+ String generatedSchema = SchemaGenerator
+ .generate(SchemaTemplateContext.questionnaire, CompositionEntityType.vsp, null);
+ try {
+ questionnaireData = new JsonSchemaDataGenerator(generatedSchema).generateData();
+ vspInfoDao.updateQuestionnaireData(vspId, version, questionnaireData);
+ }catch(Exception e){
+ return Optional.empty();
+ }
+ mdcDataDebugMessage.debugExitMessage(null, null);
+ return Optional.of(questionnaireData);
+ }
+}
diff --git a/openecomp-be/lib/openecomp-healing-lib/pom.xml b/openecomp-be/lib/openecomp-healing-lib/pom.xml
new file mode 100644
index 0000000000..76f2fdf784
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/pom.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-healing-lib</artifactId>
+ <packaging>pom</packaging>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+
+ <modules>
+ <module>openecomp-sdc-healing-api</module>
+ <module>openecomp-sdc-healing-core</module>
+ <module>openecomp-sdc-healing-impl</module>
+ </modules>
+</project>
diff --git a/openecomp-be/lib/openecomp-healing-lib/pom.xml.versionsBackup b/openecomp-be/lib/openecomp-healing-lib/pom.xml.versionsBackup
new file mode 100644
index 0000000000..02ba7f140b
--- /dev/null
+++ b/openecomp-be/lib/openecomp-healing-lib/pom.xml.versionsBackup
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-sdc-lib</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.openecomp.sdc</groupId>
+ <artifactId>openecomp-healing-lib</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>openecomp-sdc-healing-api</module>
+ <module>openecomp-sdc-healing-core</module>
+ <module>openecomp-sdc-healing-impl</module>
+ </modules>
+</project> \ No newline at end of file