diff options
author | mark.j.leonard <mark.j.leonard@gmail.com> | 2019-01-15 10:34:53 +0000 |
---|---|---|
committer | mark.j.leonard <mark.j.leonard@gmail.com> | 2019-01-16 13:38:29 +0000 |
commit | 715e009fa1b0b148fc64f8cf1bc2f536e4e2cb23 (patch) | |
tree | d0e126ba6052557a49f7e9a11f820b7946a5266a /src/main | |
parent | c7e9ff11f28009c4fbc13f7ed1a3ffbb765d358b (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')
7 files changed, 84 insertions, 150 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. * diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 44df999..38b3d34 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,5 +1,5 @@ # ============LICENSE_START=================================================== -# Copyright (c) 2018 Amdocs +# Copyright (c) 2018-2019 Amdocs # ============================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -22,7 +22,6 @@ com.att.eelf.logging.path=src/main/resources com.att.eelf.logging.file=logback.xml logback.configurationFile=${com.att.eelf.logging.path}/${com.att.eelf.logging.file} -schemaIngestPropLoc=${CONFIG_HOME}/schemaIngest.properties server.port=9501 server.ssl.client-auth=want @@ -42,3 +41,5 @@ publisher.topic.names=poa-audit-result topics.properties.location=${CONFIG_HOME}/topics/ +schema.translator.list=schema-service +spring.application.name=aai-validation
\ No newline at end of file diff --git a/src/main/resources/validation-service-beans.xml b/src/main/resources/validation-service-beans.xml index 862fd13..d0baca2 100644 --- a/src/main/resources/validation-service-beans.xml +++ b/src/main/resources/validation-service-beans.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs +Copyright (c) 2018-2019 Amdocs ============================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -16,8 +16,8 @@ See the License for the specific language governing permissions and limitations under the License. ============LICENSE_END===================================================== --> -<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xmlns:util="http://www.springframework.org/schema/util" +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd @@ -28,22 +28,34 @@ limitations under the License. <!-- ////////////////////////////////////////////////////////////////// --> <!-- PROPERTY AND CONFIGURATION FILES --> <!-- ////////////////////////////////////////////////////////////////// --> - <context:property-placeholder location="classpath:event-reader.properties" ignore-unresolvable="true" /> - <context:property-placeholder location="file:${CONFIG_HOME}/aai-environment.properties" ignore-unresolvable="true" /> - <context:property-placeholder location="file:${CONFIG_HOME}/validation-service.properties" ignore-unresolvable="true" /> - <context:property-placeholder location="file:${CONFIG_HOME}/validation-service-auth.properties" ignore-unresolvable="true" /> - <context:property-placeholder location="file:${CONFIG_HOME}/rule-indexing.properties" ignore-unresolvable="true" ignore-resource-not-found="true" /> - <context:property-placeholder location="file:${schemaIngestPropLoc}" ignore-unresolvable="true" /> + <context:property-placeholder location="file:${CONFIG_HOME}/rule-indexing.properties" + ignore-unresolvable="true" ignore-resource-not-found="true" /> + <context:property-placeholder + location=" + classpath:event-reader.properties, + file:${CONFIG_HOME}/aai-environment.properties, + file:${CONFIG_HOME}/validation-service.properties, + file:${CONFIG_HOME}/validation-service-auth.properties, + file:${CONFIG_HOME}/schemaIngest.properties" + ignore-unresolvable="true" /> <bean id="mappingFile" class="org.apache.commons.io.IOUtils" factory-method="toString"> - <constructor-arg value="file:${APP_HOME}/bundleconfig/etc/appprops/model-instance-mapping.json_conf" type="java.io.InputStream" /> + <constructor-arg value="file:${APP_HOME}/bundleconfig/etc/appprops/model-instance-mapping.json_conf" + type="java.io.InputStream" /> </bean> - <util:properties id="dataDictionaryProperties" location="file:${CONFIG_HOME}/rule-data-dictionary.properties" /> + <util:properties id="dataDictionaryProperties" location="file:${CONFIG_HOME}/rule-data-dictionary.properties" /> <!-- ////////////////////////////////////////////////////////////////// --> <!-- CONFIG BEANS --> <!-- ////////////////////////////////////////////////////////////////// --> + + <!-- Component scan for schema service components --> + <context:component-scan base-package="org.onap.aai.config,org.onap.aai.setup"> + <!-- Exclude EdgesConfiguration since edge rules are not required --> + <context:exclude-filter type="assignable" expression="org.onap.aai.config.EdgesConfiguration" /> + </context:component-scan> + <bean id="eventReaderConfig" class="org.onap.aai.validation.config.EventReaderConfig"> <property name="eventDomainPath" value="${event.domain.path}" /> <property name="eventActionPath" value="${event.action.path}" /> @@ -77,6 +89,7 @@ limitations under the License. <property name="connectionTimeout" value="${connectionTimeout}" /> <property name="readTimeout" value="${readTimeout}" /> </bean> + <bean id="topicConfig" class="org.onap.aai.validation.config.TopicConfig" /> <bean id="topicAdminConfig" class="org.onap.aai.validation.config.TopicAdminConfig"> <property name="publishEnable" value="${topic.publish.enable}" /> @@ -91,7 +104,7 @@ limitations under the License. <property name="eventTypeRule" value="#{'${event.type.rule}'.split(',')}" /> <property name="eventTypeModel" value="#{'${event.type.model}'.split(',')}" /> </bean> - + <bean id="ruleIndexingConfig" class="org.onap.aai.validation.config.RuleIndexingConfig"> <property name="indexedEvents" value="#{'${rule.indexing.events}'.split(',')}" /> <property name="excludedOxmValidationEvents" value="#{'${rule.indexing.exclude.oxm.validation}'.split(',')}" /> @@ -112,26 +125,18 @@ limitations under the License. </list> </property> </bean> - <!-- ////////////////////////////////////////////////////////////////// --> <!-- READER BEANS --> <!-- ////////////////////////////////////////////////////////////////// --> - <bean id="schemaLocationsBean" class="org.onap.aai.setup.SchemaLocationsBean"> - <property name="nodeDirectory" value="${nodeDir}" /> - <property name="edgeDirectory" value="${edgeDir}" /> - </bean> - - <bean id="configTranslator" class="org.onap.aai.validation.reader.OxmConfigTranslator"> - <constructor-arg ref="schemaLocationsBean" /> - </bean> + <bean id="configTranslator" class="org.onap.aai.setup.AAIConfigTranslator" /> - <bean id="nodeIngestor" class="org.onap.aai.nodes.NodeIngestor"> - <constructor-arg ref="configTranslator" /> + <bean id="schemaVersionBean" class="org.onap.aai.setup.SchemaVersion"> + <constructor-arg value="${schema.version.api.default}" /> </bean> <bean id="oxmReader" class="org.onap.aai.validation.reader.OxmReader" init-method="init"> <constructor-arg ref="nodeIngestor" /> - <constructor-arg value="V${aai.oxm.version}" /> + <constructor-arg ref="schemaVersionBean" /> </bean> <bean id="jsonReader" class="org.onap.aai.validation.reader.JsonReader" /> @@ -177,10 +182,10 @@ limitations under the License. <constructor-arg ref="rulesConfigurationPath" /> <constructor-arg ref="oxmReader" /> <constructor-arg ref="eventReader" /> - <constructor-arg ref="ruleIndexingConfig"/> + <constructor-arg ref="ruleIndexingConfig" /> </bean> - <bean id="restClient" class="org.onap.aai.validation.data.client.RestClient"> + <bean id="aaiRestClient" class="org.onap.aai.validation.data.client.RestClient"> <constructor-arg ref="restConfig" /> </bean> diff --git a/src/main/resources/validation-service-logging-resources.properties b/src/main/resources/validation-service-logging-resources.properties index 21cbff1..c5d1c11 100644 --- a/src/main/resources/validation-service-logging-resources.properties +++ b/src/main/resources/validation-service-logging-resources.properties @@ -86,21 +86,24 @@ MESSAGE_AUDIT=\ LOG0012I|\ {0}|\ |\ - + MESSAGE_METRIC=\ LOG0013I|\ {0}|\ |\ - + MISSING_REQUEST_ID=\ LOG0014I|\ Missing request ID. Assigned {0}|\ + INVALID_EVENT_TYPE=\ LOG0015I|\ Event has not been validated. Invalid event type. Event:{0}|\ + MISSING_EVENT_TYPE=\ LOG0016I|\ Event has not been validated. Missing event type. Event:{0}|\ + FILTERED_EVENT=\ LOG0017I|\ Event has been filtered.Event:{0}|\ @@ -178,13 +181,14 @@ CANNOT_VALIDATE_ERROR=\ CANNOT_VALIDATE_HANDLE_EXCEPTION_ERROR=\ LOG0902E|\ Error during handling the exception for an event that could not be validated: {0}|\ - |\ - + |\ + MALFORMED_REQUEST_ERROR=\ LOG1000E|\ Malformed request.|\ - + PROCESS_REQUEST_ERROR=\ LOG1001E|\ Error while processing request.|\ + |