Interface TenantManager
TenantManager
service interface defines the API that
administrative tools will use to created, update or remove Tenants.
The implementation will make use of
TenantCustomizer
services to customize
management of tenants.
Tenant properties can be created, modified, and removed with the
setProperty(Tenant, String, Object)
,
setProperties(Tenant, Map)
and
removeProperties(Tenant, String...)
methods. Please note that every
call to any of these methods causes the
TenantCustomizer
services to be called.
To limit these calls for multiple changes the
setProperties(Tenant, Map)
method should be called.
-
Method Summary
Modifier and TypeMethodDescriptionCreates a new tenant with the given tenant ID and the initial set of properties.void
Removes the given tenant.void
removeProperties
(Tenant tenant, String... propertyNames) Removes one or more properties from the tenant.void
setProperties
(Tenant tenant, Map<String, Object> properties) Sets or removes multiple properties on the tenant.void
setProperty
(Tenant tenant, String name, Object value) Sets a single property of the tenant to a new value or removes the property if the value isnull
.
-
Method Details
-
create
Creates a new tenant with the given tenant ID and the initial set of properties.After creating the tenant, the
TenantManagerHook.setup(Tenant)
method is called to allow customizers to configure additional properties.Before returning the newly created tenant object the data is persisted.
- Parameters:
tenantId
- The name of the new tenant. This name must not benull
or an empty string. It must also not be the same name as that of an existing tenant.properties
- An optional map of initial properties. This may benull
to not preset any properties. It is recommended, though, that this map contain at least theTenant.PROP_NAME
andTenant.PROP_DESCRIPTION
properties.- Returns:
- The newly created
Tenant
instance ornull
if a tenant with the id already exists. - Throws:
NullPointerException
- iftenantId
isnull
.
-
setProperty
Sets a single property of the tenant to a new value or removes the property if the value isnull
.Before returning the
TenantManagerHook.change(Tenant)
method is called to allow customizers to configure additional properties.- Parameters:
tenant
- The tenant whose property is to be set or remove.name
- The name of the property to set or remove.value
- The new value of the property. If this value isnull
the property is actually removed.- Throws:
NullPointerException
- iftenant
orname
isnull
.
-
setProperties
Sets or removes multiple properties on the tenant.Before returning the
TenantManagerHook.change(Tenant)
method is called to allow customizers to configure additional properties.- Parameters:
tenant
- The tenant whose properties are to be modified.properties
- The map of properties to set or remove. A property whose value isnull
is removed from the tenant.- Throws:
NullPointerException
- iftenant
orproperties
isnull
.
-
removeProperties
Removes one or more properties from the tenant.Before returning the
TenantManagerHook.change(Tenant)
method is called to allow customizers to configure additional properties unless theproperties
parameter isnull
or empty.- Parameters:
tenant
- The tenant from which to remove properties.propertyNames
- The list of properties to be removed. If this isnull
or empty, nothing happens and theTenantCustomizer
is not called.- Throws:
NullPointerException
- iftenant
isnull
.
-
remove
Removes the given tenant.Before returning the
TenantManagerHook.remove(Tenant)
method is called to allow customizers to implement further cleanup upon tenant removal.- Parameters:
tenant
- The tenant to remove.- Throws:
NullPointerException
- iftenant
isnull
-