summaryrefslogtreecommitdiffstats
path: root/aai-schema-ingest/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'aai-schema-ingest/src/main')
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java4
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java42
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java13
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java6
-rw-r--r--aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java4
5 files changed, 40 insertions, 29 deletions
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java b/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java
index cdd87492..701fd17d 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/config/SchemaServiceConfiguration.java
@@ -23,13 +23,13 @@
package org.onap.aai.config;
import org.onap.aai.setup.*;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
-@ConditionalOnExpression("'${schema.translator.list}'.contains('schema-service')")
+@ConditionalOnProperty(name = "schema.translator.list", havingValue = "schema-service", matchIfMissing = false)
@PropertySource(value = "classpath:schema-ingest.properties", ignoreResourceNotFound = true)
@PropertySource(value = "file:${schema.ingest.file}", ignoreResourceNotFound = true)
public class SchemaServiceConfiguration {
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java
index 8949891e..66ffcf88 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/AAIConfigTranslator.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright © 2024 DEUTSCHE TELEKOM AG.
+ * ================================================================================
* 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
@@ -24,23 +26,24 @@ import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.TreeMap;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import org.springframework.stereotype.Component;
+
/**
* <b>AAIConfigTranslator</b> is responsible for looking at the
* schema files and edge files based on the available versions
* Also has the ability to exclude them based on the node.exclusion.pattern
*/
+@Component
public class AAIConfigTranslator extends ConfigTranslator {
- private static final String FILESEP =
- (System.getProperty("file.separator") == null) ? "/" : System.getProperty("file.separator");
-
- public AAIConfigTranslator(SchemaLocationsBean bean, SchemaConfigVersions schemaVersions) {
- super(bean, schemaVersions);
+ public AAIConfigTranslator(SchemaLocationsBean schemaLocationsBean, SchemaConfigVersions schemaConfigVersions) {
+ super(schemaLocationsBean, schemaConfigVersions);
}
/*
@@ -61,8 +64,8 @@ public class AAIConfigTranslator extends ConfigTranslator {
}
private List<String> getVersionNodeFiles(SchemaVersion v) {
- return getVersionFiles(bean.getNodeDirectory(), v, () -> bean.getNodesInclusionPattern().stream(),
- () -> bean.getNodesExclusionPattern().stream());
+ return getVersionFiles(schemaLocationsBean.getNodeDirectory(), v, () -> schemaLocationsBean.getNodesInclusionPattern().stream(),
+ () -> schemaLocationsBean.getNodesExclusionPattern().stream());
}
/*
@@ -84,18 +87,25 @@ public class AAIConfigTranslator extends ConfigTranslator {
private List<String> getVersionEdgeFiles(SchemaVersion v) {
- return getVersionFiles(bean.getEdgeDirectory(), v, () -> bean.getEdgesInclusionPattern().stream(),
- () -> bean.getEdgesExclusionPattern().stream());
+ return getVersionFiles(schemaLocationsBean.getEdgeDirectory(), v, () -> schemaLocationsBean.getEdgesInclusionPattern().stream(),
+ () -> schemaLocationsBean.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());
+ Supplier<Stream<String>> inclusionPattern, Supplier<Stream<String>> exclusionPattern) {
+
+ final File versionDirectory = new File(startDirectory + "/" + schemaVersion.toString());
+ final List<String> container = Arrays.stream(versionDirectory.listFiles())
+ .filter(Objects::nonNull)
+ .map(File::getName)
+ .filter(versionFileName -> inclusionPattern
+ .get()
+ .anyMatch(versionFileName::matches))
+ .map(versionFileName -> versionDirectory.getAbsolutePath() + "/" + versionFileName)
+ .filter(versionFilePath -> exclusionPattern
+ .get()
+ .noneMatch(versionFilePath::matches))
+ .collect(Collectors.toList());
return container;
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
index e87a05cc..50b9dc2f 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/ConfigTranslator.java
@@ -1,5 +1,4 @@
-/**
- * ============LICENSE_START=======================================================
+/** ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
* Copyright © 2017-18 AT&T Intellectual Property. All rights reserved.
@@ -16,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- */
+*/
package org.onap.aai.setup;
@@ -45,12 +44,12 @@ import org.springframework.beans.factory.annotation.Autowired;
public abstract class ConfigTranslator extends Translator {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigTranslator.class);
- protected SchemaLocationsBean bean;
+ protected SchemaLocationsBean schemaLocationsBean;
@Autowired
- public ConfigTranslator(SchemaLocationsBean schemaLocationbean, SchemaConfigVersions schemaVersions) {
- super(schemaVersions);
- this.bean = schemaLocationbean;
+ public ConfigTranslator(SchemaLocationsBean schemaLocationsBean, SchemaConfigVersions schemaConfigVersions) {
+ super(schemaConfigVersions);
+ this.schemaLocationsBean = schemaLocationsBean;
}
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
index 680bdd12..ec6e41a7 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/SchemaServiceTranslator.java
@@ -22,7 +22,6 @@ package org.onap.aai.setup;
import java.io.IOException;
import java.io.InputStream;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -32,19 +31,22 @@ import org.onap.aai.restclient.RestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
/**
* <b>AAIConfigTranslator</b> is responsible for looking at the schema files and
* edge files based on the available versions Also has the ability to exclude
* them based on the node.exclusion.pattern
*/
+@Component
+@ConditionalOnProperty(name = "schema.translator.list", havingValue = "schema-service", matchIfMissing = false)
public class SchemaServiceTranslator extends Translator {
private static final Logger LOGGER = LoggerFactory.getLogger(SchemaServiceTranslator.class);
diff --git a/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java b/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
index 3d415e62..45ca0cd6 100644
--- a/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
+++ b/aai-schema-ingest/src/main/java/org/onap/aai/setup/Translator.java
@@ -45,9 +45,9 @@ public abstract class Translator {
* ingested for that version
*/
- public abstract List<InputStream> getVersionNodeStream(SchemaVersion version) throws IOException;
+ public abstract List<InputStream> getVersionNodeStream(SchemaVersion schemaVersion) throws IOException;
- public abstract List<String> getJsonPayload(SchemaVersion version) throws IOException;
+ public abstract List<String> getJsonPayload(SchemaVersion schemaVersion) throws IOException;
/**
* Translates the contents of the schema config file