Removed use of immutable and type adapters 67/8267/1
authorPatrikBuhr <patrik.buhr@est.tech>
Thu, 12 May 2022 12:30:46 +0000 (14:30 +0200)
committerPatrikBuhr <patrik.buhr@est.tech>
Thu, 12 May 2022 12:33:16 +0000 (14:33 +0200)
Signed-off-by: PatrikBuhr <patrik.buhr@est.tech>
Issue-ID: NONRTRIC-743
Change-Id: Id717cc523b82823728255f3c91648f417ecec6f9

20 files changed:
pom.xml
src/main/java/org/oransc/ics/clients/AsyncRestClient.java
src/main/java/org/oransc/ics/clients/AsyncRestClientFactory.java
src/main/java/org/oransc/ics/configuration/ApplicationConfig.java
src/main/java/org/oransc/ics/configuration/WebClientConfig.java
src/main/java/org/oransc/ics/controllers/StatusController.java
src/main/java/org/oransc/ics/controllers/VoidResponse.java
src/main/java/org/oransc/ics/controllers/a1e/A1eEiJobInfo.java
src/main/java/org/oransc/ics/controllers/a1e/A1eEiJobStatus.java
src/main/java/org/oransc/ics/controllers/a1e/A1eEiTypeInfo.java
src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerInfoTypeInfo.java
src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobInfo.java
src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerJobStatus.java
src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeRegistrationInfo.java
src/main/java/org/oransc/ics/controllers/r1consumer/ConsumerTypeSubscriptionInfo.java
src/main/java/org/oransc/ics/controllers/r1producer/ProducerInfoTypeInfo.java
src/main/java/org/oransc/ics/controllers/r1producer/ProducerJobInfo.java
src/main/java/org/oransc/ics/controllers/r1producer/ProducerRegistrationInfo.java
src/main/java/org/oransc/ics/controllers/r1producer/ProducerStatusInfo.java
src/test/java/org/oransc/ics/ApplicationTest.java

diff --git a/pom.xml b/pom.xml
index 68f6ad9..0067268 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.13</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>
                     </execution>
                 </executions>
             </plugin>
-         </plugins>
+        </plugins>
     </build>
     <issueManagement>
         <system>JIRA</system>
         <url>https://jira.o-ran-sc.org/</url>
     </issueManagement>
-</project>
+</project>
\ No newline at end of file
index 2879092..09b07b2 100644 (file)
@@ -154,8 +154,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() {
@@ -172,7 +172,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 9a6c4f7..64a3ce5 100644 (file)
@@ -59,7 +59,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;
@@ -104,8 +104,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() //
@@ -153,10 +153,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 0a63d42..f076789 100644 (file)
@@ -75,11 +75,11 @@ public class ApplicationConfig {
             } else {
                 logger.info("Http proxy is used for RAN access {}:{}", httpProxyHost, httpProxyPort);
             }
-            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 12e9cfd..e9bbbbd 100644 (file)
 
 package org.oransc.ics.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;
+
+        private ProxyProvider.Proxy httpProxyType;
     }
 
-    public HttpProxyConfig httpProxyConfig();
+    private HttpProxyConfig httpProxyConfig;
 
 }
index 0fe586c..11c9c01 100644 (file)
@@ -30,7 +30,6 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
 import io.swagger.v3.oas.annotations.responses.ApiResponses;
 import io.swagger.v3.oas.annotations.tags.Tag;
 
-import org.immutables.gson.Gson;
 import org.oransc.ics.repository.InfoJobs;
 import org.oransc.ics.repository.InfoProducers;
 import org.oransc.ics.repository.InfoTypes;
@@ -58,7 +57,6 @@ public class StatusController {
     @Autowired
     private InfoProducers infoProducers;
 
-    @Gson.TypeAdapters
     @Schema(name = "service_status_info")
     public static class StatusInfo {
         @Schema(name = "status", description = "status text")
index 8fb810d..4f69a7a 100644 (file)
@@ -22,9 +22,7 @@ package org.oransc.ics.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 e677496..2a042f1 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 = "EiJobObject", description = "Information for an Enrichment Information Job")
 public class A1eEiJobInfo {
 
index 6593051..1f22e9a 100644 (file)
@@ -25,13 +25,10 @@ import com.google.gson.annotations.SerializedName;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 
-import org.immutables.gson.Gson;
 
-@Gson.TypeAdapters
 @Schema(name = "EiJobStatusObject", description = "Status for an EI job")
 public class A1eEiJobStatus {
 
-    @Gson.TypeAdapters
     @Schema(name = "EiJobStatusValues", description = OPERATIONAL_STATE_DESCRIPTION)
     public enum EiJobStatusValues {
         ENABLED, DISABLED
index be5499f..eac18f3 100644 (file)
@@ -22,9 +22,7 @@ package org.oransc.ics.controllers.a1e;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 
-import org.immutables.gson.Gson;
 
-@Gson.TypeAdapters
 @Schema(name = "EiTypeObject", description = "Information for an EI type")
 public class A1eEiTypeInfo {
 
index 682c62b..cce345c 100644 (file)
@@ -25,9 +25,7 @@ import com.google.gson.annotations.SerializedName;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 
-import org.immutables.gson.Gson;
 
-@Gson.TypeAdapters
 @Schema(name = "consumer_information_type", description = "Information for an Information type")
 public class ConsumerInfoTypeInfo {
 
@@ -36,7 +34,6 @@ public class ConsumerInfoTypeInfo {
     @JsonProperty(value = "job_data_schema", required = true)
     public Object jobDataSchema;
 
-    @Gson.TypeAdapters
     @Schema(name = "consumer_type_status_values", description = STATUS_DESCRIPTION)
     public enum ConsumerTypeStatusValues {
         ENABLED, DISABLED
index 8dca3c7..696e827 100644 (file)
@@ -25,9 +25,7 @@ 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 12d05ed..715f88f 100644 (file)
@@ -27,13 +27,10 @@ import io.swagger.v3.oas.annotations.media.Schema;
 
 import java.util.Collection;
 
-import org.immutables.gson.Gson;
 
-@Gson.TypeAdapters
 @Schema(name = "consumer_job_status", description = "Status for an Information Job")
 public class ConsumerJobStatus {
 
-    @Gson.TypeAdapters
     @Schema(name = "info_job_status_values", description = OPERATIONAL_STATE_DESCRIPTION)
     public enum InfoJobStatusValues {
         ENABLED, DISABLED
index 73263ec..f3010c9 100644 (file)
@@ -25,9 +25,7 @@ import com.google.gson.annotations.SerializedName;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 
-import org.immutables.gson.Gson;
 
-@Gson.TypeAdapters
 @Schema(name = "consumer_type_registration_info", description = "Information for an Information type")
 public class ConsumerTypeRegistrationInfo {
 
@@ -41,7 +39,6 @@ public class ConsumerTypeRegistrationInfo {
     @JsonProperty(value = "job_data_schema", required = true)
     public Object jobDataSchema;
 
-    @Gson.TypeAdapters
     @Schema(name = "consumer_type_registration_values", description = REGISTRATION_DESCRIPTION)
     public enum ConsumerTypeStatusValues {
         REGISTERED, DEREGISTERED
index d420c57..fc8fc24 100644 (file)
@@ -26,10 +26,8 @@ import com.google.gson.annotations.SerializedName;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.EqualsAndHashCode;
 
-import org.immutables.gson.Gson;
 
 @EqualsAndHashCode
-@Gson.TypeAdapters
 @Schema(name = "consumer_type_subscription_info", description = "Information for an information type subscription")
 public class ConsumerTypeSubscriptionInfo {
 
index 64f17f9..beca34a 100644 (file)
@@ -25,9 +25,7 @@ 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 8b42ea8..1dd2afb 100644 (file)
@@ -25,10 +25,8 @@ import com.google.gson.annotations.SerializedName;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 
-import org.immutables.gson.Gson;
 import org.oransc.ics.repository.InfoJob;
 
-@Gson.TypeAdapters
 @Schema(
     name = "producer_info_job_request",
     description = "The body of the Information Producer callbacks for Information Job creation and deletion")
index 2e395dc..3493bad 100644 (file)
@@ -27,9 +27,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
 
 import java.util.Collection;
 
-import org.immutables.gson.Gson;
 
-@Gson.TypeAdapters
 @Schema(name = "producer_registration_info", description = "Information for an Information Producer")
 public class ProducerRegistrationInfo {
 
index f4c49cd..c29af8f 100644 (file)
@@ -25,13 +25,10 @@ import com.google.gson.annotations.SerializedName;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 
-import org.immutables.gson.Gson;
 
-@Gson.TypeAdapters
 @Schema(name = "producer_status", description = "Status for an Info Producer")
 public class ProducerStatusInfo {
 
-    @Gson.TypeAdapters
     @Schema(name = "producer_operational_state", description = "Represents the operational states")
     public enum OperationalState {
         ENABLED, DISABLED
index f0a4fed..4ac4283 100644 (file)
@@ -48,8 +48,6 @@ import org.oransc.ics.clients.AsyncRestClient;
 import org.oransc.ics.clients.AsyncRestClientFactory;
 import org.oransc.ics.clients.SecurityContext;
 import org.oransc.ics.configuration.ApplicationConfig;
-import org.oransc.ics.configuration.ImmutableHttpProxyConfig;
-import org.oransc.ics.configuration.ImmutableWebClientConfig;
 import org.oransc.ics.configuration.WebClientConfig;
 import org.oransc.ics.configuration.WebClientConfig.HttpProxyConfig;
 import org.oransc.ics.controller.A1eCallbacksSimulatorController;
@@ -1220,18 +1218,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);