Class TenantServiceImpl
- java.lang.Object
-
- org.craftercms.profile.services.impl.TenantServiceImpl
-
- All Implemented Interfaces:
TenantService
public class TenantServiceImpl extends Object implements TenantService
Default implementation ofTenantService.- Author:
- avasquez
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceTenantServiceImpl.UpdateCallback
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TenantServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TenantaddAttributeDefinitions(String tenantName, Collection<AttributeDefinition> attributeDefinitions)Adds the given attribute definitions to the specified tenant.protected voidaddDefaultValue(String tenantName, String attributeName, Object defaultValue)TenantaddRoles(String tenantName, Collection<String> roles)Adds the given roles to the specified tenant.protected voidcheckIfTenantActionIsAllowed(String tenantName, TenantAction action)TenantcreateTenant(Tenant tenant)Creates the given tenant, failing if it already has been created.voiddeleteTenant(String name)Deletes a tenant.List<Tenant>getAllTenants()Returns a list with all the tenants.TenantgetTenant(String name)Returns a tenant.longgetTenantCount()Returns the total number of tenants.TenantremoveAttributeDefinitions(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)TenantremoveRoles(String tenantName, Collection<String> roles)Removes the given roles from the specified tenant.voidsetAttributePermissionEvaluator(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,AttributeDefinition> attributePermissionEvaluator)voidsetEntitlementValidator(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator)voidsetProfileRepository(ProfileRepository profileRepository)voidsetProfileService(ProfileService profileService)voidsetTenantPermissionEvaluator(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,String> tenantPermissionEvaluator)voidsetTenantRepository(TenantRepository tenantRepository)TenantupdateAttributeDefinitions(String tenantName, Collection<AttributeDefinition> attributeDefinitions)Updates the given attribute definitions of the specified tenant.protected TenantupdateTenant(String tenantName, TenantServiceImpl.UpdateCallback callback)TenantupdateTenant(Tenant tenant)Updates the given tenant.TenantverifyNewProfiles(String tenantName, boolean verify)Sets if new profiles for the specified tenant should be verified or not.
-
-
-
Field Detail
-
LOG_KEY_TENANT_CREATED
public static final String LOG_KEY_TENANT_CREATED
- See Also:
- Constant Field Values
-
LOG_KEY_TENANT_DELETED
public static final String LOG_KEY_TENANT_DELETED
- See Also:
- Constant Field Values
-
LOG_KEY_VERIFY_NEW_PROFILES_FLAG_SET
public static final String LOG_KEY_VERIFY_NEW_PROFILES_FLAG_SET
- See Also:
- Constant Field Values
-
LOG_KEY_ROLES_ADDED
public static final String LOG_KEY_ROLES_ADDED
- See Also:
- Constant Field Values
-
LOG_KEY_ROLES_REMOVED
public static final String LOG_KEY_ROLES_REMOVED
- See Also:
- Constant Field Values
-
LOG_KEY_ATTRIBUTE_DEFINITIONS_ADDED
public static final String LOG_KEY_ATTRIBUTE_DEFINITIONS_ADDED
- See Also:
- Constant Field Values
-
LOG_KEY_ATTRIBUTE_DEFINITIONS_UPDATED
public static final String LOG_KEY_ATTRIBUTE_DEFINITIONS_UPDATED
- See Also:
- Constant Field Values
-
LOG_KEY_ATTRIBUTE_DEFINITIONS_REMOVED
public static final String LOG_KEY_ATTRIBUTE_DEFINITIONS_REMOVED
- See Also:
- Constant Field Values
-
ERROR_KEY_CREATE_TENANT_ERROR
public static final String ERROR_KEY_CREATE_TENANT_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_GET_TENANT_ERROR
public static final String ERROR_KEY_GET_TENANT_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_UPDATE_TENANT_ERROR
public static final String ERROR_KEY_UPDATE_TENANT_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_DELETE_TENANT_ERROR
public static final String ERROR_KEY_DELETE_TENANT_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_GET_TENANT_COUNT_ERROR
public static final String ERROR_KEY_GET_TENANT_COUNT_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_GET_ALL_TENANTS_ERROR
public static final String ERROR_KEY_GET_ALL_TENANTS_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_DELETE_ALL_PROFILES_ERROR
public static final String ERROR_KEY_DELETE_ALL_PROFILES_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_REMOVE_ROLE_FROM_ALL_PROFILES_ERROR
public static final String ERROR_KEY_REMOVE_ROLE_FROM_ALL_PROFILES_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_REMOVE_ATTRIBUTE_FROM_ALL_PROFILES_ERROR
public static final String ERROR_KEY_REMOVE_ATTRIBUTE_FROM_ALL_PROFILES_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_ADD_DEFAULT_VALUE_ERROR
public static final String ERROR_KEY_ADD_DEFAULT_VALUE_ERROR
- See Also:
- Constant Field Values
-
ERROR_KEY_ENTITLEMENT_ERROR
public static final String ERROR_KEY_ENTITLEMENT_ERROR
- See Also:
- Constant Field Values
-
tenantPermissionEvaluator
protected org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,String> tenantPermissionEvaluator
-
attributePermissionEvaluator
protected org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,AttributeDefinition> attributePermissionEvaluator
-
tenantRepository
protected TenantRepository tenantRepository
-
profileRepository
protected ProfileRepository profileRepository
-
profileService
protected ProfileService profileService
-
entitlementValidator
protected org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator
-
-
Method Detail
-
setTenantPermissionEvaluator
public void setTenantPermissionEvaluator(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,String> tenantPermissionEvaluator)
-
setAttributePermissionEvaluator
public void setAttributePermissionEvaluator(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,AttributeDefinition> attributePermissionEvaluator)
-
setTenantRepository
public void setTenantRepository(TenantRepository tenantRepository)
-
setProfileRepository
public void setProfileRepository(ProfileRepository profileRepository)
-
setProfileService
public void setProfileService(ProfileService profileService)
-
setEntitlementValidator
public void setEntitlementValidator(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator)
-
createTenant
public Tenant createTenant(Tenant tenant) throws ProfileException
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
public Tenant getTenant(String name) throws ProfileException
Description copied from interface:TenantServiceReturns a tenant.- Specified by:
getTenantin interfaceTenantService- Parameters:
name- the tenant's name- Returns:
- the tenant
- Throws:
ProfileException
-
updateTenant
public Tenant updateTenant(Tenant tenant) throws ProfileException
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
public void deleteTenant(String name) throws ProfileException
Description copied from interface:TenantServiceDeletes a tenant.- Specified by:
deleteTenantin interfaceTenantService- Parameters:
name- the tenant's name- Throws:
ProfileException
-
getTenantCount
public long getTenantCount() throws ProfileExceptionDescription copied from interface:TenantServiceReturns the total number of tenants.- Specified by:
getTenantCountin interfaceTenantService- Returns:
- the number of tenants
- Throws:
ProfileException
-
getAllTenants
public List<Tenant> getAllTenants() throws ProfileException
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
public Tenant verifyNewProfiles(String tenantName, boolean verify) throws ProfileException
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
public Tenant addRoles(String tenantName, Collection<String> roles) throws ProfileException
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
public Tenant removeRoles(String tenantName, Collection<String> roles) throws ProfileException
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
protected void checkIfTenantActionIsAllowed(String tenantName, TenantAction action)
-
updateTenant
protected Tenant updateTenant(String tenantName, TenantServiceImpl.UpdateCallback callback) throws ProfileException
- Throws:
ProfileException
-
removeRoleFromProfiles
protected void removeRoleFromProfiles(String tenantName, String role) throws ProfileException
- 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
-
-