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()); }