diff options
author | andre.schmid <andre.schmid@est.tech> | 2022-09-08 18:55:08 +0100 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-09-19 08:38:43 +0000 |
commit | 0d38a72c022fa93dba0bf052f893e51fb73d3552 (patch) | |
tree | 25f49242e6c6666c39e32abae66e4950fe4e18ed /catalog-be/src/main | |
parent | 2fe3d879319a34e9802d0bc172fa11fefe771df3 (diff) |
Support TOSCA functions in Node Capability Filters
Adds support to use TOSCA functions as value in the node capability
filters.
Removes the current capability filter component to reuse, with a few
changes, the node property filters component.
Fixes problems with the edition and deletion of node capability
filters.
Change-Id: Ic91242d6cbc24e2ce0f60b84c63e104575bef8a9
Issue-ID: SDC-4173
Signed-off-by: André Schmid <andre.schmid@est.tech>
Diffstat (limited to 'catalog-be/src/main')
7 files changed, 130 insertions, 98 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 |