aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/config/ConfigurationManager.java3
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/config/ErrorInfo.java10
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java59
-rw-r--r--src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java2
4 files changed, 55 insertions, 19 deletions
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/config/ConfigurationManager.java b/src/main/java/org/openecomp/sdc/tosca/parser/config/ConfigurationManager.java
index 72c06ed..f2fc903 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/config/ConfigurationManager.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/config/ConfigurationManager.java
@@ -118,4 +118,7 @@ public class ConfigurationManager {
public Configuration getConfiguration() {
return (Configuration) configurations.get((Configuration.class.getSimpleName()));
}
+ public void setErrorConfiguration(String fileName) {
+ loadConfigurationClass(ErrorConfiguration.class, fileName);
+ }
}
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/config/ErrorInfo.java b/src/main/java/org/openecomp/sdc/tosca/parser/config/ErrorInfo.java
index 01df115..34983ef 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/config/ErrorInfo.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/config/ErrorInfo.java
@@ -24,6 +24,7 @@ public class ErrorInfo {
private String code;
private String message;
+ private boolean failOnError;
public String getCode() {
return code;
@@ -40,10 +41,19 @@ public class ErrorInfo {
public void setMessage(String message) {
this.message = message;
}
+
+ public boolean getFailOnError() {
+ return failOnError;
+ }
+
+ public void setFailOnError(boolean failOnError) {
+ this.failOnError = failOnError;
+ }
public void cloneData(ErrorInfo other) {
this.code = other.getCode();
this.message = other.getMessage();
+ this.failOnError = other.getFailOnError();
}
}
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
index 7b94000..901b315 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcCsarHelperImpl.java
@@ -27,6 +27,7 @@ import java.util.stream.Collectors;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.openecomp.sdc.tosca.parser.api.ISdcCsarHelper;
+import org.openecomp.sdc.tosca.parser.config.ConfigurationManager;
import org.openecomp.sdc.toscaparser.api.CapabilityAssignments;
import org.openecomp.sdc.tosca.parser.utils.GeneralUtility;
import org.openecomp.sdc.toscaparser.api.RequirementAssignments;
@@ -46,12 +47,18 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
private static final String PATH_DELIMITER = "#";
private static final String CUSTOMIZATION_UUID = "customizationUUID";
private ToscaTemplate toscaTemplate;
+ private ConfigurationManager configurationManager;
private static Logger log = LoggerFactory.getLogger(SdcCsarHelperImpl.class.getName());
public SdcCsarHelperImpl(ToscaTemplate toscaTemplate) {
this.toscaTemplate = toscaTemplate;
}
+ public SdcCsarHelperImpl(ToscaTemplate toscaTemplate, ConfigurationManager configurationManager) {
+ this.toscaTemplate = toscaTemplate;
+ this.configurationManager = configurationManager;
+ }
+
@Override
//Sunny flow - covered with UT, flat and nested
public String getNodeTemplatePropertyLeafValue(NodeTemplate nodeTemplate, String leafValuePath) {
@@ -579,24 +586,40 @@ public class SdcCsarHelperImpl implements ISdcCsarHelper {
return nodeTemplate.getTypeDefinition().getType();
}
- @Override
- public String getConformanceLevel() {
- LinkedHashMap<String, Object> csarMeta = toscaTemplate.getMetaProperties("csar.meta");
- if (csarMeta == null){
- log.warn("No csar.meta file is found in CSAR - this file should hold the conformance level of the CSAR. This might be OK for older CSARs.");
- return null;
- }
-
- Object conformanceLevel = csarMeta.get("SDC-TOSCA-Definitions-Version");
- if (conformanceLevel != null){
- String confLevelStr = conformanceLevel.toString();
- log.debug("CSAR conformance level is {}", confLevelStr);
- return confLevelStr;
- } else {
- log.error("Invalid csar.meta file - no entry found for SDC-TOSCA-Definitions-Version key. This entry should hold the conformance level.");
- return null;
- }
- }
+ /**
+ * This methdd is returning the csarConformanceLevel for input CSAR
+ * When csarConformanceLevel is configured with failOnError as False in Error Configuration; it
+ * assigns the default value to csarConformanceLevel which is the max level provided in
+ * Configuration file
+ * @return csarConformanceLevel
+ */
+ @Override
+ public String getConformanceLevel() {
+ LinkedHashMap<String, Object> csarMeta = toscaTemplate.getMetaProperties("csar.meta");
+ if (csarMeta == null){
+ log.warn("No csar.meta file is found in CSAR - this file should hold the conformance level of the CSAR. This might be OK for older CSARs.");
+ if (configurationManager != null && !configurationManager.getErrorConfiguration()
+ .getErrorInfo("CONFORMANCE_LEVEL_ERROR").getFailOnError()){
+ String csarConLevel = configurationManager.getConfiguration().getConformanceLevel().getMaxVersion();
+ log.warn("csarConformanceLevel is not found in input csar; defaulting to max version {}" , csarConLevel);
+ return csarConLevel;
+ }
+ else {
+ log.warn("csarConformanceLevel is not found in input csar; returning null as no defaults defined in error configuration");
+ return null;
+ }
+ }
+
+ Object conformanceLevel = csarMeta.get("SDC-TOSCA-Definitions-Version");
+ if (conformanceLevel != null){
+ String confLevelStr = conformanceLevel.toString();
+ log.debug("CSAR conformance level is {}", confLevelStr);
+ return confLevelStr;
+ } else {
+ log.error("Invalid csar.meta file - no entry found for SDC-TOSCA-Definitions-Version key. This entry should hold the conformance level.");
+ return null;
+ }
+ }
@Override
diff --git a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java
index f1a03b7..9fc59f2 100644
--- a/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java
+++ b/src/main/java/org/openecomp/sdc/tosca/parser/impl/SdcToscaParserFactory.java
@@ -77,7 +77,7 @@ public class SdcToscaParserFactory {
} catch (JToscaException e) {
throwSdcToscaParserException(e);
}
- SdcCsarHelperImpl sdcCsarHelperImpl = new SdcCsarHelperImpl(tosca);
+ SdcCsarHelperImpl sdcCsarHelperImpl = new SdcCsarHelperImpl(tosca, configurationManager);
String cSarConformanceLevel = sdcCsarHelperImpl.getConformanceLevel();
validateCsarVersion(cSarConformanceLevel);
try {