From a63ba175e7dfe7744f4ae36036f53bdd21d25fa4 Mon Sep 17 00:00:00 2001 From: JvD_Ericsson Date: Tue, 28 Feb 2023 16:19:36 +0000 Subject: Operation implementation name not formatting correctly Issue-ID: SDC-4421 Signed-off-by: JvD_Ericsson Change-Id: I6699029dff4e78760163d01691b6a1964aacbc0e --- .../ComponentInterfaceOperationBusinessLogic.java | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'catalog-be/src/main/java/org') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java index 8a2ab8924e..3ac8ce3562 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInterfaceOperationBusinessLogic.java @@ -18,8 +18,11 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ + package org.openecomp.sdc.be.components.impl; +import static org.openecomp.sdc.be.components.impl.ImportUtils.Constants.QUOTE; + import com.google.common.reflect.TypeToken; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -64,6 +67,7 @@ import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus; import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation; import org.openecomp.sdc.be.model.operations.impl.PropertyOperation; import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder; +import org.openecomp.sdc.be.tosca.utils.OperationArtifactUtil; import org.openecomp.sdc.be.user.Role; import org.openecomp.sdc.common.datastructure.Wrapper; import org.openecomp.sdc.exception.ResponseFormat; @@ -204,14 +208,14 @@ public class ComponentInterfaceOperationBusinessLogic extends BaseBusinessLogic return componentInstanceOptional; } - private Either validateOperationInputConstraints ( + private Either validateOperationInputConstraints( OperationDataDefinition operationDataDefinition, PropertyValueConstraintValidationUtil constraintValidatorUtil, String model) { return constraintValidatorUtil .validatePropertyConstraints(convertOperationInputsToPropertyDefinitions(operationDataDefinition), applicationDataTypeCache, model); } - private Either validateOperationArtifactPropertyConstraints ( + private Either validateOperationArtifactPropertyConstraints( OperationDataDefinition operationDataDefinition, PropertyValueConstraintValidationUtil constraintValidatorUtil, String model) { return constraintValidatorUtil .validatePropertyConstraints(convertOperationArtifactPropsToPropertyDefinitions(operationDataDefinition, model), applicationDataTypeCache, @@ -330,6 +334,8 @@ public class ComponentInterfaceOperationBusinessLogic extends BaseBusinessLogic final OperationDataDefinition updatedOperationDataDefinition = optionalOperationDataDefinition.get(); updatedOperationDataDefinition.setUniqueId(UUID.randomUUID().toString()); + updatedOperationDataDefinition.getImplementation() + .setArtifactName(generateArtifactName(updatedOperationDataDefinition.getImplementation().getArtifactName())); final InterfaceDefinition interfaceDefinitionFound = componentInterfaceMap.get(componentInterfaceUpdatedKey); if (interfaceDefinitionFound != null) { @@ -381,6 +387,14 @@ public class ComponentInterfaceOperationBusinessLogic extends BaseBusinessLogic return Optional.of(component); } + private String generateArtifactName(final String name) { + if (OperationArtifactUtil.artifactNameIsALiteralValue(name)) { + return name; + } else { + return QUOTE + name + QUOTE; + } + } + public User validateUser(final String userId) { final User user = userValidations.validateUserExists(userId); userValidations.validateUserRole(user, Arrays.asList(Role.DESIGNER, Role.ADMIN)); @@ -418,7 +432,7 @@ public class ComponentInterfaceOperationBusinessLogic extends BaseBusinessLogic } private List convertOperationArtifactPropsToPropertyDefinitions(final OperationDataDefinition operationDataDefinition, - final String model) { + final String model) { List artifactPropertiesToValidateCollection = new ArrayList<>(); final ArtifactDataDefinition artifactDataDefinition = operationDataDefinition.getImplementation(); if (null != artifactDataDefinition) { -- cgit 1.2.3-korg