Attempt fix for npe (#6213)
* wip * wip * wip * remove whitespace * Add test * changelog
This commit is contained in:
parent
9e0efcaecb
commit
fa04ad6c72
|
@ -56,7 +56,7 @@ public interface IAnyResource extends IBaseResource {
|
|||
@SearchParamDefinition(
|
||||
name = SP_RES_LAST_UPDATED,
|
||||
path = "Resource.meta.lastUpdated",
|
||||
description = "The last updated date of the resource",
|
||||
description = "Only return resources which were last updated as specified by the given range",
|
||||
type = "date")
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
type: fix
|
||||
issue: 6208
|
||||
title: "A regression was temporarily introduced which caused searches by `_lastUpdated` to fail with a NullPointerException when using Lucene as the backing search engine. This has been corrected"
|
|
@ -29,6 +29,7 @@ import ca.uhn.fhir.model.primitive.InstantDt;
|
|||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.parser.StrictErrorHandler;
|
||||
import ca.uhn.fhir.rest.api.CacheControlDirective;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import ca.uhn.fhir.rest.api.MethodOutcome;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
|
@ -1112,6 +1113,34 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchByUrl() {
|
||||
// setup
|
||||
DateType dt = new DateType(new Date());
|
||||
String nowStr = dt.getValueAsString();
|
||||
|
||||
boolean storeResourceInHSearch = myStorageSettings.isStoreResourceInHSearchIndex();
|
||||
boolean advancedHSearch = myStorageSettings.isAdvancedHSearchIndexing();
|
||||
|
||||
try {
|
||||
// use full text search
|
||||
myStorageSettings.setStoreResourceInHSearchIndex(true);
|
||||
myStorageSettings.setAdvancedHSearchIndexing(true);
|
||||
|
||||
// test
|
||||
Bundle b = myClient.search()
|
||||
.byUrl("Patient?_lastUpdated=" + nowStr)
|
||||
.returnBundle(Bundle.class)
|
||||
.cacheControl(CacheControlDirective.noCache())
|
||||
.execute();
|
||||
|
||||
assertNotNull(b);
|
||||
} finally {
|
||||
// reset back to previous
|
||||
myStorageSettings.setAdvancedHSearchIndexing(advancedHSearch);
|
||||
myStorageSettings.setStoreResourceInHSearchIndex(storeResourceInHSearch);
|
||||
}
|
||||
}
|
||||
@Test
|
||||
public void testCreateConditionalWithPreferRepresentation() {
|
||||
Patient p = new Patient();
|
||||
|
|
|
@ -121,9 +121,12 @@ public class ${className}ResourceProvider extends
|
|||
@RawParam
|
||||
Map<String, List<String>> theAdditionalRawParams,
|
||||
|
||||
##DSTU2 is not an IAnyResource, yet supports LastUpdated, so we keep the magic SP in this case.
|
||||
#if ( $version == 'dstu2' )
|
||||
@Description(shortDefinition="Only return resources which were last updated as specified by the given range")
|
||||
@OptionalParam(name="_lastUpdated")
|
||||
DateRangeParam theLastUpdated,
|
||||
DateRangeParam the_lastUpdated,
|
||||
#end
|
||||
|
||||
@IncludeParam
|
||||
Set<Include> theIncludes,
|
||||
|
@ -162,11 +165,18 @@ public class ${className}ResourceProvider extends
|
|||
|
||||
paramMap.add("_has", theHas);
|
||||
#foreach ( $param in $searchParams )
|
||||
#if( ${param.name} == "_lastUpdated")
|
||||
## Skip Last Updated since its handled by param defined below.
|
||||
#else
|
||||
paramMap.add("${param.name}", the${param.nameCapitalized});
|
||||
#end
|
||||
#end
|
||||
#if ( $version != 'dstu' )
|
||||
paramMap.setRevIncludes(theRevIncludes);
|
||||
paramMap.setLastUpdated(theLastUpdated);
|
||||
paramMap.setRevIncludes(theRevIncludes);
|
||||
## Note that since we have added an SearchParamDefinition on IAnyResource for this, we had to remove
|
||||
## the magic _lastUpdated that was previously hardcoded as an OperationParam. However, we still need to populate
|
||||
## This special variable in the SP map.
|
||||
paramMap.setLastUpdated(the_lastUpdated);
|
||||
#end
|
||||
paramMap.setIncludes(theIncludes);
|
||||
paramMap.setSort(theSort);
|
||||
|
|
Loading…
Reference in New Issue