From b2bef47100370e1248834523d73a630950032d7a Mon Sep 17 00:00:00 2001 From: James Date: Tue, 27 Jun 2017 21:13:23 -0400 Subject: [PATCH] Work on refactor --- .../ca/uhn/fhir/model/api/IFhirVersion.java | 26 ++++++++++--------- .../fhir/rest/api/server/IRequestDetails.java | 4 ++- .../fhir/rest/api/server/IRestfulServer.java | 9 ------- .../fhir/rest/param/BaseQueryParameter.java | 4 +-- .../BaseHttpClientInvocationWithContents.java | 2 +- .../BaseResourceReturningMethodBinding.java | 2 +- .../rest/client/method/PageMethodBinding.java | 2 +- .../rest/api/server/IFhirVersionServer.java | 22 ++++++++++++++++ .../IVersionSpecificBundleFactory.java | 5 ++-- .../BaseResourceReturningMethodBinding.java | 1 - .../rest/server/method/PageMethodBinding.java | 1 - 11 files changed, 46 insertions(+), 32 deletions(-) delete mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/server/IRestfulServer.java create mode 100644 hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/IFhirVersionServer.java rename {hapi-fhir-base/src/main/java/ca/uhn/fhir/context/api => hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server}/IVersionSpecificBundleFactory.java (94%) diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IFhirVersion.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IFhirVersion.java index 70873dc5a71..69725f6ba0f 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IFhirVersion.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/IFhirVersion.java @@ -23,24 +23,28 @@ package ca.uhn.fhir.model.api; import java.io.InputStream; import java.util.Date; -import org.hl7.fhir.instance.model.api.*; +import org.hl7.fhir.instance.model.api.IBase; +import org.hl7.fhir.instance.model.api.IBaseResource; +import org.hl7.fhir.instance.model.api.IIdType; +import org.hl7.fhir.instance.model.api.IPrimitiveType; -import ca.uhn.fhir.context.*; -import ca.uhn.fhir.context.api.IVersionSpecificBundleFactory; +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.context.FhirVersionEnum; +import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.context.support.IContextValidationSupport; import ca.uhn.fhir.fluentpath.IFluentPath; -import ca.uhn.fhir.rest.server.IResourceProvider; -import ca.uhn.fhir.rest.server.IServerConformanceProvider; -import ca.uhn.fhir.rest.server.RestfulServer; +/** + * Each structure version JAR will have an implementation of this interface. + * This is used internally by HAPI and subject to change. Do not use this interface + * directly in user code. + * + * See also IFhirVersionServer for the hapi-fhir-server equivalent. + */ public interface IFhirVersion { IFluentPath createFluentPathExecutor(FhirContext theFhirContext); - IServerConformanceProvider createServerConformanceProvider(RestfulServer theRestfulServer); - - IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer); - IContextValidationSupport createValidationSupport(); IBaseResource generateProfile(RuntimeResourceDefinition theRuntimeResourceDefinition, String theServerBase); @@ -57,8 +61,6 @@ public interface IFhirVersion { FhirVersionEnum getVersion(); - IVersionSpecificBundleFactory newBundleFactory(FhirContext theContext); - IBase newCodingDt(); IIdType newIdType(); diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/server/IRequestDetails.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/server/IRequestDetails.java index 4b8f551544d..59174f9ad07 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/server/IRequestDetails.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/server/IRequestDetails.java @@ -2,12 +2,14 @@ package ca.uhn.fhir.rest.api.server; import java.util.*; +import ca.uhn.fhir.context.FhirContext; + public interface IRequestDetails { Map getParameters(); Map> getUnqualifiedToQualifiedNames(); - IRestfulServer getServer(); + FhirContext getFhirContext(); } diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/server/IRestfulServer.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/server/IRestfulServer.java deleted file mode 100644 index 121990b1736..00000000000 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/server/IRestfulServer.java +++ /dev/null @@ -1,9 +0,0 @@ -package ca.uhn.fhir.rest.api.server; - -import ca.uhn.fhir.context.FhirContext; - -public interface IRestfulServer { - - FhirContext getFhirContext(); - -} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/BaseQueryParameter.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/BaseQueryParameter.java index 4626da05825..7c5fcf9f631 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/BaseQueryParameter.java +++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/param/BaseQueryParameter.java @@ -143,12 +143,12 @@ public abstract class BaseQueryParameter implements IParameter { ourLog.debug("No value for parameter '{}' - Qualified names {} and qualifier whitelist {}", new Object[] { getName(), qualified, getQualifierWhitelist() }); if (handlesMissing()) { - return parse(theRequest.getServer().getFhirContext(), paramList); + return parse(theRequest.getFhirContext(), paramList); } return null; } - return parse(theRequest.getServer().getFhirContext(), paramList); + return parse(theRequest.getFhirContext(), paramList); } diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java index 071e5238757..a8c87854c3b 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseHttpClientInvocationWithContents.java @@ -33,13 +33,13 @@ import org.hl7.fhir.instance.model.api.IIdType; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; -import ca.uhn.fhir.context.api.IVersionSpecificBundleFactory; import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.TagList; import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.parser.DataFormatException; import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.rest.api.RequestTypeEnum; +import ca.uhn.fhir.rest.api.server.IVersionSpecificBundleFactory; import ca.uhn.fhir.rest.client.api.IHttpClient; import ca.uhn.fhir.rest.client.api.IHttpRequest; import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation; diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseResourceReturningMethodBinding.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseResourceReturningMethodBinding.java index 2c48f33801c..75432f8593a 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseResourceReturningMethodBinding.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/BaseResourceReturningMethodBinding.java @@ -35,7 +35,6 @@ import org.hl7.fhir.instance.model.api.IPrimitiveType; import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; -import ca.uhn.fhir.context.api.IVersionSpecificBundleFactory; import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.Include; @@ -44,6 +43,7 @@ import ca.uhn.fhir.parser.IParser; import ca.uhn.fhir.rest.api.MethodOutcome; import ca.uhn.fhir.rest.api.RequestTypeEnum; import ca.uhn.fhir.rest.api.SummaryEnum; +import ca.uhn.fhir.rest.api.server.IVersionSpecificBundleFactory; import ca.uhn.fhir.rest.client.exceptions.InvalidResponseException; import ca.uhn.fhir.rest.server.*; import ca.uhn.fhir.rest.server.RestfulServerUtils.ResponseEncoding; diff --git a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/PageMethodBinding.java b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/PageMethodBinding.java index 8851a9b63d0..06310879eac 100644 --- a/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/PageMethodBinding.java +++ b/hapi-fhir-client/src/main/java/ca/uhn/fhir/rest/client/method/PageMethodBinding.java @@ -30,12 +30,12 @@ import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseResource; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.api.IVersionSpecificBundleFactory; import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.rest.api.RequestTypeEnum; import ca.uhn.fhir.rest.api.RestOperationTypeEnum; +import ca.uhn.fhir.rest.api.server.IVersionSpecificBundleFactory; import ca.uhn.fhir.rest.client.impl.BaseHttpClientInvocation; import ca.uhn.fhir.rest.server.*; import ca.uhn.fhir.rest.server.RestfulServerUtils.ResponseEncoding; diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/IFhirVersionServer.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/IFhirVersionServer.java new file mode 100644 index 00000000000..4890b478b2a --- /dev/null +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/IFhirVersionServer.java @@ -0,0 +1,22 @@ +package ca.uhn.fhir.rest.api.server; + +import org.hl7.fhir.instance.model.api.IBaseResource; + +import ca.uhn.fhir.context.FhirContext; +import ca.uhn.fhir.model.api.IFhirVersion; +import ca.uhn.fhir.rest.server.IResourceProvider; +import ca.uhn.fhir.rest.server.IServerConformanceProvider; +import ca.uhn.fhir.rest.server.RestfulServer; + +/** + * This class is the server specific equivalent to {@link IFhirVersion} + */ +public interface IFhirVersionServer { + + IServerConformanceProvider createServerConformanceProvider(RestfulServer theRestfulServer); + + IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer); + + IVersionSpecificBundleFactory newBundleFactory(FhirContext theContext); + +} diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/api/IVersionSpecificBundleFactory.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/IVersionSpecificBundleFactory.java similarity index 94% rename from hapi-fhir-base/src/main/java/ca/uhn/fhir/context/api/IVersionSpecificBundleFactory.java rename to hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/IVersionSpecificBundleFactory.java index a2383ca5b9f..9ef8bf1de83 100644 --- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/api/IVersionSpecificBundleFactory.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/api/server/IVersionSpecificBundleFactory.java @@ -1,4 +1,4 @@ -package ca.uhn.fhir.context.api; +package ca.uhn.fhir.rest.api.server; /* * #%L @@ -24,12 +24,11 @@ import java.util.*; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IPrimitiveType; +import ca.uhn.fhir.context.api.BundleInclusionRule; import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.valueset.BundleTypeEnum; import ca.uhn.fhir.rest.api.EncodingEnum; -import ca.uhn.fhir.rest.api.server.IBundleProvider; -import ca.uhn.fhir.rest.api.server.IRestfulServer; /** * This interface should be considered experimental and will likely change in future releases of HAPI. Use with caution! diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseResourceReturningMethodBinding.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseResourceReturningMethodBinding.java index 137b4192792..7fecece4a46 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseResourceReturningMethodBinding.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/BaseResourceReturningMethodBinding.java @@ -35,7 +35,6 @@ import org.hl7.fhir.instance.model.api.IPrimitiveType; import ca.uhn.fhir.context.ConfigurationException; import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirVersionEnum; -import ca.uhn.fhir.context.api.IVersionSpecificBundleFactory; import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.IResource; import ca.uhn.fhir.model.api.Include; diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/PageMethodBinding.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/PageMethodBinding.java index bc6743b7157..38588baa11e 100644 --- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/PageMethodBinding.java +++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/PageMethodBinding.java @@ -30,7 +30,6 @@ import org.hl7.fhir.instance.model.api.IBase; import org.hl7.fhir.instance.model.api.IBaseResource; import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.api.IVersionSpecificBundleFactory; import ca.uhn.fhir.model.api.Bundle; import ca.uhn.fhir.model.api.Include; import ca.uhn.fhir.model.valueset.BundleTypeEnum;