summaryrefslogtreecommitdiffstats
path: root/sdc-tosca-parser/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'sdc-tosca-parser/src/main/java')
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java8
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java204
-rw-r--r--sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java54
3 files changed, 110 insertions, 156 deletions
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
index 88e22a0..8d04d97 100644
--- a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/api/ISdcCsarHelper.java
@@ -22,10 +22,10 @@ package org.openecomp.sdc.tosca.parser.api;
import java.util.List;
import org.apache.commons.lang3.tuple.Pair;
-import org.openecomp.sdc.toscaparser.api.Group;
-import org.openecomp.sdc.toscaparser.api.Metadata;
-import org.openecomp.sdc.toscaparser.api.NodeTemplate;
-import org.openecomp.sdc.toscaparser.api.parameters.Input;
+import org.openecomp.sdc.toscaparser.Group;
+import org.openecomp.sdc.toscaparser.NodeTemplate;
+import org.openecomp.sdc.toscaparser.elements.Metadata;
+import org.openecomp.sdc.toscaparser.parameters.Input;
public interface ISdcCsarHelper {
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
index 9ee3132..f24dce7 100644
--- a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
@@ -21,8 +21,10 @@
package org.openecomp.sdc.tosca.parser.impl;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
import java.util.stream.Collectors;
@@ -31,21 +33,21 @@ import org.apache.commons.lang3.tuple.Pair;
import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
import org.openecomp.sdc.tosca.parser.utils.GeneralUtility;
import org.openecomp.sdc.tosca.parser.utils.SdcToscaUtility;
-import org.openecomp.sdc.toscaparser.api.Group;
-import org.openecomp.sdc.toscaparser.api.Metadata;
-import org.openecomp.sdc.toscaparser.api.NodeTemplate;
-import org.openecomp.sdc.toscaparser.api.Property;
-import org.openecomp.sdc.toscaparser.api.SubstitutionMappings;
-import org.openecomp.sdc.toscaparser.api.TopologyTemplate;
-import org.openecomp.sdc.toscaparser.api.ToscaTemplate;
-import org.openecomp.sdc.toscaparser.api.elements.NodeType;
-import org.openecomp.sdc.toscaparser.api.parameters.Input;
+import org.openecomp.sdc.toscaparser.Group;
+import org.openecomp.sdc.toscaparser.NodeTemplate;
+import org.openecomp.sdc.toscaparser.Property;
+import org.openecomp.sdc.toscaparser.SubstitutionMappings;
+import org.openecomp.sdc.toscaparser.TopologyTemplate;
+import org.openecomp.sdc.toscaparser.ToscaTemplate;
+import org.openecomp.sdc.toscaparser.elements.Metadata;
+import org.openecomp.sdc.toscaparser.elements.NodeType;
+import org.openecomp.sdc.toscaparser.parameters.Input;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.yaml.snakeyaml.Yaml;
public class SdcCsarHelperImpl implements ISdcCsarHelper {
+ private static final String PATH_DELIMITER = "#";
private ToscaTemplate toscaTemplate;
private static Logger log = LoggerFactory.getLogger(SdcCsarHelperImpl.class.getName());
@@ -64,18 +66,17 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
log.error("getNodeTemplatePropertyLeafValue - leafValuePath is null or empty");
return null;
}
- log.trace("getNodeTemplatePropertyLeafValue - nodeTemplate is : {}, leafValuePath is {} ", nodeTemplate, leafValuePath);
- String[] split = leafValuePath.split("#");
- List<Property> properties = nodeTemplate.getProperties();
- log.trace("getNodeTemplatePropertyLeafValue - properties of nodeTemplate are : {}", properties);
+ log.debug("getNodeTemplatePropertyLeafValue - nodeTemplate is : {}, leafValuePath is {} ", nodeTemplate, leafValuePath);
+ String[] split = getSplittedPath(leafValuePath);
+ LinkedHashMap<String, Property> properties = nodeTemplate.getProperties();
+ log.debug("getNodeTemplatePropertyLeafValue - properties of nodeTemplate are : {}", properties);
return processProperties(split, properties);
}
-
@Override
//Sunny flow - covered with UT
public List<NodeTemplate> getServiceVlList() {
List<NodeTemplate> serviceVlList = getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), Types.TYPE_VL);
- log.trace("getServiceVlList - the VL list is {}", serviceVlList);
+ log.debug("getServiceVlList - the VL list is {}", serviceVlList);
return serviceVlList;
}
@@ -83,7 +84,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
//Sunny flow - covered with UT
public List<NodeTemplate> getServiceVfList() {
List<NodeTemplate> serviceVfList = getNodeTemplateBySdcType(toscaTemplate.getTopologyTemplate(), Types.TYPE_VF);
- log.trace("getServiceVfList - the VF list is {}", serviceVfList);
+ log.debug("getServiceVfList - the VF list is {}", serviceVfList);
return serviceVfList;
}
@@ -99,7 +100,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return null;
}
String metadataPropertyValue = metadata.getValue(metadataPropertyName);
- log.trace("getMetadataPropertyValue - metadata is {} metadataPropertyName is {} the value is : {}", metadata, metadataPropertyName , metadataPropertyValue);
+ log.debug("getMetadataPropertyValue - metadata is {} metadataPropertyName is {} the value is : {}", metadata, metadataPropertyName , metadataPropertyValue);
return metadataPropertyValue;
}
@@ -120,7 +121,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
}
}
- log.trace("getServiceNodeTemplatesByType - NodeTemplate list value is: {}", res);
+ log.debug("getServiceNodeTemplatesByType - For Node Type : {} - NodeTemplate list value is: {}", nodeType, res);
return res;
}
@@ -134,7 +135,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
List<NodeTemplate> serviceVfList = getServiceVfList();
NodeTemplate vfInstance = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationId);
- log.trace("getVfcListByVf - serviceVfList value: {}, vfInstance value: {}", serviceVfList, vfInstance);
+ log.debug("getVfcListByVf - serviceVfList value: {}, vfInstance value: {}", serviceVfList, vfInstance);
return getNodeTemplateBySdcType(vfInstance, Types.TYPE_VFC);
}
@@ -142,29 +143,29 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
//Sunny flow - covered with UT
public List<Group> getVfModulesByVf(String vfCustomizationUuid) {
List<NodeTemplate> serviceVfList = getServiceVfList();
- log.trace("getVfModulesByVf - VF list is {}", serviceVfList);
+ log.debug("getVfModulesByVf - VF list is {}", serviceVfList);
NodeTemplate nodeTemplateByCustomizationUuid = getNodeTemplateByCustomizationUuid(serviceVfList, vfCustomizationUuid);
- log.trace("getVfModulesByVf - getNodeTemplateByCustomizationUuid is {}, customizationUuid {}", nodeTemplateByCustomizationUuid, vfCustomizationUuid);
+ log.debug("getVfModulesByVf - getNodeTemplateByCustomizationUuid is {}, customizationUuid {}", nodeTemplateByCustomizationUuid, vfCustomizationUuid);
if (nodeTemplateByCustomizationUuid != null){
/*SubstitutionMappings substitutionMappings = nodeTemplateByCustomizationUuid.getSubstitutionMappings();
if (substitutionMappings != null){
List<Group> groups = substitutionMappings.getGroups();
if (groups != null){
List<Group> collect = groups.stream().filter(x -> "org.openecomp.groups.VfModule".equals(x.getTypeDefinition().getType())).collect(Collectors.toList());
- log.trace("getVfModulesByVf - VfModules are {}", collect);
+ log.debug("getVfModulesByVf - VfModules are {}", collect);
return collect;
}
}*/
String name = nodeTemplateByCustomizationUuid.getName();
String normaliseComponentInstanceName = SdcToscaUtility.normaliseComponentInstanceName(name);
List<Group> serviceLevelGroups = toscaTemplate.getTopologyTemplate().getGroups();
- log.trace("getVfModulesByVf - VF node template name {}, normalized name {}. Searching groups on service level starting with VF normalized name...", name, normaliseComponentInstanceName);
+ log.debug("getVfModulesByVf - VF node template name {}, normalized name {}. Searching groups on service level starting with VF normalized name...", name, normaliseComponentInstanceName);
if (serviceLevelGroups != null){
List<Group> collect = serviceLevelGroups
.stream()
.filter(x -> "org.openecomp.groups.VfModule".equals(x.getTypeDefinition().getType()) && x.getName().startsWith(normaliseComponentInstanceName))
.collect(Collectors.toList());
- log.trace("getVfModulesByVf - VfModules are {}", collect);
+ log.debug("getVfModulesByVf - VfModules are {}", collect);
return collect;
}
}
@@ -179,62 +180,71 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return null;
}
- String[] split = inputLeafValuePath.split("#");
+ String[] split = getSplittedPath(inputLeafValuePath);
if (split.length < 2 || !split[1].equals("default")){
log.error("getServiceInputLeafValue - inputLeafValuePath should be of format <input name>#default[optionally #<rest of path>] ");
return null;
}
List<Input> inputs = toscaTemplate.getInputs();
- log.trace("getServiceInputLeafValue - the leafValuePath is {} , the inputs are {}", inputLeafValuePath, inputs);
+ log.debug("getServiceInputLeafValue - the leafValuePath is {} , the inputs are {}", inputLeafValuePath, inputs);
if (inputs != null){
Optional<Input> findFirst = inputs.stream().filter(x -> x.getName().equals(split[0])).findFirst();
if (findFirst.isPresent()){
- log.trace("getServiceInputLeafValue - find first item is {}", findFirst.get());
+ log.debug("getServiceInputLeafValue - find first item is {}", findFirst.get());
Input input = findFirst.get();
Object current = input.getDefault();
- if (current == null){
- log.error("getServiceInputLeafValue - this input has no default");
+ return iterateProcessPath(2, current, split);
+ }
+ }
+ log.error("getServiceInputLeafValue - value not found");
+ return null;
+ }
+
+ private String iterateProcessPath(Integer index, Object current, String[] split) {
+ if (current == null) {
+ log.error("iterateProcessPath - this input has no default");
+ return null;
+ }
+ if (split.length > index) {
+ for (int i = index; i < split.length; i++) {
+ if (current instanceof Map){
+ current = ((Map<String, Object>)current).get(split[i]);
+ } else {
+ log.error("iterateProcessPath - found an unexpected leaf where expected to find a complex type");
return null;
}
- if (split.length > 2){
- current = new Yaml().load(current.toString());
- for (int i = 2; i < split.length; i++) {
- if (current instanceof Map){
- current = ((Map<String, Object>)current).get(split[i]);
- } else {
- log.error("getServiceInputLeafValue - found an unexpected leaf where expected to find a complex type");
- return null;
- }
- }
- }
- if (current != null){
- log.trace("getServiceInputLeafValue - the input default leaf value is {}", String.valueOf(current));
- return String.valueOf(current);
- }
}
}
- log.error("getServiceInputLeafValue - value not found");
+ if (current != null) {
+ log.debug("iterateProcessPath - the input default leaf value is {}", String.valueOf(current));
+ return String.valueOf(current);
+ }
+ log.error("iterateProcessPath - Path not Found");
return null;
}
+ private String[] getSplittedPath(String inputLeafValuePath) {
+ return inputLeafValuePath.split(PATH_DELIMITER);
+ }
+
@Override
//Sunny flow - covered with UT
public String getServiceSubstitutionMappingsTypeName() {
SubstitutionMappings substitutionMappings = toscaTemplate.getTopologyTemplate().getSubstitutionMappings();
if (substitutionMappings == null) {
- log.trace("getServiceSubstitutionMappingsTypeName - No Substitution Mappings defined");
+ log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings defined");
return null;
}
- log.trace("getServiceSubstitutionMappingsTypeName - SubstitutionMappings value: {}", substitutionMappings);
+ log.debug("getServiceSubstitutionMappingsTypeName - SubstitutionMappings value: {}", substitutionMappings);
NodeType nodeType = substitutionMappings.getNodeDefinition();
if (nodeType == null) {
- log.trace("getServiceSubstitutionMappingsTypeName - No Substitution Mappings node defined");
+ log.debug("getServiceSubstitutionMappingsTypeName - No Substitution Mappings node defined");
return null;
}
- log.trace("getServiceSubstitutionMappingsTypeName - nodeType value: {}", nodeType);
+ log.debug("getServiceSubstitutionMappingsTypeName - nodeType value: {}", nodeType);
return nodeType.getType();
}
@@ -242,7 +252,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
@Override
//Sunny flow - covered with UT
public Metadata getServiceMetadata() {
- return toscaTemplate.getMetadata();
+ return toscaTemplate.getMetaData();
}
@Override
@@ -264,8 +274,8 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return null;
}
- String[] split = leafValuePath.split("#");
- List<Property> properties = group.getProperties();
+ String[] split = getSplittedPath(leafValuePath);
+ LinkedHashMap<String,Property> properties = group.getProperties();
return processProperties(split, properties);
}
@@ -291,7 +301,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
}
cpList = getNodeTemplateBySdcType(vfInstance, Types.TYPE_CP);
if(cpList == null || cpList.size()==0)
- log.trace("getCpListByVf cps not exist for vfCustomizationId {}",vfCustomizationId);
+ log.debug("getCpListByVf cps not exist for vfCustomizationId {}",vfCustomizationId);
return cpList;
}
@@ -309,7 +319,7 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
}
- SubstitutionMappings substitutionMappings = vf.getSubstitutionMappings();
+ SubstitutionMappings substitutionMappings = vf.getSubMappingToscaTemplate();
if (substitutionMappings != null){
List<Group> groups = substitutionMappings.getGroups();
if (groups != null){
@@ -317,12 +327,12 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
.stream()
.filter(x -> (x.getMetadata() != null && serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID).equals(x.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)))).findFirst();
if (findFirst.isPresent()){
- log.trace("getMembersOfVfModule - Found VF level group with vfModuleModelInvariantUUID {}", serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID));
+ log.debug("getMembersOfVfModule - Found VF level group with vfModuleModelInvariantUUID {}", serviceLevelVfModule.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID));
List<String> members = findFirst.get().getMembers();
- log.trace("getMembersOfVfModule - members section is {}", members);
+ log.debug("getMembersOfVfModule - members section is {}", members);
if (members != null){
List<NodeTemplate> collect = substitutionMappings.getNodeTemplates().stream().filter(x -> members.contains(x.getName())).collect(Collectors.toList());
- log.trace("getMembersOfVfModule - Node templates are {}", collect);
+ log.debug("getMembersOfVfModule - Node templates are {}", collect);
return collect;
}
}
@@ -344,19 +354,17 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
if (listOfReqNodeTemplates != null){
for (NodeTemplate reqNodeTemplate : listOfReqNodeTemplates) {
- List<Map<String, Map<String, Object>>> requirements = reqNodeTemplate.getRequirements();
- if (requirements != null){
- for (Map<String, Map<String, Object>> reqEntry : requirements){
- Map<String, Object> reqEntryMap = reqEntry.get(reqName);
-
- if (reqEntryMap != null){
- Object node = reqEntryMap.get("node");
- if (node != null){
- String nodeString = (String)node;
- Optional<NodeTemplate> findFirst = listOfCapNodeTemplates.stream().filter(x -> x.getName().equals(nodeString)).findFirst();
- if (findFirst.isPresent()){
- pairsList.add(new ImmutablePair<NodeTemplate, NodeTemplate>(reqNodeTemplate, findFirst.get()));
- }
+ List<Object> requirements = reqNodeTemplate.getRequirements();
+ for (Object reqEntry : requirements) {
+ LinkedHashMap<String, Object> reqEntryHash = (LinkedHashMap<String, Object>) reqEntry;
+ Map<String, Object> reqEntryMap = (Map<String, Object>) reqEntryHash.get(reqName);
+ if (reqEntryMap != null){
+ Object node = reqEntryMap.get("node");
+ if (node != null){
+ String nodeString = (String)node;
+ Optional<NodeTemplate> findFirst = listOfCapNodeTemplates.stream().filter(x -> x.getName().equals(nodeString)).findFirst();
+ if (findFirst.isPresent()){
+ pairsList.add(new ImmutablePair<NodeTemplate, NodeTemplate>(reqNodeTemplate, findFirst.get()));
}
}
}
@@ -376,12 +384,12 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
log.error("getAllottedResources nodeTemplates not exist");
}
nodeTemplates = nodeTemplates.stream().filter(
- x -> x.getMetadata() != null && x.getMetadata().getValue("category").equals("Allotted Resources"))
+ x -> x.getMetaData() != null && x.getMetaData().getValue("category").equals("Allotted Resources"))
.collect(Collectors.toList());
if (nodeTemplates.isEmpty()) {
- log.trace("getAllottedResources - allotted resources not exist");
+ log.debug("getAllottedResources - allotted resources not exist");
} else {
- log.trace("getAllottedResources - the allotted resources list is {}", nodeTemplates);
+ log.debug("getAllottedResources - the allotted resources list is {}", nodeTemplates);
}
return nodeTemplates;
@@ -410,16 +418,16 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return new ArrayList<>();
}
- SubstitutionMappings substitutionMappings = nodeTemplate.getSubstitutionMappings();
+ SubstitutionMappings substitutionMappings = nodeTemplate.getSubMappingToscaTemplate();
if (substitutionMappings != null) {
List<NodeTemplate> nodeTemplates = substitutionMappings.getNodeTemplates();
if (nodeTemplates != null && nodeTemplates.size() > 0)
- return nodeTemplates.stream().filter(x -> (x.getMetadata() != null && sdcType.equals(x.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)))).collect(Collectors.toList());
+ return nodeTemplates.stream().filter(x -> (x.getMetaData() != null && sdcType.equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)))).collect(Collectors.toList());
else
- log.trace("getNodeTemplateBySdcType - SubstitutionMappings' node Templates not exist");
+ log.debug("getNodeTemplateBySdcType - SubstitutionMappings' node Templates not exist");
} else
- log.trace("getNodeTemplateBySdcType - SubstitutionMappings not exist");
+ log.debug("getNodeTemplateBySdcType - SubstitutionMappings not exist");
return new ArrayList<>();
}
@@ -438,47 +446,29 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
List<NodeTemplate> nodeTemplates = topologyTemplate.getNodeTemplates();
if (nodeTemplates != null && nodeTemplates.size() > 0)
- return nodeTemplates.stream().filter(x -> (x.getMetadata() != null && sdcType.equals(x.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)))).collect(Collectors.toList());
+ return nodeTemplates.stream().filter(x -> (x.getMetaData() != null && sdcType.equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)))).collect(Collectors.toList());
- log.trace("getNodeTemplateBySdcType - topologyTemplate's nodeTemplates not exist");
+ log.debug("getNodeTemplateBySdcType - topologyTemplate's nodeTemplates not exist");
return new ArrayList<>();
}
//Assumed to be unique property for the list
private NodeTemplate getNodeTemplateByCustomizationUuid(List<NodeTemplate> nodeTemplates, String customizationId){
- log.trace("getNodeTemplateByCustomizationUuid - nodeTemplates {}, customizationId {}", nodeTemplates, customizationId);
- Optional<NodeTemplate> findFirst = nodeTemplates.stream().filter(x -> (x.getMetadata() != null && customizationId.equals(x.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)))).findFirst();
+ log.debug("getNodeTemplateByCustomizationUuid - nodeTemplates {}, customizationId {}", nodeTemplates, customizationId);
+ Optional<NodeTemplate> findFirst = nodeTemplates.stream().filter(x -> (x.getMetaData() != null && customizationId.equals(x.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)))).findFirst();
return findFirst.isPresent() ? findFirst.get() : null;
}
- private String processProperties(String[] split, List<Property> properties) {
- log.trace("processProperties - the leafValuePath is {} , the properties are {}", split.toString(), properties.toString());
- Optional<Property> findFirst = properties.stream().filter(x -> x.getName().equals(split[0])).findFirst();
+ private String processProperties(String[] split, LinkedHashMap<String, Property> properties) {
+ log.debug("processProperties - the leafValuePath is {} , the properties are {}", split.toString(), properties.toString());
+ Optional<Entry<String, Property>> findFirst = properties.entrySet().stream().filter(x -> x.getKey().equals(split[0])).findFirst();
if (findFirst.isPresent()){
- log.trace("processProperties - find first item is {}", findFirst.get());
- Property property = findFirst.get();
+ log.debug("processProperties - find first item is {}", findFirst.get());
+ Property property = findFirst.get().getValue();
Object current = property.getValue();
- if (current == null){
- log.error("processProperties - this property has no value");
- return null;
- }
- if (split.length > 1){
- current = new Yaml().load(current.toString());
- for (int i = 1; i < split.length; i++) {
- if (current instanceof Map){
- current = ((Map<String, Object>)current).get(split[i]);
- } else {
- log.error("processProperties - found an unexpected leaf where expected to find a complex type");
- return null;
- }
- }
- }
- if (current != null){
- log.trace("processProperties - the property value is {}", String.valueOf(current));
- return String.valueOf(current);
- }
+ return iterateProcessPath(1, current, split);
}
log.error("processProperties - Dont find property");
return null;
- }
+ }
}
diff --git a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java
index 243d238..f8ac3cc 100644
--- a/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java
+++ b/sdc-tosca-parser/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java
@@ -5,15 +5,13 @@ import java.util.List;
import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
import org.openecomp.sdc.tosca.parser.exceptions.SdcToscaParserException;
-import org.openecomp.sdc.toscaparser.ToscaParser;
-import org.openecomp.sdc.toscaparser.ToscaParserFactory;
-import org.openecomp.sdc.toscaparser.api.NodeTemplate;
-import org.openecomp.sdc.toscaparser.api.ToscaTemplate;
+import org.openecomp.sdc.toscaparser.NodeTemplate;
+import org.openecomp.sdc.toscaparser.ToscaTemplate;
+import org.openecomp.sdc.toscaparser.common.JToscaException;
-public class SdcToscaParserFactory implements AutoCloseable{
+public class SdcToscaParserFactory{
private static SdcToscaParserFactory instance;
- private static ToscaParserFactory toscaParserFactory;
private SdcToscaParserFactory(){}
@@ -26,7 +24,6 @@ public class SdcToscaParserFactory implements AutoCloseable{
synchronized (SdcToscaParserFactory.class) {
if (instance == null) {
instance = new SdcToscaParserFactory();
- toscaParserFactory = new ToscaParserFactory();
}
}
}
@@ -38,48 +35,15 @@ public class SdcToscaParserFactory implements AutoCloseable{
* @param csarPath - the path to CSAR file.
* @return ISdcCsarHelper object.
* @throws SdcToscaParserException - in case the path or CSAR are invalid.
+ * @throws JToscaException
*/
- public ISdcCsarHelper getSdcCsarHelper(String csarPath) throws SdcToscaParserException{
+ public ISdcCsarHelper getSdcCsarHelper(String csarPath) throws SdcToscaParserException, JToscaException, IOException{
//TODO add logic to check if legal file and csar
synchronized (SdcToscaParserFactory.class) {
- if (toscaParserFactory == null){
- throw new SdcToscaParserException("The factory is closed. It was probably closed too soon.");
- }
- try {
- ToscaParser create = toscaParserFactory.create();
- ToscaTemplate parse = create.parse(csarPath);
- SdcCsarHelperImpl sdcCsarHelperImpl = new SdcCsarHelperImpl(parse);
- return sdcCsarHelperImpl;
- } catch (IOException e) {
- throw new SdcToscaParserException("Exception when creating the parser: "+e.getMessage());
- }
+ ToscaTemplate tosca = new ToscaTemplate(csarPath, null, true, null);
+ SdcCsarHelperImpl sdcCsarHelperImpl = new SdcCsarHelperImpl(tosca);
+ return sdcCsarHelperImpl;
}
}
- /**
- * Close the SdcToscaParserFactory.
- */
- public void close() {
- if (toscaParserFactory != null){
- synchronized (SdcToscaParserFactory.class) {
- if (toscaParserFactory != null) {
- try {
- toscaParserFactory.close();
- toscaParserFactory = null;
- } catch (IOException e) {
- //TODO add logging
- }
- }
- }
- }
- }
-
- public static void main(String[] args) throws SdcToscaParserException {
- try (SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance()){ //Autoclosable
- ISdcCsarHelper sdcCsarHelper = factory.getSdcCsarHelper("C:\\Users\\pa0916\\Desktop\\Work\\ASDC\\CSARs\\csar_hello_world.zip");
- //Can run methods on the helper
- List<NodeTemplate> allottedResources = sdcCsarHelper.getAllottedResources();
- //..............
- }
- }
} \ No newline at end of file