diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_1_0/1855-remove-server-profile-provider.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_1_0/1855-remove-server-profile-provider.yaml new file mode 100644 index 00000000000..5b9d47cac66 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_1_0/1855-remove-server-profile-provider.yaml @@ -0,0 +1,11 @@ +--- +type: remove +issue: 1855 +title: "A very old feature that is not believed to be used anywhere has been removed: The ServerProfileProvider is + a special resource provider that was automatically registered to HAPI FHIR REST servers, and served up StructureDefinitions + that were registered to the FhirContext. Registering custom StructureDefinitions against the FhirContext for exposure through + the REST API (as what was then the /Profile endpoint) was planned to be a common feature during the DSTU1 lifecycle but + did not turn out to be a useful approach. This feature was mostly forgotten about until the logic for selecting resource + provider handler methods was revamped and the old mechanism suddenly became the default resource provider for StructureDefinition + resources in the JPA server. We don't expect any negative impact by this change, please post in our mailing list if you + disagree." diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4StructureDefinitionTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4StructureDefinitionTest.java index ad52e73f723..8b1c690fe71 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4StructureDefinitionTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/ResourceProviderR4StructureDefinitionTest.java @@ -4,13 +4,16 @@ import ca.uhn.fhir.jpa.model.util.JpaConstants; import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.util.TestUtil; +import org.hl7.fhir.instance.model.api.IIdType; +import org.hl7.fhir.r4.model.Bundle; import org.hl7.fhir.r4.model.IdType; import org.hl7.fhir.r4.model.Parameters; import org.hl7.fhir.r4.model.StringType; import org.hl7.fhir.r4.model.StructureDefinition; -import org.hl7.fhir.instance.model.api.IIdType; import org.junit.AfterClass; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; @@ -18,9 +21,22 @@ import static org.junit.Assert.assertEquals; public class ResourceProviderR4StructureDefinitionTest extends BaseResourceProviderR4Test { - @AfterClass - public static void afterClassClearContext() { - TestUtil.clearAllStaticFieldsForUnitTest(); + private static final Logger ourLog = LoggerFactory.getLogger(ResourceProviderR4StructureDefinitionTest.class); + + @Test + public void testSearchAllStructureDefinitions() throws IOException { + StructureDefinition sd = loadResource(myFhirCtx, StructureDefinition.class, "/r4/sd-david-dhtest7.json"); + myStructureDefinitionDao.update(sd); + + Bundle response = ourClient + .search() + .forResource(StructureDefinition.class) + .returnBundle(Bundle.class) + .execute(); + + ourLog.info(myFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(response)); + assertEquals(1, response.getEntry().size()); + assertEquals("dhtest7", response.getEntry().get(0).getResource().getIdElement().getIdPart()); } @Test @@ -37,7 +53,6 @@ public class ResourceProviderR4StructureDefinitionTest extends BaseResourceProvi assertEquals(51, response.getSnapshot().getElement().size()); } - @Test public void testSnapshotWithId() throws IOException { StructureDefinition sd = loadResourceFromClasspath(StructureDefinition.class, "/r4/profile-differential-patient-r4.json"); @@ -53,7 +68,6 @@ public class ResourceProviderR4StructureDefinitionTest extends BaseResourceProvi assertEquals(51, response.getSnapshot().getElement().size()); } - @Test public void testSnapshotWithUrl() throws IOException { StructureDefinition sd = loadResourceFromClasspath(StructureDefinition.class, "/r4/profile-differential-patient-r4.json"); @@ -98,4 +112,9 @@ public class ResourceProviderR4StructureDefinitionTest extends BaseResourceProvi assertEquals("HTTP 404 Not Found: No StructureDefiniton found with url = 'http://hl7.org/fhir/StructureDefinition/FOO'", e.getMessage()); } } + + @AfterClass + public static void afterClassClearContext() { + TestUtil.clearAllStaticFieldsForUnitTest(); + } } 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 index 611e2c70213..b3979ca26e6 100644 --- 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 @@ -34,6 +34,4 @@ public interface IFhirVersionServer { IServerConformanceProvider createServerConformanceProvider(RestfulServer theRestfulServer); - IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer); - } 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 3c80504455a..db3b8d23b76 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 @@ -859,11 +859,6 @@ public class RestfulServer extends HttpServlet implements IRestfulServer myPublished = InstantDt.withCurrentTime(); - public SimpleBundleProvider(List theList) { - this(theList, null); - } + /** + * Constructor + */ public SimpleBundleProvider(IBaseResource theResource) { this(Collections.singletonList(theResource)); } @@ -52,6 +52,13 @@ public class SimpleBundleProvider implements IBundleProvider { this(Collections.emptyList()); } + /** + * Constructor + */ + public SimpleBundleProvider(List theList) { + this(theList, null); + } + public SimpleBundleProvider(List theList, String theUuid) { myList = theList; myUuid = theUuid; diff --git a/hapi-fhir-server/src/test/java/ca/uhn/fhir/rest/server/RestfulServerTest.java b/hapi-fhir-server/src/test/java/ca/uhn/fhir/rest/server/RestfulServerTest.java index 315f18ff9b5..47527d507a8 100644 --- a/hapi-fhir-server/src/test/java/ca/uhn/fhir/rest/server/RestfulServerTest.java +++ b/hapi-fhir-server/src/test/java/ca/uhn/fhir/rest/server/RestfulServerTest.java @@ -102,10 +102,6 @@ public class RestfulServerTest { }; } - @Override - public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) { - return new MyResourceProvider(); - } } @SuppressWarnings("unused") diff --git a/hapi-fhir-structures-dstu2.1/src/main/java/org/hl7/fhir/dstu2016may/hapi/ctx/FhirServerDstu2_1.java b/hapi-fhir-structures-dstu2.1/src/main/java/org/hl7/fhir/dstu2016may/hapi/ctx/FhirServerDstu2_1.java index a2e67747476..2535c1d2853 100644 --- a/hapi-fhir-structures-dstu2.1/src/main/java/org/hl7/fhir/dstu2016may/hapi/ctx/FhirServerDstu2_1.java +++ b/hapi-fhir-structures-dstu2.1/src/main/java/org/hl7/fhir/dstu2016may/hapi/ctx/FhirServerDstu2_1.java @@ -1,11 +1,8 @@ package org.hl7.fhir.dstu2016may.hapi.ctx; -import org.hl7.fhir.dstu2016may.hapi.rest.server.ServerConformanceProvider; -import org.hl7.fhir.dstu2016may.hapi.rest.server.ServerProfileProvider; - import ca.uhn.fhir.rest.api.server.IFhirVersionServer; -import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.RestfulServer; +import org.hl7.fhir.dstu2016may.hapi.rest.server.ServerConformanceProvider; public class FhirServerDstu2_1 implements IFhirVersionServer { @@ -14,9 +11,4 @@ public class FhirServerDstu2_1 implements IFhirVersionServer { return new ServerConformanceProvider(theServer); } - @Override - public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) { - return new ServerProfileProvider(theRestfulServer); - } - } diff --git a/hapi-fhir-structures-dstu2.1/src/main/java/org/hl7/fhir/dstu2016may/hapi/rest/server/ServerProfileProvider.java b/hapi-fhir-structures-dstu2.1/src/main/java/org/hl7/fhir/dstu2016may/hapi/rest/server/ServerProfileProvider.java deleted file mode 100644 index 048e538447a..00000000000 --- a/hapi-fhir-structures-dstu2.1/src/main/java/org/hl7/fhir/dstu2016may/hapi/rest/server/ServerProfileProvider.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.hl7.fhir.dstu2016may.hapi.rest.server; - -/* - * #%L - * HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) - * %% - * Copyright (C) 2014 - 2015 University Health Network - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.RuntimeResourceDefinition; -import ca.uhn.fhir.rest.annotation.IdParam; -import ca.uhn.fhir.rest.annotation.Read; -import ca.uhn.fhir.rest.annotation.Search; -import ca.uhn.fhir.rest.server.IResourceProvider; -import ca.uhn.fhir.rest.server.RestfulServer; -import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; -import org.hl7.fhir.dstu2016may.model.IdType; -import org.hl7.fhir.dstu2016may.model.StructureDefinition; -import org.hl7.fhir.instance.model.api.IBaseResource; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class ServerProfileProvider implements IResourceProvider { - - private final FhirContext myContext; - private final RestfulServer myRestfulServer; - - public ServerProfileProvider(RestfulServer theServer) { - myContext = theServer.getFhirContext(); - myRestfulServer = theServer; - } - - @Override - public Class getResourceType() { - return StructureDefinition.class; - } - - @Read() - public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) { - RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); - if (retVal==null) { - return null; - } - String serverBase = getServerBase(theRequest); - return (StructureDefinition) retVal.toProfile(serverBase); - } - - @Search() - public List getAllProfiles(ServletRequestDetails theRequest) { - final String serverBase = getServerBase(theRequest); - List defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId()); - Collections.sort(defs, new Comparator() { - @Override - public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { - int cmp = theO1.getName().compareTo(theO2.getName()); - if (cmp==0) { - cmp=theO1.getResourceProfile(serverBase).compareTo(theO2.getResourceProfile(serverBase)); - } - return cmp; - }}); - ArrayList retVal = new ArrayList<>(); - for (RuntimeResourceDefinition next : defs) { - retVal.add((StructureDefinition) next.toProfile(serverBase)); - } - return retVal; - } - - private String getServerBase(ServletRequestDetails theHttpRequest) { - return myRestfulServer.getServerBaseForRequest(theHttpRequest); - } -} diff --git a/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/model/dstu2/FhirServerDstu2.java b/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/model/dstu2/FhirServerDstu2.java index 594dd58f153..e90f78d02b4 100644 --- a/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/model/dstu2/FhirServerDstu2.java +++ b/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/model/dstu2/FhirServerDstu2.java @@ -21,10 +21,8 @@ package ca.uhn.fhir.model.dstu2; */ import ca.uhn.fhir.rest.api.server.IFhirVersionServer; -import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.provider.dstu2.ServerConformanceProvider; -import ca.uhn.fhir.rest.server.provider.dstu2.ServerProfileProvider; public class FhirServerDstu2 implements IFhirVersionServer { @@ -33,9 +31,4 @@ public class FhirServerDstu2 implements IFhirVersionServer { return new ServerConformanceProvider(theServer); } - @Override - public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) { - return new ServerProfileProvider(theRestfulServer); - } - } diff --git a/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/rest/server/provider/dstu2/ServerProfileProvider.java b/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/rest/server/provider/dstu2/ServerProfileProvider.java deleted file mode 100644 index 09ae243b7d6..00000000000 --- a/hapi-fhir-structures-dstu2/src/main/java/ca/uhn/fhir/rest/server/provider/dstu2/ServerProfileProvider.java +++ /dev/null @@ -1,88 +0,0 @@ -package ca.uhn.fhir.rest.server.provider.dstu2; - -/* - * #%L - * HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) - * %% - * Copyright (C) 2014 - 2020 University Health Network - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.RuntimeResourceDefinition; -import ca.uhn.fhir.model.api.IResource; -import ca.uhn.fhir.model.dstu2.resource.StructureDefinition; -import ca.uhn.fhir.model.primitive.IdDt; -import ca.uhn.fhir.rest.annotation.IdParam; -import ca.uhn.fhir.rest.annotation.Read; -import ca.uhn.fhir.rest.annotation.Search; -import ca.uhn.fhir.rest.server.IResourceProvider; -import ca.uhn.fhir.rest.server.RestfulServer; -import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class ServerProfileProvider implements IResourceProvider { - - private final FhirContext myContext; - private final RestfulServer myRestfulServer; - - public ServerProfileProvider(RestfulServer theServer) { - myContext = theServer.getFhirContext(); - myRestfulServer = theServer; - } - - @Override - public Class getResourceType() { - return StructureDefinition.class; - } - - @Read() - public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdDt theId) { - RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); - if (retVal==null) { - return null; - } - String serverBase = getServerBase(theRequest); - return (StructureDefinition) retVal.toProfile(serverBase); - } - - @Search() - public List getAllProfiles(ServletRequestDetails theRequest) { - final String serverBase = getServerBase(theRequest); - List defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId()); - Collections.sort(defs, new Comparator() { - @Override - public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { - int cmp = theO1.getName().compareTo(theO2.getName()); - if (cmp==0) { - cmp=theO1.getResourceProfile(serverBase).compareTo(theO2.getResourceProfile(serverBase)); - } - return cmp; - }}); - ArrayList retVal = new ArrayList<>(); - for (RuntimeResourceDefinition next : defs) { - retVal.add((StructureDefinition) next.toProfile(serverBase)); - } - return retVal; - } - - private String getServerBase(ServletRequestDetails theHttpRequest) { - return myRestfulServer.getServerBaseForRequest(theHttpRequest); - } -} diff --git a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/FhirServerDstu3.java b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/FhirServerDstu3.java index 6f84a0de1d9..e05f36bb820 100644 --- a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/FhirServerDstu3.java +++ b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/ctx/FhirServerDstu3.java @@ -1,11 +1,8 @@ package org.hl7.fhir.dstu3.hapi.ctx; -import org.hl7.fhir.dstu3.hapi.rest.server.ServerCapabilityStatementProvider; -import org.hl7.fhir.dstu3.hapi.rest.server.ServerProfileProvider; - import ca.uhn.fhir.rest.api.server.IFhirVersionServer; -import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.RestfulServer; +import org.hl7.fhir.dstu3.hapi.rest.server.ServerCapabilityStatementProvider; public class FhirServerDstu3 implements IFhirVersionServer { @Override @@ -13,9 +10,4 @@ public class FhirServerDstu3 implements IFhirVersionServer { return new ServerCapabilityStatementProvider(theServer); } - @Override - public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) { - return new ServerProfileProvider(theRestfulServer); - } - } diff --git a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/rest/server/ServerProfileProvider.java b/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/rest/server/ServerProfileProvider.java deleted file mode 100644 index d20614fa32d..00000000000 --- a/hapi-fhir-structures-dstu3/src/main/java/org/hl7/fhir/dstu3/hapi/rest/server/ServerProfileProvider.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.hl7.fhir.dstu3.hapi.rest.server; - -/* - * #%L - * HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) - * %% - * Copyright (C) 2014 - 2015 University Health Network - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.RuntimeResourceDefinition; -import ca.uhn.fhir.rest.annotation.IdParam; -import ca.uhn.fhir.rest.annotation.Read; -import ca.uhn.fhir.rest.annotation.Search; -import ca.uhn.fhir.rest.server.IResourceProvider; -import ca.uhn.fhir.rest.server.RestfulServer; -import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; -import org.hl7.fhir.dstu3.model.IdType; -import org.hl7.fhir.dstu3.model.StructureDefinition; -import org.hl7.fhir.instance.model.api.IBaseResource; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class ServerProfileProvider implements IResourceProvider { - - private final FhirContext myContext; - private final RestfulServer myRestfulServer; - - public ServerProfileProvider(RestfulServer theServer) { - myContext = theServer.getFhirContext(); - myRestfulServer = theServer; - } - - @Override - public Class getResourceType() { - return StructureDefinition.class; - } - - @Read() - public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) { - RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); - if (retVal==null) { - return null; - } - String serverBase = getServerBase(theRequest); - return (StructureDefinition) retVal.toProfile(serverBase); - } - - @Search() - public List getAllProfiles(ServletRequestDetails theRequest) { - final String serverBase = getServerBase(theRequest); - List defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId()); - Collections.sort(defs, new Comparator() { - @Override - public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { - int cmp = theO1.getName().compareTo(theO2.getName()); - if (cmp==0) { - cmp=theO1.getResourceProfile(serverBase).compareTo(theO2.getResourceProfile(serverBase)); - } - return cmp; - }}); - ArrayList retVal = new ArrayList<>(); - for (RuntimeResourceDefinition next : defs) { - retVal.add((StructureDefinition) next.toProfile(serverBase)); - } - return retVal; - } - - private String getServerBase(ServletRequestDetails theHttpRequest) { - return myRestfulServer.getServerBaseForRequest(theHttpRequest); - } -} diff --git a/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/dstu2/hapi/ctx/FhirServerDstu2Hl7Org2.java b/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/dstu2/hapi/ctx/FhirServerDstu2Hl7Org2.java index 2031265d92e..bc83877b948 100644 --- a/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/dstu2/hapi/ctx/FhirServerDstu2Hl7Org2.java +++ b/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/dstu2/hapi/ctx/FhirServerDstu2Hl7Org2.java @@ -1,11 +1,8 @@ package org.hl7.fhir.dstu2.hapi.ctx; -import org.hl7.fhir.dstu2.hapi.rest.server.ServerConformanceProvider; -import org.hl7.fhir.dstu2.hapi.rest.server.ServerProfileProvider; - import ca.uhn.fhir.rest.api.server.IFhirVersionServer; -import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.RestfulServer; +import org.hl7.fhir.dstu2.hapi.rest.server.ServerConformanceProvider; public class FhirServerDstu2Hl7Org2 implements IFhirVersionServer { @@ -14,9 +11,4 @@ public class FhirServerDstu2Hl7Org2 implements IFhirVersionServer { return new ServerConformanceProvider(theServer); } - @Override - public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) { - return new ServerProfileProvider(theRestfulServer); - } - } diff --git a/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/dstu2/hapi/rest/server/ServerProfileProvider.java b/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/dstu2/hapi/rest/server/ServerProfileProvider.java deleted file mode 100644 index 02524de14e4..00000000000 --- a/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/dstu2/hapi/rest/server/ServerProfileProvider.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.hl7.fhir.dstu2.hapi.rest.server; - -/* - * #%L - * HAPI FHIR Structures - HL7.org DSTU2 - * %% - * Copyright (C) 2014 - 2015 University Health Network - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.RuntimeResourceDefinition; -import ca.uhn.fhir.rest.annotation.IdParam; -import ca.uhn.fhir.rest.annotation.Read; -import ca.uhn.fhir.rest.annotation.Search; -import ca.uhn.fhir.rest.server.IResourceProvider; -import ca.uhn.fhir.rest.server.RestfulServer; -import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; -import org.hl7.fhir.dstu2.model.IdType; -import org.hl7.fhir.dstu2.model.StructureDefinition; -import org.hl7.fhir.instance.model.api.IBaseResource; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class ServerProfileProvider implements IResourceProvider { - - private final FhirContext myContext; - private final RestfulServer myRestfulServer; - - public ServerProfileProvider(RestfulServer theServer) { - myContext = theServer.getFhirContext(); - myRestfulServer = theServer; - } - - @Override - public Class getResourceType() { - return StructureDefinition.class; - } - - @Read() - public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) { - RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); - if (retVal==null) { - return null; - } - String serverBase = getServerBase(theRequest); - return (StructureDefinition) retVal.toProfile(serverBase); - } - - @Search() - public List getAllProfiles(ServletRequestDetails theRequest) { - final String serverBase = getServerBase(theRequest); - List defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId()); - Collections.sort(defs, new Comparator() { - @Override - public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { - int cmp = theO1.getName().compareTo(theO2.getName()); - if (cmp==0) { - cmp=theO1.getResourceProfile(serverBase).compareTo(theO2.getResourceProfile(serverBase)); - } - return cmp; - }}); - ArrayList retVal = new ArrayList<>(); - for (RuntimeResourceDefinition next : defs) { - retVal.add((StructureDefinition) next.toProfile(serverBase)); - } - return retVal; - } - - private String getServerBase(ServletRequestDetails theHttpRequest) { - return myRestfulServer.getServerBaseForRequest(theHttpRequest); - } -} diff --git a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/FhirServerR4.java b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/FhirServerR4.java index eb5c05c4199..6557858b62a 100644 --- a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/FhirServerR4.java +++ b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/ctx/FhirServerR4.java @@ -1,10 +1,8 @@ package org.hl7.fhir.r4.hapi.ctx; import ca.uhn.fhir.rest.api.server.IFhirVersionServer; -import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.RestfulServer; import org.hl7.fhir.r4.hapi.rest.server.ServerCapabilityStatementProvider; -import org.hl7.fhir.r4.hapi.rest.server.ServerProfileProvider; public class FhirServerR4 implements IFhirVersionServer { @Override @@ -12,9 +10,4 @@ public class FhirServerR4 implements IFhirVersionServer { return new ServerCapabilityStatementProvider(theServer); } - @Override - public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) { - return new ServerProfileProvider(theRestfulServer); - } - } diff --git a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/rest/server/ServerProfileProvider.java b/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/rest/server/ServerProfileProvider.java deleted file mode 100644 index e47707ae6b6..00000000000 --- a/hapi-fhir-structures-r4/src/main/java/org/hl7/fhir/r4/hapi/rest/server/ServerProfileProvider.java +++ /dev/null @@ -1,86 +0,0 @@ -package org.hl7.fhir.r4.hapi.rest.server; - -/* - * #%L - * HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) - * %% - * Copyright (C) 2014 - 2015 University Health Network - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ -import java.util.*; - -import javax.servlet.http.HttpServletRequest; - -import ca.uhn.fhir.rest.api.server.RequestDetails; -import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.r4.model.IdType; -import org.hl7.fhir.r4.model.StructureDefinition; - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.RuntimeResourceDefinition; -import ca.uhn.fhir.rest.annotation.*; -import ca.uhn.fhir.rest.server.IResourceProvider; -import ca.uhn.fhir.rest.server.RestfulServer; - -public class ServerProfileProvider implements IResourceProvider { - - private final FhirContext myContext; - private final RestfulServer myRestfulServer; - - public ServerProfileProvider(RestfulServer theServer) { - myContext = theServer.getFhirContext(); - myRestfulServer = theServer; - } - - @Override - public Class getResourceType() { - return StructureDefinition.class; - } - - @Read() - public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) { - RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); - if (retVal==null) { - return null; - } - String serverBase = getServerBase(theRequest); - return (StructureDefinition) retVal.toProfile(serverBase); - } - - @Search() - public List getAllProfiles(ServletRequestDetails theRequest) { - final String serverBase = getServerBase(theRequest); - List defs = new ArrayList(myContext.getResourceDefinitionsWithExplicitId()); - Collections.sort(defs, new Comparator() { - @Override - public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { - int cmp = theO1.getName().compareTo(theO2.getName()); - if (cmp==0) { - cmp=theO1.getResourceProfile(serverBase).compareTo(theO2.getResourceProfile(serverBase)); - } - return cmp; - }}); - ArrayList retVal = new ArrayList(); - for (RuntimeResourceDefinition next : defs) { - retVal.add((StructureDefinition) next.toProfile(serverBase)); - } - return retVal; - } - - private String getServerBase(ServletRequestDetails theHttpRequest) { - return myRestfulServer.getServerBaseForRequest(theHttpRequest); - } -} diff --git a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/FhirServerR5.java b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/FhirServerR5.java index 98785cc7446..318ad9e578a 100644 --- a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/FhirServerR5.java +++ b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/ctx/FhirServerR5.java @@ -1,10 +1,8 @@ package org.hl7.fhir.r5.hapi.ctx; import ca.uhn.fhir.rest.api.server.IFhirVersionServer; -import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.RestfulServer; import org.hl7.fhir.r5.hapi.rest.server.ServerCapabilityStatementProvider; -import org.hl7.fhir.r5.hapi.rest.server.ServerProfileProvider; public class FhirServerR5 implements IFhirVersionServer { @Override @@ -12,9 +10,4 @@ public class FhirServerR5 implements IFhirVersionServer { return new ServerCapabilityStatementProvider(); } - @Override - public IResourceProvider createServerProfilesProvider(RestfulServer theRestfulServer) { - return new ServerProfileProvider(theRestfulServer); - } - } diff --git a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/rest/server/ServerProfileProvider.java b/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/rest/server/ServerProfileProvider.java deleted file mode 100644 index 212132d5098..00000000000 --- a/hapi-fhir-structures-r5/src/main/java/org/hl7/fhir/r5/hapi/rest/server/ServerProfileProvider.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.hl7.fhir.r5.hapi.rest.server; - -/* - * #%L - * HAPI FHIR Structures - DSTU2 (FHIR v1.0.0) - * %% - * Copyright (C) 2014 - 2015 University Health Network - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ - -import ca.uhn.fhir.context.FhirContext; -import ca.uhn.fhir.context.RuntimeResourceDefinition; -import ca.uhn.fhir.rest.annotation.IdParam; -import ca.uhn.fhir.rest.annotation.Read; -import ca.uhn.fhir.rest.annotation.Search; -import ca.uhn.fhir.rest.server.IResourceProvider; -import ca.uhn.fhir.rest.server.RestfulServer; -import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; -import org.hl7.fhir.instance.model.api.IBaseResource; -import org.hl7.fhir.r5.model.IdType; -import org.hl7.fhir.r5.model.StructureDefinition; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -public class ServerProfileProvider implements IResourceProvider { - - private final FhirContext myContext; - private final RestfulServer myRestfulServer; - - public ServerProfileProvider(RestfulServer theServer) { - myContext = theServer.getFhirContext(); - myRestfulServer = theServer; - } - - @Override - public Class getResourceType() { - return StructureDefinition.class; - } - - @Read() - public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) { - RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); - if (retVal==null) { - return null; - } - String serverBase = getServerBase(theRequest); - return (StructureDefinition) retVal.toProfile(serverBase); - } - - @Search() - public List getAllProfiles(ServletRequestDetails theRequest) { - final String serverBase = getServerBase(theRequest); - List defs = new ArrayList(myContext.getResourceDefinitionsWithExplicitId()); - Collections.sort(defs, new Comparator() { - @Override - public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { - int cmp = theO1.getName().compareTo(theO2.getName()); - if (cmp==0) { - cmp=theO1.getResourceProfile(serverBase).compareTo(theO2.getResourceProfile(serverBase)); - } - return cmp; - }}); - ArrayList retVal = new ArrayList(); - for (RuntimeResourceDefinition next : defs) { - retVal.add((StructureDefinition) next.toProfile(serverBase)); - } - return retVal; - } - - private String getServerBase(ServletRequestDetails theHttpRequest) { - return myRestfulServer.getServerBaseForRequest(theHttpRequest); - } -}