public class Tenants extends Object
UserAccount and Tenant.
 Also some boiler plate methods are provided to perform some assertions.
| Modifier and Type | Field and Description | 
|---|---|
static String | 
FRAMEWORK_TENANTS
Names the framework which must be enabled to activate the tenant based user management. 
 | 
| Constructor and Description | 
|---|
Tenants()  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
assertTenantOrParentTenant(TenantAware tenantAware)
Checks if the tenant aware entity belongs to the current tenant or to its parent tenant. 
 | 
protected void | 
flushTenantChildrenCache()
Flushes the cache which determines if a tenant has children or not. 
 | 
<E extends SQLTenantAware> | 
forCurrentTenant(sirius.db.jdbc.SmartQuery<E> qry)  | 
Optional<Tenant> | 
getCurrentTenant()
Returns the  
Tenant of the current user. | 
Optional<UserAccount> | 
getCurrentUser()
Returns the current user as  
UserAccount which is logged in. | 
Tenant | 
getRequiredTenant()
Returns the tenant of the currently logged in user or throws an exception if no user is present. 
 | 
UserAccount | 
getRequiredUser()
Returns the current user or throws an exception if no user is currently available. 
 | 
boolean | 
hasChildTenants(long tenantId)
Determines if the tenant with the given ID has child tenants. 
 | 
boolean | 
hasTenant()
Determines if there is a user logged in which has a tenant. 
 | 
boolean | 
hasUser()
Determines if there is currently a user logged in. 
 | 
public static final String FRAMEWORK_TENANTS
@Nonnull public Optional<UserAccount> getCurrentUser()
UserAccount which is logged in.Optional or an empty optional, if no user is logged in.@Nonnull public UserAccount getRequiredUser()
public boolean hasUser()
@Nonnull public Optional<Tenant> getCurrentTenant()
Tenant of the current user.Optional or an empty optional, if no user is logged in.@Nonnull public Tenant getRequiredTenant()
public boolean hasTenant()
public boolean hasChildTenants(long tenantId)
This call utilizes a cache, therefore a lookup if quite fast and cheap.
tenantId - the id of the tenant to check if there are childrenprotected void flushTenantChildrenCache()
public void assertTenantOrParentTenant(TenantAware tenantAware)
tenantAware - TenantAware entity to be assertedpublic <E extends SQLTenantAware> sirius.db.jdbc.SmartQuery<E> forCurrentTenant(sirius.db.jdbc.SmartQuery<E> qry)
Copyright © 2018. All rights reserved.