summaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-10-02 12:28:06 +0100
committerMichael Morris <michael.morris@est.tech>2023-10-03 09:54:57 +0000
commit39dd951527bf62568cf5815a6b1e4901c2b89c3f (patch)
treea99222b3dd5a5475a8a3fb067c1cc0d7e9abbf1d /catalog-be
parent8a9eed8e6e97068a47aa14016cc0601f89eb0939 (diff)
Allow import of handcrafted templates with specific substitution filter format
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I363e36c349aac35653de92a43cc14c9a68327c65 Issue-ID: SDC-4641
Diffstat (limited to 'catalog-be')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/YamlTemplateParsingHandler.java25
1 files changed, 17 insertions, 8 deletions
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 2d29f80017..5556548b50 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
@@ -257,21 +257,30 @@ public class YamlTemplateParsingHandler {
return ImportUtils.getProperties(toscaJson).left().on(err -> new HashMap<>());
}
- private ListDataDefinition<SubstitutionFilterPropertyDataDefinition> getSubstitutionFilterProperties(Map<String, Object> toscaJson) {
- ListDataDefinition<SubstitutionFilterPropertyDataDefinition> propertyList = new ListDataDefinition<>();
- Map<String, Object> substitutionFilters = findFirstToscaMapElement(toscaJson, SUBSTITUTION_FILTERS).left().on(err -> new HashMap<>());
+ private ListDataDefinition<SubstitutionFilterPropertyDataDefinition> getSubstitutionFilterProperties(final Map<String, Object> toscaJson) {
+ final ListDataDefinition<SubstitutionFilterPropertyDataDefinition> propertyList = new ListDataDefinition<>();
+ final Map<String, Object> substitutionFilters = findFirstToscaMapElement(toscaJson, SUBSTITUTION_FILTERS).left().on(err -> new HashMap<>());
if (MapUtils.isEmpty(substitutionFilters)) {
return propertyList;
}
- ArrayList<Map<String, List<Map<String, Object>>>> substitutionFilterProperties =
- (ArrayList<Map<String, List<Map<String, Object>>>>) substitutionFilters.get("properties");
+ final List<Map<String, Object>> substitutionFilterProperties = (List<Map<String, Object>>) substitutionFilters.get("properties");
if (CollectionUtils.isEmpty(substitutionFilterProperties)) {
return propertyList;
}
- for (Map<String, List<Map<String, Object>>> filterProps : substitutionFilterProperties) {
- for (Map.Entry<String, List<Map<String, Object>>> propertyFilterEntry : filterProps.entrySet()) {
+ for (final Map<String, Object> filterProps : substitutionFilterProperties) {
+ for (final Map.Entry<String, Object> propertyFilterEntry : filterProps.entrySet()) {
final String propertyName = propertyFilterEntry.getKey();
- for (Map<String, Object> filterValueMap : propertyFilterEntry.getValue()) {
+ final Object value = propertyFilterEntry.getValue();
+ if (value instanceof List) {
+ final List<Map<String, Object>> propertyFilterEntryValue = (List<Map<String, Object>>) value;
+ for (final Map<String, Object> filterValueMap : propertyFilterEntryValue) {
+ final var substitutionFilterPropertyDataDefinition = new SubstitutionFilterPropertyDataDefinition();
+ substitutionFilterPropertyDataDefinition.setName(propertyName);
+ substitutionFilterPropertyDataDefinition.setConstraints(createSubstitutionFilterConstraints(propertyName, filterValueMap));
+ propertyList.add(substitutionFilterPropertyDataDefinition);
+ }
+ } else if (value instanceof Map) {
+ final Map<String, Object> filterValueMap = (Map<String, Object>) value;
final var substitutionFilterPropertyDataDefinition = new SubstitutionFilterPropertyDataDefinition();
substitutionFilterPropertyDataDefinition.setName(propertyName);
substitutionFilterPropertyDataDefinition.setConstraints(createSubstitutionFilterConstraints(propertyName, filterValueMap));