Package ca.uhn.fhir.rest.server.tenant
Class UrlBaseTenantIdentificationStrategy
java.lang.Object
ca.uhn.fhir.rest.server.tenant.UrlBaseTenantIdentificationStrategy
- All Implemented Interfaces:
ITenantIdentificationStrategy
public class UrlBaseTenantIdentificationStrategy
extends Object
implements ITenantIdentificationStrategy
This class is a tenant identification strategy which assumes that a single path
element will be present between the server base URL and individual request.
For example,
with this strategy enabled, given the following URL on a server with base URL http://example.com/base
,
the server will extract the TENANT-A
portion of the URL and use it as the tenant identifier. The
request will then proceed to read the resource with ID Patient/123
.
GET http://example.com/base/TENANT-A/Patient/123
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
extractTenant
(ca.uhn.fhir.util.UrlPathTokenizer theUrlPathTokenizer, RequestDetails theRequestDetails) Implementations should use this method to determine the tenant ID based on the incoming request and populate it in theRequestDetails.setTenantId(String)
.massageServerBaseUrl
(String theFhirServerBase, RequestDetails theRequestDetails) Implementations may use this method to tweak the server base URL if necessary based on the tenant IDresolveRelativeUrl
(String theRelativeUrl, RequestDetails theRequestDetails) Implementations may use this method to resolve relative URL based on the tenant ID from RequestDetails.
-
Constructor Details
-
UrlBaseTenantIdentificationStrategy
public UrlBaseTenantIdentificationStrategy()
-
-
Method Details
-
extractTenant
public void extractTenant(ca.uhn.fhir.util.UrlPathTokenizer theUrlPathTokenizer, RequestDetails theRequestDetails) Description copied from interface:ITenantIdentificationStrategy
Implementations should use this method to determine the tenant ID based on the incoming request and populate it in theRequestDetails.setTenantId(String)
.- Specified by:
extractTenant
in interfaceITenantIdentificationStrategy
- Parameters:
theUrlPathTokenizer
- The tokenizer which is used to parse the request paththeRequestDetails
- The request details object which can be used to access headers and to populate the tenant ID to
-
massageServerBaseUrl
Description copied from interface:ITenantIdentificationStrategy
Implementations may use this method to tweak the server base URL if necessary based on the tenant ID- Specified by:
massageServerBaseUrl
in interfaceITenantIdentificationStrategy
-
resolveRelativeUrl
Description copied from interface:ITenantIdentificationStrategy
Implementations may use this method to resolve relative URL based on the tenant ID from RequestDetails.- Specified by:
resolveRelativeUrl
in interfaceITenantIdentificationStrategy
- Parameters:
theRelativeUrl
- URL that only includes the path, e.g. "Patient/123"theRequestDetails
- The request details object which can be used to access tenant ID- Returns:
- Resolved relative URL that starts with tenant ID (if tenant ID present in RequestDetails). Example: "TENANT-A/Patient/123".
-