From 44a97f36217248ec9229c5817045154e9bea81ef Mon Sep 17 00:00:00 2001 From: James Agnew Date: Sun, 7 Jul 2019 14:59:26 -0400 Subject: [PATCH] Still fire appropriate interceptor methods if the cached capabiliotystatement is being returned --- .../method/ConformanceMethodBinding.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/ConformanceMethodBinding.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/ConformanceMethodBinding.java index 2a0bd33fdb2..15e2d285594 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/ConformanceMethodBinding.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/ConformanceMethodBinding.java @@ -24,6 +24,10 @@ import java.lang.reflect.Method; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; +import ca.uhn.fhir.interceptor.api.HookParams; +import ca.uhn.fhir.interceptor.api.Pointcut; +import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; +import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import org.hl7.fhir.instance.model.api.IBaseConformance; import org.hl7.fhir.instance.model.api.IBaseResource; @@ -74,17 +78,33 @@ public class ConformanceMethodBinding extends BaseResourceReturningMethodBinding IBaseResource conf; conf = myCachedResponse.get(); - if ("true".equals(System.getProperty("test"))) { conf = null; } - if (conf != null) { long expires = myCachedResponseExpires.get(); if (expires < System.currentTimeMillis()) { conf = null; } } + if (conf != null) { + // Handle server action interceptors + RestOperationTypeEnum operationType = getRestOperationType(theRequest); + if (operationType != null) { + IServerInterceptor.ActionRequestDetails details = new IServerInterceptor.ActionRequestDetails(theRequest); + populateActionRequestDetailsForInterceptor(theRequest, details, theMethodParams); + HookParams preHandledParams = new HookParams(); + preHandledParams.add(RestOperationTypeEnum.class, theRequest.getRestOperationType()); + preHandledParams.add(RequestDetails.class, theRequest); + preHandledParams.addIfMatchesType(ServletRequestDetails.class, theRequest); + preHandledParams.add(IServerInterceptor.ActionRequestDetails.class, details); + if (theRequest.getInterceptorBroadcaster() != null) { + theRequest + .getInterceptorBroadcaster() + .callHooks(Pointcut.SERVER_INCOMING_REQUEST_PRE_HANDLED, preHandledParams); + } + } + } if (conf == null) { conf = (IBaseResource) invokeServerMethod(theServer, theRequest, theMethodParams);