From 4e2db2b58b654313f462db784c4c17dd8f8ca744 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Thu, 11 Jan 2018 11:23:14 -0500 Subject: [PATCH] More work on multitenancy --- .../rest/server/ServerProfileProvider.java | 30 +++++++++---------- .../provider/dstu2/ServerProfileProvider.java | 23 +++++++------- .../rest/server/ServerProfileProvider.java | 30 +++++++++---------- .../instance/conf/ServerProfileProvider.java | 30 +++++++++---------- 4 files changed, 53 insertions(+), 60 deletions(-) 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 index 6fa08650fb4..048e538447a 100644 --- 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 @@ -20,17 +20,6 @@ package org.hl7.fhir.dstu2016may.hapi.rest.server; * #L% */ -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - -import org.hl7.fhir.dstu2016may.model.IdType; -import org.hl7.fhir.dstu2016may.model.StructureDefinition; -import org.hl7.fhir.instance.model.api.IBaseResource; - import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.rest.annotation.IdParam; @@ -38,6 +27,15 @@ 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 { @@ -55,7 +53,7 @@ public class ServerProfileProvider implements IResourceProvider { } @Read() - public StructureDefinition getProfileById(HttpServletRequest theRequest, @IdParam IdType theId) { + public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) { RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); if (retVal==null) { return null; @@ -65,9 +63,9 @@ public class ServerProfileProvider implements IResourceProvider { } @Search() - public List getAllProfiles(HttpServletRequest theRequest) { + public List getAllProfiles(ServletRequestDetails theRequest) { final String serverBase = getServerBase(theRequest); - List defs = new ArrayList(myContext.getResourceDefinitionsWithExplicitId()); + List defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId()); Collections.sort(defs, new Comparator() { @Override public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { @@ -77,14 +75,14 @@ public class ServerProfileProvider implements IResourceProvider { } return cmp; }}); - ArrayList retVal = new ArrayList(); + ArrayList retVal = new ArrayList<>(); for (RuntimeResourceDefinition next : defs) { retVal.add((StructureDefinition) next.toProfile(serverBase)); } return retVal; } - private String getServerBase(HttpServletRequest theHttpRequest) { + private String getServerBase(ServletRequestDetails theHttpRequest) { return myRestfulServer.getServerBaseForRequest(theHttpRequest); } } 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 index 51b0084f8d7..e37a4a4fe29 100644 --- 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 @@ -20,13 +20,6 @@ package ca.uhn.fhir.rest.server.provider.dstu2; * #L% */ -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.model.api.IResource; @@ -37,6 +30,12 @@ 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 { @@ -54,7 +53,7 @@ public class ServerProfileProvider implements IResourceProvider { } @Read() - public StructureDefinition getProfileById(HttpServletRequest theRequest, @IdParam IdDt theId) { + public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdDt theId) { RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); if (retVal==null) { return null; @@ -64,9 +63,9 @@ public class ServerProfileProvider implements IResourceProvider { } @Search() - public List getAllProfiles(HttpServletRequest theRequest) { + public List getAllProfiles(ServletRequestDetails theRequest) { final String serverBase = getServerBase(theRequest); - List defs = new ArrayList(myContext.getResourceDefinitionsWithExplicitId()); + List defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId()); Collections.sort(defs, new Comparator() { @Override public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { @@ -76,14 +75,14 @@ public class ServerProfileProvider implements IResourceProvider { } return cmp; }}); - ArrayList retVal = new ArrayList(); + ArrayList retVal = new ArrayList<>(); for (RuntimeResourceDefinition next : defs) { retVal.add((StructureDefinition) next.toProfile(serverBase)); } return retVal; } - private String getServerBase(HttpServletRequest theHttpRequest) { + private String getServerBase(ServletRequestDetails theHttpRequest) { return myRestfulServer.getServerBaseForRequest(theHttpRequest); } } 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 index 2af584933f9..d20614fa32d 100644 --- 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 @@ -20,17 +20,6 @@ package org.hl7.fhir.dstu3.hapi.rest.server; * #L% */ -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - -import org.hl7.fhir.dstu3.model.IdType; -import org.hl7.fhir.dstu3.model.StructureDefinition; -import org.hl7.fhir.instance.model.api.IBaseResource; - import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.rest.annotation.IdParam; @@ -38,6 +27,15 @@ 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 { @@ -55,7 +53,7 @@ public class ServerProfileProvider implements IResourceProvider { } @Read() - public StructureDefinition getProfileById(HttpServletRequest theRequest, @IdParam IdType theId) { + public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) { RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); if (retVal==null) { return null; @@ -65,9 +63,9 @@ public class ServerProfileProvider implements IResourceProvider { } @Search() - public List getAllProfiles(HttpServletRequest theRequest) { + public List getAllProfiles(ServletRequestDetails theRequest) { final String serverBase = getServerBase(theRequest); - List defs = new ArrayList(myContext.getResourceDefinitionsWithExplicitId()); + List defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId()); Collections.sort(defs, new Comparator() { @Override public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { @@ -77,14 +75,14 @@ public class ServerProfileProvider implements IResourceProvider { } return cmp; }}); - ArrayList retVal = new ArrayList(); + ArrayList retVal = new ArrayList<>(); for (RuntimeResourceDefinition next : defs) { retVal.add((StructureDefinition) next.toProfile(serverBase)); } return retVal; } - private String getServerBase(HttpServletRequest theHttpRequest) { + private String getServerBase(ServletRequestDetails theHttpRequest) { return myRestfulServer.getServerBaseForRequest(theHttpRequest); } } diff --git a/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/conf/ServerProfileProvider.java b/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/conf/ServerProfileProvider.java index 330a34b1969..49fb0e442e5 100644 --- a/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/conf/ServerProfileProvider.java +++ b/hapi-fhir-structures-hl7org-dstu2/src/main/java/org/hl7/fhir/instance/conf/ServerProfileProvider.java @@ -20,17 +20,6 @@ package org.hl7.fhir.instance.conf; * #L% */ -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - -import org.hl7.fhir.instance.model.IdType; -import org.hl7.fhir.instance.model.StructureDefinition; -import org.hl7.fhir.instance.model.api.IBaseResource; - import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.RuntimeResourceDefinition; import ca.uhn.fhir.rest.annotation.IdParam; @@ -38,6 +27,15 @@ 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.IdType; +import org.hl7.fhir.instance.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 { @@ -55,7 +53,7 @@ public class ServerProfileProvider implements IResourceProvider { } @Read() - public StructureDefinition getProfileById(HttpServletRequest theRequest, @IdParam IdType theId) { + public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) { RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart()); if (retVal==null) { return null; @@ -65,9 +63,9 @@ public class ServerProfileProvider implements IResourceProvider { } @Search() - public List getAllProfiles(HttpServletRequest theRequest) { + public List getAllProfiles(ServletRequestDetails theRequest) { final String serverBase = getServerBase(theRequest); - List defs = new ArrayList(myContext.getResourceDefinitionsWithExplicitId()); + List defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId()); Collections.sort(defs, new Comparator() { @Override public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) { @@ -77,14 +75,14 @@ public class ServerProfileProvider implements IResourceProvider { } return cmp; }}); - ArrayList retVal = new ArrayList(); + ArrayList retVal = new ArrayList<>(); for (RuntimeResourceDefinition next : defs) { retVal.add((StructureDefinition) next.toProfile(serverBase)); } return retVal; } - private String getServerBase(HttpServletRequest theHttpRequest) { + private String getServerBase(ServletRequestDetails theHttpRequest) { return myRestfulServer.getServerBaseForRequest(theHttpRequest); } }