Class SetTenantAction
- java.lang.Object
-
- com.ibm.fhir.persistence.jdbc.connection.ChainedAction
-
- com.ibm.fhir.persistence.jdbc.connection.SetTenantAction
-
- All Implemented Interfaces:
Action
public class SetTenantAction extends ChainedAction
Set the tenant variable in the session (part of Db2 multi-tenancy support). This needs to be executed at the beginning of an interaction with a database connection, before any other DML/SQL.
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.List<java.lang.String>
DATASTORE_REQUIRES_ROW_PERMISSIONS
-
Constructor Summary
Constructors Constructor Description SetTenantAction(FHIRConfigProvider configProvider)
Public constructor.SetTenantAction(FHIRConfigProvider configProvider, Action next)
Public constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configureTenantAccess(java.sql.Connection connection)
Find the tenantKey for the datasource/tenant from the FHIR server configuration and use it to set up the connection for access by this tenant by setting the SV_TENANT_ID session variable (via the FHIR_ADMIN.SET_TENANT stored procedure).void
performOn(FHIRDbFlavor flavor, java.sql.Connection c)
Perform this action on the given connection
-
-
-
Constructor Detail
-
SetTenantAction
public SetTenantAction(FHIRConfigProvider configProvider)
Public constructor. No next action, so this will be the last action applied- Parameters:
configProvider
- adapter for access to fhir-server-config properties
-
SetTenantAction
public SetTenantAction(FHIRConfigProvider configProvider, Action next)
Public constructor- Parameters:
configProvider
- adapter for access to fhir-server-config propertiesnext
- the next action in the chain
-
-
Method Detail
-
performOn
public void performOn(FHIRDbFlavor flavor, java.sql.Connection c) throws FHIRPersistenceDBConnectException
Description copied from interface:Action
Perform this action on the given connection- Specified by:
performOn
in interfaceAction
- Overrides:
performOn
in classChainedAction
- Parameters:
flavor
- describes the type of database associated with the given connectionc
- the connection to perform the action on- Throws:
FHIRPersistenceDBConnectException
-
configureTenantAccess
public void configureTenantAccess(java.sql.Connection connection) throws FHIRPersistenceDBConnectException
Find the tenantKey for the datasource/tenant from the FHIR server configuration and use it to set up the connection for access by this tenant by setting the SV_TENANT_ID session variable (via the FHIR_ADMIN.SET_TENANT stored procedure). Note that the database user we connect as does not have direct access to WRITE to the SV_TENANT_ID...it can only be set through the SET_TENANT call, for which we have been explicitly granted execute privilege.- Parameters:
connection
- the connection to configure- Throws:
FHIRPersistenceException
- if the configuration failsFHIRPersistenceDBConnectException
-
-