summaryrefslogtreecommitdiffstats
path: root/aai-schema-service/src/main
diff options
context:
space:
mode:
authorFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-09-17 20:42:06 +0200
committerFiete Ostkamp <Fiete.Ostkamp@telekom.de>2022-09-17 20:42:06 +0200
commite0ad4f2890f9f933199bc6f1b3f0e988da471aa9 (patch)
tree0c42f25d258aeb0327cdafab0012ddbba13e040d /aai-schema-service/src/main
parent1b2c97dbc18bc0db5610fc18e9ae690b7a40d06d (diff)
Replace all tab characters in java files with two spaces to remove linter warning
Issue-ID: AAI-3525 Signed-off-by: Fiete Ostkamp <Fiete.Ostkamp@telekom.de> Change-Id: I36cf7b83dd33c3b69de51e56e00bbd93a79c5ec4
Diffstat (limited to 'aai-schema-service/src/main')
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/AAIConfigTranslator.java148
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/ConfigTranslator.java52
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/SchemaLocationsBean.java208
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/NodeIngestor.java10
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/AAISchemaValidationException.java6
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/CheckEverythingStrategy.java56
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultDuplicateNodeDefinitionValidationModule.java94
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultVersionValidationModule.java60
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DuplicateNodeDefinitionValidationModule.java18
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/FailFastStrategy.java50
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/NodeValidator.java42
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/SchemaErrorStrategy.java60
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidationModule.java14
-rw-r--r--aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidator.java34
14 files changed, 426 insertions, 426 deletions
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/AAIConfigTranslator.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/AAIConfigTranslator.java
index 51417b4..38645db 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/AAIConfigTranslator.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/AAIConfigTranslator.java
@@ -41,78 +41,78 @@ public class AAIConfigTranslator extends ConfigTranslator {
private static final String FILESEP = (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
public AAIConfigTranslator(SchemaLocationsBean bean, SchemaVersions schemaVersions) {
- super(bean, schemaVersions);
- }
-
- /* (non-Javadoc)
- * @see org.onap.aai.setup.ConfigTranslator#getNodeFiles()
- */
- @Override
- public Map<SchemaVersion, List<String>> getNodeFiles() {
-
- Map<SchemaVersion, List<String>> files = new TreeMap<>();
- for (SchemaVersion v : schemaVersions.getVersions()) {
- List<String> container = getVersionNodeFiles(v);
- files.put(v, container);
- }
-
- return files;
- }
-
-
- private List<String> getVersionNodeFiles(SchemaVersion v) {
-
- return getVersionFiles(
- bean.getNodeDirectory(),
- v,
- () -> bean.getNodesInclusionPattern().stream(),
- () -> bean.getNodesExclusionPattern().stream()
- );
- }
-
-
- /* (non-Javadoc)
- * @see org.onap.aai.setup.ConfigTranslator#getEdgeFiles()
- */
- @Override
- public Map<SchemaVersion, List<String>> getEdgeFiles() {
-
- Map<SchemaVersion, List<String>> files = new TreeMap<>();
- for (SchemaVersion v : schemaVersions.getVersions()) {
- List<String> container = getVersionEdgeFiles(v);
- files.put(v, container);
- }
-
- return files;
- }
-
- private List<String> getVersionEdgeFiles(SchemaVersion v) {
-
- return getVersionFiles(
- bean.getEdgeDirectory(),
- v,
- () -> bean.getEdgesInclusionPattern().stream(),
- () -> bean.getEdgesExclusionPattern().stream()
- );
- }
-
- private List<String> getVersionFiles(
- String startDirectory,
- SchemaVersion schemaVersion,
- Supplier<Stream<String>> inclusionPattern,
- Supplier<Stream<String>> exclusionPattern
- ){
-
- List<String> container;
- final String directoryName = startDirectory + FILESEP + schemaVersion.toString() + FILESEP;
-
- container = Arrays.stream(new File(directoryName).listFiles())
- .map(File::getName)
- .filter(name -> inclusionPattern.get().anyMatch(name::matches))
- .map(name -> directoryName + name)
- .filter(name -> exclusionPattern.get().noneMatch(name::matches))
- .collect(Collectors.toList());
-
- return container;
- }
+ super(bean, schemaVersions);
+ }
+
+ /* (non-Javadoc)
+ * @see org.onap.aai.setup.ConfigTranslator#getNodeFiles()
+ */
+ @Override
+ public Map<SchemaVersion, List<String>> getNodeFiles() {
+
+ Map<SchemaVersion, List<String>> files = new TreeMap<>();
+ for (SchemaVersion v : schemaVersions.getVersions()) {
+ List<String> container = getVersionNodeFiles(v);
+ files.put(v, container);
+ }
+
+ return files;
+ }
+
+
+ private List<String> getVersionNodeFiles(SchemaVersion v) {
+
+ return getVersionFiles(
+ bean.getNodeDirectory(),
+ v,
+ () -> bean.getNodesInclusionPattern().stream(),
+ () -> bean.getNodesExclusionPattern().stream()
+ );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.onap.aai.setup.ConfigTranslator#getEdgeFiles()
+ */
+ @Override
+ public Map<SchemaVersion, List<String>> getEdgeFiles() {
+
+ Map<SchemaVersion, List<String>> files = new TreeMap<>();
+ for (SchemaVersion v : schemaVersions.getVersions()) {
+ List<String> container = getVersionEdgeFiles(v);
+ files.put(v, container);
+ }
+
+ return files;
+ }
+
+ private List<String> getVersionEdgeFiles(SchemaVersion v) {
+
+ return getVersionFiles(
+ bean.getEdgeDirectory(),
+ v,
+ () -> bean.getEdgesInclusionPattern().stream(),
+ () -> bean.getEdgesExclusionPattern().stream()
+ );
+ }
+
+ private List<String> getVersionFiles(
+ String startDirectory,
+ SchemaVersion schemaVersion,
+ Supplier<Stream<String>> inclusionPattern,
+ Supplier<Stream<String>> exclusionPattern
+ ){
+
+ List<String> container;
+ final String directoryName = startDirectory + FILESEP + schemaVersion.toString() + FILESEP;
+
+ container = Arrays.stream(new File(directoryName).listFiles())
+ .map(File::getName)
+ .filter(name -> inclusionPattern.get().anyMatch(name::matches))
+ .map(name -> directoryName + name)
+ .filter(name -> exclusionPattern.get().noneMatch(name::matches))
+ .collect(Collectors.toList());
+
+ return container;
+ }
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/ConfigTranslator.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/ConfigTranslator.java
index a177c6d..e13367d 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/ConfigTranslator.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/ConfigTranslator.java
@@ -33,34 +33,34 @@ import java.util.Map;
*
*/
public abstract class ConfigTranslator {
- protected SchemaLocationsBean bean;
- protected SchemaVersions schemaVersions;
+ protected SchemaLocationsBean bean;
+ protected SchemaVersions schemaVersions;
- @Autowired
- public ConfigTranslator(SchemaLocationsBean schemaLocationbean, SchemaVersions schemaVersions) {
- this.bean = schemaLocationbean;
- this.schemaVersions = schemaVersions;
- }
+ @Autowired
+ public ConfigTranslator(SchemaLocationsBean schemaLocationbean, SchemaVersions schemaVersions) {
+ this.bean = schemaLocationbean;
+ this.schemaVersions = schemaVersions;
+ }
- /**
- * Translates the contents of the schema config file
- * into the input for the NodeIngestor
- *
- * @return Map of Version to the list of (string) filenames to be
- * ingested for that version
- */
- public abstract Map<SchemaVersion, List<String>> getNodeFiles();
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the NodeIngestor
+ *
+ * @return Map of Version to the list of (string) filenames to be
+ * ingested for that version
+ */
+ public abstract Map<SchemaVersion, List<String>> getNodeFiles();
- /**
- * Translates the contents of the schema config file
- * into the input for the EdgeIngestor
- *
- * @return Map of Version to the List of (String) filenames to be
- * ingested for that version
- */
- public abstract Map<SchemaVersion, List<String>> getEdgeFiles();
+ /**
+ * Translates the contents of the schema config file
+ * into the input for the EdgeIngestor
+ *
+ * @return Map of Version to the List of (String) filenames to be
+ * ingested for that version
+ */
+ public abstract Map<SchemaVersion, List<String>> getEdgeFiles();
- public SchemaVersions getSchemaVersions(){
- return schemaVersions;
- }
+ public SchemaVersions getSchemaVersions(){
+ return schemaVersions;
+ }
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/SchemaLocationsBean.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/SchemaLocationsBean.java
index e24aa78..042889b 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/SchemaLocationsBean.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/SchemaLocationsBean.java
@@ -31,108 +31,108 @@ import java.util.List;
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound=true)
@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound=true)
public class SchemaLocationsBean {
- /*
- * Per Spring documentation, the last PropertySource that works will
- * be applied. Here, schema.ingest.file will be an environment variable
- * set on install that tells Spring where to look for the schema
- * ingest properties file (and the actual filename), but the former
- * PropertySource gives the default of looking on the classpath for
- * schema-ingest.properties in case that second one doesn't work.
- *
- * The schema-ingest.properties file (or its equivalent if you choose
- * to name it otherwise) must contain the entries the below @Value
- * annotations are looking for.
- */
-
- @Value("${schema.configuration.location}")
- private String schemaConfigLoc;
-
- @Value("${schema.nodes.location}")
- private String nodeDirectory;
-
- @Value("${schema.edges.location}")
- private String edgeDirectory;
-
- @Value("${schema.nodes.inclusion.list:}#{T(java.util.Arrays).asList(\".*oxm(.*).xml\")}")
- private List<String> nodesInclusionPattern;
-
- @Value("${schema.nodes.exclusion.list:}#{T(java.util.Collections).emptyList()}")
- private List<String> nodesExclusionPattern;
-
- @Value("${schema.edges.inclusion.list:}#{T(java.util.Arrays).asList(\"DbEdgeRules_.*.json\")}")
- private List<String> edgesInclusionPattern;
-
- @Value("${schema.edges.exclusion.list:}#{T(java.util.Collections).emptyList()}")
- private List<String> edgesExclusionPattern;
-
- /**
- * @return the file name/location with the list of schema files to be ingested
- */
- public String getSchemaConfigLocation() {
- return schemaConfigLoc;
- }
-
- /**
- * Sets the name/location of the file with the list of schema files to ingest
- *
- * @param schemaConfigLoc - the file name/location
- */
- public void setSchemaConfigLocation(String schemaConfigLoc) {
- this.schemaConfigLoc = schemaConfigLoc;
- }
-
- /**
- * @return the location of the OXM files
- */
- public String getNodeDirectory() {
- return nodeDirectory;
- }
-
- /**
- * Sets the location of the OXM files
- *
- * @param nodeDirectory - the location of the OXM files
- */
- public void setNodeDirectory(String nodeDirectory) {
- this.nodeDirectory = nodeDirectory;
- }
-
- /**
- * @return the location of the edge rule json files
- */
- public String getEdgeDirectory() {
- return edgeDirectory;
- }
-
- /**
- * Sets the location of the edge rule json files
- *
- * @param edgeDirectory - the location of the edge rule files
- */
- public void setEdgeDirectory(String edgeDirectory) {
- this.edgeDirectory = edgeDirectory;
- }
-
- public List<String> getNodesExclusionPattern(){
- return this.nodesExclusionPattern;
- }
-
- public List<String> getNodesInclusionPattern(){
- return this.nodesInclusionPattern;
- }
-
- public List<String> getEdgesExclusionPattern(){
- return this.edgesExclusionPattern;
- }
-
- public List<String> getEdgesInclusionPattern(){
- return this.edgesInclusionPattern;
- }
-
- //this allows the code to actually read the value from the config file
- //without this those strings get set to literally "${edgeDir}" etc
- @Bean
- public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
- return new PropertySourcesPlaceholderConfigurer();
- }
+ /*
+ * Per Spring documentation, the last PropertySource that works will
+ * be applied. Here, schema.ingest.file will be an environment variable
+ * set on install that tells Spring where to look for the schema
+ * ingest properties file (and the actual filename), but the former
+ * PropertySource gives the default of looking on the classpath for
+ * schema-ingest.properties in case that second one doesn't work.
+ *
+ * The schema-ingest.properties file (or its equivalent if you choose
+ * to name it otherwise) must contain the entries the below @Value
+ * annotations are looking for.
+ */
+
+ @Value("${schema.configuration.location}")
+ private String schemaConfigLoc;
+
+ @Value("${schema.nodes.location}")
+ private String nodeDirectory;
+
+ @Value("${schema.edges.location}")
+ private String edgeDirectory;
+
+ @Value("${schema.nodes.inclusion.list:}#{T(java.util.Arrays).asList(\".*oxm(.*).xml\")}")
+ private List<String> nodesInclusionPattern;
+
+ @Value("${schema.nodes.exclusion.list:}#{T(java.util.Collections).emptyList()}")
+ private List<String> nodesExclusionPattern;
+
+ @Value("${schema.edges.inclusion.list:}#{T(java.util.Arrays).asList(\"DbEdgeRules_.*.json\")}")
+ private List<String> edgesInclusionPattern;
+
+ @Value("${schema.edges.exclusion.list:}#{T(java.util.Collections).emptyList()}")
+ private List<String> edgesExclusionPattern;
+
+ /**
+ * @return the file name/location with the list of schema files to be ingested
+ */
+ public String getSchemaConfigLocation() {
+ return schemaConfigLoc;
+ }
+
+ /**
+ * Sets the name/location of the file with the list of schema files to ingest
+ *
+ * @param schemaConfigLoc - the file name/location
+ */
+ public void setSchemaConfigLocation(String schemaConfigLoc) {
+ this.schemaConfigLoc = schemaConfigLoc;
+ }
+
+ /**
+ * @return the location of the OXM files
+ */
+ public String getNodeDirectory() {
+ return nodeDirectory;
+ }
+
+ /**
+ * Sets the location of the OXM files
+ *
+ * @param nodeDirectory - the location of the OXM files
+ */
+ public void setNodeDirectory(String nodeDirectory) {
+ this.nodeDirectory = nodeDirectory;
+ }
+
+ /**
+ * @return the location of the edge rule json files
+ */
+ public String getEdgeDirectory() {
+ return edgeDirectory;
+ }
+
+ /**
+ * Sets the location of the edge rule json files
+ *
+ * @param edgeDirectory - the location of the edge rule files
+ */
+ public void setEdgeDirectory(String edgeDirectory) {
+ this.edgeDirectory = edgeDirectory;
+ }
+
+ public List<String> getNodesExclusionPattern(){
+ return this.nodesExclusionPattern;
+ }
+
+ public List<String> getNodesInclusionPattern(){
+ return this.nodesInclusionPattern;
+ }
+
+ public List<String> getEdgesExclusionPattern(){
+ return this.edgesExclusionPattern;
+ }
+
+ public List<String> getEdgesInclusionPattern(){
+ return this.edgesInclusionPattern;
+ }
+
+ //this allows the code to actually read the value from the config file
+ //without this those strings get set to literally "${edgeDir}" etc
+ @Bean
+ public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
+ return new PropertySourcesPlaceholderConfigurer();
+ }
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/NodeIngestor.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/NodeIngestor.java
index 8beb537..2459c54 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/NodeIngestor.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/NodeIngestor.java
@@ -286,12 +286,12 @@ public class NodeIngestor {
String source = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<xml-bindings xmlns=\"http://www.eclipse.org/eclipselink/xsds/persistence/oxm\" package-name=\"inventory.aai.onap.org." +
v.toString().toLowerCase() + "\" xml-mapping-metadata-complete=\"true\">\n" +
- " <xml-schema element-form-default=\"QUALIFIED\">\n" +
- " <xml-ns namespace-uri=\"http://org.onap.aai.inventory/" +
+ " <xml-schema element-form-default=\"QUALIFIED\">\n" +
+ " <xml-ns namespace-uri=\"http://org.onap.aai.inventory/" +
v.toString().toLowerCase() + "\" />\n" +
- " </xml-schema>\n" +
- " <java-types>\n" +
- " </java-types>\n" +
+ " </xml-schema>\n" +
+ " <java-types>\n" +
+ " </java-types>\n" +
"</xml-bindings>";
return new ByteArrayInputStream(source.getBytes(StandardCharsets.UTF_8));
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/AAISchemaValidationException.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/AAISchemaValidationException.java
index e096a7d..fecc079 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/AAISchemaValidationException.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/AAISchemaValidationException.java
@@ -23,7 +23,7 @@ package org.onap.aai.schemaservice.nodeschema.validation;
* Indicates that a fatal error in the A&AI schema has been found.
*/
public class AAISchemaValidationException extends IllegalStateException {
- public AAISchemaValidationException(String msg) {
- super(msg);
- }
+ public AAISchemaValidationException(String msg) {
+ super(msg);
+ }
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/CheckEverythingStrategy.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/CheckEverythingStrategy.java
index de31212..047760f 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/CheckEverythingStrategy.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/CheckEverythingStrategy.java
@@ -31,36 +31,36 @@ import java.util.List;
* keep validating so all issues are found in one run.
*/
public class CheckEverythingStrategy implements SchemaErrorStrategy {
- private boolean isOK = true;
- private List<String> errorMsgs = new ArrayList<>();
+ private boolean isOK = true;
+ private List<String> errorMsgs = new ArrayList<>();
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
- */
- @Override
- public boolean isOK() {
- return isOK;
- }
+ /* (non-Javadoc)
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
+ */
+ @Override
+ public boolean isOK() {
+ return isOK;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
- */
- @Override
- public String getErrorMsg() {
- if (errorMsgs.isEmpty()) {
- return "No errors found.";
- } else {
- return StringUtils.join(errorMsgs, "\n");
- }
- }
+ /* (non-Javadoc)
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
+ */
+ @Override
+ public String getErrorMsg() {
+ if (errorMsgs.isEmpty()) {
+ return "No errors found.";
+ } else {
+ return StringUtils.join(errorMsgs, "\n");
+ }
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
- */
- @Override
- public void notifyOnError(String errorMsg) {
- isOK = false;
- errorMsgs.add(errorMsg);
- }
+ /* (non-Javadoc)
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
+ */
+ @Override
+ public void notifyOnError(String errorMsg) {
+ isOK = false;
+ errorMsgs.add(errorMsg);
+ }
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultDuplicateNodeDefinitionValidationModule.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultDuplicateNodeDefinitionValidationModule.java
index ac3a450..fa1c36b 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultDuplicateNodeDefinitionValidationModule.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultDuplicateNodeDefinitionValidationModule.java
@@ -46,61 +46,61 @@ import java.util.List;
*/
public class DefaultDuplicateNodeDefinitionValidationModule implements DuplicateNodeDefinitionValidationModule {
- /* (non-Javadoc)
- * @see org.onap.aai.nodes.validation.DuplicateNodeDefinitionValidationModule#findDuplicates(java.util.List)
- */
- @Override
- public String findDuplicates(List<String> files, SchemaVersion v) {
- try {
- final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ /* (non-Javadoc)
+ * @see org.onap.aai.nodes.validation.DuplicateNodeDefinitionValidationModule#findDuplicates(java.util.List)
+ */
+ @Override
+ public String findDuplicates(List<String> files, SchemaVersion v) {
+ try {
+ final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
+ docFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
docFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
docFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
docFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
docFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
docFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
- final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
+ final DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
- Multimap<String, String> types = ArrayListMultimap.create();
- boolean foundDups = false;
- for (String file : files) {
- InputStream inputStream = new FileInputStream(file);
- final Document doc = docBuilder.parse(inputStream);
- final NodeList list = doc.getElementsByTagName("java-type");
+ Multimap<String, String> types = ArrayListMultimap.create();
+ boolean foundDups = false;
+ for (String file : files) {
+ InputStream inputStream = new FileInputStream(file);
+ final Document doc = docBuilder.parse(inputStream);
+ final NodeList list = doc.getElementsByTagName("java-type");
- for (int i = 0; i < list.getLength(); i++) {
- String type = list.item(i).getAttributes().getNamedItem("name").getNodeValue();
- if (types.containsKey(type)) {
- foundDups = true;
- }
- types.put(type, file);
- }
- }
+ for (int i = 0; i < list.getLength(); i++) {
+ String type = list.item(i).getAttributes().getNamedItem("name").getNodeValue();
+ if (types.containsKey(type)) {
+ foundDups = true;
+ }
+ types.put(type, file);
+ }
+ }
- if (foundDups) {
- return buildErrorMsg(types, v);
- } else {
- return "";
- }
- } catch (ParserConfigurationException | SAXException | IOException e) {
- // TODO something useful with this information
- return e.getMessage();
- }
- }
+ if (foundDups) {
+ return buildErrorMsg(types, v);
+ } else {
+ return "";
+ }
+ } catch (ParserConfigurationException | SAXException | IOException e) {
+ // TODO something useful with this information
+ return e.getMessage();
+ }
+ }
- private String buildErrorMsg(Multimap<String, String> types, SchemaVersion v) {
- StringBuilder errorMsg = new StringBuilder().append("Duplicates found in version ").append(v.toString()).append(". ");
- for (String nodeType : types.keySet()) {
- Collection<String> files = types.get(nodeType);
- if (files.size() == 1) {
- continue; //only record the duplicated ones
- }
- errorMsg.append(nodeType).append(" has definitions in ");
- for (String file : files) {
- errorMsg.append(file).append(" ");
- }
- }
- return errorMsg.toString();
- }
+ private String buildErrorMsg(Multimap<String, String> types, SchemaVersion v) {
+ StringBuilder errorMsg = new StringBuilder().append("Duplicates found in version ").append(v.toString()).append(". ");
+ for (String nodeType : types.keySet()) {
+ Collection<String> files = types.get(nodeType);
+ if (files.size() == 1) {
+ continue; //only record the duplicated ones
+ }
+ errorMsg.append(nodeType).append(" has definitions in ");
+ for (String file : files) {
+ errorMsg.append(file).append(" ");
+ }
+ }
+ return errorMsg.toString();
+ }
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultVersionValidationModule.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultVersionValidationModule.java
index acd4095..8f674fc 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultVersionValidationModule.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultVersionValidationModule.java
@@ -34,39 +34,39 @@ import java.util.Map;
*/
@Component
public class DefaultVersionValidationModule implements VersionValidationModule {
- private ConfigTranslator config;
+ private ConfigTranslator config;
- @Autowired
- public DefaultVersionValidationModule(ConfigTranslator config) {
- this.config = config;
- }
+ @Autowired
+ public DefaultVersionValidationModule(ConfigTranslator config) {
+ this.config = config;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.validation.VersionValidationModule#validate(org.onap.aai.setup.ConfigTranslator)
- */
- @Override
- public String validate() {
- Map<SchemaVersion, List<String>> nodeConfig = config.getNodeFiles();
- Map<SchemaVersion, List<String>> edgeConfig = config.getEdgeFiles();
+ /* (non-Javadoc)
+ * @see org.onap.aai.validation.VersionValidationModule#validate(org.onap.aai.setup.ConfigTranslator)
+ */
+ @Override
+ public String validate() {
+ Map<SchemaVersion, List<String>> nodeConfig = config.getNodeFiles();
+ Map<SchemaVersion, List<String>> edgeConfig = config.getEdgeFiles();
- StringBuilder missingVers = new StringBuilder().append("Missing schema for the following versions: ");
- boolean isMissing = false;
- for (SchemaVersion v : config.getSchemaVersions().getVersions()) {
- if (nodeConfig.get(v) == null) {
- isMissing = true;
- missingVers.append(v.toString()).append(" has no OXM configured. ");
- }
- if (edgeConfig.get(v) == null) {
- isMissing = true;
- missingVers.append(v.toString()).append(" has no edge rules configured. ");
- }
- }
+ StringBuilder missingVers = new StringBuilder().append("Missing schema for the following versions: ");
+ boolean isMissing = false;
+ for (SchemaVersion v : config.getSchemaVersions().getVersions()) {
+ if (nodeConfig.get(v) == null) {
+ isMissing = true;
+ missingVers.append(v.toString()).append(" has no OXM configured. ");
+ }
+ if (edgeConfig.get(v) == null) {
+ isMissing = true;
+ missingVers.append(v.toString()).append(" has no edge rules configured. ");
+ }
+ }
- if (isMissing) {
- return missingVers.toString();
- } else {
- return "";
- }
- }
+ if (isMissing) {
+ return missingVers.toString();
+ } else {
+ return "";
+ }
+ }
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DuplicateNodeDefinitionValidationModule.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DuplicateNodeDefinitionValidationModule.java
index cb5f5e3..1cab48d 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DuplicateNodeDefinitionValidationModule.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/DuplicateNodeDefinitionValidationModule.java
@@ -34,13 +34,13 @@ import java.util.List;
* etc.
*/
public interface DuplicateNodeDefinitionValidationModule {
- /**
- * Finds any duplicates according to the defined rules
- *
- * @param files - the OXM files to use with full directory
- * @return empty String if none found, else a String
- * with appropriate information about what node types
- * were found
- */
- String findDuplicates(List<String> files, SchemaVersion v);
+ /**
+ * Finds any duplicates according to the defined rules
+ *
+ * @param files - the OXM files to use with full directory
+ * @return empty String if none found, else a String
+ * with appropriate information about what node types
+ * were found
+ */
+ String findDuplicates(List<String> files, SchemaVersion v);
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/FailFastStrategy.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/FailFastStrategy.java
index 7463a7d..7c05007 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/FailFastStrategy.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/FailFastStrategy.java
@@ -25,33 +25,33 @@ package org.onap.aai.schemaservice.nodeschema.validation;
* process to abort.
*/
public class FailFastStrategy implements SchemaErrorStrategy {
- private boolean isOK = true;
- private String errorMsg = "No errors found.";
+ private boolean isOK = true;
+ private String errorMsg = "No errors found.";
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
- */
- @Override
- public boolean isOK() {
- return isOK;
- }
+ /* (non-Javadoc)
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#isOK()
+ */
+ @Override
+ public boolean isOK() {
+ return isOK;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
- */
- @Override
- public String getErrorMsg() {
- return errorMsg;
- }
+ /* (non-Javadoc)
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#getErrorMsg()
+ */
+ @Override
+ public String getErrorMsg() {
+ return errorMsg;
+ }
- /* (non-Javadoc)
- * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
- */
- @Override
- public void notifyOnError(String errorMsg) {
- isOK = false;
- this.errorMsg = errorMsg;
- throw new AAISchemaValidationException(errorMsg);
- }
+ /* (non-Javadoc)
+ * @see org.onap.aai.edges.validation.SchemaErrorStrategy#notifyOnError(java.lang.String)
+ */
+ @Override
+ public void notifyOnError(String errorMsg) {
+ isOK = false;
+ this.errorMsg = errorMsg;
+ throw new AAISchemaValidationException(errorMsg);
+ }
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/NodeValidator.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/NodeValidator.java
index e73331b..bc46e16 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/NodeValidator.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/NodeValidator.java
@@ -29,29 +29,29 @@ import java.util.Map.Entry;
@Component
public class NodeValidator {
- private ConfigTranslator translator;
- private SchemaErrorStrategy strat;
- private DuplicateNodeDefinitionValidationModule dupChecker;
+ private ConfigTranslator translator;
+ private SchemaErrorStrategy strat;
+ private DuplicateNodeDefinitionValidationModule dupChecker;
- @Autowired
- public NodeValidator(ConfigTranslator translator, SchemaErrorStrategy strategy, DuplicateNodeDefinitionValidationModule dupChecker) {
- this.translator = translator;
- this.strat = strategy;
- this.dupChecker = dupChecker;
- }
+ @Autowired
+ public NodeValidator(ConfigTranslator translator, SchemaErrorStrategy strategy, DuplicateNodeDefinitionValidationModule dupChecker) {
+ this.translator = translator;
+ this.strat = strategy;
+ this.dupChecker = dupChecker;
+ }
- public boolean validate() {
+ public boolean validate() {
- for(Entry<SchemaVersion, List<String>> entry : translator.getNodeFiles().entrySet()) {
- String result = dupChecker.findDuplicates(entry.getValue(), entry.getKey());
- if (!"".equals(result)) {
- strat.notifyOnError(result);
- }
- }
- return strat.isOK();
- }
+ for(Entry<SchemaVersion, List<String>> entry : translator.getNodeFiles().entrySet()) {
+ String result = dupChecker.findDuplicates(entry.getValue(), entry.getKey());
+ if (!"".equals(result)) {
+ strat.notifyOnError(result);
+ }
+ }
+ return strat.isOK();
+ }
- public String getErrorMsg() {
- return strat.getErrorMsg();
- }
+ public String getErrorMsg() {
+ return strat.getErrorMsg();
+ }
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/SchemaErrorStrategy.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/SchemaErrorStrategy.java
index 9df66cd..a9cafa5 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/SchemaErrorStrategy.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/SchemaErrorStrategy.java
@@ -23,36 +23,36 @@ package org.onap.aai.schemaservice.nodeschema.validation;
* Controls response to finding problems in the schema files.
*/
public interface SchemaErrorStrategy {
- /**
- * Gives if it is OK to proceed with whatever process
- * invoked the validation (probably the installation of
- * the A&AI instance).
- *
- * @return boolean
- */
- public boolean isOK();
+ /**
+ * Gives if it is OK to proceed with whatever process
+ * invoked the validation (probably the installation of
+ * the A&AI instance).
+ *
+ * @return boolean
+ */
+ public boolean isOK();
- /**
- * Gets the error message(s) gathered in the course
- * of validation.
- *
- * @return String error message or messages concatenated together
- */
- public String getErrorMsg();
+ /**
+ * Gets the error message(s) gathered in the course
+ * of validation.
+ *
+ * @return String error message or messages concatenated together
+ */
+ public String getErrorMsg();
- /**
- * Invokes the ErrorStrategy to do whatever response to
- * an issue in the schema having been found.
- *
- * Options:
- * -Throw an exception if the whole process should be
- * immediately aborted
- * -Set OK status to false, store the message and allow the
- * validation process to continue and find any other issues
- * -Completely ignore that something is wrong
- * etc.
- *
- * @param String errorMsg - the error message from the validator module
- */
- public void notifyOnError(String errorMsg);
+ /**
+ * Invokes the ErrorStrategy to do whatever response to
+ * an issue in the schema having been found.
+ *
+ * Options:
+ * -Throw an exception if the whole process should be
+ * immediately aborted
+ * -Set OK status to false, store the message and allow the
+ * validation process to continue and find any other issues
+ * -Completely ignore that something is wrong
+ * etc.
+ *
+ * @param String errorMsg - the error message from the validator module
+ */
+ public void notifyOnError(String errorMsg);
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidationModule.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidationModule.java
index 607e0df..15ae19a 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidationModule.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidationModule.java
@@ -27,11 +27,11 @@ package org.onap.aai.schemaservice.nodeschema.validation;
*/
public interface VersionValidationModule {
- /**
- * Validates that all required versions have schema
- * configured for them.
- *
- * @return empty string if none missing or else an appropriate error
- */
- public String validate();
+ /**
+ * Validates that all required versions have schema
+ * configured for them.
+ *
+ * @return empty string if none missing or else an appropriate error
+ */
+ public String validate();
}
diff --git a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidator.java b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidator.java
index 8394521..0158bc3 100644
--- a/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidator.java
+++ b/aai-schema-service/src/main/java/org/onap/aai/schemaservice/nodeschema/validation/VersionValidator.java
@@ -28,25 +28,25 @@ import org.springframework.stereotype.Component;
*/
@Component
public class VersionValidator {
- private SchemaErrorStrategy strat;
- private VersionValidationModule verMod;
+ private SchemaErrorStrategy strat;
+ private VersionValidationModule verMod;
- @Autowired
- public VersionValidator(SchemaErrorStrategy strategy, VersionValidationModule verMod) {
- this.strat = strategy;
- this.verMod = verMod;
- }
+ @Autowired
+ public VersionValidator(SchemaErrorStrategy strategy, VersionValidationModule verMod) {
+ this.strat = strategy;
+ this.verMod = verMod;
+ }
- public boolean validate() {
- String result = verMod.validate();
- if (!"".equals(result)) {
- strat.notifyOnError(result);
- }
+ public boolean validate() {
+ String result = verMod.validate();
+ if (!"".equals(result)) {
+ strat.notifyOnError(result);
+ }
- return strat.isOK();
- }
+ return strat.isOK();
+ }
- public String getErrorMsg() {
- return strat.getErrorMsg();
- }
+ public String getErrorMsg() {
+ return strat.getErrorMsg();
+ }
}