From f249e09235bf760dddd3b6ce15c9c32a2695a5d3 Mon Sep 17 00:00:00 2001
From: Savchuk Mykyta <msavchuk@vertafore.com>
Date: Wed, 19 Oct 2022 14:49:48 +0300
Subject: [PATCH] use @Lazy to resolve bean cycle in CrsConversionService

---
 NOTICE                                                     | 7 +++++--
 .../osdu/storage/conversion/CrsConversionService.java      | 7 ++++++-
 .../osdu/storage/conversion/DpsConversionService.java      | 4 ++--
 3 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/NOTICE b/NOTICE
index bc13eafe7..d7fad6c5f 100644
--- a/NOTICE
+++ b/NOTICE
@@ -417,6 +417,8 @@ The following software have components provided under the terms of this license:
 - KeePassJava2 :: Simple (from https://repo1.maven.org/maven2/org/linguafranca/pwdb/KeePassJava2-simple)
 - Kotlin Stdlib (from https://kotlinlang.org/, https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib)
 - Kotlin Stdlib Common (from https://kotlinlang.org/)
+- Kotlin Stdlib Jdk7 (from https://kotlinlang.org/)
+- Kotlin Stdlib Jdk8 (from https://kotlinlang.org/)
 - LatencyUtils (from http://latencyutils.github.io/LatencyUtils/)
 - MapStruct Core (from http://mapstruct.org/mapstruct/, https://repo1.maven.org/maven2/org/mapstruct/mapstruct)
 - Metrics Core (from https://repo1.maven.org/maven2/io/dropwizard/metrics/metrics-core)
@@ -440,6 +442,7 @@ The following software have components provided under the terms of this license:
 - Netty/Common (from https://repo1.maven.org/maven2/io/netty/netty-common)
 - Netty/Handler (from https://repo1.maven.org/maven2/io/netty/netty-handler)
 - Netty/Handler/Proxy (from https://repo1.maven.org/maven2/io/netty/netty-handler-proxy)
+- Netty/Incubator/Codec/Classes/Quic (from https://repo1.maven.org/maven2/io/netty/incubator/netty-incubator-codec-classes-quic)
 - Netty/Resolver (from https://repo1.maven.org/maven2/io/netty/netty-resolver)
 - Netty/Resolver/DNS (from https://repo1.maven.org/maven2/io/netty/netty-resolver-dns)
 - Netty/Resolver/DNS/Classes/MacOS (from https://repo1.maven.org/maven2/io/netty/netty-resolver-dns-classes-macos)
@@ -776,6 +779,7 @@ The following software have components provided under the terms of this license:
 - Logback Contrib :: JSON :: Core (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-json-core)
 - Logback Contrib :: Jackson (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-jackson)
 - Logback Core Module (from http://logback.qos.ch, https://repo1.maven.org/maven2/ch/qos/logback/logback-core)
+- Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java)
 - Microsoft Application Insights Java SDK Spring Boot starter (from https://github.com/Microsoft/ApplicationInsights-Java)
 - Microsoft Application Insights Java SDK Web Module (from https://github.com/Microsoft/ApplicationInsights-Java)
 - Microsoft Application Insights Log4j 2 Appender (from https://github.com/Microsoft/ApplicationInsights-Java)
@@ -888,8 +892,6 @@ The following software have components provided under the terms of this license:
 ========================================================================
 JSON
 ========================================================================
-The following software have components provided under the terms of this license:
-
 - JSON in Java (from https://github.com/douglascrockford/JSON-java)
 
 ========================================================================
@@ -910,6 +912,7 @@ The following software have components provided under the terms of this license:
 - Logback Contrib :: JSON :: Core (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-json-core)
 - Logback Contrib :: Jackson (from https://repo1.maven.org/maven2/ch/qos/logback/contrib/logback-jackson)
 - Logback Core Module (from http://logback.qos.ch, https://repo1.maven.org/maven2/ch/qos/logback/logback-core)
+- Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java)
 - Microsoft Application Insights Java SDK Spring Boot starter (from https://github.com/Microsoft/ApplicationInsights-Java)
 - Microsoft Application Insights Java SDK Web Module (from https://github.com/Microsoft/ApplicationInsights-Java)
 - Microsoft Application Insights Log4j 2 Appender (from https://github.com/Microsoft/ApplicationInsights-Java)
diff --git a/storage-core/src/main/java/org/opengroup/osdu/storage/conversion/CrsConversionService.java b/storage-core/src/main/java/org/opengroup/osdu/storage/conversion/CrsConversionService.java
index cfac0233a..5982dc16d 100644
--- a/storage-core/src/main/java/org/opengroup/osdu/storage/conversion/CrsConversionService.java
+++ b/storage-core/src/main/java/org/opengroup/osdu/storage/conversion/CrsConversionService.java
@@ -29,6 +29,7 @@ import org.opengroup.osdu.core.common.crs.ICrsConverterFactory;
 import org.opengroup.osdu.core.common.crs.ICrsConverterService;
 import org.opengroup.osdu.core.common.crs.CrsConversionServiceErrorMessages;
 import org.opengroup.osdu.core.common.util.IServiceAccountJwtClient;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.opengroup.osdu.core.common.model.http.DpsHeaders;
@@ -52,6 +53,10 @@ public class CrsConversionService {
     @Autowired
     private CrsPropertySet crsPropertySet;
 
+    @Autowired
+    @Lazy
+    private DpsConversionService dpsConversionService;
+
     @Autowired
     private ICrsConverterFactory crsConverterFactory;
 
@@ -135,7 +140,7 @@ public class CrsConversionService {
             String recordId = this.getRecordId(recordJsonObject);
             ConversionStatus.ConversionStatusBuilder statusBuilder = this.getConversionStatusBuilderFromList(recordId, conversionStatuses);
             List<String> validationErrors = new ArrayList<>();
-            JsonObject filteredObjects = DpsConversionService.filterDataFields(recordJsonObject, validationErrors);
+            JsonObject filteredObjects = this.dpsConversionService.filterDataFields(recordJsonObject, validationErrors);
             Iterator<String> keys = filteredObjects.keySet().iterator();
             while(keys.hasNext()) {
                 String attributeName = keys.next();
diff --git a/storage-core/src/main/java/org/opengroup/osdu/storage/conversion/DpsConversionService.java b/storage-core/src/main/java/org/opengroup/osdu/storage/conversion/DpsConversionService.java
index 3f0fa0bb1..2bb080c03 100644
--- a/storage-core/src/main/java/org/opengroup/osdu/storage/conversion/DpsConversionService.java
+++ b/storage-core/src/main/java/org/opengroup/osdu/storage/conversion/DpsConversionService.java
@@ -108,7 +108,7 @@ public class DpsConversionService {
     }
 
     private boolean isAsIngestedCoordinatesPresent(JsonObject record, List<String> validationErrors) {
-        JsonObject filteredObject = filterDataFields(record, validationErrors);
+        JsonObject filteredObject = this.filterDataFields(record, validationErrors);
         return ((filteredObject != null) && (filteredObject.size() > 0));
     }
 
@@ -198,7 +198,7 @@ public class DpsConversionService {
         }
     }
 
-    public static JsonObject filterDataFields(JsonObject record, List<String> validationErrors) {
+    public JsonObject filterDataFields(JsonObject record, List<String> validationErrors) {
         JsonObject dataObject = record.get(Constants.DATA).getAsJsonObject();
         JsonObject filteredData = new JsonObject();
         Iterator var = validAttributes.iterator();
-- 
GitLab