summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/onap/sdc/toscaparser/api/ImportsLoader.java5
-rw-r--r--src/main/java/org/onap/sdc/toscaparser/api/TopologyTemplate.java3
-rw-r--r--src/main/java/org/onap/sdc/toscaparser/api/ToscaTemplate.java4
-rw-r--r--src/main/java/org/onap/sdc/toscaparser/api/functions/GetInput.java2
-rw-r--r--src/main/java/org/onap/sdc/toscaparser/api/parameters/Input.java4
5 files changed, 12 insertions, 6 deletions
diff --git a/src/main/java/org/onap/sdc/toscaparser/api/ImportsLoader.java b/src/main/java/org/onap/sdc/toscaparser/api/ImportsLoader.java
index 76800f7..19ec182 100644
--- a/src/main/java/org/onap/sdc/toscaparser/api/ImportsLoader.java
+++ b/src/main/java/org/onap/sdc/toscaparser/api/ImportsLoader.java
@@ -1,5 +1,6 @@
package org.onap.sdc.toscaparser.api;
+import com.google.common.base.Charsets;
import org.onap.sdc.toscaparser.api.common.JToscaValidationIssue;
import org.onap.sdc.toscaparser.api.utils.ThreadLocalsHolder;
import org.onap.sdc.toscaparser.api.utils.UrlUtils;
@@ -372,11 +373,11 @@ public class ImportsLoader {
al[0] = al[1] = null;
return al;
}
- try (InputStream input = new FileInputStream(new File(importTemplate));) {
+ try (BufferedReader br = new BufferedReader(new FileReader(importTemplate));) {
al[0] = importTemplate;
Yaml yaml = new Yaml();
- al[1] = yaml.load(input);
+ al[1] = yaml.load(br);
return al;
}
catch(FileNotFoundException e) {
diff --git a/src/main/java/org/onap/sdc/toscaparser/api/TopologyTemplate.java b/src/main/java/org/onap/sdc/toscaparser/api/TopologyTemplate.java
index e3d3538..4c9a53d 100644
--- a/src/main/java/org/onap/sdc/toscaparser/api/TopologyTemplate.java
+++ b/src/main/java/org/onap/sdc/toscaparser/api/TopologyTemplate.java
@@ -540,6 +540,9 @@ public class TopologyTemplate {
public boolean getResolveGetInput() {
return resolveGetInput;
}
+ public LinkedHashMap<String, Object> getCustomDefs() {
+ return customDefs;
+ }
}
/*python
diff --git a/src/main/java/org/onap/sdc/toscaparser/api/ToscaTemplate.java b/src/main/java/org/onap/sdc/toscaparser/api/ToscaTemplate.java
index bfd0716..f236a0a 100644
--- a/src/main/java/org/onap/sdc/toscaparser/api/ToscaTemplate.java
+++ b/src/main/java/org/onap/sdc/toscaparser/api/ToscaTemplate.java
@@ -103,6 +103,7 @@ public class ToscaTemplate extends Object {
private int nestingLoopCounter;
private LinkedHashMap<String, LinkedHashMap<String, Object>> metaProperties;
private Set<String> processedImports;
+ private LinkedHashMap<String,Object> customDefsFinal = new LinkedHashMap<>();
public ToscaTemplate(String _path,
LinkedHashMap<String,Object> _parsedParams,
@@ -335,14 +336,15 @@ public class ToscaTemplate extends Object {
* @param alImports all imports which needs to be processed
* @return the linked hash map containing all import definitions
*/
+
@SuppressWarnings("unchecked")
private LinkedHashMap<String,Object> _getAllCustomDefs(Object alImports) {
+
String types[] = {
IMPORTS, NODE_TYPES, CAPABILITY_TYPES, RELATIONSHIP_TYPES,
DATA_TYPES, INTERFACE_TYPES, POLICY_TYPES, GROUP_TYPES
};
- LinkedHashMap<String,Object> customDefsFinal = new LinkedHashMap<>();
List<Map<String, Object>> imports = (List<Map<String, Object>>) alImports;
if (imports != null && !imports.isEmpty()) {
diff --git a/src/main/java/org/onap/sdc/toscaparser/api/functions/GetInput.java b/src/main/java/org/onap/sdc/toscaparser/api/functions/GetInput.java
index 262d99a..f2df667 100644
--- a/src/main/java/org/onap/sdc/toscaparser/api/functions/GetInput.java
+++ b/src/main/java/org/onap/sdc/toscaparser/api/functions/GetInput.java
@@ -50,7 +50,7 @@ public class GetInput extends Function {
String type = (String)ttinpinp.get("type");
Object value = DataEntity.validateDatatype(
- type, toscaTpl.getParsedParams().get(getInputName()),null,null,null);
+ type, toscaTpl.getParsedParams().get(getInputName()),null,toscaTpl.getCustomDefs(),null);
//SDC resolving Get Input
if (value instanceof ArrayList){
if(args.size() == 2 && args.get(1) instanceof Integer && ((ArrayList) value).size()> (Integer)args.get(1)){
diff --git a/src/main/java/org/onap/sdc/toscaparser/api/parameters/Input.java b/src/main/java/org/onap/sdc/toscaparser/api/parameters/Input.java
index e7a1246..d59f406 100644
--- a/src/main/java/org/onap/sdc/toscaparser/api/parameters/Input.java
+++ b/src/main/java/org/onap/sdc/toscaparser/api/parameters/Input.java
@@ -153,7 +153,7 @@ public class Input {
String type = getType();
// if it's one of the basic types DON'T look in customDefs
if(Arrays.asList(PRIMITIVE_TYPES).contains(type)) {
- DataEntity.validateDatatype(getType(), value, null, (LinkedHashMap<String,Object>)datatype, null);
+ DataEntity.validateDatatype(getType(), value, null, customDefs, null);
return;
}
else if(customDefs.get(getType()) != null) {
@@ -162,7 +162,7 @@ public class Input {
return;
}
- DataEntity.validateDatatype(getType(), value, null, (LinkedHashMap<String,Object>)datatype, null);
+ DataEntity.validateDatatype(getType(), value, null, customDefs, null);
}
public Map<String, Annotation> getAnnotations() {