-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#414: remove deprecated fhir classes, fix Spring Boot Autoconfig, add…
… HttpClient5-based RestClientFactory. Disabled one async test (TestIti56)
- Loading branch information
Christian Ohr
committed
Mar 7, 2024
1 parent
fe093f4
commit 84fea44
Showing
70 changed files
with
853 additions
and
791 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
boot/ipf-atna-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.openehealth.ipf.boot.atna.IpfAtnaAutoConfiguration | ||
org.openehealth.ipf.boot.atna.IpfAtnaSpringSecurityAutoConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
boot/ipf-fhir-r4-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.openehealth.ipf.boot.fhir.IpfFhirAutoConfiguration | ||
org.openehealth.ipf.boot.fhir.IpfFhirPixpdqAutoConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
boot/ipf-fhir-stu3-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.openehealth.ipf.boot.fhir.IpfFhirAutoConfiguration | ||
org.openehealth.ipf.boot.fhir.IpfFhirPixpdqAutoConfiguration |
1 change: 0 additions & 1 deletion
1
boot/ipf-hl7-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.openehealth.ipf.boot.hl7v2.IpfHl7v2AutoConfiguration |
1 change: 0 additions & 1 deletion
1
boot/ipf-hl7v3-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.openehealth.ipf.boot.hl7v3.IpfHl7v3AutoConfiguration |
1 change: 0 additions & 1 deletion
1
boot/ipf-hpd-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.openehealth.ipf.boot.hpd.IpfHpdAutoConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
boot/ipf-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.openehealth.ipf.boot.IpfAutoConfiguration |
1 change: 0 additions & 1 deletion
1
boot/ipf-xacml20-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.openehealth.ipf.boot.xacml20.IpfXacml20AutoConfiguration |
1 change: 0 additions & 1 deletion
1
boot/ipf-xds-spring-boot-starter/src/main/resources/META-INF/spring.factories
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
...esources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
org.openehealth.ipf.boot.xds.IpfXdsAutoConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...s/ihe/fhir/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/ApacheHttpClient5.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* 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.openehealth.ipf.commons.ihe.fhir; | ||
|
||
import ca.uhn.fhir.rest.api.RequestTypeEnum; | ||
import ca.uhn.fhir.rest.client.apache.BaseHttpClient; | ||
import ca.uhn.fhir.rest.client.api.Header; | ||
import ca.uhn.fhir.rest.client.api.IHttpClient; | ||
import ca.uhn.fhir.rest.client.api.IHttpRequest; | ||
import org.apache.hc.client5.http.entity.UrlEncodedFormEntity; | ||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; | ||
import org.apache.hc.core5.http.HttpEntity; | ||
import org.apache.hc.core5.http.NameValuePair; | ||
import org.apache.hc.core5.http.io.entity.ByteArrayEntity; | ||
import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; | ||
import org.apache.hc.core5.http.message.BasicNameValuePair; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class ApacheHttpClient5 extends BaseHttpClient implements IHttpClient { | ||
|
||
private final CloseableHttpClient client; | ||
|
||
public ApacheHttpClient5(CloseableHttpClient client, | ||
StringBuilder url, | ||
Map<String, List<String>> ifNoneExistParams, | ||
String ifNoneExistString, | ||
RequestTypeEnum requestType, | ||
List<Header> theHeaders) { | ||
super(url, ifNoneExistParams, ifNoneExistString, requestType, theHeaders); | ||
this.client = client; | ||
} | ||
|
||
@Override | ||
protected IHttpRequest createHttpRequest() { | ||
return createHttpRequest((HttpEntity) null); | ||
} | ||
|
||
@Override | ||
protected IHttpRequest createHttpRequest(byte[] content) { | ||
return createHttpRequest(new ByteArrayEntity(content, null)); | ||
} | ||
|
||
@Override | ||
protected IHttpRequest createHttpRequest(Map<String, List<String>> params) { | ||
List<NameValuePair> parameters = new ArrayList<>(); | ||
params.forEach((key, value) -> value.stream() | ||
.map(s -> new BasicNameValuePair(key, s)) | ||
.forEach(parameters::add)); | ||
UrlEncodedFormEntity entity = createFormEntity(parameters); | ||
return createHttpRequest(entity); | ||
} | ||
|
||
private UrlEncodedFormEntity createFormEntity(List<NameValuePair> parameters) { | ||
return new UrlEncodedFormEntity(parameters, StandardCharsets.UTF_8); | ||
} | ||
|
||
@Override | ||
protected IHttpRequest createHttpRequest(String content) { | ||
return createHttpRequest(content.getBytes(StandardCharsets.UTF_8)); | ||
} | ||
|
||
private ApacheHttpRequest5 createHttpRequest(HttpEntity entity) { | ||
return new ApacheHttpRequest5(client, constructRequest(entity).build()); | ||
} | ||
|
||
private ClassicRequestBuilder constructRequest(HttpEntity entity) { | ||
String url = myUrl.toString(); | ||
return switch (myRequestType) { | ||
case DELETE -> ClassicRequestBuilder.delete(url); | ||
case PATCH -> ClassicRequestBuilder.patch(url).setEntity(entity); | ||
case OPTIONS -> ClassicRequestBuilder.options(url); | ||
case POST -> ClassicRequestBuilder.post(url).setEntity(entity); | ||
case PUT -> ClassicRequestBuilder.put(url).setEntity(entity); | ||
default -> ClassicRequestBuilder.get(url); | ||
}; | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
.../ihe/fhir/core/src/main/java/org/openehealth/ipf/commons/ihe/fhir/ApacheHttpRequest5.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* 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.openehealth.ipf.commons.ihe.fhir; | ||
|
||
import ca.uhn.fhir.rest.client.api.BaseHttpRequest; | ||
import ca.uhn.fhir.rest.client.api.IHttpRequest; | ||
import ca.uhn.fhir.rest.client.api.IHttpResponse; | ||
import ca.uhn.fhir.util.StopWatch; | ||
import org.apache.commons.io.IOUtils; | ||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; | ||
import org.apache.hc.client5.http.routing.RoutingSupport; | ||
import org.apache.hc.core5.http.ClassicHttpRequest; | ||
import org.apache.hc.core5.http.ClassicHttpResponse; | ||
import org.apache.hc.core5.http.ContentType; | ||
import org.apache.hc.core5.http.HttpException; | ||
|
||
import java.io.IOException; | ||
import java.net.URI; | ||
import java.util.*; | ||
|
||
public class ApacheHttpRequest5 extends BaseHttpRequest implements IHttpRequest { | ||
|
||
private final ClassicHttpRequest request; | ||
private final CloseableHttpClient httpClient; | ||
|
||
public ApacheHttpRequest5(CloseableHttpClient httpClient, ClassicHttpRequest request) { | ||
this.request = request; | ||
this.httpClient = httpClient; | ||
} | ||
|
||
@Override | ||
public void addHeader(String name, String value) { | ||
request.addHeader(name, value); | ||
} | ||
|
||
@Override | ||
public IHttpResponse execute() throws IOException { | ||
var responseStopWatch = new StopWatch(); | ||
try { | ||
// BaseClient will close the response stream for us | ||
ClassicHttpResponse response = httpClient.executeOpen(RoutingSupport.determineHost(request), request, null); | ||
return new ApacheHttpResponse5(response, responseStopWatch); | ||
} catch (HttpException e) { | ||
throw new IOException(e); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public Map<String, List<String>> getAllHeaders() { | ||
Map<String, List<String>> result = new HashMap<>(); | ||
for (var header : request.getHeaders()) { | ||
if (!result.containsKey(header.getName())) { | ||
result.put(header.getName(), new LinkedList<>()); | ||
} | ||
result.get(header.getName()).add(header.getValue()); | ||
} | ||
return Collections.unmodifiableMap(result); | ||
} | ||
|
||
@Override | ||
public String getRequestBodyFromStream() throws IOException { | ||
var entity = request.getEntity(); | ||
if (entity.isRepeatable()) { | ||
final var contentTypeHeader = request.getFirstHeader("Content-Type"); | ||
var charset = contentTypeHeader == null | ||
? null | ||
: ContentType.parse(contentTypeHeader.getValue()).getCharset(); | ||
return IOUtils.toString(entity.getContent(), charset); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public String getUri() { | ||
return request.getRequestUri(); | ||
} | ||
|
||
@Override | ||
public void setUri(String uri) { | ||
request.setUri(URI.create(uri)); | ||
} | ||
|
||
@Override | ||
public String getHttpVerbName() { | ||
return request.getMethod(); | ||
} | ||
|
||
@Override | ||
public void removeHeaders(String name) { | ||
request.removeHeaders(name); | ||
} | ||
} |
Oops, something went wrong.