Update to spring boot 2 25/109625/2
authorIgor Dysko <igor1.dysko@orange.com>
Sat, 27 Jun 2020 21:42:28 +0000 (23:42 +0200)
committerIgor Dysko <igor1.dysko@orange.com>
Mon, 6 Jul 2020 12:46:52 +0000 (14:46 +0200)
Update of code and dependencies, no changes in functionality

Issue-ID: AAI-2529
Signed-off-by: Igor Dysko <igor1.dysko@orange.com>
Change-Id: Ia43601c2990a67c0e8afefa1d54c53d7e606b886

14 files changed:
aai-schema-gen/pom.xml
aai-schema-service/pom.xml
aai-schema-service/src/main/java/org/onap/aai/schemaservice/SchemaServiceApp.java
aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/PropertyPasswordConfiguration.java
aai-schema-service/src/main/java/org/onap/aai/schemaservice/config/SchemaConfiguration.java
aai-schema-service/src/main/java/org/onap/aai/schemaservice/interceptors/post/ResponseTransactionLogging.java
aai-schema-service/src/main/java/org/onap/aai/schemaservice/interceptors/pre/RequestTransactionLogging.java
aai-schema-service/src/main/java/org/onap/aai/schemaservice/logging/LocalHostAccessLog.java
aai-schema-service/src/main/java/org/onap/aai/schemaservice/web/JerseyConfiguration.java
aai-schema-service/src/main/resources/application.properties
aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTest.java
aai-schema-service/src/test/java/org/onap/aai/schemaservice/SchemaServiceTestConfiguration.java
aai-schema-service/src/test/resources/application-test.properties
pom.xml

index 54fe4c4..3580a71 100644 (file)
@@ -49,7 +49,7 @@
         <schema.version.edge.label.start>v12</schema.version.edge.label.start>
         <schema.version.api.default>v19</schema.version.api.default>
         <schema.version.list>v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20</schema.version.list>
-       <springframework.version>4.3.18.RELEASE</springframework.version>
+
         <!-- End of Default ONAP Schema Properties -->
     </properties>
     <profiles>
@@ -70,7 +70,6 @@
                 <schema.version.api.default>v15</schema.version.api.default>
                 <schema.version.list>v10,v11,v12,v13,v14,v15,v16,v17,v18,v19</schema.version.list>
                 <gendoc.version>v16</gendoc.version>
-               <springframework.version>4.3.18.RELEASE</springframework.version>
             </properties>
         </profile>
         <!-- End of ONAP profile -->
         </profile>
     </profiles>
 
-    <dependencyManagement>
-      <dependencies>
+    <dependencies>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-context</artifactId>
-            <version>${springframework.version}</version>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-web</artifactId>
-            <version>${springframework.version}</version>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-core</artifactId>
-            <version>${springframework.version}</version>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-expression</artifactId>
-            <version>${springframework.version}</version>
         </dependency>
         <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-webmvc</artifactId>
-            <version>${springframework.version}</version>
         </dependency>
-         <dependency>
+        <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
-            <version>${springframework.version}</version>
             <scope>test</scope>
-        </dependency>  
-      </dependencies>
-    </dependencyManagement>
-       
-    <dependencies>
+        </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <artifactId>aai-schema-ingest</artifactId>
             <version>1.4.0</version>
             <scope>compile</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-context</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-core</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-web</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-expression</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.springframework</groupId>
+                    <artifactId>spring-webmvc</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.freemarker</groupId>
index 07cbfff..01405ec 100644 (file)
         </profile>
     </profiles>
     <dependencies>
+        <dependency>
+            <groupId>javax.annotation</groupId>
+            <artifactId>javax.annotation-api</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.el</groupId>
+            <artifactId>javax.el-api</artifactId>
+            <version>3.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish</groupId>
+            <artifactId>javax.el</artifactId>
+            <version>3.0.0</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.jms</groupId>
+            <artifactId>javax.jms-api</artifactId>
+            <version>2.0.1</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>javax.ws.rs-api</artifactId>
+            <version>2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-impl</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.sun.xml.bind</groupId>
+            <artifactId>jaxb-core</artifactId>
+        </dependency>
         <dependency>
             <groupId>com.att.eelf</groupId>
             <artifactId>eelf-core</artifactId>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-access</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.onap.aai.aai-common</groupId>
-            <artifactId>aai-core</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>com.sun.jersey</groupId>
-                    <artifactId>jersey-core</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.codehaus.jackson</groupId>
-                    <artifactId>jackson-mapper-asl</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.eclipse.jetty</groupId>
-                    <artifactId>jetty-http</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.eclipse.jetty</groupId>
-                    <artifactId>jetty-server</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.springframework</groupId>
-                    <artifactId>spring-web</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.onap.aai</groupId>
-                    <artifactId>aai-schema-ingest</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.hamcrest</groupId>
-            <artifactId>hamcrest-junit</artifactId>
-        </dependency>
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <artifactId>org.eclipse.persistence.moxy</artifactId>
             <scope>compile</scope>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-web</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-starter-tomcat</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-jetty</artifactId>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-aop</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.onap.aai.aai-common</groupId>
+            <artifactId>aai-core</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.springframework.boot</groupId>
+                    <artifactId>spring-boot-starter-web</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.onap.aai.aai-common</groupId>
+                    <artifactId>aai-schema-ingest</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-test</artifactId>
index 4e5bea5..66718dd 100644 (file)
@@ -39,6 +39,7 @@ import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
 import java.util.Map;
 import java.util.UUID;
+import org.springframework.web.context.request.RequestContextListener;
 
 @SpringBootApplication
 // Component Scan provides a way to look for spring beans
@@ -71,12 +72,11 @@ public class SchemaServiceApp {
 
         setDefaultProps();
 
-
-
         SpringApplication app = new SpringApplication(SchemaServiceApp.class);
         app.setLogStartupInfo(false);
         app.setRegisterShutdownHook(true);
         app.addInitializers(new PropertyPasswordConfiguration());
+
         Environment env = app.run(args).getEnvironment();
 
         logger.debug(
index db67ac6..df1d91c 100644 (file)
  */
 package org.onap.aai.schemaservice.config;
 
-import org.springframework.context.ApplicationContextInitializer;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.core.env.ConfigurableEnvironment;
-import org.springframework.core.env.EnumerablePropertySource;
-import org.springframework.core.env.MapPropertySource;
-import org.springframework.core.env.PropertySource;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -35,13 +28,15 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-
+import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.commons.io.IOUtils;
 import org.springframework.context.ApplicationContextInitializer;
 import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.core.env.*;
+import org.springframework.core.env.ConfigurableEnvironment;
+import org.springframework.core.env.EnumerablePropertySource;
+import org.springframework.core.env.MapPropertySource;
+import org.springframework.core.env.PropertySource;
 
 public class PropertyPasswordConfiguration implements ApplicationContextInitializer<ConfigurableApplicationContext> {
 
@@ -51,6 +46,7 @@ public class PropertyPasswordConfiguration implements ApplicationContextInitiali
 
     @Override
     public void initialize(ConfigurableApplicationContext applicationContext) {
+
         ConfigurableEnvironment environment = applicationContext.getEnvironment();
         String certPath = environment.getProperty("server.certs.location");
         File passwordFile = null;
index 390525b..28f6bc1 100644 (file)
@@ -21,7 +21,11 @@ package org.onap.aai.schemaservice.config;
 
 import org.onap.aai.schemaservice.nodeschema.NodeIngestor;
 import org.onap.aai.schemaservice.nodeschema.SchemaVersions;
-import org.onap.aai.schemaservice.nodeschema.validation.*;
+import org.onap.aai.schemaservice.nodeschema.validation.CheckEverythingStrategy;
+import org.onap.aai.schemaservice.nodeschema.validation.DefaultDuplicateNodeDefinitionValidationModule;
+import org.onap.aai.schemaservice.nodeschema.validation.DuplicateNodeDefinitionValidationModule;
+import org.onap.aai.schemaservice.nodeschema.validation.NodeValidator;
+import org.onap.aai.schemaservice.nodeschema.validation.SchemaErrorStrategy;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
index bc42d0f..10f0e61 100644 (file)
  */
 package org.onap.aai.schemaservice.interceptors.post;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import com.google.gson.JsonObject;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.schemaservice.interceptors.AAIContainerFilter;
-import org.onap.aai.schemaservice.interceptors.AAIHeaderProperties;
-import org.onap.aai.util.AAIConfig;
-import org.springframework.beans.factory.annotation.Autowired;
-
+import java.io.IOException;
+import java.util.Objects;
+import java.util.Optional;
 import javax.annotation.Priority;
 import javax.servlet.http.HttpServletResponse;
 import javax.ws.rs.HttpMethod;
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerResponseContext;
 import javax.ws.rs.container.ContainerResponseFilter;
-import java.io.IOException;
-import java.util.Objects;
-import java.util.Optional;
+import org.onap.aai.logging.ErrorLogHelper;
+import org.onap.aai.schemaservice.interceptors.AAIContainerFilter;
+import org.onap.aai.schemaservice.interceptors.AAIHeaderProperties;
+import org.onap.aai.util.AAIConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
 
 @Priority(AAIResponseFilterPriority.RESPONSE_TRANS_LOGGING)
 public class ResponseTransactionLogging extends AAIContainerFilter implements ContainerResponseFilter {
 
     private static final Logger TRANSACTION_LOGGER = LoggerFactory.getLogger(ResponseTransactionLogging.class);
 
-    @Autowired
-    private HttpServletResponse httpServletResponse;
-
     @Override
     public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
         throws IOException {
@@ -97,10 +94,19 @@ public class ResponseTransactionLogging extends AAIContainerFilter implements Co
         }
     }
 
+    private String getHttpServletResponseContentType() {
+        final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
+        if (requestAttributes != null) {
+            HttpServletResponse response = ((ServletRequestAttributes) requestAttributes).getResponse();
+            return response.getContentType();
+        }
+        return null;
+    }
+
     private String getResponseString(ContainerResponseContext responseContext) {
         JsonObject response = new JsonObject();
         response.addProperty("ID", responseContext.getHeaderString(AAIHeaderProperties.AAI_TX_ID));
-        response.addProperty("Content-Type", this.httpServletResponse.getContentType());
+        response.addProperty("Content-Type", getHttpServletResponseContentType());
         response.addProperty("Response-Code", responseContext.getStatus());
         response.addProperty("Headers", responseContext.getHeaders().toString());
         Optional<Object> entityOptional = Optional.ofNullable(responseContext.getEntity());
index 4208649..fbf9fbe 100644 (file)
 package org.onap.aai.schemaservice.interceptors.pre;
 
 import com.google.gson.JsonObject;
-import org.glassfish.jersey.message.internal.ReaderWriter;
-import org.glassfish.jersey.server.ContainerException;
-import org.onap.aai.schemaservice.interceptors.AAIContainerFilter;
-import org.onap.aai.schemaservice.interceptors.AAIHeaderProperties;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.StringUtils;
-
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.UUID;
 import javax.annotation.Priority;
 import javax.servlet.http.HttpServletRequest;
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerRequestFilter;
 import javax.ws.rs.container.PreMatching;
 import javax.ws.rs.core.MediaType;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.UUID;
+import org.glassfish.jersey.message.internal.ReaderWriter;
+import org.glassfish.jersey.server.ContainerException;
+import org.onap.aai.schemaservice.interceptors.AAIContainerFilter;
+import org.onap.aai.schemaservice.interceptors.AAIHeaderProperties;
+import org.springframework.util.StringUtils;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
 
 @PreMatching
 @Priority(AAIRequestFilterPriority.REQUEST_TRANS_LOGGING)
@@ -48,8 +49,6 @@ public class RequestTransactionLogging extends AAIContainerFilter implements Con
     private static final String CONTENT_TYPE = "Content-Type";
     private static final String ACCEPT = "Accept";
     private static final String TEXT_PLAIN = "text/plain";
-    @Autowired
-    private HttpServletRequest httpServletRequest;
 
     @Override
     public void filter(ContainerRequestContext requestContext) {
@@ -85,12 +84,21 @@ public class RequestTransactionLogging extends AAIContainerFilter implements Con
         return txId;
     }
 
+    private String getHttpServletRequestContentType() {
+        final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
+        if (requestAttributes != null) {
+            HttpServletRequest request = ((ServletRequestAttributes) requestAttributes).getRequest();
+            return request.getContentType();
+        }
+        return null;
+    }
+
     private String getRequest(ContainerRequestContext requestContext, String fullId) {
 
         JsonObject request = new JsonObject();
         request.addProperty("ID", fullId);
         request.addProperty("Http-Method", requestContext.getMethod());
-        request.addProperty(CONTENT_TYPE, httpServletRequest.getContentType());
+        request.addProperty(CONTENT_TYPE, getHttpServletRequestContentType());
         request.addProperty("Headers", requestContext.getHeaders().toString());
 
         ByteArrayOutputStream out = new ByteArrayOutputStream();
index 4da1122..9ff3cb2 100644 (file)
@@ -24,9 +24,9 @@ import org.eclipse.jetty.server.handler.HandlerCollection;
 import org.eclipse.jetty.server.handler.RequestLogHandler;
 import org.eclipse.jetty.util.thread.QueuedThreadPool;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
-import org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory;
-import org.springframework.boot.context.embedded.jetty.JettyServerCustomizer;
+import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
+import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
+import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
@@ -36,12 +36,12 @@ import java.util.Arrays;
 public class LocalHostAccessLog {
 
     @Bean
-    public EmbeddedServletContainerFactory jettyConfigBean(
+    public AbstractServletWebServerFactory jettyConfigBean(
         @Value("${jetty.threadPool.maxThreads:200}") final String maxThreads,
         @Value("${jetty.threadPool.minThreads:8}") final String minThreads
     ) {
 
-        JettyEmbeddedServletContainerFactory jef = new JettyEmbeddedServletContainerFactory();
+        JettyServletWebServerFactory jef = new JettyServletWebServerFactory();
         jef.addServerCustomizers((JettyServerCustomizer) server -> {
 
             HandlerCollection handlers = new HandlerCollection();
index 3023fab..182203d 100644 (file)
  */
 package org.onap.aai.schemaservice.web;
 
+import java.util.List;
+import java.util.Set;
+import java.util.logging.Logger;
+import java.util.stream.Collectors;
+import javax.annotation.Priority;
+import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.container.ContainerResponseFilter;
 import org.glassfish.jersey.server.ResourceConfig;
 import org.onap.aai.schemaservice.edges.EdgeResource;
 import org.onap.aai.schemaservice.healthcheck.EchoResource;
 import org.onap.aai.schemaservice.nodeschema.NodeSchemaResource;
 import org.onap.aai.schemaservice.query.QueryResource;
 import org.onap.aai.schemaservice.versions.VersionResource;
+import org.onap.logging.filter.base.AuditLogContainerFilter;
 import org.reflections.Reflections;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Profile;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
 
-import javax.annotation.Priority;
-import javax.ws.rs.container.ContainerRequestFilter;
-import javax.ws.rs.container.ContainerResponseFilter;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Logger;
-import java.util.stream.Collectors;
-import org.onap.logging.filter.base.AuditLogContainerFilter;
-
 
 @Component
 public class JerseyConfiguration extends ResourceConfig {
index c586bfd..605a92b 100644 (file)
@@ -5,8 +5,10 @@ info.build.version=@project.version@
 
 spring.application.name=Schema Service Microservice
 spring.jersey.type=filter
+spring.main.allow-bean-definition-overriding=true
+
+server.servlet.context-path=${schema.uri.base.path}
 
-server.contextPath=${schema.uri.base.path}
 spring.autoconfigure.exclude=\
   org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
   org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
index 5b24be2..9c214bd 100644 (file)
@@ -27,8 +27,8 @@ import org.onap.aai.exceptions.AAIException;
 import org.onap.aai.schemaservice.config.PropertyPasswordConfiguration;
 import org.onap.aai.util.AAIConfig;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.context.embedded.LocalServerPort;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.boot.web.server.LocalServerPort;
 import org.springframework.context.annotation.Import;
 import org.springframework.http.*;
 import org.springframework.test.context.ContextConfiguration;
index f712b79..ba8ae26 100644 (file)
@@ -84,7 +84,7 @@ public class SchemaServiceTestConfiguration {
                 .build();
 
             restTemplate = builder
-                .requestFactory(new HttpComponentsClientHttpRequestFactory(client))
+                .requestFactory(() -> new HttpComponentsClientHttpRequestFactory(client))
                 .build();
         }else {
             restTemplate = builder.build();
index bad8309..c3d72b5 100644 (file)
@@ -1,7 +1,7 @@
 spring.application.name=aai-schema-service
 spring.jersey.type=filter
 
-server.contextPath=${schema.uri.base.path}
+server.servlet.context-path=${schema.uri.base.path}
 
 spring.autoconfigure.exclude=\
   org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,\
diff --git a/pom.xml b/pom.xml
index c1fb257..fb14ffd 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -26,7 +26,7 @@
     <parent>
         <groupId>org.onap.aai.aai-common</groupId>
         <artifactId>aai-parent</artifactId>
-        <version>1.6.8</version>
+        <version>1.7.0-SNAPSHOT</version>
     </parent>
     <groupId>org.onap.aai.schema-service</groupId>
     <artifactId>schema-service</artifactId>
@@ -61,7 +61,7 @@
                 Using https://code.revelc.net/formatter-maven-plugin/ for Eclipse formatter
                 Using https://github.com/diffplug/spotless/tree/master/plugin-maven for import order
                 Use in combination to rewrite code and imports, then checkstyle
-                
+
                 mvn formatter:format spotless:apply process-sources
                 -->
                 <plugin>