diff options
author | Ittay Stern <ittay.stern@att.com> | 2018-11-27 18:18:40 +0200 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2018-11-29 15:02:54 +0200 |
commit | afe1a57be3724123792fb974b2ae4b8b150fa441 (patch) | |
tree | 346d776b8d77958dd4e91979086fbf778a65deb1 /vid-app-common/src/main/java | |
parent | d0e33a075713cb711d97a4186f858b931ff793ef (diff) |
Handle annotated-input which has 2 properties
Handle correctly an annotated input, when it has more than a single
"vf_module_label".
Change-Id: Ibe3f6408d7d5c18b13e47846235a2b3ab66f35f8
Issue-ID: VID-362
Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-app-common/src/main/java')
-rw-r--r-- | vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java index 17fb29b59..57d80ce9d 100644 --- a/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java +++ b/vid-app-common/src/main/java/org/onap/vid/asdc/parser/ToscaParserImpl2.java @@ -1,7 +1,6 @@ package org.onap.vid.asdc.parser; -import org.onap.vid.asdc.beans.Service; -import org.onap.vid.model.*; +import org.apache.commons.lang3.StringUtils; import org.onap.sdc.tosca.parser.api.ISdcCsarHelper; import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException; import org.onap.sdc.tosca.parser.impl.FilterType; @@ -11,6 +10,8 @@ import org.onap.sdc.toscaparser.api.Group; import org.onap.sdc.toscaparser.api.*; import org.onap.sdc.toscaparser.api.elements.Metadata; import org.onap.sdc.toscaparser.api.parameters.Input; +import org.onap.vid.asdc.beans.Service; +import org.onap.vid.model.*; import java.nio.file.Path; import java.util.*; @@ -417,7 +418,22 @@ public class ToscaParserImpl2 { private boolean isInputMatchesToGroup(List<Property> annotationProperties, org.onap.vid.model.Group group){ for(Property property: annotationProperties){ if(property.getName().equals(VF_MODULE_LABEL)){ - return getPropertyValueAsString(property).equals(group.getProperties().getVfModuleLabel()); + final Object values = property.getValue(); + final String vfModuleLabel = group.getProperties().getVfModuleLabel(); + if (values instanceof List) { + if (listContainsAsString((List) values, vfModuleLabel)) return true; + } else { + return getPropertyValueAsString(property).equals(vfModuleLabel); + } + } + } + return false; + } + + private boolean listContainsAsString(List list, String value) { + for (Object v : list) { + if (StringUtils.equals(v.toString(), value)) { + return true; } } return false; @@ -428,7 +444,7 @@ public class ToscaParserImpl2 { } private String removeSquareBrackets(String stringWithSquareBrackets){ - return stringWithSquareBrackets.substring(1, stringWithSquareBrackets.length()-1); + return stringWithSquareBrackets.replaceAll("(^\\[|\\]$)", ""); } private GroupProperties extractVfModuleProperties(Group group, ISdcCsarHelper csarHelper){ @@ -507,7 +523,10 @@ public class ToscaParserImpl2 { for (Property property : properties) { //special handling to necessary sub-property "ecomp_generated_naming" if(property.getName().equals("nf_naming")){ - propertiesMap.put(removeSquareBrackets(((LinkedHashMap)(property.getValue())).keySet().toString()) ,((LinkedHashMap)(property.getValue())).get("ecomp_generated_naming").toString()); + final Object ecompGeneratedNaming = ((Map) (property.getValue())).get("ecomp_generated_naming"); + if (ecompGeneratedNaming != null) { + propertiesMap.put("ecomp_generated_naming", ecompGeneratedNaming.toString()); + } } propertiesMap.put(property.getName(), property.getValue().toString()); } |