diff options
author | vasraz <vasyl.razinkov@est.tech> | 2022-12-12 15:18:18 +0000 |
---|---|---|
committer | Michael Morris <michael.morris@est.tech> | 2022-12-14 15:49:17 +0000 |
commit | 7a3dcaaba77cf6ab3212db9ce7539ee90cb33eab (patch) | |
tree | aa48d62bd5962a76d707f19093c2cb69d1872f8c /catalog-be/src/main/java/org | |
parent | ed4d851990393a1863b82b6c15484d5250897707 (diff) |
Fix bug 'Pattern constraint validation failure'
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Change-Id: If7c59aa37db974c57195775f963c8400cf474a51
Issue-ID: SDC-4294
Diffstat (limited to 'catalog-be/src/main/java/org')
-rw-r--r-- | catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java index 2ad6a942d0..ae97b89b78 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/PropertyConvertor.java @@ -92,9 +92,9 @@ public class PropertyConvertor { if (props != null) { Map<String, ToscaProperty> properties = new HashMap<>(); // take only the properties of this resource - props.stream().filter(p -> p.getOwnerId() == null || p.getOwnerId().equals(component.getUniqueId())).forEach(property -> { - properties.put(property.getName(), convertProperty(dataTypes, property, PropertyType.PROPERTY)); - }); + props.stream().filter(p -> p.getOwnerId() == null || p.getOwnerId().equals(component.getUniqueId())).forEach(property -> + properties.put(property.getName(), convertProperty(dataTypes, property, PropertyType.PROPERTY)) + ); if (!properties.isEmpty()) { toscaNodeType.setProperties(properties); } @@ -129,18 +129,16 @@ public class PropertyConvertor { prop.setStatus(property.getStatus()); } prop.setMetadata(property.getMetadata()); - - List<ToscaPropertyConstraint> constraints = new ArrayList<>(); + if (CollectionUtils.isNotEmpty(property.getConstraints())) { - constraints = convertConstraints(property.getConstraints()); - prop.setConstraints(constraints); + prop.setConstraints(convertConstraints(property.getConstraints())); } return prop; } - + private List<ToscaPropertyConstraint> convertConstraints(List<PropertyConstraint> constraints) { List<ToscaPropertyConstraint> convertedConstraints = new ArrayList<>(); - for (PropertyConstraint constraint: constraints){ + for (PropertyConstraint constraint : constraints) { if (constraint instanceof EqualConstraint) { convertedConstraints.add(new ToscaPropertyConstraintEqual(((EqualConstraint) constraint).getEqual())); } @@ -260,10 +258,10 @@ public class PropertyConvertor { .convertDataTypeToToscaObject(innerType, dataTypes, innerConverter, isScalar, jsonElement, preserveEmptyValue); } return convertedValue; - + } catch (JsonParseException e) { log.trace("{} not parsable as JSON. Convert as YAML instead", value); - return new Yaml().load(value); + return new Yaml().load(value); } catch (Exception e) { log.debug("convertToToscaValue failed to parse json value :", e); return null; |