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.EntitlementValidatorstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected ProfileRepositoryprotected ProfileServiceprotected 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 voidaddDefaultValue(String tenantName, String attributeName, Object defaultValue) addRoles(String tenantName, Collection<String> roles) Adds the given roles to the specified tenant.protected voidcheckIfTenantActionIsAllowed(String tenantName, TenantAction action) createTenant(Tenant tenant) Creates the given tenant, failing if it already has been created.voiddeleteTenant(String name) Deletes a tenant.Returns a list with all the tenants.Returns a tenant.longReturns the total number of tenants.removeAttributeDefinitions(String tenantName, Collection<String> attributeNames) Removes the given attribute definitions from the specified tenant.protected voidremoveAttributeFromProfiles(String tenantName, String attributeName) protected voidremoveRoleFromProfiles(String tenantName, String role) removeRoles(String tenantName, Collection<String> roles) Removes the given roles from the specified tenant.voidsetProfileService(ProfileService profileService) updateAttributeDefinitions(String tenantName, Collection<AttributeDefinition> attributeDefinitions) Updates the given attribute definitions of the specified tenant.protected TenantupdateTenant(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:TenantServiceCreates the given tenant, failing if it already has been created.- Specified by:
createTenantin interfaceTenantService- Parameters:
tenant- the tenant to create- Returns:
- the created tenant
- Throws:
ProfileException
-
getTenant
Description copied from interface:TenantServiceReturns a tenant.- Specified by:
getTenantin interfaceTenantService- Parameters:
name- the tenant's name- Returns:
- the tenant
- Throws:
ProfileException
-
updateTenant
Description copied from interface:TenantServiceUpdates the given tenant.- Specified by:
updateTenantin interfaceTenantService- Parameters:
tenant- the tenant to update- Returns:
- the updated tenant
- Throws:
ProfileException
-
deleteTenant
Description copied from interface:TenantServiceDeletes a tenant.- Specified by:
deleteTenantin interfaceTenantService- Parameters:
name- the tenant's name- Throws:
ProfileException
-
getTenantCount
Description copied from interface:TenantServiceReturns the total number of tenants.- Specified by:
getTenantCountin interfaceTenantService- Returns:
- the number of tenants
- Throws:
ProfileException
-
getAllTenants
Description copied from interface:TenantServiceReturns a list with all the tenants.- Specified by:
getAllTenantsin interfaceTenantService- Returns:
- a list with al the tenants.
- Throws:
ProfileException
-
verifyNewProfiles
Description copied from interface:TenantServiceSets if new profiles for the specified tenant should be verified or not.- Specified by:
verifyNewProfilesin 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:TenantServiceAdds the given roles to the specified tenant.- Specified by:
addRolesin interfaceTenantService- Parameters:
tenantName- the tenant's nameroles- the roles to add- Returns:
- the tenant
- Throws:
ProfileException
-
removeRoles
Description copied from interface:TenantServiceRemoves the given roles from the specified tenant.- Specified by:
removeRolesin 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:TenantServiceAdds the given attribute definitions to the specified tenant.- Specified by:
addAttributeDefinitionsin 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:TenantServiceUpdates the given attribute definitions of the specified tenant.- Specified by:
updateAttributeDefinitionsin 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:TenantServiceRemoves the given attribute definitions from the specified tenant.- Specified by:
removeAttributeDefinitionsin 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
-