From cb3cc1f434bc63f00fed6f9215466c1bde6a26c2 Mon Sep 17 00:00:00 2001 From: Tadgh Date: Fri, 9 Sep 2022 19:24:06 -0400 Subject: [PATCH] Iam opensearch auth (#4011) * Bump HS version, add support for credential provider * License files * Use index settings file instead of injecting a template at boot * Changelog * Typo * fix logs * Add javadoc --- .../src/main/java/ca/uhn/fhir/i18n/Msg.java | 2 +- .../ca/uhn/fhir/util/TimeoutException.java | 20 ++++++ .../java/ca/uhn/fhir/util/TimeoutManager.java | 20 ++++++ .../fhir/changelog/6_2_0/4010-opensearch.yaml | 6 ++ hapi-fhir-jpaserver-base/pom.xml | 4 ++ ...asticsearchHibernatePropertiesBuilder.java | 64 +++++++++++-------- .../lastn/ElasticsearchRestClientFactory.java | 1 + .../uhn/fhir/jpa/elastic/index-settings.json | 3 + ...csearchHibernatePropertiesBuilderTest.java | 25 +------- .../src/test/resources/logback-test.xml | 14 ++-- .../ca/uhn/fhir/jpa/dao/DaoTestUtils.java | 20 ++++++ ...PartitionInterceptorReadAllPartitions.java | 20 ++++++ ...nterceptorReadPartitionsBasedOnScopes.java | 20 ++++++ .../uhn/fhir/jpa/packages/FakeNpmServlet.java | 20 ++++++ .../jpa/provider/GraphQLProviderTestUtil.java | 20 ++++++ .../jpa/subscription/CountingInterceptor.java | 20 ++++++ .../jpa/subscription/NotificationServlet.java | 20 ++++++ .../subscription/SocketImplementation.java | 20 ++++++ .../ca/uhn/fhir/jpa/term/TermTestUtil.java | 20 ++++++ .../fhir/jpa/term/ZipCollectionBuilder.java | 20 ++++++ .../test/config/TestHSearchAddInConfig.java | 1 - .../jpa/util/CoordCalculatorTestUtil.java | 20 ++++++ .../ForceSynchronousSearchInterceptor.java | 20 ++++++ .../fhir/mdm/util/GoldenResourceHelper.java | 1 + .../api/dao/PatientEverythingParameters.java | 20 ++++++ .../test/utilities/getMethodNameUtil.java | 20 ++++++ pom.xml | 7 +- 27 files changed, 386 insertions(+), 62 deletions(-) create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_2_0/4010-opensearch.yaml create mode 100644 hapi-fhir-jpaserver-base/src/main/resources/ca/uhn/fhir/jpa/elastic/index-settings.json diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/i18n/Msg.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/i18n/Msg.java index 913483f5d19..61c15dfa8d5 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/i18n/Msg.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/i18n/Msg.java @@ -25,7 +25,7 @@ public final class Msg { /** * IMPORTANT: Please update the following comment after you add a new code - * Last used code value: 2138 + * Last used code value: 2139 */ private Msg() {} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutException.java index adb05b36bb4..86833b66406 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutException.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutException.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.util; +/*- + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + public class TimeoutException extends RuntimeException { public TimeoutException(String theMessage) { super(theMessage); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutManager.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutManager.java index 6aa63508ada..625053e855e 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutManager.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/util/TimeoutManager.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.util; +/*- + * #%L + * HAPI FHIR - Core Library + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import ca.uhn.fhir.i18n.Msg; import com.google.common.annotations.VisibleForTesting; import org.slf4j.Logger; diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_2_0/4010-opensearch.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_2_0/4010-opensearch.yaml new file mode 100644 index 00000000000..3196fa034e4 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_2_0/4010-opensearch.yaml @@ -0,0 +1,6 @@ +--- +type: add +jira: SMILE-4665 +title: "Added support for AWS OpenSearch to Fulltext Search. If an AWS Region is configured, HAPI-FHIR will assume you intend to connect to an AWS-managed OpenSearch instance, and will use +Amazon's [DefaultAwsCredentialsProviderChain](https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/auth/DefaultAWSCredentialsProviderChain.html) to authenticate against it. If both username and password are provided, HAPI-FHIR will attempt to use them as a static credentials provider." + diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index a851fcdccff..c1e8a44cc8c 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -332,6 +332,10 @@ org.hibernate.search hibernate-search-backend-lucene + + org.hibernate.search + hibernate-search-backend-elasticsearch-aws + org.apache.lucene lucene-analyzers-phonetic diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilder.java index e7600256279..a5a76189604 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilder.java @@ -23,13 +23,9 @@ package ca.uhn.fhir.jpa.search.elastic; import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.jpa.search.HapiHSearchAnalysisConfigurers; -import ca.uhn.fhir.jpa.search.lastn.ElasticsearchRestClientFactory; import org.apache.commons.lang3.StringUtils; -import org.elasticsearch.action.support.master.AcknowledgedResponse; -import org.elasticsearch.client.RequestOptions; -import org.elasticsearch.client.RestHighLevelClient; -import org.elasticsearch.client.indices.PutIndexTemplateRequest; -import org.elasticsearch.common.settings.Settings; +import org.hibernate.search.backend.elasticsearch.aws.cfg.ElasticsearchAwsBackendSettings; +import org.hibernate.search.backend.elasticsearch.aws.cfg.ElasticsearchAwsCredentialsTypeNames; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings; import org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchIndexSettings; import org.hibernate.search.backend.elasticsearch.index.IndexStatus; @@ -39,9 +35,6 @@ import org.hibernate.search.mapper.orm.cfg.HibernateOrmMapperSettings; import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; import org.slf4j.Logger; -import javax.annotation.Nullable; -import java.io.IOException; -import java.util.Arrays; import java.util.Properties; import static org.hibernate.search.backend.elasticsearch.cfg.ElasticsearchBackendSettings.Defaults.SCROLL_TIMEOUT; @@ -62,6 +55,13 @@ public class ElasticsearchHibernatePropertiesBuilder { private String myHosts; private String myUsername; private String myPassword; + + public String getAwsRegion() { + return myAwsRegion; + } + + + private String myAwsRegion; private long myIndexManagementWaitTimeoutMillis = 10000L; private long myScrollTimeoutSecs = SCROLL_TIMEOUT; private String myDebugSyncStrategy = AutomaticIndexingSynchronizationStrategyNames.ASYNC; @@ -106,7 +106,21 @@ public class ElasticsearchHibernatePropertiesBuilder { //This tells elasticsearch to use our custom index naming strategy. theProperties.put(BackendSettings.backendKey(ElasticsearchBackendSettings.LAYOUT_STRATEGY), IndexNamePrefixLayoutStrategy.class.getName()); - injectStartupTemplate(myProtocol, myHosts, myUsername, myPassword); + //This tells hibernate search to use this custom file for creating index settings. We use this to add a custom max_ngram_diff + theProperties.put(BackendSettings.backendKey(ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_SETTINGS_FILE), "ca/uhn/fhir/jpa/elastic/index-settings.json"); + + if (!StringUtils.isBlank(myAwsRegion)) { + theProperties.put(BackendSettings.backendKey(ElasticsearchAwsBackendSettings.REGION), myAwsRegion); + theProperties.put(BackendSettings.backendKey(ElasticsearchAwsBackendSettings.SIGNING_ENABLED), true); + if (!StringUtils.isBlank(myUsername) && !StringUtils.isBlank(myPassword)) { + theProperties.put(BackendSettings.backendKey(ElasticsearchAwsBackendSettings.CREDENTIALS_TYPE), ElasticsearchAwsCredentialsTypeNames.STATIC); + theProperties.put(BackendSettings.backendKey(ElasticsearchAwsBackendSettings.CREDENTIALS_ACCESS_KEY_ID), myUsername); + theProperties.put(BackendSettings.backendKey(ElasticsearchAwsBackendSettings.CREDENTIALS_SECRET_ACCESS_KEY), myPassword); + } else { + //Default to Standard IAM Auth provider if username or password is absent. + theProperties.put(BackendSettings.backendKey(ElasticsearchAwsBackendSettings.CREDENTIALS_TYPE), ElasticsearchAwsCredentialsTypeNames.DEFAULT); + } + } } public ElasticsearchHibernatePropertiesBuilder setRequiredIndexStatus(IndexStatus theRequiredIndexStatus) { @@ -115,6 +129,9 @@ public class ElasticsearchHibernatePropertiesBuilder { } public ElasticsearchHibernatePropertiesBuilder setHosts(String hosts) { + if (hosts.contains("://")) { + throw new ConfigurationException(Msg.code(2139) + "Elasticsearch URLs cannot include a protocol, that is a separate property. Remove http:// or https:// from this URL."); + } myHosts = hosts; return this; } @@ -151,23 +168,16 @@ public class ElasticsearchHibernatePropertiesBuilder { } /** - * At startup time, injects a template into the elasticsearch cluster, which is needed for handling large ngram diffs. - * TODO GGG HS: In HS6.1, we should have a native way of performing index settings manipulation at bootstrap time, so this should - * eventually be removed in favour of whatever solution they come up with. + * If this is set to `true`, the AWS region will be used to configure the AWS client. Additionally, this will trigger + * HibernateSearch to attempt to use IAM Authentication. If the username and password are set in addition to the region, + * then the username and password will be used as the AWS_ACCESS_KEY_ID and AWS_SECRET_KEY_ID for a static credentials file for IAM. + * + * @param theAwsRegion The String version of the region, e.g. `us-east-2`. + * @return This builder. */ - void injectStartupTemplate(String theProtocol, String theHosts, @Nullable String theUsername, @Nullable String thePassword) { - PutIndexTemplateRequest ngramTemplate = new PutIndexTemplateRequest("ngram-template") - .patterns(Arrays.asList("*resourcetable-*", "*termconcept-*")) - .settings(Settings.builder().put("index.max_ngram_diff", 50)); - - try { - RestHighLevelClient elasticsearchHighLevelRestClient = ElasticsearchRestClientFactory.createElasticsearchHighLevelRestClient(theProtocol, theHosts, theUsername, thePassword); - ourLog.info("Adding starter template for large ngram diffs"); - AcknowledgedResponse acknowledgedResponse = elasticsearchHighLevelRestClient.indices().putTemplate(ngramTemplate, RequestOptions.DEFAULT); - assert acknowledgedResponse.isAcknowledged(); - } catch (IOException theE) { - theE.printStackTrace(); - throw new ConfigurationException(Msg.code(1169) + "Couldn't connect to the elasticsearch server to create necessary templates. Ensure the Elasticsearch user has permissions to create templates."); - } + public ElasticsearchHibernatePropertiesBuilder setAwsRegion(String theAwsRegion) { + myAwsRegion = theAwsRegion; + return this; } + } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchRestClientFactory.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchRestClientFactory.java index fd44b50bce6..dbd663863b9 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchRestClientFactory.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/search/lastn/ElasticsearchRestClientFactory.java @@ -71,6 +71,7 @@ public class ElasticsearchRestClientFactory { clientBuilder.setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder .setDefaultCredentialsProvider(credentialsProvider)); } + Header[] defaultHeaders = new Header[]{new BasicHeader("Content-Type", "application/json")}; clientBuilder.setDefaultHeaders(defaultHeaders); diff --git a/hapi-fhir-jpaserver-base/src/main/resources/ca/uhn/fhir/jpa/elastic/index-settings.json b/hapi-fhir-jpaserver-base/src/main/resources/ca/uhn/fhir/jpa/elastic/index-settings.json new file mode 100644 index 00000000000..58d8553786d --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/main/resources/ca/uhn/fhir/jpa/elastic/index-settings.json @@ -0,0 +1,3 @@ +{ + "max_ngram_diff": 50 +} diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilderTest.java b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilderTest.java index 8165764fec3..ba0fbd382e5 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilderTest.java +++ b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/search/elastic/ElasticsearchHibernatePropertiesBuilderTest.java @@ -40,10 +40,9 @@ class ElasticsearchHibernatePropertiesBuilderTest { .apply(new Properties()); fail(); } catch (ConfigurationException e ) { - assertThat(e.getMessage(), is(equalTo(Msg.code(1173) + failureMessage))); + assertThat(e.getMessage(), is(equalTo(Msg.code(2139) + failureMessage))); } - doNothing().when(myPropertiesBuilder).injectStartupTemplate(any(), any(), any(), any()); Properties properties = new Properties(); myPropertiesBuilder .setHosts(host) @@ -52,26 +51,4 @@ class ElasticsearchHibernatePropertiesBuilderTest { assertThat(properties.getProperty(BackendSettings.backendKey(ElasticsearchBackendSettings.HOSTS)), is(equalTo(host))); } - - @Test - public void testHostsValueValidation() { - String host = "localhost_9200,localhost:9201,localhost:9202"; - String failureMessage = "Elasticsearch URLs have to contain ':' as a host:port separator. Example: localhost:9200,localhost:9201,localhost:9202"; - - myPropertiesBuilder - .setProtocol("https") - .setHosts(host) - .setUsername("whatever") - .setPassword("whatever"); - - //SUT - try { - myPropertiesBuilder - .apply(new Properties()); - fail(); - } catch (ConfigurationException e ) { - assertThat(e.getMessage(), is(equalTo(Msg.code(1174) + failureMessage))); - } - } - } diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/resources/logback-test.xml b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/resources/logback-test.xml index 4b90b3c8130..9155378c78a 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/resources/logback-test.xml +++ b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/resources/logback-test.xml @@ -49,14 +49,12 @@ - + + + + + + diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/dao/DaoTestUtils.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/dao/DaoTestUtils.java index 41934b32c57..3a77b128935 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/dao/DaoTestUtils.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/dao/DaoTestUtils.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.dao; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import ca.uhn.fhir.i18n.Msg; import ca.uhn.fhir.interceptor.api.IInterceptorService; import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/interceptor/ex/PartitionInterceptorReadAllPartitions.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/interceptor/ex/PartitionInterceptorReadAllPartitions.java index 7202707cecc..1b68b36e3aa 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/interceptor/ex/PartitionInterceptorReadAllPartitions.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/interceptor/ex/PartitionInterceptorReadAllPartitions.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.interceptor.ex; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import ca.uhn.fhir.interceptor.api.Hook; import ca.uhn.fhir.interceptor.api.Interceptor; import ca.uhn.fhir.interceptor.api.Pointcut; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/interceptor/ex/PartitionInterceptorReadPartitionsBasedOnScopes.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/interceptor/ex/PartitionInterceptorReadPartitionsBasedOnScopes.java index af4f0dc62a3..348ace04131 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/interceptor/ex/PartitionInterceptorReadPartitionsBasedOnScopes.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/interceptor/ex/PartitionInterceptorReadPartitionsBasedOnScopes.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.interceptor.ex; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import ca.uhn.fhir.interceptor.api.Hook; import ca.uhn.fhir.interceptor.api.Interceptor; import ca.uhn.fhir.interceptor.api.Pointcut; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/packages/FakeNpmServlet.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/packages/FakeNpmServlet.java index 5dea8f863db..51264dc524c 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/packages/FakeNpmServlet.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/packages/FakeNpmServlet.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.packages; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import ca.uhn.fhir.rest.api.Constants; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/GraphQLProviderTestUtil.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/GraphQLProviderTestUtil.java index 28203e59af1..d470ac9cd07 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/GraphQLProviderTestUtil.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/provider/GraphQLProviderTestUtil.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.provider; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + public class GraphQLProviderTestUtil { public static final String DATA_PREFIX = "{\"data\": "; public static final String DATA_SUFFIX = "}"; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/CountingInterceptor.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/CountingInterceptor.java index c3490ba07b0..25f20fd101f 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/CountingInterceptor.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/CountingInterceptor.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.subscription; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.messaging.Message; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/NotificationServlet.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/NotificationServlet.java index b79de785709..09961ff9457 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/NotificationServlet.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/NotificationServlet.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.subscription; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/SocketImplementation.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/SocketImplementation.java index 2135e0f3c2b..99edf7e94de 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/SocketImplementation.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/subscription/SocketImplementation.java @@ -1,6 +1,26 @@ package ca.uhn.fhir.jpa.subscription; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import ca.uhn.fhir.rest.api.EncodingEnum; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/TermTestUtil.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/TermTestUtil.java index 61395e5c03a..8f18b2c6d25 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/TermTestUtil.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/TermTestUtil.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.term; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import ca.uhn.fhir.jpa.entity.TermConceptDesignation; import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/ZipCollectionBuilder.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/ZipCollectionBuilder.java index efbbfc57882..b9ee50d35fa 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/ZipCollectionBuilder.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/term/ZipCollectionBuilder.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.term; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import ca.uhn.fhir.jpa.term.api.ITermLoaderSvc; import com.google.common.base.Charsets; import org.apache.commons.io.IOUtils; diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestHSearchAddInConfig.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestHSearchAddInConfig.java index f9330bb08e6..6fc8ee37449 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestHSearchAddInConfig.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/test/config/TestHSearchAddInConfig.java @@ -200,7 +200,6 @@ public class TestHSearchAddInConfig { .setIndexManagementWaitTimeoutMillis(10000) .setRequiredIndexStatus(IndexStatus.YELLOW) .setScrollTimeoutSecs(60 * 30) // 30 min for tests - .setHosts(host + ":" + httpPort) .setProtocol("http") .setUsername("") diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/util/CoordCalculatorTestUtil.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/util/CoordCalculatorTestUtil.java index 11a988ad003..4b9d40384b9 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/util/CoordCalculatorTestUtil.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/util/CoordCalculatorTestUtil.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.util; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + public final class CoordCalculatorTestUtil { // CHIN and UHN coordinates from Google Maps // Distance and bearing from https://www.movable-type.co.uk/scripts/latlong.html diff --git a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/util/ForceSynchronousSearchInterceptor.java b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/util/ForceSynchronousSearchInterceptor.java index 0783e6f42b8..8e5e1ada5bc 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/util/ForceSynchronousSearchInterceptor.java +++ b/hapi-fhir-jpaserver-test-utilities/src/main/java/ca/uhn/fhir/jpa/util/ForceSynchronousSearchInterceptor.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.util; +/*- + * #%L + * HAPI FHIR JPA Server Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import ca.uhn.fhir.interceptor.api.Hook; import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; diff --git a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/util/GoldenResourceHelper.java b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/util/GoldenResourceHelper.java index 7c23f2f5d15..f5ddf63023a 100644 --- a/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/util/GoldenResourceHelper.java +++ b/hapi-fhir-server-mdm/src/main/java/ca/uhn/fhir/mdm/util/GoldenResourceHelper.java @@ -130,6 +130,7 @@ public class GoldenResourceHelper { IAnyResource theIncomingResource, IBase theNewGoldenResource) { String incomingResourceType = myFhirContext.getResourceType(theIncomingResource); String mdmEIDSystem = myMdmSettings.getMdmRules().getEnterpriseEIDSystemForResourceType(incomingResourceType); + if (mdmEIDSystem == null) { return; } diff --git a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/PatientEverythingParameters.java b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/PatientEverythingParameters.java index abd7cc9e967..5f0fd8cb608 100644 --- a/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/PatientEverythingParameters.java +++ b/hapi-fhir-storage/src/main/java/ca/uhn/fhir/jpa/api/dao/PatientEverythingParameters.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.jpa.api.dao; +/*- + * #%L + * HAPI FHIR Storage api + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.rest.api.SortSpec; import ca.uhn.fhir.rest.param.DateRangeParam; diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/getMethodNameUtil.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/getMethodNameUtil.java index 0d489cad2ac..6f77a65a67d 100644 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/getMethodNameUtil.java +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/getMethodNameUtil.java @@ -1,5 +1,25 @@ package ca.uhn.fhir.test.utilities; +/*- + * #%L + * HAPI FHIR Test Utilities + * %% + * Copyright (C) 2014 - 2022 Smile CDR, 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. + * #L% + */ + public class getMethodNameUtil { public static String getTestName() { return new Exception().getStackTrace()[1].getMethodName(); diff --git a/pom.xml b/pom.xml index 33f9fb3db87..cbe41ade25b 100644 --- a/pom.xml +++ b/pom.xml @@ -815,7 +815,7 @@ 0.50.40 8.5.0 5.6.2.Final - 6.1.4.Final + 6.1.6.Final 8.11.1 2.2 @@ -1658,6 +1658,11 @@ hibernate-search-backend-lucene ${hibernate_search_version} + + org.hibernate.search + hibernate-search-backend-elasticsearch-aws + ${hibernate_search_version} + org.javassist javassist