From ebbd31accdee04a9b66fdf7798b4681e9f6a1165 Mon Sep 17 00:00:00 2001 From: Sviatoslav Nekhaienko <snekhaienko@slb.com> Date: Wed, 2 Dec 2020 16:50:07 +0200 Subject: [PATCH] final updates --- devops/azure/release.yaml | 2 ++ .../indexer/service/impl/SchemaServiceImpl.java | 14 ++++++++++---- .../service/impl/SchemaServiceImplTest.java | 4 ++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/devops/azure/release.yaml b/devops/azure/release.yaml index 7c5645257..ef866679b 100644 --- a/devops/azure/release.yaml +++ b/devops/azure/release.yaml @@ -156,6 +156,8 @@ spec: value: http://storage/api/storage/v2 - name: SCHEMA_HOST value: http://schema/api/schema-service/v1/schema + - name: STORAGE_SCHEMA_HOST + value: http://storage/api/storage/v2/schemas - name: STORAGE_QUERY_RECORD_FOR_CONVERSION_HOST value: http://storage/api/storage/v2/query/records:batch - name: STORAGE_QUERY_RECORD_HOST diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImpl.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImpl.java index 82e2d42c0..22600ae59 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImpl.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImpl.java @@ -56,6 +56,14 @@ public class SchemaServiceImpl implements SchemaService { @Override public String getSchema(String kind) throws URISyntaxException, UnsupportedEncodingException { + String schemaFromStorageService = storageService.getStorageSchema(kind); + + if (schemaFromStorageService != null) { + return schemaFromStorageService; + } + + log.warning("Schema is not found on the Storage Service:" + kind); + String url = String.format("%s/%s", SCHEMA_HOST, URLEncoder.encode(kind, StandardCharsets.UTF_8.toString())); FetchServiceHttpRequest request = FetchServiceHttpRequest.builder() .httpMethod(HttpMethods.GET) @@ -65,12 +73,10 @@ public class SchemaServiceImpl implements SchemaService { HttpResponse response = this.urlFetchService.sendRequest(request); if (response.getResponseCode() == HttpStatus.SC_NOT_FOUND) { - log.info("Schema is not found on Schema Service:" + kind); - return storageService.getStorageSchema(kind); + log.warning("Schema is not found on the Schema Service:" + kind); + return null; } - log.info("Schema is found on the Schema Service:" + kind); - return response.getResponseCode() != HttpStatus.SC_OK ? null : schemaToStorageFormat.convertToString(response.getBody(), kind); } diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImplTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImplTest.java index d2f88b245..74228df4e 100644 --- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImplTest.java +++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/service/impl/SchemaServiceImplTest.java @@ -25,6 +25,7 @@ import org.opengroup.osdu.core.common.http.IUrlFetchService; import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo; import org.opengroup.osdu.indexer.schema.converter.SchemaToStorageFormatImpl; import org.opengroup.osdu.indexer.schema.converter.interfaces.SchemaToStorageFormat; +import org.opengroup.osdu.indexer.service.StorageService; import org.opengroup.osdu.indexer.service.impl.SchemaServiceImpl; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.test.context.junit4.SpringRunner; @@ -50,6 +51,9 @@ public class SchemaServiceImplTest { @Mock private IRequestInfo requestInfo; + @Mock + private StorageService storageService; + @InjectMocks private SchemaServiceImpl sut; -- GitLab