From eddb98084dd8c7d2dd07b82038166101bd608c93 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Thu, 19 Sep 2019 15:48:58 -0400 Subject: [PATCH] Move PreferReturnEnum back to original location to avoid regressions --- .../android/client/GenericClientDstu3IT.java | 4 +-- .../ca/uhn/fhir/rest/api/PreferHeader.java | 32 ----------------- .../uhn/fhir/rest/api/PreferReturnEnum.java | 34 +++++++++++++++++++ .../uhn/fhir/rest/gclient/ICreateTyped.java | 4 +-- .../fhir/rest/gclient/IPatchExecutable.java | 4 +-- .../fhir/rest/gclient/IUpdateExecutable.java | 4 +-- .../okhttp/GenericOkHttpClientDstu2Test.java | 8 ++--- .../fhir/rest/client/impl/GenericClient.java | 20 +++++------ .../server/AbstractJaxRsPageProvider.java | 4 +-- .../server/AbstractJaxRsResourceProvider.java | 4 +-- .../client/GenericJaxRsClientDstu2Test.java | 8 ++--- .../client/GenericJaxRsClientDstu3Test.java | 8 ++--- ...bstractJaxRsResourceProviderDstu3Test.java | 4 +-- .../AbstractJaxRsResourceProviderTest.java | 4 +-- .../JaxRsPatientProviderDstu3Test.java | 6 ++-- .../example/JaxRsPatientProviderR4Test.java | 11 +++--- .../example/JaxRsPatientProviderTest.java | 6 ++-- .../fhir/jpa/dao/TransactionProcessor.java | 5 ++- ...sentInterceptorResourceProviderR4Test.java | 4 +-- .../provider/r4/ResourceProviderR4Test.java | 2 +- .../fhir/rest/api/server/IRestfulServer.java | 4 +-- .../uhn/fhir/rest/server/RestfulServer.java | 14 ++++---- .../fhir/rest/server/RestfulServerUtils.java | 2 +- .../BaseOutcomeReturningMethodBinding.java | 4 +-- .../rest/server/RestfulServerUtilsTest.java | 5 +-- .../rest/client/GenericClientDstu2_1Test.java | 12 +++---- .../rest/client/GenericClientDstu2Test.java | 8 ++--- .../rest/client/GenericClientDstu3Test.java | 12 +++---- .../fhir/rest/client/GenericClientR4Test.java | 12 +++---- .../ca/uhn/fhir/rest/server/CreateR4Test.java | 6 ++-- .../main/webapp/WEB-INF/templates/home.html | 6 ++-- .../main/webapp/WEB-INF/templates/result.html | 24 +++++++------ .../templates/tmpl-navbar-top-farright.html | 2 +- .../ca/uhn/fhir/jpa/test/OverlayTestApp.java | 30 ++++++++++++++-- .../karaf/client/FhirClientTest.java | 4 +-- 35 files changed, 175 insertions(+), 146 deletions(-) create mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/PreferReturnEnum.java diff --git a/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/client/GenericClientDstu3IT.java b/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/client/GenericClientDstu3IT.java index e11b26a920a..b61df6acb0a 100644 --- a/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/client/GenericClientDstu3IT.java +++ b/hapi-fhir-android/src/test/java/ca/uhn/fhir/android/client/GenericClientDstu3IT.java @@ -8,7 +8,7 @@ import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.Date; -import ca.uhn.fhir.rest.api.PreferHeader; +import ca.uhn.fhir.rest.api.PreferReturnEnum; import org.hl7.fhir.dstu3.model.*; import org.junit.*; import org.mockito.ArgumentCaptor; @@ -246,7 +246,7 @@ public class GenericClientDstu3IT { Patient pt = new Patient(); pt.getText().setDivAsString("A PATIENT"); - MethodOutcome outcome = client.create().resource(pt).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + MethodOutcome outcome = client.create().resource(pt).prefer(PreferReturnEnum.REPRESENTATION).execute(); assertNull(outcome.getOperationOutcome()); assertNotNull(outcome.getResource()); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/PreferHeader.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/PreferHeader.java index 9a0459e6ba5..0e1dfe34e97 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/PreferHeader.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/PreferHeader.java @@ -1,7 +1,6 @@ package ca.uhn.fhir.rest.api; import javax.annotation.Nullable; -import java.util.HashMap; public class PreferHeader { @@ -27,35 +26,4 @@ public class PreferHeader { return this; } - /** - * Represents values for "return" value as provided in the the HTTP Prefer header. - */ - public enum PreferReturnEnum { - - REPRESENTATION("representation"), MINIMAL("minimal"), OPERATION_OUTCOME("OperationOutcome"); - - private static HashMap ourValues; - private String myHeaderValue; - - PreferReturnEnum(String theHeaderValue) { - myHeaderValue = theHeaderValue; - } - - public String getHeaderValue() { - return myHeaderValue; - } - - public static PreferReturnEnum fromHeaderValue(String theHeaderValue) { - if (ourValues == null) { - HashMap values = new HashMap<>(); - for (PreferReturnEnum next : PreferReturnEnum.values()) { - values.put(next.getHeaderValue(), next); - } - ourValues = values; - } - return ourValues.get(theHeaderValue); - } - - } - } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/PreferReturnEnum.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/PreferReturnEnum.java new file mode 100644 index 00000000000..4037c9fce81 --- /dev/null +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/PreferReturnEnum.java @@ -0,0 +1,34 @@ +package ca.uhn.fhir.rest.api; + +import java.util.HashMap; + +/** + * Represents values for "return" value as provided in the the HTTP Prefer header. + */ +public enum PreferReturnEnum { + + REPRESENTATION("representation"), MINIMAL("minimal"), OPERATION_OUTCOME("OperationOutcome"); + + private static HashMap ourValues; + private String myHeaderValue; + + PreferReturnEnum(String theHeaderValue) { + myHeaderValue = theHeaderValue; + } + + public String getHeaderValue() { + return myHeaderValue; + } + + public static PreferReturnEnum fromHeaderValue(String theHeaderValue) { + if (ourValues == null) { + HashMap values = new HashMap<>(); + for (PreferReturnEnum next : PreferReturnEnum.values()) { + values.put(next.getHeaderValue(), next); + } + ourValues = values; + } + return ourValues.get(theHeaderValue); + } + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/ICreateTyped.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/ICreateTyped.java index a126d94e912..ea53ca9e005 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/ICreateTyped.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/gclient/ICreateTyped.java @@ -21,7 +21,7 @@ package ca.uhn.fhir.rest.gclient; */ import ca.uhn.fhir.rest.api.MethodOutcome; -import ca.uhn.fhir.rest.api.PreferHeader; +import ca.uhn.fhir.rest.api.PreferReturnEnum; public interface ICreateTyped extends IClientExecutable { @@ -47,6 +47,6 @@ public interface ICreateTyped extends IClientExecutable{ @@ -32,6 +32,6 @@ public interface IPatchExecutable extends IClientExecutable{ @@ -32,6 +32,6 @@ public interface IUpdateExecutable extends IClientExecutable implements ICreate, ICreateTyped, ICreateWithQuery, ICreateWithQueryTyped { private boolean myConditional; - private PreferHeader.PreferReturnEnum myPrefer; + private PreferReturnEnum myPrefer; private IBaseResource myResource; private String myResourceBody; private String mySearchUrl; @@ -580,7 +580,7 @@ public class GenericClient extends BaseClient implements IGenericClient { } @Override - public ICreateTyped prefer(PreferHeader.PreferReturnEnum theReturn) { + public ICreateTyped prefer(PreferReturnEnum theReturn) { myPrefer = theReturn; return this; } @@ -1380,13 +1380,13 @@ public class GenericClient extends BaseClient implements IGenericClient { } private final class OutcomeResponseHandler implements IClientResponseHandler { - private PreferHeader.PreferReturnEnum myPrefer; + private PreferReturnEnum myPrefer; private OutcomeResponseHandler() { super(); } - private OutcomeResponseHandler(PreferHeader.PreferReturnEnum thePrefer) { + private OutcomeResponseHandler(PreferReturnEnum thePrefer) { this(); myPrefer = thePrefer; } @@ -1396,7 +1396,7 @@ public class GenericClient extends BaseClient implements IGenericClient { MethodOutcome response = MethodUtil.process2xxResponse(myContext, theResponseStatusCode, theResponseMimeType, theResponseInputStream, theHeaders); response.setCreatedUsingStatusCode(theResponseStatusCode); - if (myPrefer == PreferHeader.PreferReturnEnum.REPRESENTATION) { + if (myPrefer == PreferReturnEnum.REPRESENTATION) { if (response.getResource() == null) { if (response.getId() != null && isNotBlank(response.getId().getValue()) && response.getId().hasBaseUrl()) { ourLog.info("Server did not return resource for Prefer-representation, going to fetch: {}", response.getId().getValue()); @@ -1418,7 +1418,7 @@ public class GenericClient extends BaseClient implements IGenericClient { private IIdType myId; private String myPatchBody; private PatchTypeEnum myPatchType; - private PreferHeader.PreferReturnEnum myPrefer; + private PreferReturnEnum myPrefer; private String myResourceType; private String mySearchUrl; @@ -1476,7 +1476,7 @@ public class GenericClient extends BaseClient implements IGenericClient { } @Override - public IPatchExecutable prefer(PreferHeader.PreferReturnEnum theReturn) { + public IPatchExecutable prefer(PreferReturnEnum theReturn) { myPrefer = theReturn; return this; } @@ -2048,7 +2048,7 @@ public class GenericClient extends BaseClient implements IGenericClient { private boolean myConditional; private IIdType myId; - private PreferHeader.PreferReturnEnum myPrefer; + private PreferReturnEnum myPrefer; private IBaseResource myResource; private String myResourceBody; private String mySearchUrl; @@ -2102,7 +2102,7 @@ public class GenericClient extends BaseClient implements IGenericClient { } @Override - public IUpdateExecutable prefer(PreferHeader.PreferReturnEnum theReturn) { + public IUpdateExecutable prefer(PreferReturnEnum theReturn) { myPrefer = theReturn; return this; } @@ -2282,7 +2282,7 @@ public class GenericClient extends BaseClient implements IGenericClient { params.get(parameterName).add(parameterValue); } - private static void addPreferHeader(PreferHeader.PreferReturnEnum thePrefer, BaseHttpClientInvocation theInvocation) { + private static void addPreferHeader(PreferReturnEnum thePrefer, BaseHttpClientInvocation theInvocation) { if (thePrefer != null) { theInvocation.addHeader(Constants.HEADER_PREFER, Constants.HEADER_PREFER_RETURN + '=' + thePrefer.getHeaderValue()); } diff --git a/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsPageProvider.java b/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsPageProvider.java index 64f0cc7d236..131187d4197 100644 --- a/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsPageProvider.java +++ b/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsPageProvider.java @@ -112,8 +112,8 @@ public abstract class AbstractJaxRsPageProvider extends AbstractJaxRsProvider im } @Override - public PreferHeader.PreferReturnEnum getDefaultPreferReturn() { - return PreferHeader.PreferReturnEnum.REPRESENTATION; + public PreferReturnEnum getDefaultPreferReturn() { + return PreferReturnEnum.REPRESENTATION; } } diff --git a/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProvider.java b/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProvider.java index 0c3d2a6544e..1f74e8a8955 100644 --- a/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProvider.java +++ b/hapi-fhir-jaxrsserver-base/src/main/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProvider.java @@ -370,8 +370,8 @@ implements IRestfulServer, IResourceProvider { } @Override - public PreferHeader.PreferReturnEnum getDefaultPreferReturn() { - return PreferHeader.PreferReturnEnum.REPRESENTATION; + public PreferReturnEnum getDefaultPreferReturn() { + return PreferReturnEnum.REPRESENTATION; } /** diff --git a/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu2Test.java b/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu2Test.java index 014390c674a..c45919cc76d 100644 --- a/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu2Test.java +++ b/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu2Test.java @@ -301,12 +301,12 @@ public class GenericJaxRsClientDstu2Test { Patient p = new Patient(); p.addName().addFamily("FOOFAMILY"); - client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute(); + client.create().resource(p).prefer(PreferReturnEnum.MINIMAL).execute(); assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size()); assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue()); - client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + client.create().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute(); assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size()); assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue()); @@ -1937,12 +1937,12 @@ public class GenericJaxRsClientDstu2Test { p.setId(new IdDt("1")); p.addName().addFamily("FOOFAMILY"); - client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute(); + client.update().resource(p).prefer(PreferReturnEnum.MINIMAL).execute(); assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size()); assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue()); - client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + client.update().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute(); assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size()); assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue()); diff --git a/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu3Test.java b/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu3Test.java index 4b6b5da307d..b7d1ffb7dbe 100644 --- a/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu3Test.java +++ b/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/client/GenericJaxRsClientDstu3Test.java @@ -321,12 +321,12 @@ public class GenericJaxRsClientDstu3Test { Patient p = new Patient(); p.addName().setFamily("FOOFAMILY"); - client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute(); + client.create().resource(p).prefer(PreferReturnEnum.MINIMAL).execute(); assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size()); assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue()); - client.create().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + client.create().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute(); assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size()); assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue()); @@ -1990,12 +1990,12 @@ public class GenericJaxRsClientDstu3Test { p.setId(new IdType("1")); p.addName().setFamily("FOOFAMILY"); - client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.MINIMAL).execute(); + client.update().resource(p).prefer(PreferReturnEnum.MINIMAL).execute(); assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size()); assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_MINIMAL, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue()); - client.update().resource(p).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + client.update().resource(p).prefer(PreferReturnEnum.REPRESENTATION).execute(); assertEquals(1, ourRequestHeaders.get(Constants.HEADER_PREFER).size()); assertEquals(Constants.HEADER_PREFER_RETURN + '=' + Constants.HEADER_PREFER_RETURN_REPRESENTATION, ourRequestHeaders.get(Constants.HEADER_PREFER).get(0).getValue()); diff --git a/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProviderDstu3Test.java b/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProviderDstu3Test.java index 345231b2427..c2ac1525c42 100644 --- a/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProviderDstu3Test.java +++ b/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProviderDstu3Test.java @@ -135,7 +135,7 @@ public class AbstractJaxRsResourceProviderDstu3Test { client.setEncoding(EncodingEnum.JSON); MethodOutcome response = client.create().resource(toCreate).conditional() - .where(Patient.IDENTIFIER.exactly().identifier("2")).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + .where(Patient.IDENTIFIER.exactly().identifier("2")).prefer(PreferReturnEnum.REPRESENTATION).execute(); assertEquals("myIdentifier", patientCaptor.getValue().getIdentifier().get(0).getValue()); IBaseResource resource = response.getResource(); @@ -158,7 +158,7 @@ public class AbstractJaxRsResourceProviderDstu3Test { when(mock.create(patientCaptor.capture(), isNull(String.class))).thenReturn(outcome); client.setEncoding(EncodingEnum.JSON); - final MethodOutcome response = client.create().resource(toCreate).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION) + final MethodOutcome response = client.create().resource(toCreate).prefer(PreferReturnEnum.REPRESENTATION) .execute(); IBaseResource resource = response.getResource(); compareResultId(1, resource); diff --git a/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProviderTest.java b/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProviderTest.java index 75c5331038d..fb3e1b1d911 100644 --- a/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProviderTest.java +++ b/hapi-fhir-jaxrsserver-base/src/test/java/ca/uhn/fhir/jaxrs/server/AbstractJaxRsResourceProviderTest.java @@ -131,7 +131,7 @@ public class AbstractJaxRsResourceProviderTest { client.setEncoding(EncodingEnum.JSON); MethodOutcome response = client.create().resource(toCreate).conditional() - .where(Patient.IDENTIFIER.exactly().identifier("2")).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + .where(Patient.IDENTIFIER.exactly().identifier("2")).prefer(PreferReturnEnum.REPRESENTATION).execute(); assertEquals("myIdentifier", patientCaptor.getValue().getIdentifierFirstRep().getValue()); IResource resource = (IResource) response.getResource(); @@ -154,7 +154,7 @@ public class AbstractJaxRsResourceProviderTest { when(mock.create(patientCaptor.capture(), isNull(String.class))).thenReturn(outcome); client.setEncoding(EncodingEnum.JSON); - final MethodOutcome response = client.create().resource(toCreate).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION) + final MethodOutcome response = client.create().resource(toCreate).prefer(PreferReturnEnum.REPRESENTATION) .execute(); IResource resource = (IResource) response.getResource(); compareResultId(1, resource); diff --git a/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderDstu3Test.java b/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderDstu3Test.java index a475778725e..9c3db5e1244 100644 --- a/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderDstu3Test.java +++ b/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderDstu3Test.java @@ -138,7 +138,7 @@ public class JaxRsPatientProviderDstu3Test { existing.setId((IdType) null); existing.getName().add(new HumanName().setFamily("Created Patient 54")); client.setEncoding(EncodingEnum.JSON); - final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute(); System.out.println(results.getId()); final Patient patient = (Patient) results.getResource(); System.out.println(patient); @@ -154,7 +154,7 @@ public class JaxRsPatientProviderDstu3Test { existing.setId((IdType) null); existing.getName().add(new HumanName().setFamily("Created Patient 54")); client.setEncoding(EncodingEnum.XML); - final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute(); System.out.println(results.getId()); final Patient patient = (Patient) results.getResource(); @@ -187,7 +187,7 @@ public class JaxRsPatientProviderDstu3Test { public void testDeletePatient() { final Patient existing = new Patient(); existing.getName().add(new HumanName().setFamily("Created Patient XYZ")); - final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute(); System.out.println(results.getId()); final Patient patient = (Patient) results.getResource(); client.delete().resourceById(patient.getIdElement()).execute(); diff --git a/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderR4Test.java b/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderR4Test.java index 761cd388b19..414d5167675 100644 --- a/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderR4Test.java +++ b/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderR4Test.java @@ -5,10 +5,7 @@ import ca.uhn.fhir.jaxrs.client.JaxRsRestfulClientFactory; import ca.uhn.fhir.model.primitive.BoundCodeDt; import ca.uhn.fhir.model.primitive.IdDt; import ca.uhn.fhir.model.valueset.BundleEntryTransactionMethodEnum; -import ca.uhn.fhir.rest.api.EncodingEnum; -import ca.uhn.fhir.rest.api.MethodOutcome; -import ca.uhn.fhir.rest.api.PreferHeader; -import ca.uhn.fhir.rest.api.SearchStyleEnum; +import ca.uhn.fhir.rest.api.*; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; @@ -152,7 +149,7 @@ public class JaxRsPatientProviderR4Test { existing.setId((IdDt) null); existing.getNameFirstRep().setFamily("Created Patient 54"); client.setEncoding(EncodingEnum.JSON); - final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute(); System.out.println(results.getId()); final Patient patient = (Patient) results.getResource(); System.out.println(patient); @@ -167,7 +164,7 @@ public class JaxRsPatientProviderR4Test { existing.setId((IdDt) null); existing.getNameFirstRep().setFamily("Created Patient 54"); client.setEncoding(EncodingEnum.XML); - final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute(); System.out.println(results.getId()); final Patient patient = (Patient) results.getResource(); @@ -199,7 +196,7 @@ public class JaxRsPatientProviderR4Test { public void testDeletePatient() { final Patient existing = new Patient(); existing.getNameFirstRep().setFamily("Created Patient XYZ"); - final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute(); System.out.println(results.getId()); final Patient patient = (Patient) results.getResource(); client.delete().resource(patient).execute(); diff --git a/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderTest.java b/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderTest.java index 71803f9756f..215ba2bf300 100644 --- a/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderTest.java +++ b/hapi-fhir-jaxrsserver-example/src/test/java/ca/uhn/fhir/jaxrs/server/example/JaxRsPatientProviderTest.java @@ -149,7 +149,7 @@ public class JaxRsPatientProviderTest { existing.setId((IdDt) null); existing.getNameFirstRep().addFamily("Created Patient 54"); client.setEncoding(EncodingEnum.JSON); - final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute(); System.out.println(results.getId()); final Patient patient = (Patient) results.getResource(); System.out.println(patient); @@ -164,7 +164,7 @@ public class JaxRsPatientProviderTest { existing.setId((IdDt) null); existing.getNameFirstRep().addFamily("Created Patient 54"); client.setEncoding(EncodingEnum.XML); - final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute(); System.out.println(results.getId()); final Patient patient = (Patient) results.getResource(); @@ -196,7 +196,7 @@ public class JaxRsPatientProviderTest { public void testDeletePatient() { final Patient existing = new Patient(); existing.getNameFirstRep().addFamily("Created Patient XYZ"); - final MethodOutcome results = client.create().resource(existing).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + final MethodOutcome results = client.create().resource(existing).prefer(PreferReturnEnum.REPRESENTATION).execute(); System.out.println(results.getId()); final Patient patient = (Patient) results.getResource(); client.delete().resourceById(patient.getId()).execute(); diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java index 93cafb602e6..5dcdd2e90eb 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/TransactionProcessor.java @@ -64,7 +64,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.support.TransactionCallback; import org.springframework.transaction.support.TransactionTemplate; import javax.persistence.EntityManager; @@ -185,9 +184,9 @@ public class TransactionProcessor { if (theRequestDetails != null) { if (outcome.getResource() != null) { String prefer = theRequestDetails.getHeader(Constants.HEADER_PREFER); - PreferHeader.PreferReturnEnum preferReturn = RestfulServerUtils.parsePreferHeader(null, prefer).getReturn(); + PreferReturnEnum preferReturn = RestfulServerUtils.parsePreferHeader(null, prefer).getReturn(); if (preferReturn != null) { - if (preferReturn == PreferHeader.PreferReturnEnum.REPRESENTATION) { + if (preferReturn == PreferReturnEnum.REPRESENTATION) { outcome.fireResourceViewCallbacks(); myVersionAdapter.setResource(newEntry, outcome.getResource()); } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java index 005a4fce51f..ae4b221e433 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ConsentInterceptorResourceProviderR4Test.java @@ -4,7 +4,7 @@ import ca.uhn.fhir.jpa.config.BaseConfig; import ca.uhn.fhir.jpa.config.TestR4Config; import ca.uhn.fhir.jpa.dao.DaoConfig; import ca.uhn.fhir.rest.api.Constants; -import ca.uhn.fhir.rest.api.PreferHeader; +import ca.uhn.fhir.rest.api.PreferReturnEnum; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.client.interceptor.CapturingInterceptor; import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException; @@ -349,7 +349,7 @@ public class ConsentInterceptorResourceProviderR4Test extends BaseResourceProvid Patient patient = new Patient(); patient.setActive(true); - IIdType id = ourClient.create().resource(patient).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute().getId().toUnqualifiedVersionless(); + IIdType id = ourClient.create().resource(patient).prefer(PreferReturnEnum.REPRESENTATION).execute().getId().toUnqualifiedVersionless(); DelegatingConsentService consentService = new DelegatingConsentService(); myConsentInterceptor = new ConsentInterceptor(consentService, IConsentContextServices.NULL_IMPL); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java index ee180009174..2c25bc2c640 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4Test.java @@ -683,7 +683,7 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test { .create() .resource(p) .conditionalByUrl("Patient?identifier=foo|bar") - .prefer(PreferHeader.PreferReturnEnum.REPRESENTATION) + .prefer(PreferReturnEnum.REPRESENTATION) .execute(); assertEquals(id.getIdPart(), outcome.getId().getIdPart()); diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/IRestfulServer.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/IRestfulServer.java index 29745b1ace6..8c076e5842c 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/IRestfulServer.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/IRestfulServer.java @@ -1,7 +1,7 @@ package ca.uhn.fhir.rest.api.server; import ca.uhn.fhir.context.api.BundleInclusionRule; -import ca.uhn.fhir.rest.api.PreferHeader; +import ca.uhn.fhir.rest.api.PreferReturnEnum; import ca.uhn.fhir.rest.server.IPagingProvider; import ca.uhn.fhir.rest.server.IRestfulServerDefaults; @@ -31,6 +31,6 @@ public interface IRestfulServer extends IRestfulServer BundleInclusionRule getBundleInclusionRule(); - PreferHeader.PreferReturnEnum getDefaultPreferReturn(); + PreferReturnEnum getDefaultPreferReturn(); } diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java index ebaa0684368..5921e6ba67f 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java @@ -98,9 +98,9 @@ public class RestfulServer extends HttpServlet implements IRestfulServerPrefer header. *

* This setting changes the default behaviour if no Prefer header is supplied by the client. - * The default is {@link PreferHeader.PreferReturnEnum#REPRESENTATION} + * The default is {@link PreferReturnEnum#REPRESENTATION} *

* * @see HL7 FHIR Specification section on the Prefer header */ @Override - public PreferHeader.PreferReturnEnum getDefaultPreferReturn() { + public PreferReturnEnum getDefaultPreferReturn() { return myDefaultPreferReturn; } @@ -1786,12 +1786,12 @@ public class RestfulServer extends HttpServlet implements IRestfulServerPrefer header. *

* This setting changes the default behaviour if no Prefer header is supplied by the client. - * The default is {@link PreferHeader.PreferReturnEnum#REPRESENTATION} + * The default is {@link PreferReturnEnum#REPRESENTATION} *

* * @see HL7 FHIR Specification section on the Prefer header */ - public void setDefaultPreferReturn(PreferHeader.PreferReturnEnum theDefaultPreferReturn) { + public void setDefaultPreferReturn(PreferReturnEnum theDefaultPreferReturn) { Validate.notNull(theDefaultPreferReturn, "theDefaultPreferReturn must not be null"); myDefaultPreferReturn = theDefaultPreferReturn; } diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java index e27ad31748e..5246f524173 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/RestfulServerUtils.java @@ -704,7 +704,7 @@ public class RestfulServerUtils { value = value.substring(1, value.length() - 1); } - retVal.setReturn(PreferHeader.PreferReturnEnum.fromHeaderValue(value)); + retVal.setReturn(PreferReturnEnum.fromHeaderValue(value)); } else if (key.equals(Constants.HEADER_PREFER_RESPOND_ASYNC)) { diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseOutcomeReturningMethodBinding.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseOutcomeReturningMethodBinding.java index f66e1699936..5a4e95c5543 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseOutcomeReturningMethodBinding.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseOutcomeReturningMethodBinding.java @@ -184,8 +184,8 @@ abstract class BaseOutcomeReturningMethodBinding extends BaseMethodBinding - + Conformance @@ -240,7 +242,7 @@

Bundle contains no entries - + @@ -307,8 +309,8 @@ - - + + @@ -328,13 +330,15 @@ diff --git a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-navbar-top-farright.html b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-navbar-top-farright.html index ccb7f837fd7..4eb13a64d3b 100644 --- a/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-navbar-top-farright.html +++ b/hapi-fhir-testpage-overlay/src/main/webapp/WEB-INF/templates/tmpl-navbar-top-farright.html @@ -1,4 +1,4 @@ diff --git a/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/OverlayTestApp.java b/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/OverlayTestApp.java index f2572ab2b33..38e511c6caf 100644 --- a/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/OverlayTestApp.java +++ b/hapi-fhir-testpage-overlay/src/test/java/ca/uhn/fhir/jpa/test/OverlayTestApp.java @@ -1,5 +1,6 @@ package ca.uhn.fhir.jpa.test; +import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -26,6 +27,8 @@ import ca.uhn.fhir.rest.param.DateRangeParam; import ca.uhn.fhir.rest.param.TokenOrListParam; import ca.uhn.fhir.rest.server.IResourceProvider; +import javax.annotation.Nonnull; + public class OverlayTestApp { private static AnnotationConfigApplicationContext ourAppCtx; @@ -156,14 +159,37 @@ public class OverlayTestApp { @Search public List findDiagnosticReportsByPatient(@RequiredParam(name = DiagnosticReport.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER) IdentifierDt thePatientId, @OptionalParam(name = DiagnosticReport.SP_CODE) TokenOrListParam theNames, @OptionalParam(name = DiagnosticReport.SP_DATE) DateRangeParam theDateRange, @IncludeParam(allow = { "DiagnosticReport.result" }) Set theIncludes) throws Exception { - return null; + return getDiagnosticReports(); } @Description(shortDefinition = "This is a query by issued.. blah blah foo bar blah blah") @Search public List findDiagnosticReportsByPatientIssued(@RequiredParam(name = DiagnosticReport.SP_SUBJECT + '.' + Patient.SP_IDENTIFIER) IdentifierDt thePatientId, @OptionalParam(name = DiagnosticReport.SP_CODE) TokenOrListParam theNames, @OptionalParam(name = DiagnosticReport.SP_ISSUED) DateRangeParam theDateRange, @IncludeParam(allow = { "DiagnosticReport.result" }) Set theIncludes) throws Exception { - return null; + return getDiagnosticReports(); + } + + @Description(shortDefinition = "This is a query by issued.. blah blah foo bar blah blah") + @Search + public List findDiagnosticReportsByPatientIssued() throws Exception { + return getDiagnosticReports(); + } + + @Nonnull + private List getDiagnosticReports() { + ArrayList retVal = new ArrayList<>(); + + DiagnosticReport dr = new DiagnosticReport(); + dr.addResult().setReference("Observation/123"); + dr.setId("DiagnosticReport/1"); + retVal.add(dr); + + dr = new DiagnosticReport(); + dr.addResult().setReference("Observation/123"); + dr.setId("DiagnosticReport/2"); + retVal.add(dr); + + return retVal; } @Override diff --git a/osgi/hapi-fhir-karaf-integration-tests/src/test/java/ca/uhn/fhir/tests/integration/karaf/client/FhirClientTest.java b/osgi/hapi-fhir-karaf-integration-tests/src/test/java/ca/uhn/fhir/tests/integration/karaf/client/FhirClientTest.java index e6852ba8067..55e3a507524 100644 --- a/osgi/hapi-fhir-karaf-integration-tests/src/test/java/ca/uhn/fhir/tests/integration/karaf/client/FhirClientTest.java +++ b/osgi/hapi-fhir-karaf-integration-tests/src/test/java/ca/uhn/fhir/tests/integration/karaf/client/FhirClientTest.java @@ -3,7 +3,7 @@ package ca.uhn.fhir.tests.integration.karaf.client; import java.io.IOException; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.rest.api.MethodOutcome; -import ca.uhn.fhir.rest.api.PreferHeader; +import ca.uhn.fhir.rest.api.PreferReturnEnum; import ca.uhn.fhir.rest.client.api.IGenericClient; import org.hl7.fhir.dstu3.model.Patient; import org.junit.Ignore; @@ -56,7 +56,7 @@ public class FhirClientTest { patient.setId("PATIENTID"); patient.getMeta().addProfile("http://BAR"); patient.addName().addGiven("GIVEN"); - MethodOutcome execute = client.create().resource(patient).prefer(PreferHeader.PreferReturnEnum.REPRESENTATION).execute(); + MethodOutcome execute = client.create().resource(patient).prefer(PreferReturnEnum.REPRESENTATION).execute(); ourLog.info(execute.toString()); }