Error with a 404 on invalid valueset

This commit is contained in:
James Agnew 2019-09-09 18:01:41 -04:00
parent 19676a01b7
commit 2052df3152
4 changed files with 9 additions and 4 deletions

View File

@ -32,9 +32,11 @@ import ca.uhn.fhir.jpa.util.ScrollableResultsIterator;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
import ca.uhn.fhir.util.ObjectUtil;
import ca.uhn.fhir.util.StopWatch;
import ca.uhn.fhir.util.UrlUtil;
import ca.uhn.fhir.util.ValidateUtil;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
@ -487,7 +489,6 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
if (!optionalTermValueSet.isPresent()) {
ourLog.warn("ValueSet is not present in terminology tables. Will perform in-memory expansion without parameters. Will schedule this ValueSet for pre-expansion. {}", getValueSetInfo(theValueSetToExpand));
myDeferredValueSets.add(theValueSetToExpand);
return expandValueSet(theValueSetToExpand); // In-memory expansion.
}
@ -2366,6 +2367,10 @@ public abstract class BaseHapiTerminologySvcImpl implements IHapiTerminologySvc,
return retVal;
}
protected void throwInvalidValueSet(String theValueSet) {
throw new ResourceNotFoundException("Unknown ValueSet: " + UrlUtil.escapeUrlParam(theValueSet));
}
private static void extractLinksFromConceptAndChildren(TermConcept theConcept, List<TermConceptParentChildLink> theLinks) {
theLinks.addAll(theConcept.getParents());
for (TermConceptParentChildLink child : theConcept.getChildren()) {

View File

@ -212,7 +212,7 @@ public class HapiTerminologySvcDstu3 extends BaseHapiTerminologySvcImpl implemen
public List<VersionIndependentConcept> expandValueSet(String theValueSet) {
ValueSet vs = myValidationSupport.fetchResource(myContext, ValueSet.class, theValueSet);
if (vs == null) {
return Collections.emptyList();
super.throwInvalidValueSet(theValueSet);
}
org.hl7.fhir.r4.model.ValueSet valueSetToExpandR4;

View File

@ -124,7 +124,7 @@ public class HapiTerminologySvcR4 extends BaseHapiTerminologySvcImpl implements
public List<VersionIndependentConcept> expandValueSet(String theValueSet) {//FIXME: DM COWABUNGA
ValueSet vs = myValidationSupport.fetchResource(myContext, ValueSet.class, theValueSet);
if (vs == null) {
return Collections.emptyList();
super.throwInvalidValueSet(theValueSet);
}
return expandValueSetAndReturnVersionIndependentConcepts(vs);

View File

@ -133,7 +133,7 @@ public class HapiTerminologySvcR5 extends BaseHapiTerminologySvcImpl implements
public List<VersionIndependentConcept> expandValueSet(String theValueSet) {
ValueSet valueSetR5 = myValidationSupport.fetchResource(myContext, ValueSet.class, theValueSet);
if (valueSetR5 == null) {
return Collections.emptyList();
super.throwInvalidValueSet(theValueSet);
}
return expandValueSetAndReturnVersionIndependentConcepts(org.hl7.fhir.convertors.conv40_50.ValueSet.convertValueSet(valueSetR5));