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.yaml8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java31
3 files changed, 46 insertions, 1 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 c5b417d725..4d26e08831 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
@@ -2926,3 +2926,11 @@ errors:
message: "Error: The following properties:\n%1\nused in the substitution mapping node type in CSAR are missing from the system. Please add these to the node in the SDC catalog prior to importing the template",
messageId: "SVC4021"
}
+
+ # %1 - Output name
+ #---------SVC4022-----------------------------
+ OUTPUT_NAME_ALREADY_EXIST: {
+ code: 400,
+ message: "Output name '%1' already exist.",
+ messageId: "SVC4022"
+ }
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java
index 394d6b314b..e494934d4d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/attribute/DefaultAttributeDeclarator.java
@@ -119,7 +119,13 @@ public abstract class DefaultAttributeDeclarator<PROPERTYOWNER extends Propertie
//Creating input from property create on self using add property..Do not add the prefix
generatedInputPrefix = null;
}
- final String generatedOutputName = generateOutputName(generatedInputPrefix, attribOutput);
+ String generatedOutputName = null;
+ if (StringUtils.isNotEmpty(attribOutput.getOutputName())) {
+ generatedOutputName = attribOutput.getOutputName();
+ } else {
+ generatedOutputName = generateOutputName(generatedInputPrefix, attribOutput);
+ }
+
log.debug("createInput: propOwner.uniqueId={}, attribOutput.parentUniqueId={}", propertiesOwner.getUniqueId(),
attribOutput.getParentUniqueId());
return createOutputFromAttribute(component.getUniqueId(), propertiesOwner, generatedOutputName, attribOutput, attributeDataDefinition);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java
index 62ef98b985..58baad1a58 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/OutputsBusinessLogic.java
@@ -23,10 +23,14 @@ package org.openecomp.sdc.be.components.impl;
import fj.data.Either;
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.ImmutablePair;
import org.jetbrains.annotations.NotNull;
import org.openecomp.sdc.be.components.attribute.AttributeDeclarationOrchestrator;
import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException;
@@ -130,6 +134,10 @@ public class OutputsBusinessLogic extends BaseBusinessLogic {
try {
validateUserExists(userId);
component = getAndValidateComponentForCreate(userId, componentId, componentType, shouldLockComp);
+ ImmutablePair<StorageOperationStatus, String> status = validateOutputName(component, componentInstOutputsMapUi);
+ if (status.getLeft() != StorageOperationStatus.OK) {
+ throw new ByResponseFormatComponentException(componentsUtils.getResponseFormat(ActionStatus.OUTPUT_NAME_ALREADY_EXIST, status.getRight()));
+ }
result = attributeDeclarationOrchestrator.declareAttributesToOutputs(component, componentInstOutputsMapUi).left()
.bind(outputsToCreate -> prepareOutputsForCreation(userId, componentId, outputsToCreate)).right()
.map(componentsUtils::getResponseFormat);
@@ -155,6 +163,29 @@ public class OutputsBusinessLogic extends BaseBusinessLogic {
}
}
+ private ImmutablePair<StorageOperationStatus, String> validateOutputName(final Component component,
+ final ComponentInstOutputsMap componentInstOutputsMapUi) {
+ final Map<String, List<ComponentInstanceAttribOutput>> outputDeclaredProperties = new HashMap<>();
+ if (MapUtils.isNotEmpty(componentInstOutputsMapUi.getComponentInstanceOutputsMap())) {
+ outputDeclaredProperties.putAll(componentInstOutputsMapUi.getComponentInstanceOutputsMap());
+ } else if (MapUtils.isNotEmpty(componentInstOutputsMapUi.getComponentInstanceAttributes())) {
+ outputDeclaredProperties.putAll(componentInstOutputsMapUi.getComponentInstanceAttributes());
+ }
+ if (MapUtils.isNotEmpty(outputDeclaredProperties) && CollectionUtils.isNotEmpty(component.getOutputs())) {
+ for (final List<ComponentInstanceAttribOutput> componentInstancePropOutputs : outputDeclaredProperties.values()) {
+ for (final ComponentInstanceAttribOutput componentInstancePropOutput : componentInstancePropOutputs) {
+ final Optional<OutputDefinition> outputDefinition = component.getOutputs().stream()
+ .filter(output -> output.getName().equals(componentInstancePropOutput.getOutputName())
+ || output.getName().equals(componentInstancePropOutput.getName())).findAny();
+ if (outputDefinition.isPresent()) {
+ return new ImmutablePair<>(StorageOperationStatus.INVALID_VALUE, outputDefinition.get().getName());
+ }
+ }
+ }
+ }
+ return new ImmutablePair<>(StorageOperationStatus.OK, StringUtils.EMPTY);
+ }
+
private Component getAndValidateComponentForCreate(final String userId, final String componentId,
final ComponentTypeEnum componentType,
final boolean shouldLockComp) {