[SDC-20] fix sdc csar for tosca parser 47/4147/1
authorPavel Aharoni <pa0916@att.com>
Thu, 11 May 2017 16:51:35 +0000 (19:51 +0300)
committerPavel Aharoni <pa0916@att.com>
Thu, 11 May 2017 16:51:35 +0000 (19:51 +0300)
Change-Id: Ibfa18bd03cf1d4dc56062fbe1a55331217c6c76f
Signed-off-by: Pavel Aharoni <pa0916@att.com>
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/DataEntity.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/EntityTemplate.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/ToscaTemplate.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/PropertyDef.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/ScalarUnit.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Constraint.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/elements/constraints/Schema.java
jtosca/src/main/java/org/openecomp/sdc/toscaparser/api/functions/GetInput.java
jtosca/src/main/resources/TOSCA_definition_1_0.yaml
sdc-distribution-ci/src/main/java/org/openecomp/test/CsarToscaTester.java

index 3598d02..a96b36a 100644 (file)
@@ -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);
                }
index cb765ec..224d5df 100644 (file)
@@ -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()));
             }
index 08b66bd..9f2fd7a 100644 (file)
@@ -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);
index bbc1de1..5e6b47d 100644 (file)
@@ -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));
                        }
index 5b17b9a..42e94eb 100644 (file)
@@ -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;
index d82b76c..60b756f 100644 (file)
@@ -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));
         }
        }
 
index 5fa7547..eb4b6ce 100644 (file)
@@ -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,
index 7970207..df32699 100644 (file)
@@ -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()));
            }
index 27c3e49..554b7b6 100644 (file)
@@ -278,7 +278,7 @@ node_types:
     capabilities:
       link:
         type: tosca.capabilities.network.Linkable
-
+    
   tosca.nodes.network.Port:
     derived_from: tosca.nodes.Root
     description: >
@@ -777,7 +777,7 @@ data_types:
   tosca.datatypes.Root:
     description: >
       The TOSCA root Data Type all other TOSCA base Data Types derive from
-
+    
   tosca.datatypes.network.NetworkInfo:
     derived_from: tosca.datatypes.Root
     properties:
index 0ac842c..404f6d2 100644 (file)
@@ -48,14 +48,14 @@ public class CsarToscaTester {
                        if (!exceptionReport.isEmpty())  {\r
                                \r
                                        try {\r
-                                               fw = new FileWriter(new File(dir + "/critical-" + file.getName() + ".txt"));\r
+                                               fw = new FileWriter(new File(dir + "/" + exceptionReport.size() / 2 + "-critical-" + file.getName() + ".txt"));\r
                                                for (String exception : exceptionReport) {\r
                                                        fw.write(exception);\r
                                                        fw.write("\r\n");\r
                                                }\r
                                                fw.close();\r
                                                \r
-                                               fw = new FileWriter(new File(dir + "/warning-" + file.getName() + ".txt"));\r
+                                               fw = new FileWriter(new File(dir + "/" + warningsReport.size() / 2 +  "-warning-" + file.getName() + ".txt"));\r
                                                for (String warning : warningsReport) {\r
                                                        fw.write(warning);\r
                                                        fw.write("\r\n");\r