Allow for improved overriding of RestfulServer#newRequestDetails
This commit is contained in:
parent
371bf2e5cf
commit
9e44049847
|
@ -78,7 +78,8 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.jar.Manifest;
|
import java.util.jar.Manifest;
|
||||||
import java.util.stream.Collectors;
|
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")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public class RestfulServer extends HttpServlet implements IRestfulServer<ServletRequestDetails> {
|
public class RestfulServer extends HttpServlet implements IRestfulServer<ServletRequestDetails> {
|
||||||
|
@ -849,11 +850,7 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
protected void handleRequest(RequestTypeEnum theRequestType, HttpServletRequest theRequest, HttpServletResponse theResponse) throws ServletException, IOException {
|
protected void handleRequest(RequestTypeEnum theRequestType, HttpServletRequest theRequest, HttpServletResponse theResponse) throws ServletException, IOException {
|
||||||
String fhirServerBase;
|
String fhirServerBase;
|
||||||
ServletRequestDetails requestDetails = newRequestDetails();
|
ServletRequestDetails requestDetails = newRequestDetails(theRequestType, theRequest, theResponse);
|
||||||
requestDetails.setServer(this);
|
|
||||||
requestDetails.setRequestType(theRequestType);
|
|
||||||
requestDetails.setServletRequest(theRequest);
|
|
||||||
requestDetails.setServletResponse(theResponse);
|
|
||||||
|
|
||||||
String requestId = getOrCreateRequestId(theRequest);
|
String requestId = getOrCreateRequestId(theRequest);
|
||||||
requestDetails.setRequestId(requestId);
|
requestDetails.setRequestId(requestId);
|
||||||
|
@ -1096,6 +1093,30 @@ public class RestfulServer extends HttpServlet implements IRestfulServer<Servlet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subclasses may override this to customize the way that the RequestDetails object is created. Generally speaking, the
|
||||||
|
* right way to do this is to override this method, but call the super-implementation (<code>super.newRequestDetails</code>)
|
||||||
|
* 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() {
|
protected ServletRequestDetails newRequestDetails() {
|
||||||
return new ServletRequestDetails(getInterceptorService());
|
return new ServletRequestDetails(getInterceptorService());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue