aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/sdc/toscaparser/api/elements/TypeValidation.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/sdc/toscaparser/api/elements/TypeValidation.java')
-rw-r--r--src/main/java/org/onap/sdc/toscaparser/api/elements/TypeValidation.java126
1 files changed, 63 insertions, 63 deletions
diff --git a/src/main/java/org/onap/sdc/toscaparser/api/elements/TypeValidation.java b/src/main/java/org/onap/sdc/toscaparser/api/elements/TypeValidation.java
index 9321064..18dd5ca 100644
--- a/src/main/java/org/onap/sdc/toscaparser/api/elements/TypeValidation.java
+++ b/src/main/java/org/onap/sdc/toscaparser/api/elements/TypeValidation.java
@@ -7,9 +7,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,25 +30,25 @@ import org.onap.sdc.toscaparser.api.extensions.ExtTools;
public class TypeValidation {
- private static final String DEFINITION_VERSION = "tosca_definitions_version";
- private static final String DESCRIPTION = "description";
- private static final String IMPORTS = "imports";
- private static final String DSL_DEFINITIONS = "dsl_definitions";
- private static final String NODE_TYPES = "node_types";
- private static final String REPOSITORIES = "repositories";
- private static final String DATA_TYPES = "data_types";
- private static final String ARTIFACT_TYPES = "artifact_types";
- private static final String GROUP_TYPES = "group_types";
- private static final String RELATIONSHIP_TYPES = "relationship_types";
- private static final String CAPABILITY_TYPES = "capability_types";
- private static final String INTERFACE_TYPES = "interface_types";
- private static final String POLICY_TYPES = "policy_types";
- private static final String TOPOLOGY_TEMPLATE = "topology_template";
- //Pavel
- private static final String METADATA = "metadata";
-
- private String ALLOWED_TYPE_SECTIONS[] = {
- DEFINITION_VERSION, DESCRIPTION, IMPORTS,
+ private static final String DEFINITION_VERSION = "tosca_definitions_version";
+ private static final String DESCRIPTION = "description";
+ private static final String IMPORTS = "imports";
+ private static final String DSL_DEFINITIONS = "dsl_definitions";
+ private static final String NODE_TYPES = "node_types";
+ private static final String REPOSITORIES = "repositories";
+ private static final String DATA_TYPES = "data_types";
+ private static final String ARTIFACT_TYPES = "artifact_types";
+ private static final String GROUP_TYPES = "group_types";
+ private static final String RELATIONSHIP_TYPES = "relationship_types";
+ private static final String CAPABILITY_TYPES = "capability_types";
+ private static final String INTERFACE_TYPES = "interface_types";
+ private static final String POLICY_TYPES = "policy_types";
+ private static final String TOPOLOGY_TEMPLATE = "topology_template";
+ //Pavel
+ private static final String METADATA = "metadata";
+
+ private String ALLOWED_TYPE_SECTIONS[] = {
+ DEFINITION_VERSION, DESCRIPTION, IMPORTS,
DSL_DEFINITIONS, NODE_TYPES, REPOSITORIES,
DATA_TYPES, ARTIFACT_TYPES, GROUP_TYPES,
RELATIONSHIP_TYPES, CAPABILITY_TYPES,
@@ -57,65 +57,65 @@ public class TypeValidation {
};
private static ArrayList<String> VALID_TEMPLATE_VERSIONS = _getVTV();
-
+
private static ArrayList<String> _getVTV() {
- ArrayList<String> vtv = new ArrayList<>();
- vtv.add("tosca_simple_yaml_1_0");
- vtv.add("tosca_simple_yaml_1_1");
- ExtTools exttools = new ExtTools();
+ ArrayList<String> vtv = new ArrayList<>();
+ vtv.add("tosca_simple_yaml_1_0");
+ vtv.add("tosca_simple_yaml_1_1");
+ ExtTools exttools = new ExtTools();
vtv.addAll(exttools.getVersions());
return vtv;
}
-
+
//private LinkedHashMap<String,Object> customTypes;
private Object importDef;
//private String version;
-
- public TypeValidation(LinkedHashMap<String,Object> _customTypes,
- Object _importDef) {
+
+ public TypeValidation(LinkedHashMap<String, Object> _customTypes,
+ Object _importDef) {
importDef = _importDef;
_validateTypeKeys(_customTypes);
}
-
- private void _validateTypeKeys(LinkedHashMap<String,Object> customTypes) {
-
- String sVersion = (String)customTypes.get(DEFINITION_VERSION);
- if(sVersion != null) {
- _validateTypeVersion(sVersion);
+
+ private void _validateTypeKeys(LinkedHashMap<String, Object> customTypes) {
+
+ String sVersion = (String) customTypes.get(DEFINITION_VERSION);
+ if (sVersion != null) {
+ _validateTypeVersion(sVersion);
//version = sVersion;
}
- for(String name: customTypes.keySet()) {
- boolean bFound = false;
- for(String ats: ALLOWED_TYPE_SECTIONS) {
- if(name.equals(ats)) {
- bFound = true;
- break;
- }
- }
- if(!bFound) {
+ for (String name : customTypes.keySet()) {
+ boolean bFound = false;
+ for (String ats : ALLOWED_TYPE_SECTIONS) {
+ if (name.equals(ats)) {
+ bFound = true;
+ break;
+ }
+ }
+ if (!bFound) {
ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE138", String.format(
- "UnknownFieldError: Template \"%s\" contains unknown field \"%s\"",
- importDef.toString(),name)));
- }
+ "UnknownFieldError: Template \"%s\" contains unknown field \"%s\"",
+ importDef.toString(), name)));
+ }
}
}
-
+
private void _validateTypeVersion(String sVersion) {
- boolean bFound = false;
- String allowed = "";
- for(String atv: VALID_TEMPLATE_VERSIONS) {
- allowed += "\"" + atv + "\" ";
- if(sVersion.equals(atv)) {
- bFound = true;
- break;
- }
- }
- if(!bFound) {
+ boolean bFound = false;
+ String allowed = "";
+ for (String atv : VALID_TEMPLATE_VERSIONS) {
+ allowed += "\"" + atv + "\" ";
+ if (sVersion.equals(atv)) {
+ bFound = true;
+ break;
+ }
+ }
+ if (!bFound) {
ThreadLocalsHolder.getCollector().appendValidationIssue(new JToscaValidationIssue("JE139", String.format(
- "InvalidTemplateVersion: version \"%s\" in \"%s\" is not supported\n" +
- "Allowed versions: [%s]",
- sVersion,importDef.toString(),allowed)));
- }
+ "InvalidTemplateVersion: version \"%s\" in \"%s\" is not supported\n" +
+ "Allowed versions: [%s]",
+ sVersion, importDef.toString(), allowed)));
+ }
}
}