From 6d3581b757316b2a61814d83bff874ce434db90c Mon Sep 17 00:00:00 2001 From: Shwetank Dave Date: Wed, 23 Aug 2017 12:07:33 -0400 Subject: Safeguard against deprecated DbEdgeRules versions. Currently we require a DbEdgeRules_vX.json file and it's associated edge_properties_vX.json files. If an edge_properties file is not found for a DbEdgeRules file, it throws an exeption. We should log and entry stating DbEdgeRules and it's associaded edge_properties files is not found and not throw an error. Issue-ID: AAI-21 Change-Id: I05f5b4d14c3cef1586cefe579e38df03ca4fb438 Signed-off-by: Shwetank Dave --- .../java/org/openecomp/schema/RelationshipSchemaLoader.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/openecomp/schema/RelationshipSchemaLoader.java b/src/main/java/org/openecomp/schema/RelationshipSchemaLoader.java index 7b68b35..d4ae2b9 100644 --- a/src/main/java/org/openecomp/schema/RelationshipSchemaLoader.java +++ b/src/main/java/org/openecomp/schema/RelationshipSchemaLoader.java @@ -145,7 +145,14 @@ public class RelationshipSchemaLoader { // Also update the "versionContextMap" with the version and it's schema. rulesFiles.stream().sorted(Comparator.comparing(RelationshipSchemaLoader::filename)) .collect(Collectors.groupingBy(f -> myMatcher(versionPattern, filename(f)))) - .forEach((version, resourceAndFile) -> versionContextMap.put(version, jsonFilesLoader(version, resourceAndFile))); + .forEach((version, resourceAndFile) -> { + if (resourceAndFile.size() == 2 ) { + versionContextMap.put(version, jsonFilesLoader(version, resourceAndFile)); + } else { + String filenames = resourceAndFile.stream().map(f-> filename(f)).collect(Collectors.toList()).toString(); + String errorMsg = "Expecting a rules and a edge_properties files for " + version + ". Found: " + filenames; + logger.warn(CrudServiceMsgs.INVALID_OXM_FILE, errorMsg); + }}); logger.info(CrudServiceMsgs.LOADED_OXM_FILE, "Relationship Schema and Properties files: " + rulesFiles.stream().map(f -> filename(f)).collect(Collectors.toList())); } catch (IOException e) { @@ -181,9 +188,6 @@ public class RelationshipSchemaLoader { files.stream().map(f -> filename(f)).collect(Collectors.toList()).toString(), e.getMessage()); } return rsSchema; - } else { - logger.debug(CrudServiceMsgs.INVALID_OXM_FILE, "Expecting a rules file and a properties file but found: " + - files.stream().map(f-> filename(f)).collect(Collectors.toList()).toString()); } return rsSchema; } -- cgit 1.2.3-korg