diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java index 40129fa9d6b..e7dd916e9fb 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirDao.java @@ -786,11 +786,7 @@ public abstract class BaseHapiFhirDao implements IDao { if (theRequestDetails.getUserData().get(PROCESSING_SUB_REQUEST) == Boolean.TRUE) { theRequestDetails.notifyIncomingRequestPreHandled(theOperationType); } - List interceptors = getConfig().getInterceptors(); - if (interceptors == null) { - return; - } for (IServerInterceptor next : interceptors) { next.incomingRequestPreHandled(theOperationType, theRequestDetails); } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java index 75bb3f76f95..425f2666fa5 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java @@ -61,6 +61,7 @@ import ca.uhn.fhir.rest.method.SearchMethodBinding.QualifierDetails; import ca.uhn.fhir.rest.server.IBundleProvider; import ca.uhn.fhir.rest.server.exceptions.*; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; +import ca.uhn.fhir.rest.server.interceptor.IServerOperationInterceptor; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor.ActionRequestDetails; import ca.uhn.fhir.util.FhirTerser; import ca.uhn.fhir.util.ObjectUtil; @@ -208,6 +209,9 @@ public abstract class BaseHapiFhirResourceDao extends B if (next instanceof IJpaServerInterceptor) { ((IJpaServerInterceptor) next).resourceDeleted(requestDetails, entity); } + if (next instanceof IServerOperationInterceptor) { + ((IServerOperationInterceptor) next).resourceDeleted(theRequestDetails, resourceToDelete); + } } } @@ -274,6 +278,9 @@ public abstract class BaseHapiFhirResourceDao extends B if (next instanceof IJpaServerInterceptor) { ((IJpaServerInterceptor) next).resourceDeleted(requestDetails, entity); } + if (next instanceof IServerOperationInterceptor) { + ((IServerOperationInterceptor) next).resourceDeleted(theRequestDetails, resourceToDelete); + } } } @@ -385,6 +392,9 @@ public abstract class BaseHapiFhirResourceDao extends B if (next instanceof IJpaServerInterceptor) { ((IJpaServerInterceptor) next).resourceCreated(requestDetails, entity); } + if (next instanceof IServerOperationInterceptor) { + ((IServerOperationInterceptor) next).resourceCreated(theRequestDetails, theResource); + } } } @@ -1126,6 +1136,9 @@ public abstract class BaseHapiFhirResourceDao extends B if (next instanceof IJpaServerInterceptor) { ((IJpaServerInterceptor) next).resourceUpdated(requestDetails, entity); } + if (next instanceof IServerOperationInterceptor) { + ((IServerOperationInterceptor) next).resourceDeleted(theRequestDetails, theResource); + } } } diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java index 90c02c78e14..b922d6248e2 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/DaoConfig.java @@ -1,11 +1,6 @@ package ca.uhn.fhir.jpa.dao; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.Validate; @@ -32,7 +27,6 @@ import org.apache.commons.lang3.time.DateUtils; */ import ca.uhn.fhir.jpa.entity.ResourceEncodingEnum; -import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; public class DaoConfig { @@ -174,13 +168,10 @@ public class DaoConfig { * Returns the interceptors which will be notified of operations. * * @see #setInterceptors(List) - * @deprecated As of 2.2 this method is deprecated. There is no good reason to register an interceptor - * with the DaoConfig and not with the server via {@link RestfulServer#registerInterceptor(IServerInterceptor)} */ - @Deprecated public List getInterceptors() { if (myInterceptors == null) { - return Collections.emptyList(); + return myInterceptors = new ArrayList(); } return myInterceptors; } @@ -526,11 +517,7 @@ public class DaoConfig { /** * This may be used to optionally register server interceptors directly against the DAOs. - * - * @deprecated As of 2.2 this method is deprecated. There is no good reason to register an interceptor - * with the DaoConfig and not with the server via {@link RestfulServer#registerInterceptor(IServerInterceptor)} */ - @Deprecated public void setInterceptors(IServerInterceptor... theInterceptor) { setInterceptors(new ArrayList()); if (theInterceptor != null && theInterceptor.length != 0) { @@ -540,11 +527,7 @@ public class DaoConfig { /** * This may be used to optionally register server interceptors directly against the DAOs. - * - * @deprecated As of 2.2 this method is deprecated. There is no good reason to register an interceptor - * with the DaoConfig and not with the server via {@link RestfulServer#registerInterceptor(IServerInterceptor)} */ - @Deprecated public void setInterceptors(List theInterceptors) { myInterceptors = theInterceptors; } diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 1031bbd91c6..6174751dd73 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -87,6 +87,12 @@ when a scalar value was found in a spot where an object is expected. This has been corrected to include much more information. Thanks to GitHub user @jasminas for reporting! + + DaoConfig#setInterceptors() has been un-deprecated. It was previously deprecated as + we thought it was not useful, but uses have been identified so it turns out this method + will live after all. Interceptors registered to this method will now be treated + appropriately if they implement IServerOperationInterceptor too. +