Add adapter for IServerOperationInterceptor
This commit is contained in:
parent
344e324929
commit
8e0a904997
|
@ -24,6 +24,13 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
|
|||
|
||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
||||
|
||||
/**
|
||||
* Server interceptor with added methods which can be called within the lifecycle of
|
||||
* write operations (create/update/delete) or within transaction and batch
|
||||
* operations that call these sub-operations.
|
||||
*
|
||||
* @see ServerOperationInterceptorAdapter
|
||||
*/
|
||||
public interface IServerOperationInterceptor extends IServerInterceptor {
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package ca.uhn.fhir.rest.server.interceptor;
|
||||
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
|
||||
import ca.uhn.fhir.rest.method.RequestDetails;
|
||||
|
||||
/**
|
||||
* NOP implementation of {@link IServerOperationInterceptor}
|
||||
*/
|
||||
public class ServerOperationInterceptorAdapter extends InterceptorAdapter implements IServerOperationInterceptor {
|
||||
|
||||
@Override
|
||||
public void resourceDeleted(RequestDetails theRequest, IBaseResource theResource) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resourceCreated(RequestDetails theRequest, IBaseResource theResource) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resourceUpdated(RequestDetails theRequest, IBaseResource theResource) {
|
||||
// nothing
|
||||
}
|
||||
|
||||
}
|
|
@ -72,22 +72,26 @@ public class StaleSearchDeletingSvc {
|
|||
return;
|
||||
}
|
||||
|
||||
TransactionTemplate tt = new TransactionTemplate(myTransactionManager);
|
||||
for (final Search next : toDelete) {
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus theArg0) {
|
||||
Search searchToDelete = mySearchDao.findOne(next.getId());
|
||||
ourLog.info("Expiring stale search {} / {}", searchToDelete.getId(), searchToDelete.getUuid());
|
||||
mySearchIncludeDao.deleteForSearch(searchToDelete.getId());
|
||||
mySearchResultDao.deleteForSearch(searchToDelete.getId());
|
||||
mySearchDao.delete(searchToDelete);
|
||||
}
|
||||
});
|
||||
deleteSearch(next);
|
||||
}
|
||||
|
||||
ourLog.info("Deleted {} searches, {} remaining", toDelete.size(), mySearchDao.count());
|
||||
}
|
||||
}
|
||||
|
||||
protected void deleteSearch(final Search next) {
|
||||
TransactionTemplate tt = new TransactionTemplate(myTransactionManager);
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus theArg0) {
|
||||
Search searchToDelete = mySearchDao.findOne(next.getId());
|
||||
ourLog.info("Expiring stale search {} / {}", searchToDelete.getId(), searchToDelete.getUuid());
|
||||
mySearchIncludeDao.deleteForSearch(searchToDelete.getId());
|
||||
mySearchResultDao.deleteForSearch(searchToDelete.getId());
|
||||
mySearchDao.delete(searchToDelete);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue