From 9e44049847526385ec520018971ff9ad21601eeb Mon Sep 17 00:00:00 2001 From: James Agnew Date: Tue, 22 Oct 2019 18:09:21 -0400 Subject: [PATCH] Allow for improved overriding of RestfulServer#newRequestDetails --- .../uhn/fhir/rest/server/RestfulServer.java | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java index e4c7c52672c..6a1d2fe7c5f 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java @@ -78,7 +78,8 @@ import java.util.concurrent.locks.ReentrantLock; import java.util.jar.Manifest; import java.util.stream.Collectors; -import static org.apache.commons.lang3.StringUtils.*; +import static org.apache.commons.lang3.StringUtils.isBlank; +import static org.apache.commons.lang3.StringUtils.isNotBlank; @SuppressWarnings("WeakerAccess") public class RestfulServer extends HttpServlet implements IRestfulServer { @@ -849,11 +850,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServersuper.newRequestDetails) + * and then customize the returned object before returning it. + * + * @param theRequestType The HTTP request verb + * @param theRequest The servlet request + * @param theResponse The servlet response + * @return A ServletRequestDetails instance to be passed to any resource providers, interceptors, etc. that are invoked as a part of serving this request. + */ + @Nonnull + protected ServletRequestDetails newRequestDetails(RequestTypeEnum theRequestType, HttpServletRequest theRequest, HttpServletResponse theResponse) { + ServletRequestDetails requestDetails = newRequestDetails(); + requestDetails.setServer(this); + requestDetails.setRequestType(theRequestType); + requestDetails.setServletRequest(theRequest); + requestDetails.setServletResponse(theResponse); + return requestDetails; + } + + /** + * @deprecated Deprecated in HAPI FHIR 4.1.0 - Users wishing to override this method should override {@link #newRequestDetails(RequestTypeEnum, HttpServletRequest, HttpServletResponse)} instead + */ + @Deprecated protected ServletRequestDetails newRequestDetails() { return new ServletRequestDetails(getInterceptorService()); }