From a522a3a2c2b262780dd0efab5747ef937e124bee Mon Sep 17 00:00:00 2001 From: vasraz Date: Mon, 6 Mar 2023 17:52:41 +0000 Subject: Add backend support for VFC property metadata Remove empty tags from tosca file Signed-off-by: Vasyl Razinkov Change-Id: I0c446b537934ffd19c1162326e075e13845db23e Issue-ID: SDC-4424 --- .../org/openecomp/sdc/be/components/impl/ImportUtils.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'catalog-be/src/main/java') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java index fff9f0bf1c..62b345c499 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java @@ -40,7 +40,10 @@ import java.util.Map; import java.util.Map.Entry; import java.util.function.Consumer; import java.util.function.Function; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections4.MapUtils; import org.apache.commons.text.StringEscapeUtils; import org.onap.sdc.tosca.datatypes.model.EntrySchema; import org.openecomp.sdc.be.components.impl.exceptions.ByActionStatusComponentException; @@ -83,6 +86,7 @@ import org.yaml.snakeyaml.nodes.Tag; import org.yaml.snakeyaml.representer.Representer; import org.yaml.snakeyaml.resolver.Resolver; +@NoArgsConstructor(access = AccessLevel.PRIVATE) @Component public final class ImportUtils { @@ -91,9 +95,6 @@ public final class ImportUtils { private static final Logger log = Logger.getLogger(ImportUtils.class); private static ComponentsUtils componentsUtils; - private ImportUtils() { - } - @Autowired public static void setComponentsUtils(ComponentsUtils cu) { componentsUtils = cu; @@ -361,6 +362,7 @@ public final class ImportUtils { setJsonStringField(propertyValue, TypeUtils.ToscaTagNamesEnum.VALUE, propertyDef.getType(), propertyDef::setValue); setFieldBoolean(propertyValue, TypeUtils.ToscaTagNamesEnum.IS_PASSWORD, pass -> propertyDef.setPassword(Boolean.parseBoolean(pass))); setField(propertyValue, TypeUtils.ToscaTagNamesEnum.STATUS, propertyDef::setStatus); + setFieldMap(propertyValue, ToscaTagNamesEnum.METADATA, propertyDef::setMetadata); setSchema(propertyValue, propertyDef); setPropertyConstraints(propertyValue, propertyDef); return propertyDef; @@ -533,7 +535,7 @@ public final class ImportUtils { private static void setFieldMap(final Map toscaJson, final ToscaTagNamesEnum tagName, final Consumer> setter) { final Either, ResultStatusEnum> toscaMapElement = findFirstToscaMapElement(toscaJson, tagName); - if (toscaMapElement.isLeft()) { + if (toscaMapElement.isLeft() && MapUtils.isNotEmpty(toscaMapElement.left().value())) { setter.accept(toscaMapElement.left().value()); } } @@ -770,6 +772,7 @@ public final class ImportUtils { } } + @NoArgsConstructor(access = AccessLevel.PRIVATE) public static class Constants { public static final String FIRST_NON_CERTIFIED_VERSION = "0.1"; @@ -790,7 +793,5 @@ public final class ImportUtils { public static final String VF_DESCRIPTION = "Nested VF in service"; public static final String TENANT = "tenant"; - private Constants() { - } } } -- cgit 1.2.3-korg