public abstract class AbstractTenantFacade extends Object implements TenantFacade
TenantFacade
s which allows to use a mocked Tenant
if the environment variable
"USE_MOCKED_TENANT" is set to "true".Constructor and Description |
---|
AbstractTenantFacade() |
Modifier and Type | Method and Description |
---|---|
Tenant |
getCurrentTenant()
Returns the current
Tenant . |
Optional<Tenant> |
getCurrentTenantIfAvailable()
Returns the current
Tenant , if available. |
Optional<Tenant> |
getMockedTenant()
Returns a mocked
Tenant , if the environment variable "USE_MOCKED_TENANT" is set to "true". |
protected abstract Tenant |
newMockedTenant()
Instantiates a mocked
Tenant . |
io.vavr.control.Try<Tenant> |
tryGetCurrentTenant()
Returns a
Try for the current Tenant . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getTenantClass, resolveCurrentTenant
@Nonnull protected abstract Tenant newMockedTenant()
Tenant
.Tenant
.@Nonnull public Optional<Tenant> getMockedTenant()
Tenant
, if the environment variable "USE_MOCKED_TENANT" is set to "true".Tenant
, if present.@Nonnull public Tenant getCurrentTenant() throws TenantNotAvailableException, TenantAccessException
Tenant
.getCurrentTenant
in interface TenantFacade
Tenant
.TenantNotAvailableException
- If there is currently no Tenant
available. This typically occurs when trying to access the
tenant within code that is running outside any tenant context, e.g., within a background task. For
more details on how the availability of a tenant is defined, refer to
TenantFacade.getCurrentTenantIfAvailable()
.TenantAccessException
- If there is an issue while accessing the Tenant
.@Nonnull public Optional<Tenant> getCurrentTenantIfAvailable() throws TenantAccessException
Tenant
, if available.
The availability of the tenant is defined as follows:
Tenant available | Tenant not available | |
---|---|---|
SAP Cloud Platform Cloud Foundry | A request is present with an "Authorization" header that contains a valid JWT bearer with field "zid". As a fallback a JWT will be retrieved from a bound XSUAA instance. |
A request is not available, no "Authorization" header is present in the current request, the JWT bearer does not hold a field "zid", or there is no XSUAA service bound to this application. |
SAP Cloud Platform Neo | Successful JNDI lookup of TenantContext. | Never. If correctly configured, a TenantContext is always available. If not, a TenantAccessException
is thrown. |
getCurrentTenantIfAvailable
in interface TenantFacade
Optional
of the current Tenant
.TenantAccessException
- If there is an issue while accessing the Tenant
.@Nonnull public io.vavr.control.Try<Tenant> tryGetCurrentTenant()
Try
for the current Tenant
.tryGetCurrentTenant
in interface TenantFacade
Try
for the current Tenant
.Copyright © 2019 SAP SE. All rights reserved.