From 472984ac65cbf3e9076652cd9dabccf66e1655a9 Mon Sep 17 00:00:00 2001
From: Martha Mitran
* Hooks may accept the following parameters:
*
@@ -902,7 +905,6 @@ public enum Pointcut implements IPointcut {
* canonical subscription such as adding headers, modifying the channel
* endpoint, etc.
* Furthermore, you may modify the outgoing message wrapper, for example adding headers via ResourceModifiedJsonMessage field.
- *
*
* Hooks may accept the following parameters: *
@@ -1228,7 +1229,7 @@ public enum Pointcut implements IPointcut { /** * Storage Hook: - * Invoked when a batch of resource pids are about to be deleted and expunged via url like http://localhost/Patient?active=false&_expunge=true + * Invoked when a batch of resource pids are about to be deleted and expunged via url like {@code http://localhost/Patient?active=false&_expunge=true}. ** Hooks may accept the following parameters: *
@@ -2957,7 +2958,6 @@ public enum Pointcut implements IPointcut { "ca.uhn.fhir.rest.server.servlet.ServletRequestDetails", "ca.uhn.fhir.jpa.util.SqlQueryList"), - @Deprecated(since = "7.2.0 - Use STORAGE_BINARY_ASSIGN_BINARY_CONTENT_ID_PREFIX instead.") /** * Deprecated but still supported. Will eventually be removed.Please use Pointcut.STORAGE_BINARY_ASSIGN_BINARY_CONTENT_ID_PREFIX
* Binary Blob Prefix Assigning Hook:
@@ -2980,6 +2980,7 @@ public enum Pointcut implements IPointcut {
* Hooks should return String
, which represents the full prefix to be applied to the blob.
*
*/
+ @Deprecated(since = "7.2.0 - Use STORAGE_BINARY_ASSIGN_BINARY_CONTENT_ID_PREFIX instead.")
STORAGE_BINARY_ASSIGN_BLOB_ID_PREFIX(
String.class,
"ca.uhn.fhir.rest.api.server.RequestDetails",
diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java
index f33bbcd2c28..14fb2bb0d7e 100644
--- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java
+++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java
@@ -3,6 +3,8 @@ package ca.uhn.fhir.jpa.provider.r4;
import ca.uhn.fhir.context.RuntimeSearchParam;
import ca.uhn.fhir.i18n.HapiLocalizer;
import ca.uhn.fhir.i18n.Msg;
+import ca.uhn.fhir.interceptor.api.Hook;
+import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.api.config.JpaStorageSettings;
import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.dao.data.ISearchDao;
@@ -44,12 +46,16 @@ import ca.uhn.fhir.rest.gclient.NumberClientParam;
import ca.uhn.fhir.rest.gclient.StringClientParam;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.ParamPrefixEnum;
+import ca.uhn.fhir.rest.param.TokenParam;
+import ca.uhn.fhir.rest.param.TokenParamModifier;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
+import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
+import ca.uhn.fhir.rest.server.util.ICachedSearchDetails;
import ca.uhn.fhir.util.ClasspathUtil;
import ca.uhn.fhir.util.StopWatch;
import ca.uhn.fhir.util.TestUtil;
@@ -198,15 +204,12 @@ import static ca.uhn.fhir.util.TestUtil.sleepAtLeast;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
-
import static org.mockito.Mockito.when;
@SuppressWarnings("Duplicates")
@@ -5324,6 +5327,40 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
}
+ @Test
+ public void testSearchWithParameterAddedInInterceptor() {
+ Object interceptor = new Object() {
+ @Hook(Pointcut.STORAGE_PRESEARCH_REGISTERED)
+ public void storagePreSearchRegistered(
+ ICachedSearchDetails theCachedSearchDetails,
+ RequestDetails theRequestDetails,
+ ServletRequestDetails theServletRequestDetails,
+ SearchParameterMap theSearchParameterMap) {
+ theSearchParameterMap.add("_security", new TokenParam("http://system", "security1").setModifier(TokenParamModifier.NOT));
+ }
+ };
+ myInterceptorRegistry.registerInterceptor(interceptor);
+
+ try {
+ final Patient patient1 = new Patient().setActive(true);
+ patient1.getMeta().addSecurity("http://system", "security1", "Tag 1");
+ MethodOutcome outcome1 = myPatientDao.create(patient1, mySrd);
+ assertTrue(outcome1.getCreated());
+
+ final Patient patient2 = new Patient().setActive(true);
+ patient2.getMeta().addSecurity("http://system", "security2", "Tag 2");
+ MethodOutcome outcome2 = myPatientDao.create(patient2, mySrd);
+ assertTrue(outcome2.getCreated());
+ String idForPatient2 = outcome2.getId().toUnqualifiedVersionless().getValue();
+
+ IBaseBundle bundle = myClient.search().forResource("Patient").execute();
+ List