summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorPriyanshuAgarwal <pagarwal@amdocs.com>2018-01-22 20:15:01 +0200
committerpriyanshu <pagarwal@amdocs.com>2018-02-07 02:01:09 +0530
commit0dcd1eef24541d074edcf3c8640b38cf7528ef6b (patch)
tree4fee5b77673f0246111bedf25dd2c2fb89036b3c /src/main
parent8f26703ebe460602d150faaba7759031c6088a5a (diff)
configuration overriding capabilities.
Updated files in SDC Parser Library. Change-Id: I885f0a155e52e337f776f74ef5675c080eecfaa8 Issue-ID: SDC-955 Signed-off-by: priyanshu <pagarwal@amdocs.com>
Diffstat (limited to 'src/main')
-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
-rw-r--r--src/main/resources/config/error-configuration.yaml6
5 files changed, 60 insertions, 20 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 {
diff --git a/src/main/resources/config/error-configuration.yaml b/src/main/resources/config/error-configuration.yaml
index 3febd33..58d1de3 100644
--- a/src/main/resources/config/error-configuration.yaml
+++ b/src/main/resources/config/error-configuration.yaml
@@ -2,17 +2,21 @@
errors:
FILE_NOT_FOUND: {
code: TP0001,
+ failOnError: true,
message: "Error: CSAR file not found."
}
BAD_FORMAT: {
code: TP0002,
+ failOnError: true,
message: "Error: CSAR file bad format. Check the log for details."
}
CONFORMANCE_LEVEL_ERROR: {
code: TP0003,
+ failOnError: true,
message: "Error: CSAR version is unsupported. Parser supports versions %s to %s."
}
GENERAL_ERROR: {
code: TP0004,
+ failOnError: true,
message: "Error: an unexpected internal error occured."
- } \ No newline at end of file
+ }