diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9cd10d68a2926e36f601e1619a42b588f2558423..1455572f7535e72b310b8bbe478e69954498a26a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,11 +17,12 @@ variables: OSDU_GCP_APPLICATION_NAME: os-indexer OSDU_GCP_SERVICE: indexer OSDU_GCP_VENDOR: gcp + OSDU_GCP_QUEUE_SA_EMAIL: pub-sub-indexer-queue@nice-etching-277309.iam.gserviceaccount.com OSDU_GCP_SERVICE_ACCOUNT: osdu-gcp-sa@nice-etching-277309.iam.gserviceaccount.com OSDU_SECURITY_HTTPS_CERTIFICATE_TRUST: 'true' OSDU_GCP_STORAGE_RECORDS_BATCH_SIZE: 20 OSDU_GCP_DATA_GROUP: osdu - OSDU_GCP_ENV_VARS: AUTHORIZE_API=$OSDU_GCP_ENTITLEMENTS_URL,GOOGLE_CLOUD_PROJECT=$OSDU_GCP_PROJECT,REDIS_SEARCH_HOST=$REDIS_SEARCH_HOST,REDIS_GROUP_HOST=$REDIS_GROUP_HOST,SECURITY_HTTPS_CERTIFICATE_TRUST=$OSDU_SECURITY_HTTPS_CERTIFICATE_TRUST,INDEXER_HOST=$OSDU_GCP_INDEXER_HOST,STORAGE_QUERY_RECORD_HOST=$OSDU_GCP_STORAGE_QUERY_RECORD_HOST,STORAGE_SCHEMA_HOST=$OSDU_GCP_STORAGE_SCHEMA_HOST,STORAGE_QUERY_RECORD_FOR_CONVERSION_HOST=$OSDU_GCP_STORAGE_QUERY_RECORD_FOR_CONVERSION_HOST,STORAGE_HOSTNAME=$OSDU_GCP_STORAGE_HOSTNAME,STORAGE_RECORDS_BATCH_SIZE=$OSDU_GCP_STORAGE_RECORDS_BATCH_SIZE,INDEXER_QUEUE_HOST=$OSDU_GCP_INDEXER_QUEUE_HOST,LEGALTAG_API=$OSDU_GCP_LEGALTAG_API,CRS_API=$OSDU_GCP_CRS_API,DATA_GROUP=$OSDU_GCP_DATA_GROUP,GOOGLE_AUDIENCES=$GOOGLE_AUDIENCE,INDEXER_QUE_SERVICE_MAIL=$OSDU_GCP_SERVICE_ACCOUNT --vpc-connector=$OSDU_GCP_VPC_CONNECTOR + OSDU_GCP_ENV_VARS: AUTHORIZE_API=$OSDU_GCP_ENTITLEMENTS_URL,GOOGLE_CLOUD_PROJECT=$OSDU_GCP_PROJECT,REDIS_SEARCH_HOST=$REDIS_SEARCH_HOST,REDIS_GROUP_HOST=$REDIS_GROUP_HOST,SECURITY_HTTPS_CERTIFICATE_TRUST=$OSDU_SECURITY_HTTPS_CERTIFICATE_TRUST,INDEXER_HOST=$OSDU_GCP_INDEXER_HOST,STORAGE_QUERY_RECORD_HOST=$OSDU_GCP_STORAGE_QUERY_RECORD_HOST,STORAGE_SCHEMA_HOST=$OSDU_GCP_STORAGE_SCHEMA_HOST,STORAGE_QUERY_RECORD_FOR_CONVERSION_HOST=$OSDU_GCP_STORAGE_QUERY_RECORD_FOR_CONVERSION_HOST,STORAGE_HOSTNAME=$OSDU_GCP_STORAGE_HOSTNAME,STORAGE_RECORDS_BATCH_SIZE=$OSDU_GCP_STORAGE_RECORDS_BATCH_SIZE,INDEXER_QUEUE_HOST=$OSDU_GCP_INDEXER_QUEUE_HOST,LEGALTAG_API=$OSDU_GCP_LEGALTAG_API,CRS_API=$OSDU_GCP_CRS_API,DATA_GROUP=$OSDU_GCP_DATA_GROUP,GOOGLE_AUDIENCES=$GOOGLE_AUDIENCE,INDEXER_QUE_SERVICE_MAIL=$OSDU_GCP_QUEUE_SA_EMAIL --vpc-connector=$OSDU_GCP_VPC_CONNECTOR IBM_BUILD_SUBDIR: provider/indexer-ibm IBM_INT_TEST_SUBDIR: testing/indexer-test-ibm diff --git a/NOTICE b/NOTICE index 5a99a8143ef989906b8ce9ad5b15c77340c18191..904f996db8a0de08d7b00b36acbb5ed3c1c968ad 100644 --- a/NOTICE +++ b/NOTICE @@ -694,6 +694,7 @@ CPL-1.0 ======================================================================== The following software have components provided under the terms of this license: +- JUnit (from http://junit.org) - System Rules (from http://stefanbirkner.github.io/system-rules/) ======================================================================== @@ -701,7 +702,6 @@ EPL-1.0 ======================================================================== The following software have components provided under the terms of this license: -- JUnit (from http://junit.org) - Logback Classic Module (from ) - Logback Core Module (from ) - Microsoft Application Insights Java SDK Core (from https://github.com/Microsoft/ApplicationInsights-Java) @@ -1008,6 +1008,7 @@ The following software have components provided under the terms of this license: - Bouncy Castle Provider (from http://www.bouncycastle.org/java.html) - Bouncy Castle Provider (from http://www.bouncycastle.org/java.html) - Byte Buddy (without dependencies) (from ) +- JUnit (from http://junit.org) - JavaBeans Activation Framework API jar (from ) - Servlet Specification 2.5 API (from ) - Spongy Castle (from http://rtyley.github.io/spongycastle/) diff --git a/devops/azure/development-pipeline.yml b/devops/azure/development-pipeline.yml index 3b09fa1b05e9ecfc936c525e58cbbc76e872c023..adbc5ad1f823ba858c2ff2e8e80fa73bd81c2cd7 100644 --- a/devops/azure/development-pipeline.yml +++ b/devops/azure/development-pipeline.yml @@ -50,14 +50,16 @@ variables: value: $[ resources.repositories['FluxRepo'].name ] - name: SKIP_TESTS value: 'false' + - name: 'MAVEN_CACHE_FOLDER' + value: $(Pipeline.Workspace)/.m2/repository stages: - template: /devops/build-stage.yml@TemplateRepo parameters: mavenGoal: 'package' mavenPublishJUnitResults: true - serviceCoreMavenOptions: '-P indexer-core' - mavenOptions: '-P indexer-azure' + serviceCoreMavenOptions: '-P indexer-core --settings .mvn/community-maven.settings.xml -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' + mavenOptions: '-P indexer-azure --settings .mvn/community-maven.settings.xml -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' copyFileContents: | pom.xml provider/indexer-azure/maven/settings.xml diff --git a/devops/azure/pipeline.yml b/devops/azure/pipeline.yml index dbfc9fae6f271fbd28235be8a7696752796f25ad..1ccfb6beea0048b15c65afe5629f84b5ca143bb6 100644 --- a/devops/azure/pipeline.yml +++ b/devops/azure/pipeline.yml @@ -50,14 +50,16 @@ variables: value: $[ resources.repositories['FluxRepo'].name ] - name: SKIP_TESTS value: 'false' + - name: 'MAVEN_CACHE_FOLDER' + value: $(Pipeline.Workspace)/.m2/repository stages: - template: /devops/build-stage.yml@TemplateRepo parameters: mavenGoal: 'package' mavenPublishJUnitResults: true - serviceCoreMavenOptions: '-P indexer-core' - mavenOptions: '-P indexer-azure' + serviceCoreMavenOptions: '-P indexer-core --settings .mvn/community-maven.settings.xml -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' + mavenOptions: '-P indexer-azure --settings .mvn/community-maven.settings.xml -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' copyFileContents: | pom.xml provider/indexer-azure/maven/settings.xml diff --git a/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/di/EntitlementsClientFactory.java b/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/di/EntitlementsClientFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..dd7cbd1efa355aebf59aab8b148371afa29f8569 --- /dev/null +++ b/provider/indexer-aws/src/main/java/org/opengroup/osdu/indexer/aws/di/EntitlementsClientFactory.java @@ -0,0 +1,58 @@ +// Copyright © Amazon Web Services +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +package org.opengroup.osdu.indexer.aws.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-gcp/src/main/java/org/opengroup/osdu/indexer/IndexerGcpApplication.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/IndexerGcpApplication.java index f72e93440739667f6f7ad9a5694a39e32eedf4aa..6ee70305369eba6f03ef966ce1d442f336eaa87b 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/IndexerGcpApplication.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/IndexerGcpApplication.java @@ -1,3 +1,20 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer; import org.springframework.boot.SpringApplication; diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/ServletInitializer.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/ServletInitializer.java index 0e5ee0a8243d6365fac37b98f0a4a42b2368e85b..dd76cbdb7cc7fa44954c59b4a0e69088dc532f55 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/ServletInitializer.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/ServletInitializer.java @@ -1,3 +1,20 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer; import org.springframework.boot.builder.SpringApplicationBuilder; diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/AttributesCache.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/AttributesCache.java index 889e4476794ea42013afbb1a0ecb49e09e5f0371..0f66e377bb331e53a55b16c5cfceae4895dd9684 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/AttributesCache.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/AttributesCache.java @@ -14,13 +14,12 @@ package org.opengroup.osdu.indexer.cache; -import javax.inject.Inject; import org.opengroup.osdu.core.common.cache.RedisCache; -import org.opengroup.osdu.core.common.model.search.ClusterSettings; import org.opengroup.osdu.core.common.provider.interfaces.IAttributesCache; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; + +import javax.inject.Inject; import java.util.Set; @Component diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/DatastoreCredentialCache.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/DatastoreCredentialCache.java index 0084dcb2c5e729066923b880108071e527e41b1d..6a3b330aad0dcc5a7ba09687a82e0c5e1f53548c 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/DatastoreCredentialCache.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/DatastoreCredentialCache.java @@ -18,14 +18,13 @@ import com.google.auth.oauth2.AccessToken; import org.opengroup.osdu.core.common.cache.RedisCache; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component public class DatastoreCredentialCache extends RedisCache<String, AccessToken> { - @Autowired - public DatastoreCredentialCache(final IndexerConfigurationProperties configurationProperties) { - super(configurationProperties.getRedisSearchHost(), Integer.parseInt(configurationProperties.getRedisSearchPort()), 58 * 60, String.class, AccessToken.class); - } + @Autowired + public DatastoreCredentialCache(final IndexerConfigurationProperties configurationProperties) { + super(configurationProperties.getRedisSearchHost(), Integer.parseInt(configurationProperties.getRedisSearchPort()), 58 * 60, String.class, AccessToken.class); + } } \ No newline at end of file diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/ElasticCredentialsCache.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/ElasticCredentialsCache.java index 8a5e763e783d01b0c4696d9ebc77a51e50ba3c7f..720d21c7256f4bbd838431de4b9e25336587035e 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/ElasticCredentialsCache.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/ElasticCredentialsCache.java @@ -1,13 +1,30 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer.cache; -import javax.inject.Inject; import org.opengroup.osdu.core.common.cache.RedisCache; import org.opengroup.osdu.core.common.model.search.ClusterSettings; import org.opengroup.osdu.core.common.provider.interfaces.IElasticCredentialsCache; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import javax.inject.Inject; + @Component public class ElasticCredentialsCache implements IElasticCredentialsCache<String, ClusterSettings>, AutoCloseable { diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/IndexCache.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/IndexCache.java index 2e8ead781a1f5e0b9b303ee411b953057696dbe2..7f7911db5d70cf5a5c34c77c828fa67e68adbc8d 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/IndexCache.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/IndexCache.java @@ -1,13 +1,29 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer.cache; -import javax.inject.Inject; import org.opengroup.osdu.core.common.cache.RedisCache; -import org.opengroup.osdu.core.common.model.search.ClusterSettings; import org.opengroup.osdu.core.common.provider.interfaces.IIndexCache; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import javax.inject.Inject; + @Component public class IndexCache implements IIndexCache<String, Boolean>, AutoCloseable { private RedisCache<String, Boolean> cache; diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/JwtCache.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/JwtCache.java index a44747cd6426255bd90d3085e95b04c182b84186..4ba364f5bd4523a44e07f74ec5dcd18c10f4ed11 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/JwtCache.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/JwtCache.java @@ -1,20 +1,37 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer.cache; -import javax.inject.Inject; import org.opengroup.osdu.core.common.cache.RedisCache; import org.opengroup.osdu.core.common.model.search.IdToken; import org.opengroup.osdu.core.common.provider.interfaces.IJwtCache; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import javax.inject.Inject; + @Component public class JwtCache implements IJwtCache<String, IdToken>, AutoCloseable { RedisCache<String, IdToken> cache; // google service account id_token can be requested only for 1 hr - private final static int EXPIRED_AFTER = 59; + private static final int EXPIRED_AFTER = 59; @Inject public JwtCache(final IndexerConfigurationProperties properties) { cache = new RedisCache<>(properties.getRedisSearchHost(), Integer.parseInt(properties.getRedisSearchPort()), diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/KindsCache.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/KindsCache.java index 92481f2418fd238c7c051d5c39a6d0b8becd50c0..e20d2f3ca240d33b44cc3bb9261593cae657f8ee 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/KindsCache.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/KindsCache.java @@ -1,12 +1,28 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer.cache; -import javax.inject.Inject; import org.opengroup.osdu.core.common.cache.RedisCache; import org.opengroup.osdu.core.common.provider.interfaces.IKindsCache; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import javax.inject.Inject; import java.util.Set; @Component diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/SchemaCache.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/SchemaCache.java index 04f69cded8bea50fe3486349182a4d3e80a8bd01..0ee20756541b14b4c8a6d94fb153317722c233df 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/SchemaCache.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/cache/SchemaCache.java @@ -1,13 +1,29 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer.cache; -import javax.inject.Inject; import org.opengroup.osdu.core.common.cache.RedisCache; -import org.opengroup.osdu.core.common.model.search.ClusterSettings; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; import org.opengroup.osdu.indexer.provider.interfaces.ISchemaCache; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import javax.inject.Inject; + @Component public class SchemaCache implements ISchemaCache<String, String>, AutoCloseable { private RedisCache<String, String> cache; diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/DatastoreCredentialsCacheFactory.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/DatastoreCredentialsCacheFactory.java index 94e9d343b980c905ff0b72941e5232e40ff42e8d..6f4d9b7505504f259ceca3d3b8e1834dc53f91ba 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/DatastoreCredentialsCacheFactory.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/DatastoreCredentialsCacheFactory.java @@ -1,3 +1,20 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer.di; import org.opengroup.osdu.core.common.cache.ICache; diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/EntitlementsClientFactory.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/EntitlementsClientFactory.java index debcc593970c05f7d4b7291de7519e99c7155890..37e23c94763621e6b06123f2e51cdfd74f7f1507 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/EntitlementsClientFactory.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/EntitlementsClientFactory.java @@ -31,10 +31,10 @@ import org.springframework.web.context.annotation.RequestScope; public class EntitlementsClientFactory extends AbstractFactoryBean<IEntitlementsFactory> { @Value("${AUTHORIZE_API}") - private String AUTHORIZE_API; + private String authorizeApi; @Value("${AUTHORIZE_API_KEY:}") - private String AUTHORIZE_API_KEY; + private String authorizeApiKey; @Autowired private HttpResponseBodyMapper mapper; @@ -44,8 +44,8 @@ public class EntitlementsClientFactory extends AbstractFactoryBean<IEntitlements return new EntitlementsFactory(EntitlementsAPIConfig .builder() - .rootUrl(AUTHORIZE_API) - .apiKey(AUTHORIZE_API_KEY) + .rootUrl(authorizeApi) + .apiKey(authorizeApiKey) .build(), mapper); } diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/PubSubExtensionsFactory.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/PubSubExtensionsFactory.java index 256686206ea33b431d869cbb14b7c41cea009fc9..c0995677c674dc1192b4c9533903454af441cfeb 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/PubSubExtensionsFactory.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/di/PubSubExtensionsFactory.java @@ -1,3 +1,20 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer.di; import org.opengroup.osdu.core.gcp.PubSub.PubSubExtensions; diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/middleware/IndexFilter.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/middleware/IndexFilter.java index 5bdf78f04d24485d4678cb3cb227b42df62dfe62..cd7d4622c847e13f109c6ee89adc8c679b645144 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/middleware/IndexFilter.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/middleware/IndexFilter.java @@ -1,15 +1,31 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer.middleware; import com.google.common.base.Strings; import lombok.extern.java.Log; import org.apache.http.HttpStatus; -import org.opengroup.osdu.core.common.model.http.DpsHeaders; -import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.http.ResponseHeaders; +import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.search.DeploymentEnvironment; import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; -import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpMethod; import org.springframework.stereotype.Component; @@ -35,14 +51,11 @@ public class IndexFilter implements Filter { @Inject private IndexerConfigurationProperties properties; - private FilterConfig filterConfig; - - private static final String PATH_SWAGGER = "/swagger.json"; private static final String PATH_TASK_HANDLERS = "task-handlers"; private static final String PATH_CRON_HANDLERS = "cron-handlers"; @Override - public void init(FilterConfig filterConfig) throws ServletException { + public void init(FilterConfig filterConfig) { } @Override @@ -61,10 +74,6 @@ public class IndexFilter implements Filter { checkWorkerApiAccess(requestInfo); } -// if (!httpRequest.isSecure()) { -// throw new AppException(302, "Redirect", "HTTP is not supported. Use HTTPS."); -// } - filterChain.doFilter(servletRequest, servletResponse); HttpServletResponse httpResponse = (HttpServletResponse) servletResponse; diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/persistence/ElasticRepositoryDatastore.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/persistence/ElasticRepositoryDatastore.java index 0c70475ae974c1fc47f52b926519b4a124ef20dd..7e773c20b9c7f12bec2878c7c3ef4d3d349f8ab1 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/persistence/ElasticRepositoryDatastore.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/persistence/ElasticRepositoryDatastore.java @@ -20,16 +20,16 @@ import com.google.cloud.datastore.Entity; import com.google.cloud.datastore.Key; import lombok.extern.java.Log; import org.apache.http.HttpStatus; +import org.opengroup.osdu.core.common.model.http.AppException; import org.opengroup.osdu.core.common.model.search.ClusterSettings; import org.opengroup.osdu.core.common.model.tenant.TenantInfo; -import org.opengroup.osdu.core.common.model.http.AppException; -import org.opengroup.osdu.core.common.provider.interfaces.IKmsClient; import org.opengroup.osdu.core.common.provider.interfaces.IElasticRepository; +import org.opengroup.osdu.core.common.provider.interfaces.IKmsClient; import org.opengroup.osdu.core.common.search.Preconditions; import org.opengroup.osdu.core.gcp.multitenancy.DatastoreFactory; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; + import javax.inject.Inject; @Log diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/publish/PublisherImpl.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/publish/PublisherImpl.java index 32d2dd6fc394eca3a11a95339cc9eca5599ddb2e..31d242cd46515f9b37907e458b510dd7a37557bd 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/publish/PublisherImpl.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/publish/PublisherImpl.java @@ -26,18 +26,16 @@ import com.google.pubsub.v1.PubsubMessage; import lombok.extern.java.Log; import org.apache.http.HttpStatus; import org.elasticsearch.common.Strings; - -import org.opengroup.osdu.core.common.model.http.DpsHeaders; -import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; -import org.opengroup.osdu.core.common.model.tenant.TenantInfo; import org.opengroup.osdu.core.common.model.http.AppException; +import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.model.indexer.JobStatus; import org.opengroup.osdu.core.common.model.indexer.RecordStatus; +import org.opengroup.osdu.core.common.model.search.DeploymentEnvironment; +import org.opengroup.osdu.core.common.model.tenant.TenantInfo; +import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; +import org.opengroup.osdu.core.gcp.PubSub.PubSubExtensions; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; import org.opengroup.osdu.indexer.provider.interfaces.IPublisher; -import org.opengroup.osdu.core.gcp.PubSub.PubSubExtensions; -import org.opengroup.osdu.core.common.model.search.DeploymentEnvironment; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.context.annotation.RequestScope; import org.threeten.bp.Duration; diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java index c57564a198aae80b5cf4c8316488533467cbbc04..8be38e24bb075a6042ecf6aaafe312d97bb177b1 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/security/GSuiteSecurityConfig.java @@ -1,3 +1,20 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer.security; import org.springframework.context.annotation.Configuration; diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/RequestInfoImpl.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/RequestInfoImpl.java index 03fddbbfa7f3df968506a2c609f2818fe4c10130..dffa1d5e0cb84f93b0d93d103a11738e10ed07a6 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/RequestInfoImpl.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/RequestInfoImpl.java @@ -1,3 +1,20 @@ +/* + Copyright 2020 Google LLC + Copyright 2020 EPAM Systems, Inc + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + package org.opengroup.osdu.indexer.util; import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken; @@ -50,7 +67,7 @@ public class RequestInfoImpl implements IRequestInfo { @Value("${indexer.que.service.mail}") private String indexerQueServiceMail; - private static final String expectedCronHeaderValue = "true"; + private static final String EXPECTED_CRON_HEADER_VALUE = "true"; @Override public DpsHeaders getHeaders() { @@ -83,7 +100,7 @@ public class RequestInfoImpl implements IRequestInfo { @Override public boolean isCronRequest() { String appEngineCronHeader = this.dpsHeaders.getHeaders().getOrDefault(CloudTaskHeaders.CLOUD_CRON_SERVICE, null); - return expectedCronHeaderValue.equalsIgnoreCase(appEngineCronHeader); + return EXPECTED_CRON_HEADER_VALUE.equalsIgnoreCase(appEngineCronHeader); } @Override diff --git a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/ServiceAccountJwtGcpClientImpl.java b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/ServiceAccountJwtGcpClientImpl.java index 6e946ac37ab029c2d0b8b718776bd28da71ad6b1..21af7655f45f1dcc797b5b819c2f10120067a3ba 100644 --- a/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/ServiceAccountJwtGcpClientImpl.java +++ b/provider/indexer-gcp/src/main/java/org/opengroup/osdu/indexer/util/ServiceAccountJwtGcpClientImpl.java @@ -38,16 +38,15 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; -import org.opengroup.osdu.core.common.model.http.DpsHeaders; -import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; -import org.opengroup.osdu.core.common.model.tenant.TenantInfo; +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.DpsHeaders; import org.opengroup.osdu.core.common.model.search.IdToken; -import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.opengroup.osdu.core.common.model.tenant.TenantInfo; import org.opengroup.osdu.core.common.provider.interfaces.IJwtCache; +import org.opengroup.osdu.core.common.provider.interfaces.ITenantFactory; import org.opengroup.osdu.core.common.util.IServiceAccountJwtClient; import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import org.springframework.web.context.annotation.RequestScope; @@ -64,7 +63,7 @@ public class ServiceAccountJwtGcpClientImpl implements IServiceAccountJwtClient private static final String JWT_AUDIENCE = "https://www.googleapis.com/oauth2/v4/token"; private static final String SERVICE_ACCOUNT_NAME_FORMAT = "projects/%s/serviceAccounts/%s"; - private final JsonFactory JSON_FACTORY = new JacksonFactory(); + private final JsonFactory jsonFactory = new JacksonFactory(); private Iam iam; @@ -100,7 +99,7 @@ public class ServiceAccountJwtGcpClientImpl implements IServiceAccountJwtClient Map<String, Object> signJwtPayload = this.getJWTCreationPayload(tenant); SignJwtRequest signJwtRequest = new SignJwtRequest(); - signJwtRequest.setPayload(JSON_FACTORY.toString(signJwtPayload)); + signJwtRequest.setPayload(jsonFactory.toString(signJwtPayload)); String serviceAccountName = String.format(SERVICE_ACCOUNT_NAME_FORMAT, tenant.getProjectId(), tenant.getServiceAccount()); @@ -157,7 +156,7 @@ public class ServiceAccountJwtGcpClientImpl implements IServiceAccountJwtClient } // Create IAM API object associated with the authenticated transport. - this.iam = new Iam.Builder(httpTransport, JSON_FACTORY, credential) + this.iam = new Iam.Builder(httpTransport, jsonFactory, credential) .setApplicationName(properties.getIndexerHost()) .build(); } diff --git a/provider/indexer-gcp/src/test/java/org/opengroup/osdu/indexer/service/IndexerSchemaServiceTest.java b/provider/indexer-gcp/src/test/java/org/opengroup/osdu/indexer/service/IndexerSchemaServiceTest.java index 434e9bc803383e3034c65b4d8ea66fccd60fb25c..f286c07828bcd3af44fc0dad34762f9205b86b8c 100644 --- a/provider/indexer-gcp/src/test/java/org/opengroup/osdu/indexer/service/IndexerSchemaServiceTest.java +++ b/provider/indexer-gcp/src/test/java/org/opengroup/osdu/indexer/service/IndexerSchemaServiceTest.java @@ -229,9 +229,9 @@ public class IndexerSchemaServiceTest { try { this.sut.processSchemaMessages(schemaMessages); } catch (AppException e) { - assertEquals(e.getError().getCode(), RequestStatus.SCHEMA_CONFLICT); - assertEquals(e.getError().getMessage(), "error creating or merging index mapping"); - assertEquals(e.getError().getReason(), reason); + assertEquals(RequestStatus.SCHEMA_CONFLICT, e.getError().getCode()); + assertEquals("error creating or merging index mapping", e.getError().getMessage()); + assertEquals(reason, e.getError().getReason()); } catch (Exception e) { fail("Should not throw this exception " + e.getMessage()); } @@ -262,9 +262,9 @@ public class IndexerSchemaServiceTest { try { this.sut.processSchemaMessages(schemaMessages); } catch (AppException e) { - assertEquals(e.getError().getCode(), HttpStatus.SC_FORBIDDEN); - assertEquals(e.getError().getMessage(), "blah"); - assertEquals(e.getError().getReason(), reason); + assertEquals(HttpStatus.SC_FORBIDDEN, e.getError().getCode()); + assertEquals("blah", e.getError().getMessage()); + assertEquals(reason, e.getError().getReason()); } catch (Exception e) { fail("Should not throw this exception " + e.getMessage()); } @@ -358,9 +358,9 @@ public class IndexerSchemaServiceTest { try { this.sut.syncIndexMappingWithStorageSchema(kind); } catch (AppException e) { - assertEquals(e.getError().getCode(), HttpStatus.SC_CONFLICT); - assertEquals(e.getError().getMessage(), "blah"); - assertEquals(e.getError().getReason(), "Index deletion error"); + assertEquals(HttpStatus.SC_CONFLICT, e.getError().getCode()); + assertEquals("blah", e.getError().getMessage()); + assertEquals("Index deletion error", e.getError().getReason()); } catch (Exception e) { fail("Should not throw this exception " + e.getMessage()); } diff --git a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/RunTest.java b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/RunTest.java new file mode 100644 index 0000000000000000000000000000000000000000..ccf35e02cffb041fdf0582ae87e6891028947543 --- /dev/null +++ b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/RunTest.java @@ -0,0 +1,27 @@ +// Copyright © Amazon Web Services +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.opengroup.osdu.step_definitions.index.cleanup; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; +import org.junit.runner.RunWith; + +@RunWith(Cucumber.class) +@CucumberOptions( + features = "classpath:features/indexcleanup/IndexCleanup.feature", + glue = {"classpath:org.opengroup.osdu.step_definitions/index/cleanup"}, + plugin = {"pretty", "junit:target/cucumber-reports/TEST-indexcleanup.xml"}) +public class RunTest { +} \ No newline at end of file diff --git a/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/Steps.java b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/Steps.java new file mode 100644 index 0000000000000000000000000000000000000000..b69fd683d35214a73fd9c268e6dcb879d95f97c8 --- /dev/null +++ b/testing/indexer-test-aws/src/test/java/org/opengroup/osdu/step_definitions/index/cleanup/Steps.java @@ -0,0 +1,113 @@ +// Copyright © Amazon Web Services +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +package org.opengroup.osdu.step_definitions.index.cleanup; + +import cucumber.api.DataTable; +import cucumber.api.Scenario; +import cucumber.api.java.Before; +import cucumber.api.java.en.Given; +import cucumber.api.java.en.Then; +import cucumber.api.java.en.When; +import java.io.IOException; +import java.util.HashSet; +import java.util.Set; + +import lombok.extern.java.Log; +import org.opengroup.osdu.common.CleanupIndiciesSteps; +import org.opengroup.osdu.core.common.model.legal.Legal; +import org.opengroup.osdu.util.AWSHTTPClient; +import org.opengroup.osdu.util.LegalTagUtilsAws; +import org.opengroup.osdu.util.ElasticUtilsAws; + +import static org.opengroup.osdu.util.Config.getOtherRelevantDataCountries; + +@Log +public class Steps extends CleanupIndiciesSteps { + + protected LegalTagUtilsAws legalTagUtils; + private String legalTagName; + + public Steps() { + super(new AWSHTTPClient(), new ElasticUtilsAws()); + } + + @Before + public void before(Scenario scenario) throws Exception { + this.scenario = scenario; + this.httpClient = new AWSHTTPClient(); + legalTagUtils = new LegalTagUtilsAws(this.httpClient); + this.legalTagName = this.legalTagUtils.createRandomName(); + this.legalTagUtils.create(this.legalTagName); + } + + @Override + public void tearDown() { + super.tearDown(); + this.legalTagUtils.delete(this.legalTagName); + } + + @Override + protected Legal generateLegalTag() { + Legal legal = new Legal(); + Set<String> legalTags = new HashSet<>(); + legalTags.add(this.legalTagName); + legal.setLegaltags(legalTags); + Set<String> otherRelevantCountries = new HashSet<>(); + otherRelevantCountries.add(getOtherRelevantDataCountries()); + legal.setOtherRelevantDataCountries(otherRelevantCountries); + return legal; + } + + @Given("^the schema is created with the following kind$") + public void theSchemaIsCreatedWithTheFollowingKind(DataTable dataTable) { + super.theSchemaIsCreatedWithTheFollowingKind(dataTable); + } + + @When("^I ingest records with the \"(.*?)\" with \"(.*?)\" for a given \"(.*?)\"$") + public void iIngestRecordsWithTheforAGiven(String record, String dataGroup, String kind) { + super.iIngestRecordsWithTheforAGiven(record, dataGroup, kind); + } + + @Then("^I check that the index for \"(.*?)\" has been created$") + public void iCheckThatTheIndexForHasBeenCreated(String kind) throws IOException, InterruptedException { + super.iCheckThatTheIndexForHasBeenCreated(kind); + } + + @Then("^I should delete the records I created earlier$") + public void iShouldDeleteTheRecordsForICreatedEarlier() { + super.iShouldDeleteTheRecordsForICreatedEarlier(); + } + + @Then("^I should delete the schema for \"(.*?)\" I created earlier$") + public void iShouldDeleteTheSchemaForICreatedEarlier(String kind) { + super.iShouldDeleteTheSchemaForICreatedEarlier(kind); + } + + @Then("^I should check that the index for \"(.*?)\" has not been deleted$") + public void iShouldCheckThetTheIndexforHasNotBeenDeleted(String kind) throws IOException, InterruptedException { + super.iShouldCheckThetTheIndexforHasNotBeenDeleted(kind); + } + + @Then("^I should to run cleanup of indexes for \"(.*?)\" and \"(.*?)\"$") + public void iShouldToRunCleanupOfIndexesForAnd(String kind, String message) { + super.iShouldToRunCleanupOfIndexesForAnd(kind, message); + } + + @Then("^I should check that the index for \"(.*?)\" has been deleted$") + public void iShouldCheckThatTheIndexForHasBeenDeleted(String kind) throws IOException, InterruptedException { + super.iShouldCheckThatTheIndexForHasBeenDeleted(kind); + } +} \ No newline at end of file diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/CleanupIndiciesSteps.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/CleanupIndiciesSteps.java index c87daa7ceb00dda7e1b2239f9ea95292de0d0ff9..d479f921326bcb624288ad4548ce18859c53d790 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/CleanupIndiciesSteps.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/common/CleanupIndiciesSteps.java @@ -42,6 +42,7 @@ import org.opengroup.osdu.models.Setup; import org.opengroup.osdu.models.TestIndex; import org.opengroup.osdu.util.FileHandler; import org.opengroup.osdu.util.HTTPClient; +import org.opengroup.osdu.util.ElasticUtils; @Log public class CleanupIndiciesSteps extends TestsBase { @@ -55,6 +56,11 @@ public class CleanupIndiciesSteps extends TestsBase { super(httpClient); } + public CleanupIndiciesSteps(HTTPClient httpClient, ElasticUtils elasticUtils) { + super(httpClient, elasticUtils); + } + + public void theSchemaIsCreatedWithTheFollowingKind(DataTable dataTable) { List<Setup> inputList = dataTable.asList(Setup.class); for (Setup input : inputList) {