diff --git a/hapi-fhir-base-example-embedded-ws/pom.xml b/hapi-fhir-base-example-embedded-ws/pom.xml index a9c68c05d86..12797c32c62 100644 --- a/hapi-fhir-base-example-embedded-ws/pom.xml +++ b/hapi-fhir-base-example-embedded-ws/pom.xml @@ -47,7 +47,16 @@ hapi-fhir-structures-dstu2 2.1-SNAPSHOT - + + org.slf4j + slf4j-simple + 1.7.21 + + + org.slf4j + jul-to-slf4j + 1.7.21 + diff --git a/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ServerStartup.java b/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ServerStartup.java index 5cf844aad02..984829826a2 100644 --- a/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ServerStartup.java +++ b/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/ServerStartup.java @@ -7,6 +7,7 @@ import javax.servlet.DispatcherType; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.DefaultServlet; import org.eclipse.jetty.servlet.ServletContextHandler; +import org.slf4j.bridge.SLF4JBridgeHandler; import com.google.inject.servlet.GuiceFilter; @@ -14,6 +15,9 @@ public class ServerStartup { public static void main(final String[] args) throws Exception { + SLF4JBridgeHandler.removeHandlersForRootLogger(); + SLF4JBridgeHandler.install(); + final Server server = new Server(9090); final ServletContextHandler sch = new ServletContextHandler(server, "/"); sch.addEventListener(new ContextListener()); diff --git a/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/SomeResourceProvider.java b/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/SomeResourceProvider.java index aac9da8adb9..b1d9d80cbe0 100644 --- a/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/SomeResourceProvider.java +++ b/hapi-fhir-base-example-embedded-ws/src/main/java/embedded/SomeResourceProvider.java @@ -4,6 +4,8 @@ import java.util.List; import org.hl7.fhir.instance.model.api.IBaseResource; +import com.google.common.collect.Lists; + import ca.uhn.fhir.model.dstu2.resource.Practitioner; import ca.uhn.fhir.model.primitive.StringDt; import ca.uhn.fhir.rest.annotation.RequiredParam; @@ -21,8 +23,9 @@ public class SomeResourceProvider implements IResourceProvider { @Search() public List findPractitionersByName( @RequiredParam(name = Practitioner.SP_NAME) final StringDt theName) { - throw new UnprocessableEntityException( - "Please provide more than 4 characters for the name"); +// throw new UnprocessableEntityException( +// "Please provide more than 4 characters for the name"); + return Lists.newArrayList(); } } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java index 984bdd978ab..67a952018c5 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/method/SearchMethodBinding.java @@ -37,7 +37,6 @@ import org.hl7.fhir.instance.model.api.IBaseResource; import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.FhirVersionEnum; import ca.uhn.fhir.model.api.annotation.Description; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.valueset.BundleTypeEnum; @@ -140,6 +139,21 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding { @Override public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) { + + String clientPreference = theRequest.getHeader(Constants.HEADER_PREFER); + boolean lenientHandling = false; + if(clientPreference != null) + { + String[] preferences = clientPreference.split(";"); + for( String p : preferences){ + if("handling:lenient".equalsIgnoreCase(p)) + { + lenientHandling = true; + break; + } + } + } + if (theRequest.getId() != null && myIdParamIndex == null) { ourLog.trace("Method {} doesn't match because ID is not null: {}", theRequest.getId()); return false; @@ -235,6 +249,9 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding { } } Set keySet = theRequest.getParameters().keySet(); + if(lenientHandling == true) + return true; + if (myAllowUnknownParams == false) { for (String next : keySet) { if (!methodParamsTemp.contains(next)) { @@ -271,7 +288,7 @@ public class SearchMethodBinding extends BaseResourceReturningMethodBinding { } @Override - public IBundleProvider invokeServer(IRestfulServer theServer, RequestDetails theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException { + public IBundleProvider invokeServer(IRestfulServer theServer, RequestDetails theRequest, Object[] theMethodParams) throws InvalidRequestException, InternalErrorException { if (myIdParamIndex != null) { theMethodParams[myIdParamIndex] = theRequest.getId(); } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java index bf3b99d2c03..19e63ef2752 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java @@ -61,7 +61,6 @@ import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.rest.api.PreferReturnEnum; import ca.uhn.fhir.rest.api.SummaryEnum; -import ca.uhn.fhir.rest.client.apache.ApacheHttpRequest; import ca.uhn.fhir.rest.client.api.IHttpRequest; import ca.uhn.fhir.rest.method.ElementsParameter; import ca.uhn.fhir.rest.method.RequestDetails; @@ -378,7 +377,7 @@ public class RestfulServerUtils { break; } } catch (IllegalArgumentException e) { - ourLog.debug("Invalid {} parameger: {}", Constants.PARAM_NARRATIVE, narrative[0]); + ourLog.debug("Invalid {} parameter: {}", Constants.PARAM_NARRATIVE, narrative[0]); } } }