aboutsummaryrefslogtreecommitdiffstats
path: root/jtosca/src/main/java
diff options
context:
space:
mode:
authorPavel Aharoni <pa0916@att.com>2017-05-11 19:51:35 +0300
committerPavel Aharoni <pa0916@att.com>2017-05-11 19:51:35 +0300
commit3940304759ebd74d05c129501aa5f92e5e938033 (patch)
treeae559b8f40d2efcbe47089a728524a1725cc5586 /jtosca/src/main/java
parent8caef088a9e5467cd0cb462acb217edceedac8fe (diff)
[SDC-20] fix sdc csar for tosca parser
Change-Id: Ibfa18bd03cf1d4dc56062fbe1a55331217c6c76f Signed-off-by: Pavel Aharoni <pa0916@att.com>
Diffstat (limited to 'jtosca/src/main/java')
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java17
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/EntityTemplate.java2
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java4
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/PropertyDef.java2
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/ScalarUnit.java2
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Constraint.java2
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Schema.java2
-rw-r--r--jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/functions/GetInput.java3
8 files changed, 23 insertions, 11 deletions
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java
index 3598d02..a96b36a 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java
@@ -48,8 +48,9 @@ public class DataEntity {
// If the datatype has 'properties' definition
else {
if(!(value instanceof LinkedHashMap)) {
- ExceptionCollector.appendException(String.format(
- "TypeMismatchError: \"%s\" doesn't match \"%s\"",
+ //ERROR under investigation
+ ExceptionCollector.appendWarning(String.format(
+ "TypeMismatchError: \"%s\" is not a map. The type is \"%s\"",
value.toString(),dataType.getType()));
if (value instanceof List)
@@ -80,7 +81,8 @@ public class DataEntity {
// check allowed field
for(String valueKey: valueDict.keySet()) {
- if(!allowedProps.contains(valueKey)) {
+ //1710 devlop JSON validation
+ if(!("json").equals(dataType.getType()) && !allowedProps.contains(valueKey)) {
ExceptionCollector.appendException(String.format(
"UnknownFieldError: Data value of type \"%s\" contains unknown field \"%s\"",
dataType.getType(),valueKey));
@@ -104,7 +106,7 @@ public class DataEntity {
}
}
if(missingProp.size() > 0) {
- ExceptionCollector.appendException(String.format(
+ ExceptionCollector.appendWarning(String.format(
"MissingRequiredFieldError: Data value of type \"%s\" is missing required field(s) \"%s\"",
dataType.getType(),missingProp.toString()));
}
@@ -162,6 +164,13 @@ public class DataEntity {
if(Function.isFunction(value)) {
return value;
}
+ else if (type == null) {
+ //NOT ANALYZED
+ ExceptionCollector.appendWarning(String.format(
+ "MissingType: Type is missing for value \"%s\"",
+ value.toString()));
+ return value;
+ }
else if(type.equals(Schema.STRING)) {
return ValidateUtils.validateString(value);
}
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/EntityTemplate.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/EntityTemplate.java
index cb765ec..224d5df 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/EntityTemplate.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/EntityTemplate.java
@@ -343,7 +343,7 @@ public abstract class EntityTemplate {
}
// Required properties found without value or a default value
if(!reqPropsNoValueOrDefault.isEmpty()) {
- ExceptionCollector.appendException(String.format(
+ ExceptionCollector.appendWarning(String.format(
"MissingRequiredFieldError: properties of template \"%s\" are missing field(s): %s",
name,reqPropsNoValueOrDefault.toString()));
}
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java
index 08b66bd..9f2fd7a 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java
@@ -404,11 +404,13 @@ public class ToscaTemplate extends Object {
for(NodeTemplate nt: nodeTemplates) {
if(_isSubMappedNode(nt,toscaTpl)) {
parsedParams = _getParamsForNestedTemplate(nt);
+ ArrayList<Object> alim = (ArrayList<Object>)toscaTpl.get(IMPORTS);
LinkedHashMap<String,Object> topologyTpl =
(LinkedHashMap<String,Object>)toscaTpl.get(TOPOLOGY_TEMPLATE);
TopologyTemplate topologyWithSubMapping =
new TopologyTemplate(topologyTpl,
- _getAllCustomDefs(null),
+ //_getAllCustomDefs(null),
+ _getAllCustomDefs(alim),
relationshipTypes,
parsedParams,
nt);
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/PropertyDef.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/PropertyDef.java
index bbc1de1..5e6b47d 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/PropertyDef.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/PropertyDef.java
@@ -116,7 +116,7 @@ public class PropertyDef {
// attr,
// value,
// valid_values)
- ExceptionCollector.appendException(String.format(
+ ExceptionCollector.appendWarning(String.format(
"Schema definition of \"%s\" has \"status\" attribute with an invalid value",
name));
}
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/ScalarUnit.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/ScalarUnit.java
index 5b17b9a..42e94eb 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/ScalarUnit.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/ScalarUnit.java
@@ -51,7 +51,7 @@ public abstract class ScalarUnit {
return key;
}
}
- ExceptionCollector.appendException(String.format(
+ ExceptionCollector.appendWarning(String.format(
"'The unit \"%s\" is not valid. Valid units are \n%s",
inputUnit,SCALAR_UNIT_DICT.keySet().toString()));
return inputUnit;
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Constraint.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Constraint.java
index d82b76c..60b756f 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Constraint.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Constraint.java
@@ -152,7 +152,7 @@ public abstract class Constraint {
value = ScalarUnit.getScalarunitValue(propertyType,value,null);
}
if(!_isValid(value)) {
- ExceptionCollector.appendException("ValidationError: " + _errMsg(value));
+ ExceptionCollector.appendWarning("ValidationError: " + _errMsg(value));
}
}
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Schema.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Schema.java
index 5fa7547..eb4b6ce 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Schema.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Schema.java
@@ -35,7 +35,7 @@ public class Schema {
public static final String VERSION = "version";
public static final String PORTDEF = "PortDef";
public static final String PORTSPEC = "PortSpec"; //??? PortSpec.SHORTNAME
- public static final String JSON = "json";
+ public static final String JSON = "json";
public static final String PROPERTY_TYPES[] = {
INTEGER, STRING, BOOLEAN, FLOAT, RANGE,NUMBER, TIMESTAMP, LIST, MAP,
diff --git a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/functions/GetInput.java b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/functions/GetInput.java
index 7970207..df32699 100644
--- a/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/functions/GetInput.java
+++ b/jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/functions/GetInput.java
@@ -18,7 +18,8 @@ public class GetInput extends Function {
@Override
void validate() {
if(args.size() != 1) {
- ExceptionCollector.appendException(String.format(
+ //ERROR under investigation
+ ExceptionCollector.appendWarning(String.format(
"ValueError: Expected one argument for function \"get_input\" but received \"%s\"",
args.toString()));
}