Fix #283 - Remove servlet 3.0 dependency where possible
This commit is contained in:
parent
944afc2785
commit
1ba03f4a9b
|
@ -1,5 +1,4 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
|
@ -14,6 +13,9 @@
|
|||
|
||||
<name>HAPI FHIR - Deployable Artifact Parent POM</name>
|
||||
|
||||
<dependencies>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
@ -53,7 +55,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<version>${maven_project_info_plugin_version}</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
|
@ -61,7 +62,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>${maven_javadoc_plugin_version}</version>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<id>default</id>
|
||||
|
@ -110,7 +110,6 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>${maven_source_plugin_version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
|
@ -123,7 +122,6 @@
|
|||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>license-maven-plugin</artifactId>
|
||||
<version>${maven_license_plugin_version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>first</id>
|
||||
|
|
|
@ -80,6 +80,12 @@ import ca.uhn.fhir.util.VersionUtil;
|
|||
|
||||
public class RestfulServer extends HttpServlet implements IRestfulServer<ServletRequestDetails> {
|
||||
|
||||
/**
|
||||
* Requests will have an HttpServletRequest attribute set with this name, containing the servlet
|
||||
* context, in order to avoid a dependency on Servlet-API 3.0+
|
||||
*/
|
||||
public static final String SERVLET_CONTEXT_ATTRIBUTE = "ca.uhn.fhir.rest.server.RestfulServer.servlet_context";
|
||||
|
||||
/**
|
||||
* Default setting for {@link #setETagSupport(ETagSupportEnum) ETag Support}: {@link ETagSupportEnum#ENABLED}
|
||||
*/
|
||||
|
@ -517,6 +523,8 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
|||
requestDetails.setRequestType(theRequestType);
|
||||
requestDetails.setServletRequest(theRequest);
|
||||
requestDetails.setServletResponse(theResponse);
|
||||
|
||||
theRequest.setAttribute(SERVLET_CONTEXT_ATTRIBUTE, getServletContext());
|
||||
|
||||
try {
|
||||
|
||||
|
|
|
@ -20,9 +20,14 @@
|
|||
<version>1.4-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
The JPA project uses a newer API but we'll try to hold to this version
|
||||
as much as possible. See #283.
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
|
||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu.resource.Conformance;
|
||||
import ca.uhn.fhir.model.dstu.resource.Conformance.Rest;
|
||||
import ca.uhn.fhir.model.dstu.resource.Conformance.RestQuery;
|
||||
|
@ -156,7 +155,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
String resourceName = next.getResourceName();
|
||||
RuntimeResourceDefinition def = myServerConfiguration.getFhirContext().getResourceDefinition(resourceName);
|
||||
resource.getType().setValue(def.getName());
|
||||
ServletContext servletContext = theRequest == null ? null : theRequest.getServletContext();
|
||||
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
|
||||
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
resource.getProfile().setReference(new IdDt(def.getResourceProfile(serverBase)));
|
||||
|
||||
|
|
|
@ -26,9 +26,15 @@
|
|||
<version>1.4-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
The JPA project uses a newer API but we'll try to hold to this version
|
||||
as much as possible. See #283.
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -85,8 +85,10 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
|||
* Server FHIR Provider which serves the conformance statement for a RESTful server implementation
|
||||
*
|
||||
* <p>
|
||||
* Note: This class is safe to extend, but it is important to note that the same instance of {@link Conformance} is always returned unless {@link #setCache(boolean)} is called with a value of
|
||||
* <code>false</code>. This means that if you are adding anything to the returned conformance instance on each call you should call <code>setCache(false)</code> in your provider constructor.
|
||||
* Note: This class is safe to extend, but it is important to note that the same instance of {@link Conformance} is
|
||||
* always returned unless {@link #setCache(boolean)} is called with a value of <code>false</code>. This means that if
|
||||
* you are adding anything to the returned conformance instance on each call you should call
|
||||
* <code>setCache(false)</code> in your provider constructor.
|
||||
* </p>
|
||||
*/
|
||||
public class ServerConformanceProvider implements IServerConformanceProvider<Conformance> {
|
||||
|
@ -101,22 +103,20 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
public ServerConformanceProvider(RestfulServer theRestfulServer) {
|
||||
this.myServerConfiguration = theRestfulServer.createConfiguration();
|
||||
}
|
||||
|
||||
|
||||
public ServerConformanceProvider(RestulfulServerConfiguration theServerConfiguration) {
|
||||
this.myServerConfiguration = theServerConfiguration;
|
||||
this.myServerConfiguration = theServerConfiguration;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Add a no-arg constructor and seetter so that the
|
||||
* ServerConfirmanceProvider can be Spring-wired with
|
||||
* the RestfulService avoiding the potential reference
|
||||
* cycle that would happen.
|
||||
* Add a no-arg constructor and seetter so that the ServerConfirmanceProvider can be Spring-wired with the
|
||||
* RestfulService avoiding the potential reference cycle that would happen.
|
||||
*/
|
||||
public ServerConformanceProvider () {
|
||||
public ServerConformanceProvider() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void setRestfulServer (RestfulServer theRestfulServer) {
|
||||
|
||||
public void setRestfulServer(RestfulServer theRestfulServer) {
|
||||
myServerConfiguration = theRestfulServer.createConfiguration();
|
||||
}
|
||||
|
||||
|
@ -167,8 +167,9 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
|
||||
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
|
||||
* Gets the value of the "publisher" that will be placed in the generated conformance statement. As this is a
|
||||
* mandatory element, the value should not be null (although this is not enforced). The value defaults to
|
||||
* "Not provided" but may be set to null, which will cause this element to be omitted.
|
||||
*/
|
||||
public String getPublisher() {
|
||||
return myPublisher;
|
||||
|
@ -186,7 +187,8 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
retVal.setPublisher(myPublisher);
|
||||
retVal.setDateElement(conformanceDate());
|
||||
retVal.setFhirVersion("1.0.2"); // TODO: pull from model
|
||||
retVal.setAcceptUnknown(UnknownContentCode.EXTENSIONS); // TODO: make this configurable - this is a fairly big effort since the parser
|
||||
retVal.setAcceptUnknown(UnknownContentCode.EXTENSIONS); // TODO: make this configurable - this is a fairly big
|
||||
// effort since the parser
|
||||
// needs to be modified to actually allow it
|
||||
|
||||
retVal.getImplementation().setDescription(myServerConfiguration.getImplementationDescription());
|
||||
|
@ -211,8 +213,8 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
String resourceName = nextEntry.getKey();
|
||||
RuntimeResourceDefinition def = myServerConfiguration.getFhirContext().getResourceDefinition(resourceName);
|
||||
resource.getTypeElement().setValue(def.getName());
|
||||
ServletContext servletContext = theRequest == null ? null : theRequest.getServletContext();
|
||||
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
|
||||
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
resource.getProfile().setReference((def.getResourceProfile(serverBase)));
|
||||
|
||||
TreeSet<String> includes = new TreeSet<String>();
|
||||
|
@ -441,7 +443,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
if (targetDef != null) {
|
||||
ResourceType code;
|
||||
try {
|
||||
code = ResourceType.fromCode(targetDef.getName());
|
||||
code = ResourceType.fromCode(targetDef.getName());
|
||||
} catch (FHIRException e) {
|
||||
code = null;
|
||||
}
|
||||
|
@ -561,8 +563,9 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a mandatory element, the value should not be null (although this is not enforced). The
|
||||
* value defaults to "Not provided" but may be set to null, which will cause this element to be omitted.
|
||||
* Sets the value of the "publisher" that will be placed in the generated conformance statement. As this is a
|
||||
* mandatory element, the value should not be null (although this is not enforced). The value defaults to
|
||||
* "Not provided" but may be set to null, which will cause this element to be omitted.
|
||||
*/
|
||||
public void setPublisher(String thePublisher) {
|
||||
myPublisher = thePublisher;
|
||||
|
|
|
@ -27,9 +27,14 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
The JPA project uses a newer API but we'll try to hold to this version
|
||||
as much as possible. See #283.
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ public class ServerConformanceProvider implements IServerConformanceProvider<Con
|
|||
String resourceName = nextEntry.getKey();
|
||||
RuntimeResourceDefinition def = myServerConfiguration.getFhirContext().getResourceDefinition(resourceName);
|
||||
resource.getTypeElement().setValue(def.getName());
|
||||
ServletContext servletContext = theRequest == null ? null : theRequest.getServletContext();
|
||||
ServletContext servletContext = (ServletContext) (theRequest == null ? null : theRequest.getAttribute(RestfulServer.SERVLET_CONTEXT_ATTRIBUTE));
|
||||
String serverBase = myServerConfiguration.getServerAddressStrategy().determineServerBase(servletContext, theRequest);
|
||||
resource.getProfile().setReference(new IdDt(def.getResourceProfile(serverBase)));
|
||||
|
||||
|
|
|
@ -26,13 +26,18 @@
|
|||
<version>1.4-SNAPSHOT</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!--
|
||||
The JPA project uses a newer API but we'll try to hold to this version
|
||||
as much as possible. See #283.
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- <dependency> <groupId>net.sf.saxon</groupId> <artifactId>saxon</artifactId>
|
||||
<version>8.7</version> </dependency> -->
|
||||
|
||||
|
|
|
@ -139,6 +139,12 @@
|
|||
implementations and wasn't compatible
|
||||
with coming changes to that API.
|
||||
</action>
|
||||
<action type="fix" issue="283">
|
||||
Remove dependency on Servlet-API 3.0+ by using methods available in 2.5 where possible.
|
||||
Note that we continue to use Servlet-API 3.0+ features in some parts of the JPA API, so
|
||||
running in an old serlvet container should be tested well before use. Thanks to Bill Denton
|
||||
for reporting!
|
||||
</action>
|
||||
</release>
|
||||
<release version="1.3" date="2015-11-14">
|
||||
<action type="add">
|
||||
|
|
Loading…
Reference in New Issue