summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authormark.j.leonard <mark.j.leonard@gmail.com>2019-01-15 10:34:53 +0000
committermark.j.leonard <mark.j.leonard@gmail.com>2019-01-16 13:38:29 +0000
commit715e009fa1b0b148fc64f8cf1bc2f536e4e2cb23 (patch)
treed0e126ba6052557a49f7e9a11f820b7946a5266a /src/main/java
parentc7e9ff11f28009c4fbc13f7ed1a3ffbb765d358b (diff)
Update to aai-schema-ingest version 1.4.1
Using SNAPSHOT version (as 1.4.1 is not released) Change-Id: I3b5959cb2d43840556a628db8fe17701d36aa6f9 Issue-ID: AAI-2077 Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/aai/validation/ValidationServiceApplication.java42
-rw-r--r--src/main/java/org/onap/aai/validation/config/TopicConfig.java2
-rw-r--r--src/main/java/org/onap/aai/validation/reader/OxmConfigTranslator.java100
-rw-r--r--src/main/java/org/onap/aai/validation/reader/OxmReader.java14
4 files changed, 41 insertions, 117 deletions
diff --git a/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java b/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java
index 409e375..103c6cb 100644
--- a/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java
+++ b/src/main/java/org/onap/aai/validation/ValidationServiceApplication.java
@@ -19,31 +19,61 @@ package org.onap.aai.validation;
import java.util.HashMap;
import java.util.Map;
+import javax.annotation.PostConstruct;
+import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.util.security.Password;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.onap.aai.validation.config.TopicPropertiesConfig;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
-import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;
+import org.springframework.core.env.Environment;
/**
* Validation Service Spring Boot Application.
*/
-@SpringBootApplication
-@ComponentScan(basePackages = "org.onap.aai.validation.config")
+@Configuration
+@EnableAutoConfiguration
+@Import(TopicPropertiesConfig.class)
@ImportResource("classpath:validation-service-beans.xml")
public class ValidationServiceApplication extends SpringBootServletInitializer {
+ @Autowired
+ private Environment env;
+
public static void main(String[] args) {
Map<String, Object> props = new HashMap<>();
String keyStorePassword = System.getProperty("KEY_STORE_PASSWORD");
- if (keyStorePassword != null && !keyStorePassword.isEmpty()) {
- props.put("server.ssl.key-store-password", Password.deobfuscate(keyStorePassword));
+ if (StringUtils.isEmpty(keyStorePassword)) {
+ throw new IllegalArgumentException("System Property KEY_STORE_PASSWORD not set");
}
+ String deobfuscated = Password.deobfuscate(keyStorePassword);
+ props.put("server.ssl.key-store-password", deobfuscated);
+ props.put("schema.service.ssl.key-store-password", deobfuscated);
+ props.put("schema.service.ssl.trust-store-password", deobfuscated);
new ValidationServiceApplication()
.configure(new SpringApplicationBuilder(ValidationServiceApplication.class).properties(props))
.run(args);
}
+ /**
+ * Set the trust store system properties using default values from the application properties.
+ */
+ @PostConstruct
+ public void setSystemProperties() {
+ String trustStorePath = env.getProperty("server.ssl.key-store");
+ if (trustStorePath != null) {
+ String trustStorePassword = env.getProperty("server.ssl.key-store-password");
+ if (trustStorePassword != null) {
+ System.setProperty("javax.net.ssl.trustStore", trustStorePath);
+ System.setProperty("javax.net.ssl.trustStorePassword", trustStorePassword);
+ } else {
+ throw new IllegalArgumentException("Env property server.ssl.key-store-password not set");
+ }
+ }
+ }
}
diff --git a/src/main/java/org/onap/aai/validation/config/TopicConfig.java b/src/main/java/org/onap/aai/validation/config/TopicConfig.java
index 327db5e..a167672 100644
--- a/src/main/java/org/onap/aai/validation/config/TopicConfig.java
+++ b/src/main/java/org/onap/aai/validation/config/TopicConfig.java
@@ -26,13 +26,11 @@ import javax.annotation.Resource;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
/**
* Gets the configuration of the topics. The topics are configured using Spring in topic-config-beans.xml.
*/
-@Component("TopicConfig")
public class TopicConfig {
private List<String> consumerTopicNames;
diff --git a/src/main/java/org/onap/aai/validation/reader/OxmConfigTranslator.java b/src/main/java/org/onap/aai/validation/reader/OxmConfigTranslator.java
deleted file mode 100644
index 53be6dd..0000000
--- a/src/main/java/org/onap/aai/validation/reader/OxmConfigTranslator.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
- * 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
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=====================================================
- */
-package org.onap.aai.validation.reader;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.PathMatcher;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.Map;
-import java.util.ServiceConfigurationError;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.onap.aai.setup.ConfigTranslator;
-import org.onap.aai.setup.SchemaLocationsBean;
-import org.onap.aai.setup.Version;
-
-/**
- * Determine which OXM and edge rules files to return based on the latest Version
- *
- */
-public class OxmConfigTranslator extends ConfigTranslator {
-
- public OxmConfigTranslator(SchemaLocationsBean bean) {
- super(bean);
- }
-
- @Override
- public Map<Version, List<String>> getNodeFiles() {
- String nodeDirectory = bean.getNodeDirectory();
- if (nodeDirectory == null) {
- throw new ServiceConfigurationError(
- "Node(s) directory is empty in the schema location bean (" + bean.getSchemaConfigLocation() + ")");
- }
- try {
- return getVersionMap(Paths.get(nodeDirectory), "*_v*.xml");
- } catch (IOException e) {
- throw new ServiceConfigurationError("Failed to read node(s) directory " + getPath(nodeDirectory), e);
- }
- }
-
- @Override
- public Map<Version, List<String>> getEdgeFiles() {
- String edgeDirectory = bean.getEdgeDirectory();
- if (edgeDirectory == null) {
- throw new ServiceConfigurationError(
- "Edge(s) directory is empty in the schema location bean (" + bean.getSchemaConfigLocation() + ")");
- }
- try {
- return getVersionMap(Paths.get(edgeDirectory), "*_v*.json");
- } catch (IOException e) {
- throw new ServiceConfigurationError("Failed to read edge(s) directory " + getPath(edgeDirectory), e);
- }
- }
-
- private String getPath(String nodeDirectory) {
- return Paths.get(nodeDirectory).toAbsolutePath().toString();
- }
-
- /**
- * Creates a map containing each OXM Version and the matching OXM file path(s)
- *
- * @param folderPath the folder/directory containing the OXM files
- * @param fileSuffix
- * @return a new Map object (may be empty)
- * @throws IOException if there is a problem reading the specified directory path
- */
- private Map<Version, List<String>> getVersionMap(Path folderPath, String globPattern) throws IOException {
- final PathMatcher filter = folderPath.getFileSystem().getPathMatcher("glob:**/" + globPattern);
- try (final Stream<Path> stream = Files.list(folderPath)) {
- return stream.filter(filter::matches).map(Path::toString).filter(p -> getVersionFromPath(p) != null)
- .collect(Collectors.groupingBy(this::getVersionFromPath));
- }
- }
-
- private Version getVersionFromPath(String pathName) {
- String version = "V" + pathName.replaceAll("\\D+", "");
- try {
- return Version.valueOf(version);
- } catch (IllegalArgumentException e) {
- return null;
- }
- }
-}
diff --git a/src/main/java/org/onap/aai/validation/reader/OxmReader.java b/src/main/java/org/onap/aai/validation/reader/OxmReader.java
index b8343f1..a62e7db 100644
--- a/src/main/java/org/onap/aai/validation/reader/OxmReader.java
+++ b/src/main/java/org/onap/aai/validation/reader/OxmReader.java
@@ -1,4 +1,4 @@
-/*
+/**
* ============LICENSE_START===================================================
* Copyright (c) 2018 Amdocs
* ============================================================================
@@ -6,7 +6,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -25,7 +25,7 @@ import java.util.ServiceConfigurationError;
import org.eclipse.persistence.internal.oxm.mappings.Descriptor;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
import org.onap.aai.nodes.NodeIngestor;
-import org.onap.aai.setup.Version;
+import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.validation.exception.ValidationServiceError;
import org.onap.aai.validation.exception.ValidationServiceException;
import org.onap.aai.validation.util.StringUtils;
@@ -36,18 +36,14 @@ import org.onap.aai.validation.util.StringUtils;
public class OxmReader {
private NodeIngestor nodeIngestor;
- private Version version;
+ private SchemaVersion version;
private Map<String, List<String>> primaryKeysMap = new HashMap<>();
- public OxmReader(NodeIngestor nodeIngestor, Version version) {
+ public OxmReader(NodeIngestor nodeIngestor, SchemaVersion version) {
this.nodeIngestor = nodeIngestor;
this.version = version;
}
- public OxmReader(NodeIngestor nodeIngestor) {
- this(nodeIngestor, Version.getLatest());
- }
-
/**
* Get the primary keys for a given entity type.
*