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.
    • 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
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DATASTORE_REQUIRES_ROW_PERMISSIONS

        public static final java.util.List<java.lang.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​(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 fails
        FHIRPersistenceDBConnectException