Removed use of immutable and type adapters 66/8266/1
authorPatrikBuhr <patrik.buhr@est.tech>
Thu, 12 May 2022 12:32:18 +0000 (14:32 +0200)
committerPatrikBuhr <patrik.buhr@est.tech>
Thu, 12 May 2022 12:32:18 +0000 (14:32 +0200)
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Issue-ID: NONRTRIC-743
Change-Id: Ie361889f57ce6e7327b2342334a8e72bbd817ead

17 files changed:
pom.xml
src/main/java/org/oran/dmaapadapter/clients/AsyncRestClient.java
src/main/java/org/oran/dmaapadapter/clients/AsyncRestClientFactory.java
src/main/java/org/oran/dmaapadapter/configuration/ApplicationConfig.java
src/main/java/org/oran/dmaapadapter/configuration/WebClientConfig.java
src/main/java/org/oran/dmaapadapter/controllers/VoidResponse.java
src/main/java/org/oran/dmaapadapter/r1/ConsumerJobInfo.java
src/main/java/org/oran/dmaapadapter/r1/ProducerInfoTypeInfo.java
src/main/java/org/oran/dmaapadapter/r1/ProducerJobInfo.java
src/main/java/org/oran/dmaapadapter/r1/ProducerRegistrationInfo.java
src/main/java/org/oran/dmaapadapter/repository/Job.java
src/main/java/org/oran/dmaapadapter/repository/filters/PmReport.java
src/main/java/org/oran/dmaapadapter/repository/filters/PmReportFilter.java
src/main/java/org/oran/dmaapadapter/tasks/DmaapTopicListener.java
src/test/java/org/oran/dmaapadapter/ApplicationTest.java
src/test/java/org/oran/dmaapadapter/IntegrationWithIcs.java
src/test/java/org/oran/dmaapadapter/IntegrationWithKafka.java

diff --git a/pom.xml b/pom.xml
index 2c2fa4f..ef3a1f1 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -48,7 +48,7 @@
     <properties>
         <java.version>11</java.version>
         <springfox.version>3.0.0</springfox.version>
-        <immutable.version>2.8.2</immutable.version>
+        <immutable.version>2.9.0</immutable.version>
         <swagger.version>2.1.6</swagger.version>
         <json.version>20211205</json.version>
         <maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
             <artifactId>swagger-jaxrs2-servlet-initializer</artifactId>
             <version>${swagger.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.immutables</groupId>
-            <artifactId>value</artifactId>
-            <version>${immutable.version}</version>
-            <scope>provided</scope>
-        </dependency>
         <dependency>
             <groupId>org.immutables</groupId>
             <artifactId>gson</artifactId>
index 4c7c1fa..adbd32d 100644 (file)
@@ -138,8 +138,8 @@ public class AsyncRestClient {
     }
 
     private boolean isHttpProxyConfigured() {
-        return httpProxyConfig != null && httpProxyConfig.httpProxyPort() > 0
-                && !httpProxyConfig.httpProxyHost().isEmpty();
+        return httpProxyConfig != null && httpProxyConfig.getHttpProxyPort() > 0
+                && !httpProxyConfig.getHttpProxyHost().isEmpty();
     }
 
     private HttpClient buildHttpClient() {
@@ -156,7 +156,7 @@ public class AsyncRestClient {
 
         if (isHttpProxyConfigured()) {
             httpClient = httpClient.proxy(proxy -> proxy.type(ProxyProvider.Proxy.HTTP)
-                    .host(httpProxyConfig.httpProxyHost()).port(httpProxyConfig.httpProxyPort()));
+                    .host(httpProxyConfig.getHttpProxyHost()).port(httpProxyConfig.getHttpProxyPort()));
         }
         return httpClient;
     }
index dc8e2db..c9f17b0 100644 (file)
@@ -60,7 +60,7 @@ public class AsyncRestClientFactory {
     public AsyncRestClientFactory(WebClientConfig clientConfig, SecurityContext securityContext) {
         if (clientConfig != null) {
             this.sslContextFactory = new CachingSslContextFactory(clientConfig);
-            this.httpProxyConfig = clientConfig.httpProxyConfig();
+            this.httpProxyConfig = clientConfig.getHttpProxyConfig();
         } else {
             logger.warn("No configuration for web client defined, HTTPS will not work");
             this.sslContextFactory = null;
@@ -105,8 +105,8 @@ public class AsyncRestClientFactory {
         private SslContext createSslContext(KeyManagerFactory keyManager)
                 throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException {
             if (this.clientConfig.isTrustStoreUsed()) {
-                return createSslContextRejectingUntrustedPeers(this.clientConfig.trustStore(),
-                        this.clientConfig.trustStorePassword(), keyManager);
+                return createSslContextRejectingUntrustedPeers(this.clientConfig.getTrustStore(),
+                        this.clientConfig.getTrustStorePassword(), keyManager);
             } else {
                 // Trust anyone
                 return SslContextBuilder.forClient() //
@@ -154,10 +154,10 @@ public class AsyncRestClientFactory {
         private KeyManagerFactory createKeyManager() throws NoSuchAlgorithmException, CertificateException, IOException,
                 UnrecoverableKeyException, KeyStoreException {
             final KeyManagerFactory keyManager = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
-            final KeyStore keyStore = KeyStore.getInstance(this.clientConfig.keyStoreType());
-            final String keyStoreFile = this.clientConfig.keyStore();
-            final String keyStorePassword = this.clientConfig.keyStorePassword();
-            final String keyPassword = this.clientConfig.keyPassword();
+            final KeyStore keyStore = KeyStore.getInstance(this.clientConfig.getKeyStoreType());
+            final String keyStoreFile = this.clientConfig.getKeyStore();
+            final String keyStorePassword = this.clientConfig.getKeyStorePassword();
+            final String keyPassword = this.clientConfig.getKeyPassword();
             try (final InputStream inputStream = new FileInputStream(keyStoreFile)) {
                 keyStore.load(inputStream, keyStorePassword.toCharArray());
             }
index 7b97486..1c5b8d0 100644 (file)
@@ -98,12 +98,12 @@ public class ApplicationConfig {
 
     public WebClientConfig getWebClientConfig() {
         if (this.webClientConfig == null) {
-            HttpProxyConfig httpProxyConfig = ImmutableHttpProxyConfig.builder() //
+            HttpProxyConfig httpProxyConfig = HttpProxyConfig.builder() //
                     .httpProxyHost(this.httpProxyHost) //
                     .httpProxyPort(this.httpProxyPort) //
                     .build();
 
-            this.webClientConfig = ImmutableWebClientConfig.builder() //
+            this.webClientConfig = WebClientConfig.builder() //
                     .keyStoreType(this.sslKeyStoreType) //
                     .keyStorePassword(this.sslKeyStorePassword) //
                     .keyStore(this.sslKeyStore) //
index e65fdb9..b3407d2 100644 (file)
 
 package org.oran.dmaapadapter.configuration;
 
-import org.immutables.value.Value;
+import lombok.Builder;
+import lombok.Getter;
+import reactor.netty.transport.ProxyProvider;
 
-@Value.Immutable
-@Value.Style(redactedMask = "####")
-public interface WebClientConfig {
-    public String keyStoreType();
+@Builder
+@Getter
+public class WebClientConfig {
+    private String keyStoreType;
 
-    @Value.Redacted
-    public String keyStorePassword();
+    private String keyStorePassword;
 
-    public String keyStore();
+    private String keyStore;
 
-    @Value.Redacted
-    public String keyPassword();
+    private String keyPassword;
 
-    public boolean isTrustStoreUsed();
+    private boolean isTrustStoreUsed;
 
-    @Value.Redacted
-    public String trustStorePassword();
+    private String trustStorePassword;
 
-    public String trustStore();
+    private String trustStore;
 
-    @Value.Immutable
-    public interface HttpProxyConfig {
-        public String httpProxyHost();
+    @Builder
+    @Getter
+    public static class HttpProxyConfig {
+        private String httpProxyHost;
 
-        public int httpProxyPort();
-    }
+        private int httpProxyPort;
 
-    public HttpProxyConfig httpProxyConfig();
+        private ProxyProvider.Proxy httpProxyType;
+    }
 
+    private HttpProxyConfig httpProxyConfig;
 }
index b7bba5f..a4ae55b 100644 (file)
@@ -22,9 +22,6 @@ package org.oran.dmaapadapter.controllers;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
 @Schema(name = "void", description = "Void/empty")
 public class VoidResponse {
     private VoidResponse() {}
index c1737db..bdc22f2 100644 (file)
@@ -25,9 +25,6 @@ import com.google.gson.annotations.SerializedName;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
 @Schema(name = "consumer_job", description = "Information for an Information Job")
 public class ConsumerJobInfo {
 
index 1bf5e47..b1517d4 100644 (file)
@@ -25,9 +25,6 @@ import com.google.gson.annotations.SerializedName;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
 @Schema(name = "producer_info_type_info", description = "Information for an Information Type")
 public class ProducerInfoTypeInfo {
 
index d378825..5638292 100644 (file)
@@ -25,9 +25,6 @@ import com.google.gson.annotations.SerializedName;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
 @Schema(name = "producer_info_job_request",
         description = "The body of the Information Producer callbacks for Information Job creation and deletion")
 public class ProducerJobInfo {
index e54c152..f826e09 100644 (file)
@@ -29,10 +29,7 @@ import java.util.Collection;
 
 import lombok.Builder;
 
-import org.immutables.gson.Gson;
-
 @Builder
-@Gson.TypeAdapters
 @Schema(name = "producer_registration_info", description = "Information for an Information Producer")
 public class ProducerRegistrationInfo {
 
index 989643c..e7c9290 100644 (file)
@@ -28,7 +28,6 @@ import java.time.Duration;
 import lombok.Getter;
 import lombok.Setter;
 
-import org.immutables.gson.Gson;
 import org.oran.dmaapadapter.clients.AsyncRestClient;
 import org.oran.dmaapadapter.repository.filters.Filter;
 import org.oran.dmaapadapter.repository.filters.JsltFilter;
@@ -43,7 +42,6 @@ public class Job {
     private static com.google.gson.Gson gson = new GsonBuilder().create();
     private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
 
-    @Gson.TypeAdapters
     public static class Parameters {
         public static final String REGEXP_TYPE = "regexp";
         public static final String PM_FILTER_TYPE = "pmdata";
@@ -102,7 +100,6 @@ public class Job {
         }
     }
 
-    @Gson.TypeAdapters
     public static class BufferTimeout {
         public BufferTimeout(int maxSize, long maxTimeMiliseconds) {
             this.maxSize = maxSize;
index 6f3300d..c13d36c 100644 (file)
 
 package org.oran.dmaapadapter.repository.filters;
 
+
 import java.util.ArrayList;
 import java.util.Collection;
 
-import org.immutables.gson.Gson;
-
-@Gson.TypeAdapters
 class PmReport {
 
     Event event = new Event();
 
-    @Gson.TypeAdapters
     public static class CommonEventHeader {
         String domain;
         String eventId;
@@ -46,12 +43,10 @@ class PmReport {
         String timeZoneOffset;
     }
 
-    @Gson.TypeAdapters
     public static class MeasInfoId {
         String sMeasInfoId;
     }
 
-    @Gson.TypeAdapters
     public static class MeasTypes {
         public String getMeasType(int pValue) {
             if (pValue > sMeasTypesList.size()) {
@@ -63,13 +58,11 @@ class PmReport {
         protected ArrayList<String> sMeasTypesList = new ArrayList<>();
     }
 
-    @Gson.TypeAdapters
     public static class MeasResult {
         int p;
         String sValue;
     }
 
-    @Gson.TypeAdapters
     public static class MeasValuesList {
         String measObjInstId;
         String suspectFlag;
@@ -83,7 +76,6 @@ class PmReport {
         }
     }
 
-    @Gson.TypeAdapters
     public static class MeasInfoList {
         MeasInfoId measInfoId;
         MeasTypes measTypes;
@@ -97,7 +89,6 @@ class PmReport {
         }
     }
 
-    @Gson.TypeAdapters
     public static class MeasDataCollection {
         int granularityPeriod;
         String measuredEntityUserName;
@@ -106,13 +97,11 @@ class PmReport {
         Collection<MeasInfoList> measInfoList = new ArrayList<>();
     }
 
-    @Gson.TypeAdapters
     public static class Perf3gppFields {
         String perf3gppFieldsVersion;
         MeasDataCollection measDataCollection;
     }
 
-    @Gson.TypeAdapters
     public static class Event {
         CommonEventHeader commonEventHeader;
         Perf3gppFields perf3gppFields;
index 9565d90..b6d65ad 100644 (file)
@@ -20,6 +20,7 @@
 
 package org.oran.dmaapadapter.repository.filters;
 
+
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
@@ -27,7 +28,6 @@ import java.util.Map;
 
 import lombok.Getter;
 
-import org.immutables.gson.Gson;
 import org.thymeleaf.util.StringUtils;
 
 public class PmReportFilter implements Filter {
@@ -35,7 +35,6 @@ public class PmReportFilter implements Filter {
     private static com.google.gson.Gson gson = new com.google.gson.GsonBuilder().create();
     private final FilterData filterData;
 
-    @Gson.TypeAdapters
     @Getter
     public static class FilterData {
         Collection<String> sourceNames = new ArrayList<>();
index c34b470..dbb6059 100644 (file)
@@ -52,8 +52,8 @@ public class DmaapTopicListener implements TopicListener {
     private Disposable topicReceiverTask;
 
     public DmaapTopicListener(ApplicationConfig applicationConfig, InfoType type, SecurityContext securityContext) {
-        AsyncRestClientFactory restclientFactory = new AsyncRestClientFactory(applicationConfig.getWebClientConfig(),
-                securityContext);
+        AsyncRestClientFactory restclientFactory =
+                new AsyncRestClientFactory(applicationConfig.getWebClientConfig(), securityContext);
         this.dmaapRestClient = restclientFactory.createRestClientNoHttpProxy("");
         this.applicationConfig = applicationConfig;
         this.type = type;
index 155e112..ea47373 100644 (file)
@@ -44,8 +44,6 @@ import org.oran.dmaapadapter.clients.AsyncRestClient;
 import org.oran.dmaapadapter.clients.AsyncRestClientFactory;
 import org.oran.dmaapadapter.clients.SecurityContext;
 import org.oran.dmaapadapter.configuration.ApplicationConfig;
-import org.oran.dmaapadapter.configuration.ImmutableHttpProxyConfig;
-import org.oran.dmaapadapter.configuration.ImmutableWebClientConfig;
 import org.oran.dmaapadapter.configuration.WebClientConfig;
 import org.oran.dmaapadapter.configuration.WebClientConfig.HttpProxyConfig;
 import org.oran.dmaapadapter.controllers.ProducerCallbacksController;
@@ -172,18 +170,18 @@ class ApplicationTest {
 
     private AsyncRestClient restClient(boolean useTrustValidation) {
         WebClientConfig config = this.applicationConfig.getWebClientConfig();
-        HttpProxyConfig httpProxyConfig = ImmutableHttpProxyConfig.builder() //
+        HttpProxyConfig httpProxyConfig = HttpProxyConfig.builder() //
                 .httpProxyHost("") //
                 .httpProxyPort(0) //
                 .build();
-        config = ImmutableWebClientConfig.builder() //
-                .keyStoreType(config.keyStoreType()) //
-                .keyStorePassword(config.keyStorePassword()) //
-                .keyStore(config.keyStore()) //
-                .keyPassword(config.keyPassword()) //
+        config = WebClientConfig.builder() //
+                .keyStoreType(config.getKeyStoreType()) //
+                .keyStorePassword(config.getKeyStorePassword()) //
+                .keyStore(config.getKeyStore()) //
+                .keyPassword(config.getKeyPassword()) //
                 .isTrustStoreUsed(useTrustValidation) //
-                .trustStore(config.trustStore()) //
-                .trustStorePassword(config.trustStorePassword()) //
+                .trustStore(config.getTrustStore()) //
+                .trustStorePassword(config.getTrustStorePassword()) //
                 .httpProxyConfig(httpProxyConfig).build();
 
         AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config, securityContext);
index 2c0dedc..6eca59d 100644 (file)
@@ -38,8 +38,6 @@ import org.oran.dmaapadapter.clients.AsyncRestClient;
 import org.oran.dmaapadapter.clients.AsyncRestClientFactory;
 import org.oran.dmaapadapter.clients.SecurityContext;
 import org.oran.dmaapadapter.configuration.ApplicationConfig;
-import org.oran.dmaapadapter.configuration.ImmutableHttpProxyConfig;
-import org.oran.dmaapadapter.configuration.ImmutableWebClientConfig;
 import org.oran.dmaapadapter.configuration.WebClientConfig;
 import org.oran.dmaapadapter.configuration.WebClientConfig.HttpProxyConfig;
 import org.oran.dmaapadapter.r1.ConsumerJobInfo;
@@ -142,18 +140,18 @@ class IntegrationWithIcs {
 
     private AsyncRestClient restClient(boolean useTrustValidation) {
         WebClientConfig config = this.applicationConfig.getWebClientConfig();
-        HttpProxyConfig httpProxyConfig = ImmutableHttpProxyConfig.builder() //
+        HttpProxyConfig httpProxyConfig = HttpProxyConfig.builder() //
                 .httpProxyHost("") //
                 .httpProxyPort(0) //
                 .build();
-        config = ImmutableWebClientConfig.builder() //
-                .keyStoreType(config.keyStoreType()) //
-                .keyStorePassword(config.keyStorePassword()) //
-                .keyStore(config.keyStore()) //
-                .keyPassword(config.keyPassword()) //
+        config = WebClientConfig.builder() //
+                .keyStoreType(config.getKeyStoreType()) //
+                .keyStorePassword(config.getKeyStorePassword()) //
+                .keyStore(config.getKeyStore()) //
+                .keyPassword(config.getKeyPassword()) //
                 .isTrustStoreUsed(useTrustValidation) //
-                .trustStore(config.trustStore()) //
-                .trustStorePassword(config.trustStorePassword()) //
+                .trustStore(config.getTrustStore()) //
+                .trustStorePassword(config.getTrustStorePassword()) //
                 .httpProxyConfig(httpProxyConfig).build();
 
         AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config, securityContext);
index 246bb0b..7bbf26c 100644 (file)
@@ -41,8 +41,6 @@ import org.oran.dmaapadapter.clients.AsyncRestClient;
 import org.oran.dmaapadapter.clients.AsyncRestClientFactory;
 import org.oran.dmaapadapter.clients.SecurityContext;
 import org.oran.dmaapadapter.configuration.ApplicationConfig;
-import org.oran.dmaapadapter.configuration.ImmutableHttpProxyConfig;
-import org.oran.dmaapadapter.configuration.ImmutableWebClientConfig;
 import org.oran.dmaapadapter.configuration.WebClientConfig;
 import org.oran.dmaapadapter.configuration.WebClientConfig.HttpProxyConfig;
 import org.oran.dmaapadapter.r1.ConsumerJobInfo;
@@ -161,18 +159,18 @@ class IntegrationWithKafka {
 
     private AsyncRestClient restClient(boolean useTrustValidation) {
         WebClientConfig config = this.applicationConfig.getWebClientConfig();
-        HttpProxyConfig httpProxyConfig = ImmutableHttpProxyConfig.builder() //
+        HttpProxyConfig httpProxyConfig = HttpProxyConfig.builder() //
                 .httpProxyHost("") //
                 .httpProxyPort(0) //
                 .build();
-        config = ImmutableWebClientConfig.builder() //
-                .keyStoreType(config.keyStoreType()) //
-                .keyStorePassword(config.keyStorePassword()) //
-                .keyStore(config.keyStore()) //
-                .keyPassword(config.keyPassword()) //
+        config = WebClientConfig.builder() //
+                .keyStoreType(config.getKeyStoreType()) //
+                .keyStorePassword(config.getKeyStorePassword()) //
+                .keyStore(config.getKeyStore()) //
+                .keyPassword(config.getKeyPassword()) //
                 .isTrustStoreUsed(useTrustValidation) //
-                .trustStore(config.trustStore()) //
-                .trustStorePassword(config.trustStorePassword()) //
+                .trustStore(config.getTrustStore()) //
+                .trustStorePassword(config.getTrustStorePassword()) //
                 .httpProxyConfig(httpProxyConfig).build();
 
         AsyncRestClientFactory restClientFactory = new AsyncRestClientFactory(config, securityContext);