summaryrefslogtreecommitdiffstats
path: root/catalog-be/src
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be/src')
-rw-r--r--catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java3
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java43
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java21
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java13
6 files changed, 50 insertions, 39 deletions
diff --git a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
index fe32ad0b22..ba2e58d6b8 100644
--- a/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
+++ b/catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml
@@ -2871,9 +2871,10 @@ errors:
messageId: "SVC4015"
}
+ # %1 - The input name
#---------SVC4016-----------------------------
INPUT_NAME_ALREADY_EXIST: {
code: 400,
- message: "Input name already exist.",
+ message: "Input name '%1' already exist.",
messageId: "SVC4016"
} \ No newline at end of file
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
index 5a6a7c91e4..e9d5c025cf 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java
@@ -196,6 +196,9 @@ public class YamlTemplateParsingHandler {
parsedToscaYamlInfo.setProperties(getProperties(loadYamlAsStrictMap(interfaceTemplateYaml)));
parsedToscaYamlInfo.setSubstitutionFilterProperties(getSubstitutionFilterProperties(mappedToscaTemplate));
}
+ if (substitutionMappings.get("properties") != null) {
+ parsedToscaYamlInfo.setSubstitutionMappingProperties((Map<String, List<String>>) substitutionMappings.get("properties"));
+ }
parsedToscaYamlInfo.setSubstitutionMappingNodeType((String) substitutionMappings.get(NODE_TYPE.getElementName()));
}
log.debug("#parseResourceInfoFromYAML - The yaml {} has been parsed ", fileName);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index b632abfcca..a24bce9837 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -38,6 +38,7 @@ import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
+import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
@@ -399,10 +400,10 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
try {
validateUserExists(userId);
component = getAndValidateComponentForCreate(userId, componentId, componentType, shouldLockComp);
- StorageOperationStatus status = validateInputName(component, componentInstInputsMapUi);
- if (status != StorageOperationStatus.OK) {
+ ImmutablePair<StorageOperationStatus, String> status = validateInputName(component, componentInstInputsMapUi);
+ if (status.getLeft() != StorageOperationStatus.OK) {
log.debug("Input name already exist");
- throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.INPUT_NAME_ALREADY_EXIST));
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.INPUT_NAME_ALREADY_EXIST, status.getRight()));
}
result = propertyDeclarationOrchestrator.declarePropertiesToInputs(component, componentInstInputsMapUi).left()
.bind(inputsToCreate -> prepareInputsForCreation(userId, componentId, inputsToCreate)).right()
@@ -429,29 +430,27 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
}
- private StorageOperationStatus validateInputName(final Component component, final ComponentInstInputsMap componentInstInputsMap) {
- AtomicReference<StorageOperationStatus> storageOperationStatus = new AtomicReference<>(StorageOperationStatus.OK);
- Map<String, List<ComponentInstancePropInput>> inputDeclaredProperties = new HashMap<>();
+ private ImmutablePair<StorageOperationStatus, String> validateInputName(final Component component,
+ final ComponentInstInputsMap componentInstInputsMap) {
+ final Map<String, List<ComponentInstancePropInput>> inputDeclaredProperties = new HashMap<>();
if (MapUtils.isNotEmpty(componentInstInputsMap.getComponentInstanceProperties())) {
- inputDeclaredProperties = componentInstInputsMap.getComponentInstanceProperties();
+ inputDeclaredProperties.putAll(componentInstInputsMap.getComponentInstanceProperties());
} else if (MapUtils.isNotEmpty(componentInstInputsMap.getServiceProperties())) {
- inputDeclaredProperties = componentInstInputsMap.getServiceProperties();
+ inputDeclaredProperties.putAll(componentInstInputsMap.getServiceProperties());
}
-
if (MapUtils.isNotEmpty(inputDeclaredProperties) && CollectionUtils.isNotEmpty(component.getInputs())) {
- inputDeclaredProperties.values()
- .forEach(componentInstancePropInputs ->
- componentInstancePropInputs
- .forEach(componentInstancePropInput -> component.getInputs()
- .forEach(existingInput -> {
- if (existingInput.getName().equals(componentInstancePropInput.getInputName())) {
- storageOperationStatus.set(StorageOperationStatus.INVALID_VALUE);
- }
- })
- )
- );
- }
- return storageOperationStatus.get();
+ for (final List<ComponentInstancePropInput> componentInstancePropInputs : inputDeclaredProperties.values()) {
+ for (final ComponentInstancePropInput componentInstancePropInput : componentInstancePropInputs) {
+ final Optional<InputDefinition> inputDefinition = component.getInputs().stream()
+ .filter(input -> input.getName().equals(componentInstancePropInput.getInputName())
+ || input.getName().equals(componentInstancePropInput.getName())).findAny();
+ if (inputDefinition.isPresent()) {
+ return new ImmutablePair<>(StorageOperationStatus.INVALID_VALUE, inputDefinition.get().getName());
+ }
+ }
+ }
+ }
+ return new ImmutablePair<>(StorageOperationStatus.OK, StringUtils.EMPTY);
}
/**
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 b3f1d57a60..ca8a13dba3 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
@@ -736,7 +736,7 @@ public class ServiceImportBusinessLogic {
throw new ComponentException(createArtifactsEither.right().value());
}
service = serviceImportParseLogic.getServiceWithGroups(createArtifactsEither.left().value().getUniqueId());
- service = updateInputs(service, userId);
+ service = updateInputs(service, userId, parsedToscaYamlInfo.getSubstitutionMappingProperties());
ASDCKpiApi.countCreatedResourcesKPI();
return service;
@@ -758,7 +758,7 @@ public class ServiceImportBusinessLogic {
}
}
- private Service updateInputs(final Service component, final String userId) {
+ private Service updateInputs(final Service component, final String userId, final Map<String, List<String>> substitutionMappingProperties) {
final List<InputDefinition> inputs = component.getInputs();
if (CollectionUtils.isNotEmpty(inputs)) {
final List<ComponentInstance> componentInstances = component.getComponentInstances();
@@ -767,7 +767,7 @@ public class ServiceImportBusinessLogic {
if (isInputFromComponentInstanceProperty(input.getName(), componentInstances)) {
associateInputToComponentInstanceProperty(userId, input, componentInstances, componentUniqueId);
} else {
- associateInputToServiceProperty(userId, input, component);
+ associateInputToServiceProperty(userId, input, component, substitutionMappingProperties);
}
}
@@ -836,11 +836,18 @@ public class ServiceImportBusinessLogic {
}
private void associateInputToServiceProperty(final String userId,
- final InputDefinition input, final Service component) {
+ final InputDefinition input, final Service component,
+ final Map<String, List<String>> substitutionMappingProperties) {
final List<PropertyDefinition> properties = component.getProperties();
- if (CollectionUtils.isNotEmpty(properties)) {
- final String propertyNameFromInput = input.getName();
- final Optional<PropertyDefinition> propDefOptional = properties.stream().filter(prop -> prop.getName().equals(propertyNameFromInput))
+ if (CollectionUtils.isNotEmpty(properties) && MapUtils.isNotEmpty(substitutionMappingProperties)) {
+ AtomicReference<String> propertyNameFromInput = new AtomicReference<>(" ");
+ substitutionMappingProperties.entrySet().forEach(stringEntry -> {
+ if (stringEntry.getValue().get(0).equals(input.getName())) {
+ propertyNameFromInput.set(stringEntry.getKey());
+ }
+ });
+
+ final Optional<PropertyDefinition> propDefOptional = properties.stream().filter(prop -> prop.getName().equals(propertyNameFromInput.get()))
.findFirst();
if (propDefOptional.isPresent()) {
// From SELF
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java
index 31a27b0457..339238f3fc 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java
@@ -274,7 +274,11 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
String[] propName = {propInput.getName()};
declaredInputName = handleInputName(inputName, propName);
}
- return declaredInputName;
+ return validateDeclaredInputName(declaredInputName);
+ }
+
+ private String validateDeclaredInputName(String inputName) {
+ return inputName.replace("::", "_");
}
private String handleInputName(String inputName, String[] parsedPropNames) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 186bcd2987..de35bcf889 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -817,7 +817,7 @@ public class ToscaExportHandler {
ToscaTemplate toscaNode, Map<String, ToscaNodeType> nodeTypes,
boolean isAssociatedComponent) {
log.debug("start convert node type for {}", component.getUniqueId());
- ToscaNodeType toscaNodeType = createNodeType(component);
+ ToscaNodeType toscaNodeType = createNodeType(component);
Either<Map<String, InterfaceDefinition>, StorageOperationStatus> lifecycleTypeEither = interfaceLifecycleOperation
.getAllInterfaceLifecycleTypes(component.getModel());
if (lifecycleTypeEither.isRight() && !StorageOperationStatus.NOT_FOUND.equals(lifecycleTypeEither.right().value())) {
@@ -835,24 +835,21 @@ public class ToscaExportHandler {
return Either.right(ToscaError.GENERAL_ERROR);
}
Map<String, DataTypeDefinition> dataTypes = dataTypesEither.left().value();
- List<InputDefinition> inputDef = component.getInputs();
interfacesOperationsConverter.addInterfaceDefinitionElement(component, toscaNodeType, dataTypes, isAssociatedComponent);
final var toscaAttributeMap = convertToToscaAttributes(component.getAttributes(), dataTypes);
if (!toscaAttributeMap.isEmpty()) {
toscaNodeType.setAttributes(toscaAttributeMap);
}
- final var mergedProperties = convertInputsToProperties(dataTypes, inputDef, component.getUniqueId());
+ Map<String, ToscaProperty> convertedProperties = new HashMap();
if (CollectionUtils.isNotEmpty(component.getProperties())) {
List<PropertyDefinition> properties = component.getProperties();
- Map<String, ToscaProperty> convertedProperties = properties.stream()
+ convertedProperties = properties.stream()
.map(propertyDefinition -> resolvePropertyValueFromInput(propertyDefinition, component.getInputs())).collect(Collectors
.toMap(PropertyDataDefinition::getName,
property -> propertyConvertor.convertProperty(dataTypes, property, PropertyConvertor.PropertyType.PROPERTY)));
- // merge component properties and inputs properties
- mergedProperties.putAll(convertedProperties);
}
- if (MapUtils.isNotEmpty(mergedProperties)) {
- toscaNodeType.setProperties(mergedProperties);
+ if (MapUtils.isNotEmpty(convertedProperties)) {
+ toscaNodeType.setProperties(convertedProperties);
}
/* convert private data_types */
List<DataTypeDefinition> privateDataTypes = component.getDataTypes();