Class 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 Detail

      • DATASTORE_REQUIRES_ROW_PERMISSIONS

        public static final List<String> DATASTORE_REQUIRES_ROW_PERMISSIONS
    • 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 properties
        next - the next action in the chain
    • Method Detail

      • configureTenantAccess

        public void configureTenantAccess​(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 fails
        FHIRPersistenceDBConnectException