Re-enable daoconfig interceptors

This commit is contained in:
James Agnew 2017-05-15 22:11:29 -04:00
parent 4948cdeef5
commit d87b4f2062
4 changed files with 21 additions and 23 deletions

View File

@ -786,11 +786,7 @@ public abstract class BaseHapiFhirDao<T extends IBaseResource> implements IDao {
if (theRequestDetails.getUserData().get(PROCESSING_SUB_REQUEST) == Boolean.TRUE) {
theRequestDetails.notifyIncomingRequestPreHandled(theOperationType);
}
List<IServerInterceptor> interceptors = getConfig().getInterceptors();
if (interceptors == null) {
return;
}
for (IServerInterceptor next : interceptors) {
next.incomingRequestPreHandled(theOperationType, theRequestDetails);
}

View File

@ -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<T extends IBaseResource> 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<T extends IBaseResource> 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<T extends IBaseResource> 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<T extends IBaseResource> extends B
if (next instanceof IJpaServerInterceptor) {
((IJpaServerInterceptor) next).resourceUpdated(requestDetails, entity);
}
if (next instanceof IServerOperationInterceptor) {
((IServerOperationInterceptor) next).resourceDeleted(theRequestDetails, theResource);
}
}
}

View File

@ -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<IServerInterceptor> getInterceptors() {
if (myInterceptors == null) {
return Collections.emptyList();
return myInterceptors = new ArrayList<IServerInterceptor>();
}
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<IServerInterceptor>());
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<IServerInterceptor> theInterceptors) {
myInterceptors = theInterceptors;
}

View File

@ -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!
</action>
<action type="add">
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.
</action>
</release>
<release version="2.4" date="2017-04-19">
<action type="add">