Address review comments

This commit is contained in:
jamesagnew 2020-03-24 06:02:55 -04:00
parent a067a2001d
commit 13f0e5384b
3 changed files with 18 additions and 12 deletions

View File

@ -29,7 +29,7 @@ jobs:
env: env:
JAVA_HOME_11_X64: /usr/local/openjdk-11 JAVA_HOME_11_X64: /usr/local/openjdk-11
inputs: inputs:
goals: 'clean install' goals: 'dependency:resolve clean install'
# These are Maven CLI options (and show up in the build logs) - "-nsu"=Don't update snapshots. We can remove this when Maven OSS is more healthy # These are Maven CLI options (and show up in the build logs) - "-nsu"=Don't update snapshots. We can remove this when Maven OSS is more healthy
options: '-P ALLMODULES,JACOCO,CI,ERRORPRONE -nsu -e -B -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)' options: '-P ALLMODULES,JACOCO,CI,ERRORPRONE -nsu -e -B -Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)'
# These are JVM options (and don't show up in the build logs) # These are JVM options (and don't show up in the build logs)

View File

@ -2,4 +2,4 @@
type: add type: add
issue: 1772 issue: 1772
title: "The JPA server now allows chained searches on the `_type` parameter. For example, the following title: "The JPA server now allows chained searches on the `_type` parameter. For example, the following
could be used to find all Encounters with a context of type Group: `Encounter?context._type=Group`." could be used to find all Encounters with a context of type Group: `Encounter?subject._type=Group`."

View File

@ -64,7 +64,6 @@ import ca.uhn.fhir.rest.param.*;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import ca.uhn.fhir.util.UrlUtil;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.hl7.fhir.instance.model.api.IAnyResource; import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
@ -327,9 +326,8 @@ class PredicateBuilderReference extends BasePredicateBuilder {
throw newInvalidResourceTypeException(typeValue); throw newInvalidResourceTypeException(typeValue);
} }
if (!resourceTypes.contains(wantedType)) { if (!resourceTypes.contains(wantedType)) {
String searchParamName = theResourceName + ":" + theParamName; InvalidRequestException invalidRequestException = newInvalidTargetTypeForChainException(theResourceName, theParamName, typeValue);
String msg = myContext.getLocalizer().getMessage(PredicateBuilderReference.class, "invalidTargetTypeForChain", typeValue, searchParamName); throw invalidRequestException;
throw new InvalidRequestException(msg);
} }
Predicate targetTypeParameter = myCriteriaBuilder.equal(theJoin.get("myTargetResourceType"), typeValue); Predicate targetTypeParameter = myCriteriaBuilder.equal(theJoin.get("myTargetResourceType"), typeValue);
@ -409,12 +407,6 @@ class PredicateBuilderReference extends BasePredicateBuilder {
return predicate; return predicate;
} }
@NotNull
private InvalidRequestException newInvalidResourceTypeException(String theResourceType) {
String msg = myContext.getLocalizer().getMessageSanitized(PredicateBuilderReference.class, "invalidResourceType", theResourceType);
throw new InvalidRequestException(msg);
}
private void warnAboutPerformanceOnUnqualifiedResources(String theParamName, RequestDetails theRequest, List<Class<? extends IBaseResource>> theCandidateTargetTypes) { private void warnAboutPerformanceOnUnqualifiedResources(String theParamName, RequestDetails theRequest, List<Class<? extends IBaseResource>> theCandidateTargetTypes) {
String message = new StringBuilder() String message = new StringBuilder()
.append("This search uses an unqualified resource(a parameter in a chain without a resource type). ") .append("This search uses an unqualified resource(a parameter in a chain without a resource type). ")
@ -996,4 +988,18 @@ class PredicateBuilderReference extends BasePredicateBuilder {
return retVal; return retVal;
} }
@NotNull
private InvalidRequestException newInvalidTargetTypeForChainException(String theResourceName, String theParamName, String theTypeValue) {
String searchParamName = theResourceName + ":" + theParamName;
String msg = myContext.getLocalizer().getMessage(PredicateBuilderReference.class, "invalidTargetTypeForChain", theTypeValue, searchParamName);
return new InvalidRequestException(msg);
}
@NotNull
private InvalidRequestException newInvalidResourceTypeException(String theResourceType) {
String msg = myContext.getLocalizer().getMessageSanitized(PredicateBuilderReference.class, "invalidResourceType", theResourceType);
throw new InvalidRequestException(msg);
}
} }