aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-api/src/main/java/org/openecomp/core/model/errors/RetrieveServiceTemplateFromDbErrorBuilder.java18
-rw-r--r--openecomp-be/lib/openecomp-sdc-model-lib/openecomp-sdc-model-impl/src/main/java/org/openecomp/sdc/model/impl/zusammen/ServiceModelDaoZusammenImpl.java12
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());
}
}