From 6a7f13fa7e284cbec5b0743c10fdd33286aaf2ec Mon Sep 17 00:00:00 2001 From: Dan Timoney Date: Mon, 19 Jun 2023 16:05:33 -0400 Subject: Port to java 17 Update to java 17 / springboot 3 to align with OpenDaylight Argon. Copied and ported CADI library from AAF Issue-ID: CCSDK-3917 Signed-off-by: Dan Timoney Change-Id: Idecb0cf43c48ccbbc0c61bf4278b87a37f92a56e --- .../ccsdk/apps/ms/neng/core/WebConfiguration.java | 6 +++--- .../apps/ms/neng/core/service/SpringServiceImpl.java | 2 +- .../ms/neng/persistence/entity/ExternalInterface.java | 8 ++++---- .../ms/neng/persistence/entity/GeneratedName.java | 12 ++++++------ .../ms/neng/persistence/entity/IdentifierMap.java | 8 ++++---- .../ms/neng/persistence/entity/PolicyDetails.java | 12 ++++++------ .../ms/neng/persistence/entity/ServiceParameter.java | 8 ++++---- .../ms/neng/service/extinf/impl/AaiServiceImpl.java | 2 +- .../service/extinf/impl/PolicyFinderServiceImpl.java | 19 +++++++++++++------ 9 files changed, 42 insertions(+), 35 deletions(-) (limited to 'ms/neng/src/main/java') diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/WebConfiguration.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/WebConfiguration.java index ca918eb9..c766b167 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/WebConfiguration.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/WebConfiguration.java @@ -26,7 +26,7 @@ import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; /** * Configuration for the API part of the micro-service. @@ -37,8 +37,8 @@ public class WebConfiguration { * Creates the bean for configuring swagger. */ @Bean - public WebMvcConfigurerAdapter forwardToIndex() { - return new WebMvcConfigurerAdapter() { + public WebMvcConfigurer forwardToIndex() { + return new WebMvcConfigurer() { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/swagger").setViewName("redirect:/swagger/index.html"); diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java index 3772fd71..14ed9bea 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Map; import java.util.logging.Logger; import java.util.regex.Pattern; -import javax.transaction.Transactional; +import jakarta.transaction.Transactional; import org.onap.ccsdk.apps.ms.neng.core.exceptions.NengException; import org.onap.ccsdk.apps.ms.neng.core.gen.NameGenerator; import org.onap.ccsdk.apps.ms.neng.core.persistence.NamePersister; diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ExternalInterface.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ExternalInterface.java index 7a729af7..40343a35 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ExternalInterface.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ExternalInterface.java @@ -22,10 +22,10 @@ package org.onap.ccsdk.apps.ms.neng.persistence.entity; import java.io.Serializable; import java.sql.Timestamp; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; /** * Entity representing the parameters and configuration of an external system/sub-system/application interface diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedName.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedName.java index b5a7463e..5831f424 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedName.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/GeneratedName.java @@ -22,12 +22,12 @@ package org.onap.ccsdk.apps.ms.neng.persistence.entity; import java.io.Serializable; import java.sql.Timestamp; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; /** * Represents a generated name. diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMap.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMap.java index de8bef18..113af252 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMap.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/IdentifierMap.java @@ -22,10 +22,10 @@ package org.onap.ccsdk.apps.ms.neng.persistence.entity; import java.io.Serializable; import java.sql.Timestamp; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; /** * Maps identifiers (such as function names) in the policy to internal names used by this diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetails.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetails.java index 01410739..1e5df401 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetails.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/PolicyDetails.java @@ -22,12 +22,12 @@ package org.onap.ccsdk.apps.ms.neng.persistence.entity; import java.io.Serializable; import java.sql.Timestamp; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.Table; /** * Represents an entity representing policies stored in this micro-service (temporarily). diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameter.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameter.java index 92cfa4ff..c90d867b 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameter.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/persistence/entity/ServiceParameter.java @@ -22,10 +22,10 @@ package org.onap.ccsdk.apps.ms.neng.persistence.entity; import java.io.Serializable; import java.sql.Timestamp; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; /** * General parameters controlling this micro-service. diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImpl.java index 41bfae47..2880f302 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImpl.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/AaiServiceImpl.java @@ -101,7 +101,7 @@ public class AaiServiceImpl { throw new NengException("Error while validating name with A&AI"); } } catch (HttpClientErrorException e) { - log.warning(e.getStatusCode().name() + " -- " + e.getResponseBodyAsString()); + log.warning(e.getStatusCode() + " -- " + e.getResponseBodyAsString()); if (HttpStatus.NOT_FOUND.equals(e.getStatusCode())) { return buildResponse(false); } diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java index 6ae3c204..d855eb4d 100644 --- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java +++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java @@ -35,10 +35,13 @@ import java.util.logging.Logger; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; import javax.net.ssl.SSLSession; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.conn.ssl.TrustStrategy; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; + +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager; +import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder; +import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory; +import org.apache.hc.core5.ssl.TrustStrategy; import org.onap.ccsdk.apps.ms.neng.core.exceptions.NengException; import org.onap.ccsdk.apps.ms.neng.core.policy.PolicyFinder; import org.onap.ccsdk.apps.ms.neng.core.resource.model.GetConfigRequest; @@ -231,13 +234,17 @@ public class PolicyFinderServiceImpl implements PolicyFinder { if (restTemplate != null) { return restTemplate; } + TrustStrategy acceptingTrustStrategy = (X509Certificate[] chain, String authType) -> true; - SSLContext sslContext = org.apache.http.ssl.SSLContexts.custom() + SSLContext sslContext = org.apache.hc.core5.ssl.SSLContexts.custom() .loadTrustMaterial(null, acceptingTrustStrategy).build(); HostnameVerifier verifier = new AcceptIpAddressHostNameVerifier(disableHostVerification); SSLConnectionSocketFactory csf = new SSLConnectionSocketFactory(sslContext, verifier); - CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(csf).build(); + + PoolingHttpClientConnectionManager connectionManager = PoolingHttpClientConnectionManagerBuilder.create().setSSLSocketFactory(csf).build(); + CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(connectionManager).build(); HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(); + requestFactory.setHttpClient(httpClient); restTemplate = new RestTemplate(requestFactory); restTemplate.getInterceptors().add(getAuthInt()); -- cgit 1.2.3-korg