summaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/docker/backend/chef-repo/cookbooks/sdc-catalog-be/files/default/error-configuration.yaml152
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java12
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/NodeFilterUploadCreator.java12
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/CINodeFilterUtils.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java28
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java8
-rw-r--r--catalog-be/src/main/resources/config/error-configuration.yaml8
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java14
-rw-r--r--catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java32
-rw-r--r--catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml8
10 files changed, 161 insertions, 121 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 7eb5ee47e9..7b3ade82c7 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
@@ -111,7 +111,7 @@ errors:
message: "Error: Invalid userId '%1'.",
messageId: "SVC4008"
}
-#---------SVC4009-----------------------------
+ #---------SVC4009-----------------------------
USER_DEFINED: {
code: 400,
message: "Error: User Defined '%1'.",
@@ -1436,10 +1436,10 @@ errors:
message: "Error: artifact %1 is defined in CSAR %2 manifest but is not provided",
messageId: "SVC4618"
}
-#---------SVC4619------------------------------
-# %1 - artifact name
-# %2 - artifact type
-# %3 - existing artifact type
+ #---------SVC4619------------------------------
+ # %1 - artifact name
+ # %2 - artifact type
+ # %3 - existing artifact type
ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR: {
code: 400,
message: "Error: artifact %1 in type %2 already exists in type %3.",
@@ -2012,29 +2012,29 @@ errors:
#---------SVC4695-----------------------------
# %1 - Interface Operation Name
INTERFACE_OPERATION_NAME_ALREADY_IN_USE: {
- code: 409,
- message: "Error: Interface Operation name '%1' already in use, Your current changes will not be saved.",
- messageId: "SVC4695"
+ code: 409,
+ message: "Error: Interface Operation name '%1' already in use, Your current changes will not be saved.",
+ messageId: "SVC4695"
}
#---------SVC4696-----------------------------
# %1 - Interface Operation Name
INTERFACE_OPERATION_NAME_INVALID: {
- code: 400,
- message: "Error: Interface Operation name '%1' is Invalid, Operation name should not contain special character, space and should not be greater than 200 characters.",
- messageId: "SVC4696"
+ code: 400,
+ message: "Error: Interface Operation name '%1' is Invalid, Operation name should not contain special character, space and should not be greater than 200 characters.",
+ messageId: "SVC4696"
}
#---------SVC4697-----------------------------
INTERFACE_OPERATION_NAME_MANDATORY: {
- code: 400,
- message: "Error: Interface Operation name is mandatory, Operation name can't be empty.",
- messageId: "SVC4697"
+ code: 400,
+ message: "Error: Interface Operation name is mandatory, Operation name can't be empty.",
+ messageId: "SVC4697"
}
-#---------SVC4698-----------------------------
-# %1 - Interface type
+ #---------SVC4698-----------------------------
+ # %1 - Interface type
INTERFACE_OPERATION_INVALID_FOR_LOCAL_TYPE: {
- code: 400,
- message: "Error: Invalid input, only one operation is allowed in local interface type '%1'.",
- messageId: "SVC4698"
+ code: 400,
+ message: "Error: Invalid input, only one operation is allowed in local interface type '%1'.",
+ messageId: "SVC4698"
}
#---------SVC4699-----------------------------
# %1 - Interface Operation input parameter name
@@ -2049,18 +2049,18 @@ errors:
message: "Error: Interface operation input parameter name should not be empty.",
messageId: "SVC4700"
}
-#---------SVC4701-----------------------------
-# %1 - component Id
+ #---------SVC4701-----------------------------
+ # %1 - component Id
INTERFACE_OPERATION_NOT_FOUND: {
- code: 404,
- message: "Error: Interface operation not found in the component '%1'.",
- messageId: "SVC4701"
+ code: 404,
+ message: "Error: Interface operation not found in the component '%1'.",
+ messageId: "SVC4701"
}
#---------SVC4702-----------------------------
INTERFACE_OPERATION_NOT_DELETED: {
- code: 400,
- message: "Error: Failed to delete interface operation.",
- messageId: "SVC4702"
+ code: 400,
+ message: "Error: Failed to delete interface operation.",
+ messageId: "SVC4702"
}
#SVC4732
INTERFACE_UNKNOWN: {
@@ -2131,32 +2131,32 @@ errors:
message: "Error: CSAR packaging failed for %1 %2.",
messageId: "SVC4706"
}
-#---------SVC4708-----------------------------
-# %1 - Interface Operation input property name, component type
+ #---------SVC4708-----------------------------
+ # %1 - Interface Operation input property name, component type
INTERFACE_OPERATION_INPUT_PROPERTY_NOT_FOUND_IN_COMPONENT: {
code: 404,
message: "Error: Interface operation input parameter property '%1' not found in '%2' input properties, capability properties or outputs of other operations.",
messageId: "SVC4708"
}
-#---------SVC4709-----------------------------
-# %1 - Interface Operation output parameter name
+ #---------SVC4709-----------------------------
+ # %1 - Interface Operation output parameter name
INTERFACE_OPERATION_OUTPUT_NAME_ALREADY_IN_USE: {
code: 400,
message: "Error: Interface Operation output parameter name '%1' already in use, Your current changes will not be saved.",
messageId: "SVC4708"
}
-#---------SVC4710-----------------------------
+ #---------SVC4710-----------------------------
INTERFACE_OPERATION_OUTPUT_NAME_MANDATORY: {
code: 400,
message: "Error: Interface operation output parameter name should not be empty.",
messageId: "SVC4710"
}
-#---------SVC4711-----------------------------
-# %1 - interface Id
+ #---------SVC4711-----------------------------
+ # %1 - interface Id
INTERFACE_NOT_FOUND_IN_COMPONENT: {
- code: 404,
- message: "Error: Interface not found in the component '%1'.",
- messageId: "SVC4711"
+ code: 404,
+ message: "Error: Interface not found in the component '%1'.",
+ messageId: "SVC4711"
}
#---------SVC4709-----------------------------
INVALID_PROPERTY_CONSTRAINTS: {
@@ -2268,18 +2268,18 @@ errors:
message: "Error: Missing value for the mandatory %1 property" ,
messageId: "SVC4721"
}
-#---------SVC4712-----------------------------
+ #---------SVC4712-----------------------------
INTERFACE_LIFECYCLE_TYPES_NOT_FOUND: {
- code: 404,
- message: "Error: Interface Lifecycle types not found.",
- messageId: "SVC4712"
+ code: 404,
+ message: "Error: Interface Lifecycle types not found.",
+ messageId: "SVC4712"
}
-#---------SVC4713-----------------------------
-# %1 - Interface Operation Name
+ #---------SVC4713-----------------------------
+ # %1 - Interface Operation Name
INTERFACE_OPERATION_INVALID_FOR_GLOBAL_TYPE: {
- code: 400,
- message: "Error: Invalid input, only pre-defined operation names are allowed in global interface type '%1'",
- messageId: "SVC4713"
+ code: 400,
+ message: "Error: Invalid input, only pre-defined operation names are allowed in global interface type '%1'",
+ messageId: "SVC4713"
}
#---------SVC4714-----------------------------
@@ -2345,89 +2345,89 @@ errors:
messageId: "SVC4721"
}
- #---------SVC4722------------------------------
- # %1 Directive value set
+ #---------SVC4722------------------------------
+ # %1 Directive value set
DIRECTIVES_INVALID_VALUE: {
- code: 404,
- message: "Error: Invalid directive value : '%1' .",
- messageId: "SVC4722"
+ code: 404,
+ message: "Error: Invalid directive value : '%1' .",
+ messageId: "SVC4722"
}
-#---------SVC4723-----------------------------
-# %1 - Interface Operation output name
+ #---------SVC4723-----------------------------
+ # %1 - Interface Operation output name
INTERFACE_OPERATION_MAPPED_OUTPUT_MODIFIED: {
code: 400,
message: "Error: Cannot update or delete interface operation output(s) '%1' mapped to an operation input",
messageId: "SVC4723"
}
-#---------SVC4724-----------------------------
-# %1 - Interface Operation output name
+ #---------SVC4724-----------------------------
+ # %1 - Interface Operation output name
INTERFACE_OPERATION_DELETE_WITH_MAPPED_OUTPUT: {
code: 400,
message: "Error: Cannot delete interface operation with output(s) '%1' mapped to another operation input",
messageId: "SVC4724"
}
-#---------SVC4725-----------------------------
+ #---------SVC4725-----------------------------
INVALID_CONSUMPTION_TYPE: {
code: 400,
message: "Error: Given value is different than input type. Needs to be %1",
messageId: "SVC4725"
}
-#---------SVC4726-----------------------------
+ #---------SVC4726-----------------------------
INVALID_PROPERTY_VALUES: {
code: 400,
message: "Error: Invalid property values provided:\n %1",
messageId: "SVC4726"
}
-#---------SVC4727------------------------------
+ #---------SVC4727------------------------------
INVALID_PROPERTY_NAME: {
code: 400,
message: "Error: Property name contains invalid characters. It should have only letters, numbers and underscores.",
messageId: "SVC4727"
}
-#---------SVC4728------------------------------
+ #---------SVC4728------------------------------
FAILED_TO_CREATE_OR_UPDATE_CAPABILITY_PROPERTIES: {
code: 500,
message: "Error: Failed to create or update capabilities properties",
messageId: "SVC4728"
}
-#---------SVC4729------------------------------
+ #---------SVC4729------------------------------
# %1 - resource Id
CAPABILITY_PROPERTIES_NOT_FOUND: {
code: 400,
message: "Error: Capability properties not found in the resource '%1'.",
messageId: "SVC4729"
}
-#---------SVC4730------------------------------
+ #---------SVC4730------------------------------
# %1 - property name
PROPERTY_EXCEEDS_LIMIT: {
- code: 400,
- message: "Error: Invalid Content. %1 exceeds limit.",
- messageId: "SVC4722"
+ code: 400,
+ message: "Error: Invalid Content. %1 exceeds limit.",
+ messageId: "SVC4722"
}
-#---------SVC4731------------------------------
+ #---------SVC4731------------------------------
INVALID_PROPERY: {
# %1 - property name
- code: 400,
- message: 'Error: Invalid Content. %1 has invalid format.',
- messageId: "SVC4723"
+ code: 400,
+ message: 'Error: Invalid Content. %1 has invalid format.',
+ messageId: "SVC4723"
}
-#---------SVC4734------------------------------
+ #---------SVC4734------------------------------
# %1 - list of validation errors
INVALID_PM_DICTIONARY_FILE: {
code: 400,
message: 'Error: Invalid PM Dictionary File. %1',
messageId: "SVC4734"
}
-#-----------SVC4735---------------------------
+ #-----------SVC4735---------------------------
#%1 - input name
INPUT_ALREADY_EXIST: {
code: 409,
message: "Error: Input with '%1' name already exists.",
messageId: "SVC4735"
}
-#---------SVC4736------------------------------
+ #---------SVC4736------------------------------
INVALID_INPUT_NAME: {
code: 400,
message: "Error: Input name contains invalid characters. It should have only letters, numbers and underscores.",
@@ -2548,7 +2548,7 @@ errors:
messageId: "SVC4153"
}
- #-----------SVC4154---------------------------
+ #-----------SVC4154---------------------------
# %1 - "Model name"
UNKNOWN_MODEL_TYPE: {
code: 400,
@@ -2813,3 +2813,11 @@ errors:
code: 400
message: "Invalid component type '%1'. Expected types are: %2"
messageId: "SVC4185"
+
+ # %1 - The capability name
+ # %2 - The component type
+ # %3 - The component name
+ CAPABILITY_NOT_FOUND_IN_COMPONENT:
+ code: 400
+ message: "Capability '%1' not found in '%2' '%3'."
+ messageId: "SVC4186" \ No newline at end of file
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
index ff65d84416..457f43865f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogic.java
@@ -52,7 +52,6 @@ import org.openecomp.sdc.be.model.operations.api.IGroupTypeOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
import org.openecomp.sdc.be.ui.mapper.FilterConstraintMapper;
-import org.openecomp.sdc.be.ui.model.UIConstraint;
import org.openecomp.sdc.be.user.Role;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.exception.ResponseFormat;
@@ -156,8 +155,7 @@ public class ComponentNodeFilterBusinessLogic extends BaseBusinessLogic {
public Optional<CINodeFilterDataDefinition> addNodeFilter(final String componentId, final String componentInstanceId,
final FilterConstraintDto filterConstraint, final boolean shouldLock,
final ComponentTypeEnum componentTypeEnum,
- final NodeFilterConstraintType nodeFilterConstraintType,
- final String capabilityName) throws BusinessLogicException {
+ final NodeFilterConstraintType nodeFilterConstraintType) throws BusinessLogicException {
final Component component = getComponent(componentId);
validateNodeFilter(component, componentInstanceId, filterConstraint);
CINodeFilterDataDefinition nodeFilterDataDefinition = getComponentInstanceNodeFilterOrThrow(componentInstanceId, component);
@@ -171,7 +169,7 @@ public class ComponentNodeFilterBusinessLogic extends BaseBusinessLogic {
filterPropertyDataDefinition.setName(filterConstraint.getPropertyName());
filterPropertyDataDefinition.setConstraints(List.of(new FilterConstraintMapper().mapTo(filterConstraint)));
final Either<CINodeFilterDataDefinition, StorageOperationStatus> result = addNodeFilter(componentId, componentInstanceId,
- nodeFilterConstraintType, nodeFilterDataDefinition, filterPropertyDataDefinition, capabilityName);
+ nodeFilterConstraintType, nodeFilterDataDefinition, filterPropertyDataDefinition, filterConstraint.getCapabilityName());
if (result.isRight()) {
throw new BusinessLogicException(componentsUtils.getResponseFormatByResource(
componentsUtils.convertFromStorageResponse(result.right().value()), component.getSystemName()
@@ -290,7 +288,7 @@ public class ComponentNodeFilterBusinessLogic extends BaseBusinessLogic {
}
public Optional<CINodeFilterDataDefinition> updateNodeFilter(final String componentId, final String componentInstanceId,
- final UIConstraint uiConstraint, final ComponentTypeEnum componentTypeEnum,
+ final FilterConstraintDto filterConstraintDto, final ComponentTypeEnum componentTypeEnum,
final NodeFilterConstraintType nodeFilterConstraintType,
final int index) throws BusinessLogicException {
final Optional<CINodeFilterDataDefinition> deleteActionResponse =
@@ -299,8 +297,8 @@ public class ComponentNodeFilterBusinessLogic extends BaseBusinessLogic {
throw new BusinessLogicException(
componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR, "Failed to delete node filter capabilities"));
}
- return addNodeFilter(componentId.toLowerCase(), componentInstanceId, new FilterConstraintMapper().mapFrom(uiConstraint), true,
- componentTypeEnum, nodeFilterConstraintType, uiConstraint.getCapabilityName());
+ return addNodeFilter(componentId.toLowerCase(), componentInstanceId, filterConstraintDto, true,
+ componentTypeEnum, nodeFilterConstraintType);
}
public StorageOperationStatus associateNodeFilterToComponentInstance(final String componentId,
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/NodeFilterUploadCreator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/NodeFilterUploadCreator.java
index f34091de0f..9cdf07c15f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/NodeFilterUploadCreator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/NodeFilterUploadCreator.java
@@ -19,7 +19,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import org.onap.sdc.tosca.services.YamlUtil;
import org.openecomp.sdc.be.model.UploadNodeFilterCapabilitiesInfo;
import org.openecomp.sdc.be.model.UploadNodeFilterInfo;
@@ -59,16 +58,13 @@ public class NodeFilterUploadCreator {
final Map.Entry<String, Object> entry = map.entrySet().iterator().next();
final Object propertyConstraintClauses = entry.getValue();
if (propertyConstraintClauses instanceof Map) {
- final List<String> propertyFilterConstraintList = new ArrayList<>();
- propertyFilterConstraintList.add(valueToProperty(map));
- retVal.add(new UploadNodeFilterPropertyInfo(entry.getKey(), propertyFilterConstraintList));
+ retVal.add(new UploadNodeFilterPropertyInfo(entry.getKey(), List.of(valueToProperty(map))));
} else if (propertyConstraintClauses instanceof List) {
- final List<String> propertyFilterConstraintList = ((List<Object>) propertyConstraintClauses).stream()
+ ((List<Object>) propertyConstraintClauses).stream()
.map(propertyConstraintClause -> Map.of(entry.getKey(), propertyConstraintClause))
.map(this::valueToProperty)
- .collect(Collectors.toList());
-
- retVal.add(new UploadNodeFilterPropertyInfo(entry.getKey(), propertyFilterConstraintList));
+ .map(filterConstraint -> new UploadNodeFilterPropertyInfo(entry.getKey(), List.of(filterConstraint)))
+ .forEach(retVal::add);
}
}
return retVal;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/CINodeFilterUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/CINodeFilterUtils.java
index 5ac9bcd2de..6f0472df61 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/CINodeFilterUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/utils/CINodeFilterUtils.java
@@ -60,15 +60,16 @@ public class CINodeFilterUtils {
private RequirementNodeFilterCapabilityDataDefinition convertCapability(UploadNodeFilterCapabilitiesInfo capability) {
RequirementNodeFilterCapabilityDataDefinition retVal = new RequirementNodeFilterCapabilityDataDefinition();
retVal.setName(capability.getName());
- List<PropertyFilterDataDefinition> props = capability.getProperties().stream().map(this::buildProperty)
+ List<PropertyFilterDataDefinition> propertyFilterList = capability.getProperties().stream()
+ .map(filterPropertyInfo -> buildProperty(capability.getName(), filterPropertyInfo))
.collect(Collectors.toList());
ListDataDefinition<PropertyFilterDataDefinition> propsList = new ListDataDefinition<>();
- propsList.getListToscaDataDefinition().addAll(props);
+ propsList.getListToscaDataDefinition().addAll(propertyFilterList);
retVal.setProperties(propsList);
return retVal;
}
- private PropertyFilterDataDefinition buildProperty(final UploadNodeFilterPropertyInfo uploadNodeFilterPropertyInfo) {
+ private PropertyFilterDataDefinition buildProperty(final String capabilityName, final UploadNodeFilterPropertyInfo uploadNodeFilterPropertyInfo) {
final var propertyFilter = new PropertyFilterDataDefinition();
propertyFilter.setName(uploadNodeFilterPropertyInfo.getName());
final List<String> propertyConstraints = uploadNodeFilterPropertyInfo.getValues();
@@ -76,6 +77,7 @@ public class CINodeFilterUtils {
propertyFilter.setConstraints(
propertyConstraints.stream()
.map(PropertyFilterConstraintDataDefinitionHelper::convertLegacyConstraint)
+ .peek(propertyFilterConstraintDataDefinition -> propertyFilterConstraintDataDefinition.setCapabilityName(capabilityName))
.collect(Collectors.toList())
);
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
index 12b58ded4a..b7b2452189 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/validation/NodeFilterValidator.java
@@ -21,6 +21,7 @@ package org.openecomp.sdc.be.components.validation;
import com.google.gson.Gson;
import fj.data.Either;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -31,6 +32,7 @@ import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.ToscaGetFunctionDataDefinition;
+import org.openecomp.sdc.be.datatypes.enums.PropertyFilterTargetType;
import org.openecomp.sdc.be.datatypes.enums.PropertySource;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.CapabilityDefinition;
@@ -290,11 +292,31 @@ public class NodeFilterValidator {
findSubProperty(propertyPathFromSource.subList(1, propertyPathFromSource.size()), sourceSelectedProperty.get().getType(),
allDataTypesEither.left().value());
}
- final Optional<? extends PropertyDefinition> targetComponentInstanceProperty =
- parentComponent.getComponentInstancesProperties()
- .get(componentInstanceId).stream()
+ final Optional<? extends PropertyDefinition> targetComponentInstanceProperty;
+ if (PropertyFilterTargetType.CAPABILITY.equals(filterConstraint.getTargetType())) {
+ final CapabilityDefinition capability = parentComponent.getComponentInstances().stream()
+ .filter(componentInstance -> componentInstance.getUniqueId().equals(componentInstanceId))
+ .map(componentInstance -> componentInstance.getCapabilities().values())
+ .flatMap(Collection::stream)
+ .flatMap(Collection::stream)
+ .filter(capabilityDefinition -> capabilityDefinition.getName().equals(filterConstraint.getCapabilityName()))
+ .findFirst().orElse(null);
+ if (capability == null) {
+ return Either.right(
+ componentsUtils.getResponseFormat(ActionStatus.CAPABILITY_NOT_FOUND_IN_COMPONENT,
+ filterConstraint.getCapabilityName(), parentComponent.getComponentType().getValue(), parentComponent.getName())
+ );
+ }
+ targetComponentInstanceProperty = capability.getProperties().stream()
.filter(property -> filterConstraint.getPropertyName().equals(property.getName()))
.findFirst();
+ } else {
+ targetComponentInstanceProperty =
+ parentComponent.getComponentInstancesProperties()
+ .get(componentInstanceId).stream()
+ .filter(property -> filterConstraint.getPropertyName().equals(property.getName()))
+ .findFirst();
+ }
if (sourceSelectedProperty.isPresent() && targetComponentInstanceProperty.isPresent()) {
final ResponseFormat responseFormat = validatePropertyData(sourceSelectedProperty.get(), targetComponentInstanceProperty.get());
if (responseFormat != null) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java
index 80c806f9c3..d69a7d367c 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServlet.java
@@ -42,7 +42,6 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.collections4.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentNodeFilterBusinessLogic;
import org.openecomp.sdc.be.components.impl.ResourceImportManager;
@@ -140,8 +139,7 @@ public class ComponentNodeFilterServlet extends AbstractValidationsServlet {
final FilterConstraintDto filterConstraintDto = new FilterConstraintMapper().mapFrom(uiConstraint);
final Optional<CINodeFilterDataDefinition> actionResponse = componentNodeFilterBusinessLogic
.addNodeFilter(componentId.toLowerCase(), componentInstanceId,
- filterConstraintDto, true, componentTypeEnum, nodeFilterConstraintType.get(),
- StringUtils.isEmpty(uiConstraint.getCapabilityName()) ? "" : uiConstraint.getCapabilityName());
+ filterConstraintDto, true, componentTypeEnum, nodeFilterConstraintType.get());
if (actionResponse.isEmpty()) {
LOGGER.error(FAILED_TO_CREATE_NODE_FILTER);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
@@ -201,8 +199,8 @@ public class ComponentNodeFilterServlet extends AbstractValidationsServlet {
}
final NodeFilterConstraintType nodeFilterConstraintType = nodeFilterConstraintTypeOptional.get();
final Optional<CINodeFilterDataDefinition> actionResponse = componentNodeFilterBusinessLogic
- .updateNodeFilter(componentId.toLowerCase(), componentInstanceId, uiConstraint, componentTypeEnum, nodeFilterConstraintType,
- index);
+ .updateNodeFilter(componentId.toLowerCase(), componentInstanceId, new FilterConstraintMapper().mapFrom(uiConstraint),
+ componentTypeEnum, nodeFilterConstraintType, index);
if (actionResponse.isEmpty()) {
LOGGER.error(FAILED_TO_UPDATE_NODE_FILTER);
return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
diff --git a/catalog-be/src/main/resources/config/error-configuration.yaml b/catalog-be/src/main/resources/config/error-configuration.yaml
index 81e302f8bd..d31d4a6203 100644
--- a/catalog-be/src/main/resources/config/error-configuration.yaml
+++ b/catalog-be/src/main/resources/config/error-configuration.yaml
@@ -2813,3 +2813,11 @@ errors:
code: 400
message: "Invalid component type '%1'. Expected types are: %2"
messageId: "SVC4185"
+
+ # %1 - The capability name
+ # %2 - The component type
+ # %3 - The component name
+ CAPABILITY_NOT_FOUND_IN_COMPONENT:
+ code: 400
+ message: "Capability '%1' not found in '%2' '%3'."
+ messageId: "SVC4186" \ No newline at end of file
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java
index 1bf075e2f6..e3e173571e 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentNodeFilterBusinessLogicTest.java
@@ -274,7 +274,7 @@ class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock {
final Optional<CINodeFilterDataDefinition> result = componentNodeFilterBusinessLogic
.addNodeFilter(componentId, componentInstanceId, filterConstraintDto, true, ComponentTypeEnum.RESOURCE,
- NodeFilterConstraintType.PROPERTIES, null);
+ NodeFilterConstraintType.PROPERTIES);
assertThat(result).isPresent();
assertThat(result.get().getProperties().getListToscaDataDefinition()).hasSize(1);
@@ -305,7 +305,7 @@ class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock {
final Optional<CINodeFilterDataDefinition> result = componentNodeFilterBusinessLogic
.addNodeFilter(componentId, componentInstanceId, filterConstraintDto, true, ComponentTypeEnum.RESOURCE,
- NodeFilterConstraintType.CAPABILITIES, capabilityName
+ NodeFilterConstraintType.CAPABILITIES
);
assertThat(result).isPresent();
@@ -342,7 +342,7 @@ class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock {
final BusinessLogicException businessLogicException = assertThrows(BusinessLogicException.class, () -> componentNodeFilterBusinessLogic
.addNodeFilter(componentId, componentInstanceId, filterConstraintDto, true, ComponentTypeEnum.RESOURCE,
- NodeFilterConstraintType.PROPERTIES, capabilityName));
+ NodeFilterConstraintType.PROPERTIES));
assertEquals(expectedResponse, businessLogicException.getResponseFormat());
verify(toscaOperationFacade, times(1)).getToscaElement(componentId);
@@ -370,7 +370,7 @@ class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock {
final BusinessLogicException businessLogicException = assertThrows(BusinessLogicException.class, () -> componentNodeFilterBusinessLogic
.addNodeFilter(componentId, componentInstanceId, filterConstraintDto, true, ComponentTypeEnum.RESOURCE,
- NodeFilterConstraintType.PROPERTIES, capabilityName));
+ NodeFilterConstraintType.PROPERTIES));
assertEquals(expectedResponse, businessLogicException.getResponseFormat());
}
@@ -473,7 +473,7 @@ class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock {
.thenReturn(StorageOperationStatus.OK);
final Optional<CINodeFilterDataDefinition> updateNodeFilterResult = componentNodeFilterBusinessLogic
- .updateNodeFilter(componentId, componentInstanceId, uiConstraint, ComponentTypeEnum.RESOURCE,
+ .updateNodeFilter(componentId, componentInstanceId, filterConstraintDto, ComponentTypeEnum.RESOURCE,
NodeFilterConstraintType.PROPERTIES, 0);
assertThat(updateNodeFilterResult).isPresent();
@@ -505,7 +505,7 @@ class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock {
.thenReturn(StorageOperationStatus.OK);
assertThrows(BusinessLogicException.class, () -> componentNodeFilterBusinessLogic
- .updateNodeFilter(componentId, componentInstanceId, uiConstraint, ComponentTypeEnum.RESOURCE,
+ .updateNodeFilter(componentId, componentInstanceId, filterConstraintDto, ComponentTypeEnum.RESOURCE,
NodeFilterConstraintType.PROPERTIES, 0));
}
@@ -516,7 +516,7 @@ class ComponentNodeFilterBusinessLogicTest extends BaseBusinessLogicMock {
.thenReturn(Either.left(true));
assertThrows(BusinessLogicException.class, () -> componentNodeFilterBusinessLogic
- .updateNodeFilter(componentId, componentInstanceId, uiConstraint, ComponentTypeEnum.RESOURCE,
+ .updateNodeFilter(componentId, componentInstanceId, filterConstraintDto, ComponentTypeEnum.RESOURCE,
NodeFilterConstraintType.PROPERTIES, 0));
verify(toscaOperationFacade, times(1)).getToscaElement(componentId);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java
index 49252109cd..29e3a54133 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ComponentNodeFilterServletTest.java
@@ -202,7 +202,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
doReturn(Optional.of(ciNodeFilterDataDefinition)).when(componentNodeFilterBusinessLogic)
.addNodeFilter(componentId, componentInstance, filterConstraintDto, true, ComponentTypeEnum.RESOURCE,
- NodeFilterConstraintType.PROPERTIES, "");
+ NodeFilterConstraintType.PROPERTIES);
final Response response = target()
.path(path)
@@ -212,7 +212,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
verify(componentNodeFilterBusinessLogic, times(1))
.addNodeFilter(anyString(), anyString(), any(FilterConstraintDto.class), anyBoolean(), any(ComponentTypeEnum.class),
- any(NodeFilterConstraintType.class), anyString()
+ any(NodeFilterConstraintType.class)
);
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
@@ -238,7 +238,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
final FilterConstraintDto filterConstraintDto1 = new FilterConstraintMapper().mapFrom(uiConstraint1);
when(componentNodeFilterBusinessLogic
.addNodeFilter(componentId, componentInstance, filterConstraintDto1, true, ComponentTypeEnum.RESOURCE,
- NodeFilterConstraintType.CAPABILITIES, capabilityName)
+ NodeFilterConstraintType.CAPABILITIES)
).thenReturn(Optional.of(ciNodeFilterDataDefinition));
final Response response = target()
.path(path)
@@ -248,14 +248,14 @@ class ComponentNodeFilterServletTest extends JerseyTest {
verify(componentNodeFilterBusinessLogic, times(1))
.addNodeFilter(componentId, componentInstance, filterConstraintDto1, true, ComponentTypeEnum.RESOURCE,
- NodeFilterConstraintType.CAPABILITIES, capabilityName);
+ NodeFilterConstraintType.CAPABILITIES);
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK_200);
verify(componentNodeFilterBusinessLogic,times(1)).validateUser(USER_ID);
}
@Test
- void addNodeFilterFailTest() throws BusinessLogicException, JsonProcessingException {
+ void addNodeFilterFailTest() {
initComponentData();
final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_NODE_FILTER;
final String path = String.format(pathFormat, componentType, componentId, componentInstance,
@@ -274,7 +274,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
}
@Test
- void addNodeFilterFailConstraintParseTest() throws JsonProcessingException {
+ void addNodeFilterFailConstraintParseTest() {
initComponentData();
final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_NODE_FILTER;
final String path = String.format(pathFormat, componentType, componentId, componentInstance, NodeFilterConstraintType.PROPERTIES_PARAM_NAME);
@@ -292,7 +292,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
}
@Test
- void addNodeFilterFailConvertTest() throws JsonProcessingException {
+ void addNodeFilterFailConvertTest() {
initComponentData();
final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_NODE_FILTER;
final String path = String.format(pathFormat, componentType, componentId, componentInstance,
@@ -311,7 +311,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
}
@Test
- void updateNodeFilterPropertiesSuccessTest() throws BusinessLogicException, JsonProcessingException {
+ void updateNodeFilterPropertiesSuccessTest() throws BusinessLogicException {
initComponentData();
final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
final String path = String.format(pathFormat, componentType, componentId, componentInstance,
@@ -325,7 +325,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
doReturn(Optional.of(uiConstraint)).when(componentsUtils)
.parseToConstraint(anyString(), any(User.class), eq(ComponentTypeEnum.RESOURCE));
when(componentNodeFilterBusinessLogic
- .updateNodeFilter(componentId, componentInstance, uiConstraint, ComponentTypeEnum.RESOURCE,
+ .updateNodeFilter(componentId, componentInstance, filterConstraintDto, ComponentTypeEnum.RESOURCE,
NodeFilterConstraintType.PROPERTIES, 0)).thenReturn(Optional.of(ciNodeFilterDataDefinition));
final Response response = target()
.path(path)
@@ -338,7 +338,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
}
@Test
- void updateNodeFilterCapabilitiesSuccessTest() throws BusinessLogicException, JsonProcessingException {
+ void updateNodeFilterCapabilitiesSuccessTest() throws BusinessLogicException {
initComponentData();
final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
final String path = String.format(pathFormat, componentType, componentId, componentInstance,
@@ -353,7 +353,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
when(componentsUtils.getResponseFormat(ActionStatus.OK)).thenReturn(responseFormat);
when(componentNodeFilterBusinessLogic
- .updateNodeFilter(componentId, componentInstance, uiConstraint,
+ .updateNodeFilter(componentId, componentInstance, filterConstraintDto,
ComponentTypeEnum.RESOURCE, NodeFilterConstraintType.CAPABILITIES, 0))
.thenReturn(Optional.of(ciNodeFilterDataDefinition));
@@ -364,7 +364,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
.put(Entity.entity(inputJson, MediaType.APPLICATION_JSON));
verify(componentNodeFilterBusinessLogic, times(1))
- .updateNodeFilter(anyString(), anyString(), any(UIConstraint.class),
+ .updateNodeFilter(anyString(), anyString(), any(FilterConstraintDto.class),
any(ComponentTypeEnum.class), any(NodeFilterConstraintType.class),
anyInt());
@@ -373,7 +373,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
}
@Test
- void updateNodeFilterFailTest() throws BusinessLogicException, JsonProcessingException {
+ void updateNodeFilterFailTest() {
initComponentData();
final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
final String path = String.format(pathFormat, componentType, componentId, componentInstance,
@@ -392,7 +392,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
}
@Test
- void updateNodeFilterFailConstraintParseTest() throws JsonProcessingException {
+ void updateNodeFilterFailConstraintParseTest() {
initComponentData();
final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
final String path = String.format(pathFormat, componentType, componentId, componentInstance,
@@ -411,7 +411,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
}
@Test
- void updateNodeFilterFailConvertTest() throws JsonProcessingException {
+ void updateNodeFilterFailConvertTest() {
initComponentData();
final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
final String path = String.format(pathFormat, componentType, componentId, componentInstance,
@@ -430,7 +430,7 @@ class ComponentNodeFilterServletTest extends JerseyTest {
}
@Test
- void deleteNodeFilterSuccessTest() throws BusinessLogicException, JsonProcessingException {
+ void deleteNodeFilterSuccessTest() throws BusinessLogicException {
initComponentData();
final String pathFormat = V_1_CATALOG_S_S_COMPONENT_INSTANCE_S_S_S_NODE_FILTER;
final String path = String.format(pathFormat, componentType, componentId, componentInstance,
diff --git a/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml b/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
index 81e302f8bd..d31d4a6203 100644
--- a/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
+++ b/catalog-be/src/test/resources/config/catalog-be/error-configuration.yaml
@@ -2813,3 +2813,11 @@ errors:
code: 400
message: "Invalid component type '%1'. Expected types are: %2"
messageId: "SVC4185"
+
+ # %1 - The capability name
+ # %2 - The component type
+ # %3 - The component name
+ CAPABILITY_NOT_FOUND_IN_COMPONENT:
+ code: 400
+ message: "Capability '%1' not found in '%2' '%3'."
+ messageId: "SVC4186" \ No newline at end of file