Skip to content
Snippets Groups Projects
Commit d780e151 authored by Neelesh Thakur's avatar Neelesh Thakur
Browse files

enable indexing meta-attributes if there are schema parsing errors

parent 4175af48
No related branches found
No related tags found
1 merge request!139Improve errors processing for Schema service schema parsing
Pipeline #37513 passed
......@@ -84,44 +84,43 @@ public class SchemaToStorageFormatImpl implements SchemaToStorageFormat {
PropertiesProcessor propertiesProcessor = new PropertiesProcessor(schemaServiceSchema.getDefinitions(), schemaConverterConfig);
final List<Map<String, Object>> storageSchemaItems = new ArrayList<>();
if (schemaServiceSchema.getProperties() != null) {
PropertiesData schemaData = schemaServiceSchema.getProperties().getData();
if (!Objects.isNull(schemaData)) {
if (schemaData.getAllOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getAllOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getAnyOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getAnyOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getOneOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getOneOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getRef() != null) {
storageSchemaItems.addAll(propertiesProcessor.processRef(schemaData.getRef())
.collect(Collectors.toList()));
}
if (schemaData.getProperties() != null) {
storageSchemaItems.addAll(propertiesProcessor.processProperties(schemaData.getProperties())
.collect(Collectors.toList()));
}
} else {
throw new SchemaProcessingException(String.format("Schema doesn't have properties section, kind: %s", kind));
}
} else {
if (schemaServiceSchema.getProperties() == null) {
throw new SchemaProcessingException(String.format("Schema doesn't have data section, kind: %s", kind));
}
PropertiesData schemaData = schemaServiceSchema.getProperties().getData();
if (Objects.isNull(schemaData)) {
throw new SchemaProcessingException(String.format("Schema doesn't have properties section, kind: %s", kind));
}
if (schemaData.getAllOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getAllOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getAnyOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getAnyOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getOneOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getOneOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getRef() != null) {
storageSchemaItems.addAll(propertiesProcessor.processRef(schemaData.getRef())
.collect(Collectors.toList()));
}
if (schemaData.getProperties() != null) {
storageSchemaItems.addAll(propertiesProcessor.processProperties(schemaData.getProperties())
.collect(Collectors.toList()));
}
if (!propertiesProcessor.getErrors().isEmpty()) {
throw new SchemaProcessingException(String.format("Errors occurred during parsing the schema, kind: %s | errors: %s" ,
kind, String.join(",", propertiesProcessor.getErrors())));
......
......@@ -19,13 +19,11 @@ import org.apache.http.HttpStatus;
import org.opengroup.osdu.core.common.http.FetchServiceHttpRequest;
import org.opengroup.osdu.core.common.http.IUrlFetchService;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.HttpResponse;
import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo;
import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties;
import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException;
import org.opengroup.osdu.indexer.schema.converter.interfaces.SchemaToStorageFormat;
import org.opengroup.osdu.indexer.service.SchemaService;
import org.opengroup.osdu.indexer.service.StorageService;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
......@@ -64,8 +62,11 @@ public class SchemaProviderImpl implements SchemaService {
try {
schemaServiceSchema = getFromSchemaService(kind);
} catch (SchemaProcessingException ex) {
log.error(ex.getMessage(), ex);
return null;
} catch (RuntimeException ex) {
log.error(String.format("Failed to get the schema from the Schema service, kind: %s | message: %s", kind, ex.getMessage(), ex));
log.error(String.format("Failed to get the schema from the Schema service, kind: %s | message: %s", kind, ex.getMessage()), ex);
return null;
}
......
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