summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java20
-rw-r--r--openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java2
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-api/src/main/java/org/openecomp/sdc/healing/api/HealingManager.java3
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-core/src/main/java/org/openecomp/sdc/healing/impl/HealingManagerImpl.java72
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/SubEntitiesQuestionnaireHealer.java7
-rw-r--r--openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java21
6 files changed, 80 insertions, 45 deletions
diff --git a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
index 78c4cbf5d9..c9f4159a4e 100644
--- a/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
+++ b/openecomp-be/backend/openecomp-sdc-vendor-software-product-manager/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/impl/VendorSoftwareProductManagerImpl.java
@@ -38,6 +38,7 @@ import org.openecomp.core.validation.util.MessageContainerUtil;
import org.openecomp.sdc.activityLog.ActivityLogManager;
import org.openecomp.sdc.activitylog.dao.type.ActivityLogEntity;
import org.openecomp.sdc.common.errors.CoreException;
+import org.openecomp.sdc.common.errors.ErrorCategory;
import org.openecomp.sdc.common.errors.ErrorCode;
import org.openecomp.sdc.common.errors.ValidationErrorBuilder;
import org.openecomp.sdc.common.utils.CommonUtil;
@@ -136,6 +137,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Optional;
import java.util.Set;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@@ -850,7 +852,8 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
: checkout(vspId, user);
version.setStatus(VersionStatus.Locked);
- healingManager.healAll(getHealingParamsAsMap(vspId, version, user));
+ Optional<String> errorMessages =
+ healingManager.healAll(getHealingParamsAsMap(vspId, version, user));
VspDetails vspDetails = new VspDetails(vspId, version);
vspDetails.setOldVersion(null);
@@ -858,6 +861,11 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
logger.audit("Healed VSP " + vspDetails.getId());
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+
+ if (errorMessages.isPresent()) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId("HEALING_ERROR")
+ .withCategory(ErrorCategory.APPLICATION).withMessage(errorMessages.get()).build());
+ }
}
private void autoHeal(String vspId, Version checkoutVersion, VspDetails vspDetails, String user) {
@@ -865,14 +873,20 @@ public class VendorSoftwareProductManagerImpl implements VendorSoftwareProductMa
checkoutVersion.setStatus(VersionStatus.Locked);
Map<String, Object> healingParams = getHealingParamsAsMap(vspId, checkoutVersion, user);
- healingManager.healAll(healingParams);
+
+ Optional<String> errorMessages = healingManager.healAll(healingParams);
+
vspDetails.setVersion(checkoutVersion);
vspDetails.setOldVersion(null);
vspInfoDao.updateOldVersionIndication(vspDetails);
logger.audit("Healed VSP " + vspDetails.getName());
-
mdcDataDebugMessage.debugExitMessage("VSP id", vspId);
+
+ if (errorMessages.isPresent()) {
+ throw new CoreException(new ErrorCode.ErrorCodeBuilder().withId("HEALING_ERROR")
+ .withCategory(ErrorCategory.APPLICATION).withMessage(errorMessages.get()).build());
+ }
}
private Map<String, Object> getHealingParamsAsMap(String vspId, Version version, String user) {
diff --git a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
index 8bcb0a5ffe..72ad3335a4 100644
--- a/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
+++ b/openecomp-be/lib/openecomp-common-lib/src/main/java/org/openecomp/sdc/common/errors/Messages.java
@@ -22,7 +22,7 @@ package org.openecomp.sdc.common.errors;
public enum Messages {
- CANT_LOAD_CLASS("Can't load class %s. Error: %s"),
+ CANT_LOAD_HEALING_CLASS("Can't load healing class %s."),
VERSION_UPGRADE("Item %s is of old version. A check out was made in order to get new " +
"functionalities"),
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 a2ce153a82..211d9a21b2 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
@@ -23,6 +23,7 @@ package org.openecomp.sdc.healing.api;
import org.openecomp.sdc.healing.types.HealCode;
import java.util.Map;
+import java.util.Optional;
/**
* Created by Talio on 11/29/2016.
@@ -30,5 +31,5 @@ import java.util.Map;
public interface HealingManager {
Object heal(HealCode code, Map<String, Object> healParameters);
- void healAll(Map<String, Object> healParameters);
+ Optional<String> healAll(Map<String, Object> healParameters);
}
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 0f2c0e7ee1..16f9c60d7f 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
@@ -20,6 +20,7 @@
package org.openecomp.sdc.healing.impl;
+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;
@@ -33,8 +34,10 @@ import org.openecomp.sdc.logging.types.LoggerErrorCode;
import org.openecomp.sdc.logging.types.LoggerErrorDescription;
import org.openecomp.sdc.logging.types.LoggerTragetServiceName;
-import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
import java.util.Map;
+import java.util.Optional;
/**
* Created by Talio on 11/29/2016.
@@ -45,34 +48,53 @@ public class HealingManagerImpl implements HealingManager {
@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);
+ ArrayList<String> healingFailureMessages = new ArrayList<>();
+
+ Object result =
+ heal(healParameters, healerCodeToImplClass.get(code.name()), healingFailureMessages);
+
+ if (!healingFailureMessages.isEmpty()) {
+ throw new RuntimeException(CommonMethods.listToSeparatedString(healingFailureMessages, '\n'));
+ }
+ return result;
+ }
+ @Override
+ public Optional<String> healAll(Map<String, Object> healParameters) {
+ ArrayList<String> healingFailureMessages = new ArrayList<>();
+
+ for (String implClassName : healerCodeToImplClass.values()) {
+ heal(healParameters, implClassName, healingFailureMessages);
+ }
+
+ 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;
+ try {
+ healerImpl = getHealerImplInstance(healerImplClassName);
} 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()));
+ healingFailureMessages
+ .add(String.format(Messages.CANT_LOAD_HEALING_CLASS.getErrorMessage(),
+ healerImplClassName));
+ return null;
}
- }
- @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()));
- }
+ try {
+ 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);
+ healingFailureMessages.add(e.getMessage());
}
+ return null;
}
private static Map<String, String> initHealers() {
@@ -80,10 +102,8 @@ public class HealingManagerImpl implements HealingManager {
}
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();
+ throws InstantiationException, IllegalAccessException, InvocationTargetException,
+ NoSuchMethodException, ClassNotFoundException {
+ return (Healer) Class.forName(implClassName).getConstructor().newInstance();
}
}
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 4e8de71ea3..130405be1d 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
@@ -67,9 +67,9 @@ public class SubEntitiesQuestionnaireHealer implements Healer {
: (Version) healingParams.get(SdcCommon.VERSION);
Collection<ComponentEntity> componentEntities =
-
componentDao.listCompositionAndQuestionnaire(vspId, version);
- networkDao.list(new NetworkEntity(vspId, version,null));
+
+ networkDao.list(new NetworkEntity(vspId, version, null));
Collection<NicEntity> nicEntities = vendorSoftwareProductDao.listNicsByVsp(vspId, version);
@@ -90,7 +90,8 @@ public class SubEntitiesQuestionnaireHealer implements Healer {
for (Object entity : compositionEntities) {
CompositionEntity compositionEntity = (CompositionEntity) entity;
- if (Objects.isNull(compositionEntity.getQuestionnaireData())) {
+ if (Objects.isNull(compositionEntity.getQuestionnaireData()) ||
+ "".equals(compositionEntity.getQuestionnaireData())) {
compositionEntity.setVersion(newVersion);
updateNullQuestionnaire(compositionEntity, type);
}
diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java
index c76b15d221..fffcc47932 100644
--- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/composition/CompositionEntityDataManagerImpl.java
@@ -51,14 +51,12 @@ import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspQuestionnaireEntity;
import org.openecomp.sdc.vendorsoftwareproduct.services.composition.CompositionEntityDataManager;
import org.openecomp.sdc.vendorsoftwareproduct.services.schemagenerator.SchemaGenerator;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Component;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentComputeAssociation;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComponentData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityId;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityType;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.CompositionEntityValidationData;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.ComputeData;
-import org.openecomp.sdc.vendorsoftwareproduct.types.composition.DeploymentFlavor;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Image;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.Network;
import org.openecomp.sdc.vendorsoftwareproduct.types.composition.NetworkType;
@@ -69,6 +67,7 @@ import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -82,6 +81,8 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
"COMPOSITION_ENTITY_DATA_MANAGER_ERR";
private static final String COMPOSITION_ENTITY_DATA_MANAGER_ERR_MSG =
"Invalid input: %s may not be null";
+ private static final String MISSING_OR_INVALID_QUESTIONNAIRE_MSG =
+ "Data is missing/invalid for this %s. Please refill and resubmit.";
private static final Logger logger =
LoggerFactory.getLogger(CompositionEntityDataManagerImpl.class);
@@ -105,7 +106,7 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
NicDao nicDao, NetworkDao networkDao,
ImageDao imageDao, ComputeDao computeDao,
DeploymentFlavorDao deploymentFlavorDao,
- VendorSoftwareProductDao vendorSoftwareProductDao ) {
+ VendorSoftwareProductDao vendorSoftwareProductDao) {
this.vspInfoDao = vspInfoDao;
this.componentDao = componentDao;
this.nicDao = nicDao;
@@ -588,12 +589,10 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
compositionEntityData.entity.getCompositionEntityId().toString(),
compositionEntityData.entity.getQuestionnaireData()));
- if(Objects.isNull(compositionEntityData.entity.getQuestionnaireData()) || !JsonUtil.isValidJson
- (compositionEntityData.entity.getQuestionnaireData())){
- List<String> errors = new ArrayList<>();
- errors.add("Data is missing for the above " + compositionEntityData.entity.getType() +
- ". Complete the mandatory fields and resubmit.");
- return errors;
+ if (Objects.isNull(compositionEntityData.entity.getQuestionnaireData()) ||
+ !JsonUtil.isValidJson(compositionEntityData.entity.getQuestionnaireData())) {
+ return Collections.singletonList(String
+ .format(MISSING_OR_INVALID_QUESTIONNAIRE_MSG, compositionEntityData.entity.getType()));
}
return JsonUtil.validate(
@@ -677,8 +676,8 @@ public class CompositionEntityDataManagerImpl implements CompositionEntityDataMa
return compute;
}
- public void saveComputesFlavorByComponent(String vspId, Version version, Component component, String
- componentId) {
+ public void saveComputesFlavorByComponent(String vspId, Version version, Component component,
+ String componentId) {
if (CollectionUtils.isNotEmpty(component.getCompute())) {
for (ComputeData flavor : component.getCompute()) {
ComputeEntity computeEntity = new ComputeEntity(vspId, version, componentId, null);