Class TenantServiceImpl
java.lang.Object
org.craftercms.profile.services.impl.TenantServiceImpl
- All Implemented Interfaces:
TenantService
Default implementation of
TenantService
.- Author:
- avasquez
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.craftercms.commons.security.permissions.PermissionEvaluator
<AccessToken, AttributeDefinition> protected org.craftercms.commons.entitlements.validator.EntitlementValidator
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
protected ProfileRepository
protected ProfileService
protected org.craftercms.commons.security.permissions.PermissionEvaluator
<AccessToken, String> protected TenantRepository
-
Constructor Summary
ConstructorsConstructorDescriptionTenantServiceImpl
(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, String> tenantPermissionEvaluator, org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, AttributeDefinition> attributePermissionEvaluator, TenantRepository tenantRepository, ProfileRepository profileRepository, org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator) -
Method Summary
Modifier and TypeMethodDescriptionaddAttributeDefinitions
(String tenantName, Collection<AttributeDefinition> attributeDefinitions) Adds the given attribute definitions to the specified tenant.protected void
addDefaultValue
(String tenantName, String attributeName, Object defaultValue) addRoles
(String tenantName, Collection<String> roles) Adds the given roles to the specified tenant.protected void
checkIfTenantActionIsAllowed
(String tenantName, TenantAction action) createTenant
(Tenant tenant) Creates the given tenant, failing if it already has been created.void
deleteTenant
(String name) Deletes a tenant.Returns a list with all the tenants.Returns a tenant.long
Returns the total number of tenants.removeAttributeDefinitions
(String tenantName, Collection<String> attributeNames) Removes the given attribute definitions from the specified tenant.protected void
removeAttributeFromProfiles
(String tenantName, String attributeName) protected void
removeRoleFromProfiles
(String tenantName, String role) removeRoles
(String tenantName, Collection<String> roles) Removes the given roles from the specified tenant.void
setProfileService
(ProfileService profileService) updateAttributeDefinitions
(String tenantName, Collection<AttributeDefinition> attributeDefinitions) Updates the given attribute definitions of the specified tenant.protected Tenant
updateTenant
(String tenantName, TenantServiceImpl.UpdateCallback callback) updateTenant
(Tenant tenant) Updates the given tenant.verifyNewProfiles
(String tenantName, boolean verify) Sets if new profiles for the specified tenant should be verified or not.
-
Field Details
-
LOG_KEY_TENANT_CREATED
- See Also:
-
LOG_KEY_TENANT_DELETED
- See Also:
-
LOG_KEY_VERIFY_NEW_PROFILES_FLAG_SET
- See Also:
-
LOG_KEY_ROLES_ADDED
- See Also:
-
LOG_KEY_ROLES_REMOVED
- See Also:
-
LOG_KEY_ATTRIBUTE_DEFINITIONS_ADDED
- See Also:
-
LOG_KEY_ATTRIBUTE_DEFINITIONS_UPDATED
- See Also:
-
LOG_KEY_ATTRIBUTE_DEFINITIONS_REMOVED
- See Also:
-
ERROR_KEY_CREATE_TENANT_ERROR
- See Also:
-
ERROR_KEY_GET_TENANT_ERROR
- See Also:
-
ERROR_KEY_UPDATE_TENANT_ERROR
- See Also:
-
ERROR_KEY_DELETE_TENANT_ERROR
- See Also:
-
ERROR_KEY_GET_TENANT_COUNT_ERROR
- See Also:
-
ERROR_KEY_GET_ALL_TENANTS_ERROR
- See Also:
-
ERROR_KEY_DELETE_ALL_PROFILES_ERROR
- See Also:
-
ERROR_KEY_REMOVE_ROLE_FROM_ALL_PROFILES_ERROR
- See Also:
-
ERROR_KEY_REMOVE_ATTRIBUTE_FROM_ALL_PROFILES_ERROR
- See Also:
-
ERROR_KEY_ADD_DEFAULT_VALUE_ERROR
- See Also:
-
ERROR_KEY_ENTITLEMENT_ERROR
- See Also:
-
tenantPermissionEvaluator
protected org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,String> tenantPermissionEvaluator -
attributePermissionEvaluator
protected org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,AttributeDefinition> attributePermissionEvaluator -
tenantRepository
-
profileRepository
-
profileService
-
entitlementValidator
protected org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator
-
-
Constructor Details
-
TenantServiceImpl
public TenantServiceImpl(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, String> tenantPermissionEvaluator, org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken, AttributeDefinition> attributePermissionEvaluator, TenantRepository tenantRepository, ProfileRepository profileRepository, org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator)
-
-
Method Details
-
setProfileService
-
createTenant
Description copied from interface:TenantService
Creates the given tenant, failing if it already has been created.- Specified by:
createTenant
in interfaceTenantService
- Parameters:
tenant
- the tenant to create- Returns:
- the created tenant
- Throws:
ProfileException
-
getTenant
Description copied from interface:TenantService
Returns a tenant.- Specified by:
getTenant
in interfaceTenantService
- Parameters:
name
- the tenant's name- Returns:
- the tenant
- Throws:
ProfileException
-
updateTenant
Description copied from interface:TenantService
Updates the given tenant.- Specified by:
updateTenant
in interfaceTenantService
- Parameters:
tenant
- the tenant to update- Returns:
- the updated tenant
- Throws:
ProfileException
-
deleteTenant
Description copied from interface:TenantService
Deletes a tenant.- Specified by:
deleteTenant
in interfaceTenantService
- Parameters:
name
- the tenant's name- Throws:
ProfileException
-
getTenantCount
Description copied from interface:TenantService
Returns the total number of tenants.- Specified by:
getTenantCount
in interfaceTenantService
- Returns:
- the number of tenants
- Throws:
ProfileException
-
getAllTenants
Description copied from interface:TenantService
Returns a list with all the tenants.- Specified by:
getAllTenants
in interfaceTenantService
- Returns:
- a list with al the tenants.
- Throws:
ProfileException
-
verifyNewProfiles
Description copied from interface:TenantService
Sets if new profiles for the specified tenant should be verified or not.- Specified by:
verifyNewProfiles
in interfaceTenantService
- Parameters:
tenantName
- the tenant's nameverify
- true to verify new profiles through email, false otherwise- Returns:
- the tenant
- Throws:
ProfileException
-
addRoles
Description copied from interface:TenantService
Adds the given roles to the specified tenant.- Specified by:
addRoles
in interfaceTenantService
- Parameters:
tenantName
- the tenant's nameroles
- the roles to add- Returns:
- the tenant
- Throws:
ProfileException
-
removeRoles
Description copied from interface:TenantService
Removes the given roles from the specified tenant.- Specified by:
removeRoles
in interfaceTenantService
- Parameters:
tenantName
- the tenant's nameroles
- the roles to remove- Returns:
- the tenant
- Throws:
ProfileException
-
addAttributeDefinitions
public Tenant addAttributeDefinitions(String tenantName, Collection<AttributeDefinition> attributeDefinitions) throws ProfileException Description copied from interface:TenantService
Adds the given attribute definitions to the specified tenant.- Specified by:
addAttributeDefinitions
in interfaceTenantService
- Parameters:
tenantName
- the tenant's nameattributeDefinitions
- the definitions to add- Returns:
- the tenant
- Throws:
ProfileException
-
updateAttributeDefinitions
public Tenant updateAttributeDefinitions(String tenantName, Collection<AttributeDefinition> attributeDefinitions) throws ProfileException Description copied from interface:TenantService
Updates the given attribute definitions of the specified tenant.- Specified by:
updateAttributeDefinitions
in interfaceTenantService
- Parameters:
tenantName
- the tenant's nameattributeDefinitions
- the definitions to update (should have the same name as definitions that the tenant already has)- Returns:
- the tenant
- Throws:
ProfileException
-
removeAttributeDefinitions
public Tenant removeAttributeDefinitions(String tenantName, Collection<String> attributeNames) throws ProfileException Description copied from interface:TenantService
Removes the given attribute definitions from the specified tenant.- Specified by:
removeAttributeDefinitions
in interfaceTenantService
- Parameters:
tenantName
- the tenant's nameattributeNames
- the name of the attributes whose definitions should be removed- Returns:
- the tenant
- Throws:
ProfileException
-
checkIfTenantActionIsAllowed
-
updateTenant
protected Tenant updateTenant(String tenantName, TenantServiceImpl.UpdateCallback callback) throws ProfileException - Throws:
ProfileException
-
removeRoleFromProfiles
- Throws:
ProfileException
-
removeAttributeFromProfiles
protected void removeAttributeFromProfiles(String tenantName, String attributeName) throws ProfileException - Throws:
ProfileException
-
addDefaultValue
protected void addDefaultValue(String tenantName, String attributeName, Object defaultValue) throws ProfileException - Throws:
ProfileException
-