Skip to content
Snippets Groups Projects
Commit ebbd31ac authored by Sviatoslav Nekhaienko's avatar Sviatoslav Nekhaienko
Browse files

final updates

parent 1d8c96d8
No related branches found
No related tags found
1 merge request!60Indexer to read from Schema Service as well as Storage Schema
......@@ -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
......
......@@ -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);
}
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment