Skip to content

Commit

Permalink
Bump RestEasy to 5.0.2 (#3329)
Browse files Browse the repository at this point in the history
* Bump deps

* Test fix

* Add test logging

* Add test logging

* Add logging
  • Loading branch information
jamesagnew committed Jan 25, 2022
1 parent a11d72b commit 31bb1d9
Show file tree
Hide file tree
Showing 20 changed files with 407 additions and 304 deletions.
5 changes: 0 additions & 5 deletions hapi-fhir-client-okhttp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<li>Jetty Server (CLI): 9.4.43.v20210629 -> 9.4.44.v20210927</li>
<li>Spring Boot (Boot): 2.5.0 -> 2.6.2</li>
<li>Swagger UI (OpenAPI): 3.46.0 -> 4.1.3</li>
<li>Resteasy (JAX-RS): 4.0.0.Beta3 -> 5.0.2.Final</li>
</ul>
"

17 changes: 6 additions & 11 deletions hapi-fhir-jaxrsserver-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,6 @@
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>ejb-api</artifactId>
Expand All @@ -87,6 +82,11 @@
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.ws.rs</groupId>
<artifactId>jboss-jaxrs-api_2.1_spec</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.annotation</groupId>
Expand Down Expand Up @@ -122,11 +122,6 @@
</dependency>


<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
Expand Down Expand Up @@ -162,7 +157,7 @@
<scope>test</scope>
</dependency>

</dependencies>
</dependencies>

<reporting>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,31 @@
* #L%
*/

import java.util.List;
import java.util.Map;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.client.api.Header;
import ca.uhn.fhir.rest.client.api.HttpClientUtil;
import ca.uhn.fhir.rest.client.api.IHttpClient;
import ca.uhn.fhir.rest.client.api.IHttpRequest;
import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.client.method.MethodUtil;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.core.*;

import javax.ws.rs.core.Form;
import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import org.hl7.fhir.instance.model.api.IBaseBinary;

import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.*;
import ca.uhn.fhir.rest.client.api.*;
import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation;
import ca.uhn.fhir.rest.client.method.MethodUtil;
import ca.uhn.fhir.rest.server.RestfulServerUtils;
import java.util.List;
import java.util.Map;

/**
* A Http Request based on JaxRs. This is an adapter around the class
* {@link javax.ws.rs.client.Client Client}
*
*
* @author Peter Van Houte | peter.vanhoute@agfa.com | Agfa Healthcare
*/
public class JaxRsHttpClient implements IHttpClient {
Expand All @@ -52,8 +56,8 @@ public class JaxRsHttpClient implements IHttpClient {
private String myIfNoneExistString;
private RequestTypeEnum myRequestType;

public JaxRsHttpClient(Client theClient, StringBuilder theUrl, Map<String, List<String>> theIfNoneExistParams, String theIfNoneExistString,
RequestTypeEnum theRequestType, List<Header> theHeaders) {
public JaxRsHttpClient(Client theClient, StringBuilder theUrl, Map<String, List<String>> theIfNoneExistParams, String theIfNoneExistString,
RequestTypeEnum theRequestType, List<Header> theHeaders) {
this.myClient = theClient;
this.myUrl = theUrl;
this.myIfNoneExistParams = theIfNoneExistParams;
Expand Down Expand Up @@ -82,7 +86,7 @@ public IHttpRequest createParamRequest(FhirContext theContext, Map<String, List<
}
Entity<Form> entity = Entity.form(map);
JaxRsHttpRequest retVal = createHttpRequest(entity);
addHeadersToRequest(retVal, theEncoding, theContext);
addHeadersToRequest(retVal, theEncoding, theContext);
return retVal;
}

Expand Down Expand Up @@ -110,13 +114,13 @@ public void addHeadersToRequest(JaxRsHttpRequest theHttpRequest, EncodingEnum th

theHttpRequest.addHeader("User-Agent", HttpClientUtil.createUserAgentString(theContext, "jax-rs"));
theHttpRequest.addHeader("Accept-Charset", "utf-8");

Builder request = theHttpRequest.getRequest();
request.acceptEncoding("gzip");

MethodUtil.addAcceptHeaderToRequest(theEncoding, theHttpRequest, theContext);
}

private JaxRsHttpRequest createHttpRequest(Entity<?> entity) {
Builder request = myClient.target(myUrl.toString()).request();
JaxRsHttpRequest result = new JaxRsHttpRequest(request, myRequestType, entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import javax.interceptor.Interceptors;
import javax.ws.rs.*;

import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,54 +20,77 @@
* #L%
*/

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

import javax.annotation.PostConstruct;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.context.RuntimeResourceDefinition;
import ca.uhn.fhir.jaxrs.server.util.JaxRsRequest.Builder;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.api.RestOperationTypeEnum;
import ca.uhn.fhir.rest.api.SummaryEnum;
import ca.uhn.fhir.rest.api.server.IRestfulResponse;
import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.ResourceBinding;
import ca.uhn.fhir.rest.server.RestfulServerConfiguration;
import ca.uhn.fhir.rest.server.method.BaseMethodBinding;
import ca.uhn.fhir.rest.server.provider.ServerCapabilityStatementProvider;
import ca.uhn.fhir.util.ReflectionUtil;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.dstu2.hapi.rest.server.ServerConformanceProvider;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.r4.model.CapabilityStatement;
import org.slf4j.LoggerFactory;

import ca.uhn.fhir.context.*;
import ca.uhn.fhir.jaxrs.server.util.JaxRsRequest.Builder;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.api.*;
import ca.uhn.fhir.rest.api.server.IRestfulResponse;
import ca.uhn.fhir.rest.server.*;
import ca.uhn.fhir.rest.server.method.BaseMethodBinding;
import ca.uhn.fhir.util.ReflectionUtil;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.ws.rs.GET;
import javax.ws.rs.OPTIONS;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
* This is the conformance provider for the jax rs servers. It requires all providers to be registered during startup because the conformance profile is generated during the postconstruct phase.
*
*
* @author Peter Van Houte | peter.vanhoute@agfa.com | Agfa Healthcare
*/
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProvider implements IResourceProvider {

/** the logger */
/**
* the logger
*/
private static final org.slf4j.Logger ourLog = LoggerFactory.getLogger(AbstractJaxRsConformanceProvider.class);
/** the server bindings */
/**
* the server bindings
*/
private ResourceBinding myServerBinding = new ResourceBinding();
/** the resource bindings */
/**
* the resource bindings
*/
private ConcurrentHashMap<String, ResourceBinding> myResourceNameToBinding = new ConcurrentHashMap<String, ResourceBinding>();
/** the server configuration */
/**
* the server configuration
*/
private RestfulServerConfiguration serverConfiguration = new RestfulServerConfiguration();

/** the conformance. It is created once during startup */
/**
* the conformance. It is created once during startup
*/
private org.hl7.fhir.r4.model.CapabilityStatement myR4CapabilityStatement;
private org.hl7.fhir.dstu3.model.CapabilityStatement myDstu3CapabilityStatement;
private org.hl7.fhir.dstu2016may.model.Conformance myDstu2_1Conformance;
Expand All @@ -77,13 +100,10 @@ public abstract class AbstractJaxRsConformanceProvider extends AbstractJaxRsProv

/**
* Constructor allowing the description, servername and server to be set
*
* @param implementationDescription
* the implementation description. If null, "" is used
* @param serverName
* the server name. If null, "" is used
* @param serverVersion
* the server version. If null, "" is used
*
* @param implementationDescription the implementation description. If null, "" is used
* @param serverName the server name. If null, "" is used
* @param serverVersion the server version. If null, "" is used
*/
protected AbstractJaxRsConformanceProvider(String implementationDescription, String serverName, String serverVersion) {
serverConfiguration.setFhirContext(getFhirContext());
Expand All @@ -94,15 +114,11 @@ protected AbstractJaxRsConformanceProvider(String implementationDescription, Str

/**
* Constructor allowing the description, servername and server to be set
*
* @param ctx
* the {@link FhirContext} instance.
* @param implementationDescription
* the implementation description. If null, "" is used
* @param serverName
* the server name. If null, "" is used
* @param serverVersion
* the server version. If null, "" is used
*
* @param ctx the {@link FhirContext} instance.
* @param implementationDescription the implementation description. If null, "" is used
* @param serverName the server name. If null, "" is used
* @param serverVersion the server version. If null, "" is used
*/
protected AbstractJaxRsConformanceProvider(FhirContext ctx, String implementationDescription, String serverName, String serverVersion) {
super(ctx);
Expand Down Expand Up @@ -167,15 +183,15 @@ protected synchronized void setUpPostConstruct() {

/**
* This method must return all the resource providers which need to be included in the conformance
*
*
* @return a map of the resource providers and their corresponding classes. This class needs to be given explicitly because retrieving the interface using {@link Object#getClass()} may not give the
* correct interface in a jee environment.
* correct interface in a jee environment.
*/
protected abstract ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider> getProviders();

/**
* This method will retrieve the conformance using the http OPTIONS method
*
*
* @return the response containing the conformance
*/
@OPTIONS
Expand All @@ -186,7 +202,7 @@ public Response conformanceUsingOptions() throws IOException {

/**
* This method will retrieve the conformance using the http GET method
*
*
* @return the response containing the conformance
*/
@GET
Expand All @@ -197,7 +213,7 @@ public Response conformance() throws IOException {
Builder request = getRequest(RequestTypeEnum.OPTIONS, RestOperationTypeEnum.METADATA);
IRestfulResponse response = request.build().getResponse();
response.addHeader(Constants.HEADER_CORS_ALLOW_ORIGIN, "*");

IBaseResource conformance;
FhirVersionEnum fhirContextVersion = super.getFhirContext().getVersion().getVersion();
switch (fhirContextVersion) {
Expand All @@ -219,7 +235,7 @@ public Response conformance() throws IOException {
default:
throw new ConfigurationException("Unsupported Fhir version: " + fhirContextVersion);
}

if (conformance != null) {
Set<SummaryEnum> summaryMode = Collections.emptySet();
return (Response) response.streamResponseAsResource(conformance, false, summaryMode, Constants.STATUS_HTTP_200_OK, null, true, false);
Expand All @@ -229,11 +245,9 @@ public Response conformance() throws IOException {

/**
* This method will add a provider to the conformance. This method is almost an exact copy of {@link ca.uhn.fhir.rest.server.RestfulServer#findResourceMethods(Object)}
*
* @param theProvider
* an instance of the provider interface
* @param theProviderInterface
* the class describing the providers interface
*
* @param theProvider an instance of the provider interface
* @param theProviderInterface the class describing the providers interface
* @return the numbers of basemethodbindings added
* @see ca.uhn.fhir.rest.server.RestfulServer#findResourceMethods(Object)
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
import java.io.IOException;

import javax.interceptor.Interceptors;
import javax.ws.rs.*;

import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@
import java.util.*;
import java.util.Map.Entry;

import javax.ws.rs.core.*;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;

import ca.uhn.fhir.interceptor.api.IInterceptorService;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.apache.commons.lang3.StringUtils;

import ca.uhn.fhir.context.FhirContext;
Expand Down

0 comments on commit 31bb1d9

Please sign in to comment.