From 53df976426f8845adf58e8ff9355764343a38549 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Wed, 16 Jun 2021 23:21:04 +0100 Subject: Specify model at service creation Allows a user to select a model when designing a service Issue-ID: SDC-3621 Signed-off-by: aribeiro Change-Id: I386e43ddeb649a4ba0805f153e4b47e8a528cff0 --- .../java/org/openecomp/sdc/be/components/impl/ModelBusinessLogic.java | 2 +- .../openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java | 3 +++ .../org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java | 1 + .../main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java | 2 ++ 4 files changed, 7 insertions(+), 1 deletion(-) (limited to 'catalog-be/src/main/java/org/openecomp') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogic.java index 6eb806d3d1..de79ec165d 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ModelBusinessLogic.java @@ -50,7 +50,7 @@ public class ModelBusinessLogic { } public Model createModel(final Model model) { - LOGGER.debug("createModel: creating model {}", model); + LOGGER.debug("creating model {}", model); return modelOperation.createModel(model, false); } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java index 2956abfe1b..c0c68d6c47 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java @@ -2451,6 +2451,9 @@ public class ServiceImportBusinessLogic { if (CollectionUtils.isEmpty(newResource.getProperties())) { newResource.setProperties(oldResource.getProperties()); } + if (newResource.getModel() == null) { + newResource.setModel(oldResource.getModel()); + } } protected Map createResourcesFromYamlNodeTypesList(String yamlName, Service service, Map mappedToscaTemplate, diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java index 706f7a7304..32a63dcc46 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java @@ -445,6 +445,7 @@ public class UiComponentDataConverter { dataTransfer.setMetadata(metadata); dataTransfer.setDerivedFromGenericType(service.getDerivedFromGenericType()); dataTransfer.setDerivedFromGenericVersion(service.getDerivedFromGenericVersion()); + dataTransfer.setModel(service.getModel()); break; case NODE_FILTER: if (service.getNodeFilterComponents() == null) { diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java index bdc9ffce43..e7966e0d08 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ResourceUploadServlet.java @@ -123,6 +123,7 @@ public class ResourceUploadServlet extends AbstractValidationsServlet { commonGeneralValidations(responseWrapper, userWrapper, uploadResourceInfoWrapper, resourceAuthorityEnum, userId, resourceInfoJsonString); final String modelNameToBeAssociated = uploadResourceInfoWrapper.getInnerElement().getModel(); if (modelNameToBeAssociated != null) { + log.debug("Model Name to be validated {}", modelNameToBeAssociated); validateModel(modelNameToBeAssociated); } fillPayload(responseWrapper, uploadResourceInfoWrapper, yamlStringWrapper, userWrapper.getInnerElement(), resourceInfoJsonString, @@ -155,6 +156,7 @@ public class ResourceUploadServlet extends AbstractValidationsServlet { */ private void validateModel(final String modelName) { if (modelBusinessLogic.findModel(modelName).isEmpty()) { + log.error("Could not find model name {}", modelName); throw ModelOperationExceptionSupplier.invalidModel(modelName).get(); } } -- cgit 1.2.3-korg