diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/config/SchemaConverterPropertiesConfig.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/config/SchemaConverterPropertiesConfig.java index f530c842ba0bae004bc3e54e080cca143edb88c9..163664f5f04b0c7ee0b03f4fb4113eddee038235 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/config/SchemaConverterPropertiesConfig.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/config/SchemaConverterPropertiesConfig.java @@ -24,7 +24,7 @@ public class SchemaConverterPropertiesConfig implements SchemaConverterConfig { } private Set<String> getDefaultSupportedArrayTypes() { - return new HashSet<>(Arrays.asList("boolean", "integer", "number", "string")); + return new HashSet<>(Arrays.asList("boolean", "integer", "number", "string", "object")); } private Map<String, String> getDefaultSpecialDefinitionsMap() { diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/TypeMapper.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/TypeMapper.java index 9e3150abc4006549f51f8ed4b2375ff522c4184a..416728dc3cb6689e4486e41798f37d74b7e7e627 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/TypeMapper.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/util/TypeMapper.java @@ -43,7 +43,7 @@ public class TypeMapper { metaAttributeIndexerType.put(RecordMetaAttribute.VERSION.getValue(), ElasticType.LONG.getValue()); metaAttributeIndexerType.put(RecordMetaAttribute.X_ACL.getValue(), ElasticType.KEYWORD.getValue()); metaAttributeIndexerType.put(RecordMetaAttribute.ACL.getValue(), getAclIndexerMapping()); - metaAttributeIndexerType.put(RecordMetaAttribute.TAGS.getValue(), ElasticType.FLATTENED.getValue()); + metaAttributeIndexerType.put(RecordMetaAttribute.TAGS.getValue(), ElasticType.OBJECT.getValue()); metaAttributeIndexerType.put(RecordMetaAttribute.LEGAL.getValue(), getLegalIndexerMapping()); metaAttributeIndexerType.put(RecordMetaAttribute.ANCESTRY.getValue(), getAncestryIndexerMapping()); metaAttributeIndexerType.put(RecordMetaAttribute.INDEX_STATUS.getValue(), getIndexStatusMapping()); diff --git a/indexer-core/src/test/resources/converter/R3-json-schema/Generated/file/File.1.0.0.json.res b/indexer-core/src/test/resources/converter/R3-json-schema/Generated/file/File.1.0.0.json.res index b0f71fc6fd26e27eb5dc2362e7667aa1d17c481e..d0cc00a8d3fe76d6ff446a8433c4b895e8a88316 100644 --- a/indexer-core/src/test/resources/converter/R3-json-schema/Generated/file/File.1.0.0.json.res +++ b/indexer-core/src/test/resources/converter/R3-json-schema/Generated/file/File.1.0.0.json.res @@ -40,6 +40,10 @@ { "kind": "string", "path": "Checksum" + }, + { + "kind": "[]object", + "path": "VectorHeaderMapping" } ] } \ No newline at end of file diff --git a/indexer-core/src/test/resources/converter/R3-json-schema/Generated/master-data/Agreement.1.0.0.json.res b/indexer-core/src/test/resources/converter/R3-json-schema/Generated/master-data/Agreement.1.0.0.json.res index 136ed0b7ecb61b50f82b8d8e213db03ab410f8da..8728c3bc5da175c23046b1f86381ef5eb99cbfe3 100644 --- a/indexer-core/src/test/resources/converter/R3-json-schema/Generated/master-data/Agreement.1.0.0.json.res +++ b/indexer-core/src/test/resources/converter/R3-json-schema/Generated/master-data/Agreement.1.0.0.json.res @@ -32,6 +32,14 @@ { "kind": "[]link", "path": "Counterparties" + }, + { + "kind": "[]object", + "path": "Terms" + }, + { + "kind": "[]object", + "path": "RestrictedResources" } ] } \ No newline at end of file diff --git a/indexer-core/src/test/resources/converter/R3-json-schema/Generated/work-product-component/WellLog.1.0.0.json.res b/indexer-core/src/test/resources/converter/R3-json-schema/Generated/work-product-component/WellLog.1.0.0.json.res index 517ca0395223bf432f8bc6b8c01bf7c768921532..359986f472e4ea54a08e6496b5230b914c3a80f0 100644 --- a/indexer-core/src/test/resources/converter/R3-json-schema/Generated/work-product-component/WellLog.1.0.0.json.res +++ b/indexer-core/src/test/resources/converter/R3-json-schema/Generated/work-product-component/WellLog.1.0.0.json.res @@ -76,6 +76,10 @@ { "kind": "string", "path": "VerticalMeasurementID" + }, + { + "kind": "[]object", + "path": "Curves" } ] } \ No newline at end of file diff --git a/indexer-core/src/test/resources/converter/R3-json-schema/Generated/work-product/WorkProduct.1.0.0.json.res b/indexer-core/src/test/resources/converter/R3-json-schema/Generated/work-product/WorkProduct.1.0.0.json.res index 0b807093bb76e1b01fa2c4d2753864bab6f52386..5852817c878ac55fcc522b6752635389135b40ae 100644 --- a/indexer-core/src/test/resources/converter/R3-json-schema/Generated/work-product/WorkProduct.1.0.0.json.res +++ b/indexer-core/src/test/resources/converter/R3-json-schema/Generated/work-product/WorkProduct.1.0.0.json.res @@ -44,6 +44,10 @@ { "kind": "[]string", "path": "Annotations" + }, + { + "kind": "[]object", + "path": "LineageAssertions" } ] } \ No newline at end of file diff --git a/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/util/IndexerQueueTaskBuilderAws.java b/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/util/IndexerQueueTaskBuilderAws.java index b93d3c94144d859cdf25cde6ff4e1cfcd7ff9358..cb47d53cd17fce4056d18d82a4371f8b1fe2d204 100644 --- a/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/util/IndexerQueueTaskBuilderAws.java +++ b/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/util/IndexerQueueTaskBuilderAws.java @@ -79,15 +79,38 @@ public class IndexerQueueTaskBuilderAws extends IndexerQueueTaskBuilder { } @Override public void createReIndexTask(String payload,DpsHeaders headers) { - this.createTask(payload, headers); + Map<String, MessageAttributeValue> messageAttributes = new HashMap<>(); + messageAttributes.put(DpsHeaders.ACCOUNT_ID, new MessageAttributeValue() + .withDataType("String") + .withStringValue(headers.getPartitionIdWithFallbackToAccountId())); + messageAttributes.put(DpsHeaders.DATA_PARTITION_ID, new MessageAttributeValue() + .withDataType("String") + .withStringValue(headers.getPartitionIdWithFallbackToAccountId())); + headers.addCorrelationIdIfMissing(); + messageAttributes.put(DpsHeaders.CORRELATION_ID, new MessageAttributeValue() + .withDataType("String") + .withStringValue(headers.getCorrelationId())); + messageAttributes.put(DpsHeaders.USER_EMAIL, new MessageAttributeValue() + .withDataType("String") + .withStringValue(headers.getUserEmail())); + messageAttributes.put(DpsHeaders.AUTHORIZATION, new MessageAttributeValue() + .withDataType("String") + .withStringValue(headers.getAuthorization())); + messageAttributes.put("ReIndexCursor", new MessageAttributeValue() + .withDataType("String") + .withStringValue("True")); + SendMessageRequest sendMessageRequest = new SendMessageRequest() + .withQueueUrl(storageQueue) + .withMessageBody(payload) + .withMessageAttributes(messageAttributes); + sqsClient.sendMessage(sendMessageRequest); } @Override public void createReIndexTask(String payload, Long countDownMillis, DpsHeaders headers){ - this.createTask(payload, headers); + this.createReIndexTask(payload, headers); } private void createTask(String payload, DpsHeaders headers) { - Map<String, MessageAttributeValue> messageAttributes = new HashMap<>(); messageAttributes.put(DpsHeaders.ACCOUNT_ID, new MessageAttributeValue() .withDataType("String") diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/AppExceptionHandler.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/AppExceptionHandler.java index 0e8293b1a59abd37ebdcd59bf3f2610a7c39e813..ebfe87ef077c4bbb244a1b68ba94d9138bfc0753 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/AppExceptionHandler.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/AppExceptionHandler.java @@ -23,12 +23,36 @@ public class AppExceptionHandler { ? e.getOriginalException().getMessage() : e.getError().getMessage(); - if (e.getError().getCode() > 499) { + Integer errorCode = e.getError().getCode(); + + if (errorCode > 499) { log.error(exceptionMsg, e.getOriginalException()); } else { log.warn(exceptionMsg, e.getOriginalException()); } - return new ResponseEntity<>(e.getError(), HttpStatus.resolve(e.getError().getCode())); + HttpStatus status = Objects.nonNull(HttpStatus.resolve(errorCode)) + ? HttpStatus.resolve(errorCode) + : resolveNotSupportedStatus(errorCode); + + return new ResponseEntity<>(e.getError(), status); + } + + //Currently not all codes provided from core can be resolved by HttpStatus + //example org.opengroup.osdu.core.common.model.http.RequestStatus have not supported by HttpStatus codes + private HttpStatus resolveNotSupportedStatus(int statusCode) { + if (statusCode > 99 && statusCode < 200) { + return HttpStatus.CONTINUE; + } + if (statusCode > 199 && statusCode < 300) { + return HttpStatus.NO_CONTENT; + } + if (statusCode > 299 && statusCode < 400) { + return HttpStatus.MULTIPLE_CHOICES; + } + if (statusCode > 399 && statusCode < 500) { + return HttpStatus.BAD_REQUEST; + } + return HttpStatus.INTERNAL_SERVER_ERROR; } } diff --git a/provider/indexer-gcp/src/main/resources/application.properties b/provider/indexer-gcp/src/main/resources/application.properties index 08ee586c371bc8fecc4e21227ef2b4f1c8b76c5e..2213e4dca947f3ad90a5998299005c613a47ef61 100644 --- a/provider/indexer-gcp/src/main/resources/application.properties +++ b/provider/indexer-gcp/src/main/resources/application.properties @@ -42,5 +42,3 @@ security.https.certificate.trust=false indexer.que.service.mail=default@iam.gserviceaccount.com SCHEMA_HOST=${HOST}/api/schema-service/v1/schema storage-query-kinds-host=https://${STORAGE_HOSTNAME}/api/storage/v2/query/kinds - -schema.converter.supported-array-types=boolean,integer,number,string,object diff --git a/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/di/EntitlementsClientFactory.java b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/di/EntitlementsClientFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..4a1938530b61f5a0530be55a47b30f7d453379bb --- /dev/null +++ b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/di/EntitlementsClientFactory.java @@ -0,0 +1,44 @@ + +package org.opengroup.osdu.indexer.ibm.di; + +import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig; +import org.opengroup.osdu.core.common.entitlements.EntitlementsFactory; +import org.opengroup.osdu.core.common.entitlements.IEntitlementsFactory; +import org.opengroup.osdu.core.common.http.json.HttpResponseBodyMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.beans.factory.config.AbstractFactoryBean; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; +import org.springframework.web.context.annotation.RequestScope; + +@Component +@RequestScope +@Lazy +public class EntitlementsClientFactory extends AbstractFactoryBean<IEntitlementsFactory> { + + @Value("${AUTHORIZE_API}") + private String AUTHORIZE_API; + + @Value("${AUTHORIZE_API_KEY:}") + private String AUTHORIZE_API_KEY; + + @Autowired + private HttpResponseBodyMapper mapper; + + @Override + protected IEntitlementsFactory createInstance() throws Exception { + + return new EntitlementsFactory(EntitlementsAPIConfig + .builder() + .rootUrl(AUTHORIZE_API) + .apiKey(AUTHORIZE_API_KEY) + .build(), + mapper); + } + + @Override + public Class<?> getObjectType() { + return IEntitlementsFactory.class; + } +} \ No newline at end of file diff --git a/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/IndexerQueueTaskBuilderIbm.java b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/IndexerQueueTaskBuilderIbm.java index 48490a966c76462f23bf88b55e07a8c51b3c2dc9..2b4e88c68de8b4786c4d80b491ef418dfaf0acbc 100644 --- a/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/IndexerQueueTaskBuilderIbm.java +++ b/provider/indexer-ibm/src/main/java/org/opengroup/osdu/indexer/ibm/util/IndexerQueueTaskBuilderIbm.java @@ -3,6 +3,8 @@ package org.opengroup.osdu.indexer.ibm.util; +import static org.opengroup.osdu.core.common.Constants.WORKER_RELATIVE_URL; + import java.util.Map; import javax.inject.Inject; @@ -46,6 +48,12 @@ public class IndexerQueueTaskBuilderIbm extends IndexerQueueTaskBuilder { public void createReIndexTask(String payload, DpsHeaders headers) { createTask(payload, headers); } + + //used by reindexer api + @Override + public void createWorkerTask(String payload, Long countdownMillis, DpsHeaders headers) { + createTask(payload, headers); + } private void createTask(String payload, DpsHeaders headers) {