diff options
author | talio <tali.orenbach@amdocs.com> | 2017-11-21 09:53:17 +0200 |
---|---|---|
committer | Avi Gaffa <avi.gaffa@amdocs.com> | 2017-11-21 09:22:17 +0000 |
commit | 15dfe1e9a127bc73f671b9601d8b8c8e25c2d65f (patch) | |
tree | 656c6b72380aecd1c4cb235eb53b47108031f306 | |
parent | 7bd878afa02d188e687a6958ae999807c2106392 (diff) |
invalid yaml exception
throw an invalid yaml exception if one of the retrieved service templates is corrupted, while submitting a VSP
Issue - Id : SDC-693
Change-Id: Icf37cf1aa847385ef118a1395b1afdfe99e9d79d
Signed-off-by: talio <tali.orenbach@amdocs.com>
2 files changed, 23 insertions, 7 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/errors/RetrieveServiceTemplateFromDbErrorBuilder.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/errors/RetrieveServiceTemplateFromDbErrorBuilder.java new file mode 100644 index 0000000000..f47eca3b50 --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/errors/RetrieveServiceTemplateFromDbErrorBuilder.java @@ -0,0 +1,18 @@ +package org.openecomp.core.model.errors; + +import org.openecomp.sdc.common.errors.BaseErrorBuilder; +import org.openecomp.sdc.common.errors.ErrorCategory; + +public class RetrieveServiceTemplateFromDbErrorBuilder extends BaseErrorBuilder { + private static final String CANT_RETRIEVE_SERVICE_TEMPLATE = "Could not retrirve service " + + "template named %s. Reason - %s"; + private static final String CREATE_SERVICE_TEMPLATE = "CREATE_SERVICE_TEMPLATE"; + + public RetrieveServiceTemplateFromDbErrorBuilder(String serviceTemplateName, + String reason){ + this.getErrorCodeBuilder() + .withCategory(ErrorCategory.APPLICATION) + .withId(CREATE_SERVICE_TEMPLATE) + .withMessage(String.format(CANT_RETRIEVE_SERVICE_TEMPLATE, serviceTemplateName, reason)); + } +} diff --git a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java index 88a1c756c9..b5e3627e61 100644 --- a/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java +++ b/openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java @@ -11,10 +11,12 @@ import com.amdocs.zusammen.datatypes.item.Info; import com.amdocs.zusammen.datatypes.item.ItemVersion; import org.apache.commons.io.IOUtils; import org.openecomp.core.model.dao.ServiceModelDao; +import org.openecomp.core.model.errors.RetrieveServiceTemplateFromDbErrorBuilder; import org.openecomp.core.model.types.ServiceElement; import org.openecomp.core.utilities.file.FileContentHandler; import org.openecomp.core.zusammen.api.ZusammenAdaptor; import org.openecomp.core.zusammen.api.ZusammenUtil; +import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; @@ -84,17 +86,12 @@ public class ServiceModelDaoZusammenImpl context, elementContext, serviceModelElementId, StructureElement.Templates.name()); if (templatesElementInfo.isPresent()) { - - //Map<String, ServiceTemplate> serviceTemplateMap = new HashMap<>(); Collection<Element> elements = zusammenAdaptor.listElementData(context, elementContext, templatesElementInfo.get().getId()); return elements.stream().collect(Collectors.toMap( element -> element.getInfo().getName(), this::elementToServiceTemplate)); - /*elements.stream().forEach(element ->serviceTemplateMap.put(element.getInfo().getName(), - elementToServiceTemplate(element))); - return serviceTemplateMap;*/ } return null; } @@ -186,8 +183,9 @@ public class ServiceModelDaoZusammenImpl return new ToscaExtensionYamlUtil(). yamlToObject(yamlContent, ServiceTemplate.class); }catch (Exception e){ - logger.debug("",e); - return null; + throw new CoreException( + new RetrieveServiceTemplateFromDbErrorBuilder( + element.getInfo().getName(), e.getMessage()).build()); } } |