More work on multitenancy
This commit is contained in:
parent
f6c9e3d0fe
commit
4e2db2b58b
|
@ -20,17 +20,6 @@ package org.hl7.fhir.dstu2016may.hapi.rest.server;
|
||||||
* #L%
|
* #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.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
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.annotation.Search;
|
||||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
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 {
|
public class ServerProfileProvider implements IResourceProvider {
|
||||||
|
|
||||||
|
@ -55,7 +53,7 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Read()
|
@Read()
|
||||||
public StructureDefinition getProfileById(HttpServletRequest theRequest, @IdParam IdType theId) {
|
public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) {
|
||||||
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart());
|
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart());
|
||||||
if (retVal==null) {
|
if (retVal==null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -65,9 +63,9 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Search()
|
@Search()
|
||||||
public List<StructureDefinition> getAllProfiles(HttpServletRequest theRequest) {
|
public List<StructureDefinition> getAllProfiles(ServletRequestDetails theRequest) {
|
||||||
final String serverBase = getServerBase(theRequest);
|
final String serverBase = getServerBase(theRequest);
|
||||||
List<RuntimeResourceDefinition> defs = new ArrayList<RuntimeResourceDefinition>(myContext.getResourceDefinitionsWithExplicitId());
|
List<RuntimeResourceDefinition> defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId());
|
||||||
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
|
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
|
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
|
||||||
|
@ -77,14 +75,14 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
return cmp;
|
return cmp;
|
||||||
}});
|
}});
|
||||||
ArrayList<StructureDefinition> retVal = new ArrayList<StructureDefinition>();
|
ArrayList<StructureDefinition> retVal = new ArrayList<>();
|
||||||
for (RuntimeResourceDefinition next : defs) {
|
for (RuntimeResourceDefinition next : defs) {
|
||||||
retVal.add((StructureDefinition) next.toProfile(serverBase));
|
retVal.add((StructureDefinition) next.toProfile(serverBase));
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getServerBase(HttpServletRequest theHttpRequest) {
|
private String getServerBase(ServletRequestDetails theHttpRequest) {
|
||||||
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
|
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,6 @@ package ca.uhn.fhir.rest.server.provider.dstu2;
|
||||||
* #L%
|
* #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.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.model.api.IResource;
|
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.annotation.Search;
|
||||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
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 {
|
public class ServerProfileProvider implements IResourceProvider {
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Read()
|
@Read()
|
||||||
public StructureDefinition getProfileById(HttpServletRequest theRequest, @IdParam IdDt theId) {
|
public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdDt theId) {
|
||||||
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart());
|
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart());
|
||||||
if (retVal==null) {
|
if (retVal==null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -64,9 +63,9 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Search()
|
@Search()
|
||||||
public List<StructureDefinition> getAllProfiles(HttpServletRequest theRequest) {
|
public List<StructureDefinition> getAllProfiles(ServletRequestDetails theRequest) {
|
||||||
final String serverBase = getServerBase(theRequest);
|
final String serverBase = getServerBase(theRequest);
|
||||||
List<RuntimeResourceDefinition> defs = new ArrayList<RuntimeResourceDefinition>(myContext.getResourceDefinitionsWithExplicitId());
|
List<RuntimeResourceDefinition> defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId());
|
||||||
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
|
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
|
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
|
||||||
|
@ -76,14 +75,14 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
return cmp;
|
return cmp;
|
||||||
}});
|
}});
|
||||||
ArrayList<StructureDefinition> retVal = new ArrayList<StructureDefinition>();
|
ArrayList<StructureDefinition> retVal = new ArrayList<>();
|
||||||
for (RuntimeResourceDefinition next : defs) {
|
for (RuntimeResourceDefinition next : defs) {
|
||||||
retVal.add((StructureDefinition) next.toProfile(serverBase));
|
retVal.add((StructureDefinition) next.toProfile(serverBase));
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getServerBase(HttpServletRequest theHttpRequest) {
|
private String getServerBase(ServletRequestDetails theHttpRequest) {
|
||||||
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
|
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,17 +20,6 @@ package org.hl7.fhir.dstu3.hapi.rest.server;
|
||||||
* #L%
|
* #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.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
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.annotation.Search;
|
||||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
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 {
|
public class ServerProfileProvider implements IResourceProvider {
|
||||||
|
|
||||||
|
@ -55,7 +53,7 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Read()
|
@Read()
|
||||||
public StructureDefinition getProfileById(HttpServletRequest theRequest, @IdParam IdType theId) {
|
public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) {
|
||||||
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart());
|
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart());
|
||||||
if (retVal==null) {
|
if (retVal==null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -65,9 +63,9 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Search()
|
@Search()
|
||||||
public List<StructureDefinition> getAllProfiles(HttpServletRequest theRequest) {
|
public List<StructureDefinition> getAllProfiles(ServletRequestDetails theRequest) {
|
||||||
final String serverBase = getServerBase(theRequest);
|
final String serverBase = getServerBase(theRequest);
|
||||||
List<RuntimeResourceDefinition> defs = new ArrayList<RuntimeResourceDefinition>(myContext.getResourceDefinitionsWithExplicitId());
|
List<RuntimeResourceDefinition> defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId());
|
||||||
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
|
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
|
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
|
||||||
|
@ -77,14 +75,14 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
return cmp;
|
return cmp;
|
||||||
}});
|
}});
|
||||||
ArrayList<StructureDefinition> retVal = new ArrayList<StructureDefinition>();
|
ArrayList<StructureDefinition> retVal = new ArrayList<>();
|
||||||
for (RuntimeResourceDefinition next : defs) {
|
for (RuntimeResourceDefinition next : defs) {
|
||||||
retVal.add((StructureDefinition) next.toProfile(serverBase));
|
retVal.add((StructureDefinition) next.toProfile(serverBase));
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getServerBase(HttpServletRequest theHttpRequest) {
|
private String getServerBase(ServletRequestDetails theHttpRequest) {
|
||||||
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
|
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,17 +20,6 @@ package org.hl7.fhir.instance.conf;
|
||||||
* #L%
|
* #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.FhirContext;
|
||||||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||||
import ca.uhn.fhir.rest.annotation.IdParam;
|
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.annotation.Search;
|
||||||
import ca.uhn.fhir.rest.server.IResourceProvider;
|
import ca.uhn.fhir.rest.server.IResourceProvider;
|
||||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
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 {
|
public class ServerProfileProvider implements IResourceProvider {
|
||||||
|
|
||||||
|
@ -55,7 +53,7 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Read()
|
@Read()
|
||||||
public StructureDefinition getProfileById(HttpServletRequest theRequest, @IdParam IdType theId) {
|
public StructureDefinition getProfileById(ServletRequestDetails theRequest, @IdParam IdType theId) {
|
||||||
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart());
|
RuntimeResourceDefinition retVal = myContext.getResourceDefinitionById(theId.getIdPart());
|
||||||
if (retVal==null) {
|
if (retVal==null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -65,9 +63,9 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Search()
|
@Search()
|
||||||
public List<StructureDefinition> getAllProfiles(HttpServletRequest theRequest) {
|
public List<StructureDefinition> getAllProfiles(ServletRequestDetails theRequest) {
|
||||||
final String serverBase = getServerBase(theRequest);
|
final String serverBase = getServerBase(theRequest);
|
||||||
List<RuntimeResourceDefinition> defs = new ArrayList<RuntimeResourceDefinition>(myContext.getResourceDefinitionsWithExplicitId());
|
List<RuntimeResourceDefinition> defs = new ArrayList<>(myContext.getResourceDefinitionsWithExplicitId());
|
||||||
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
|
Collections.sort(defs, new Comparator<RuntimeResourceDefinition>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
|
public int compare(RuntimeResourceDefinition theO1, RuntimeResourceDefinition theO2) {
|
||||||
|
@ -77,14 +75,14 @@ public class ServerProfileProvider implements IResourceProvider {
|
||||||
}
|
}
|
||||||
return cmp;
|
return cmp;
|
||||||
}});
|
}});
|
||||||
ArrayList<StructureDefinition> retVal = new ArrayList<StructureDefinition>();
|
ArrayList<StructureDefinition> retVal = new ArrayList<>();
|
||||||
for (RuntimeResourceDefinition next : defs) {
|
for (RuntimeResourceDefinition next : defs) {
|
||||||
retVal.add((StructureDefinition) next.toProfile(serverBase));
|
retVal.add((StructureDefinition) next.toProfile(serverBase));
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getServerBase(HttpServletRequest theHttpRequest) {
|
private String getServerBase(ServletRequestDetails theHttpRequest) {
|
||||||
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
|
return myRestfulServer.getServerBaseForRequest(theHttpRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue