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 interface
TenantServiceImpl.UpdateCallback
-
Field Summary
-
Constructor Summary
Constructors Constructor Description TenantServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tenant
addAttributeDefinitions(String tenantName, Collection<AttributeDefinition> attributeDefinitions)
Adds the given attribute definitions to the specified tenant.protected void
addDefaultValue(String tenantName, String attributeName, Object defaultValue)
Tenant
addRoles(String tenantName, Collection<String> roles)
Adds the given roles to the specified tenant.protected void
checkIfTenantActionIsAllowed(String tenantName, TenantAction action)
Tenant
createTenant(Tenant tenant)
Creates the given tenant, failing if it already has been created.void
deleteTenant(String name)
Deletes a tenant.List<Tenant>
getAllTenants()
Returns a list with all the tenants.Tenant
getTenant(String name)
Returns a tenant.long
getTenantCount()
Returns the total number of tenants.Tenant
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)
Tenant
removeRoles(String tenantName, Collection<String> roles)
Removes the given roles from the specified tenant.void
setAttributePermissionEvaluator(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,AttributeDefinition> attributePermissionEvaluator)
void
setEntitlementValidator(org.craftercms.commons.entitlements.validator.EntitlementValidator entitlementValidator)
void
setProfileRepository(ProfileRepository profileRepository)
void
setProfileService(ProfileService profileService)
void
setTenantPermissionEvaluator(org.craftercms.commons.security.permissions.PermissionEvaluator<AccessToken,String> tenantPermissionEvaluator)
void
setTenantRepository(TenantRepository tenantRepository)
Tenant
updateAttributeDefinitions(String tenantName, Collection<AttributeDefinition> attributeDefinitions)
Updates the given attribute definitions of the specified tenant.protected Tenant
updateTenant(String tenantName, TenantServiceImpl.UpdateCallback callback)
Tenant
updateTenant(Tenant tenant)
Updates the given tenant.Tenant
verifyNewProfiles(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: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
public Tenant getTenant(String name) throws ProfileException
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
public Tenant updateTenant(Tenant tenant) throws ProfileException
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
public void deleteTenant(String name) throws ProfileException
Description copied from interface:TenantService
Deletes a tenant.- Specified by:
deleteTenant
in interfaceTenantService
- Parameters:
name
- the tenant's name- Throws:
ProfileException
-
getTenantCount
public long getTenantCount() throws ProfileException
Description copied from interface:TenantService
Returns the total number of tenants.- Specified by:
getTenantCount
in interfaceTenantService
- Returns:
- the number of tenants
- Throws:
ProfileException
-
getAllTenants
public List<Tenant> getAllTenants() throws ProfileException
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
public Tenant verifyNewProfiles(String tenantName, boolean verify) throws ProfileException
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
public Tenant addRoles(String tenantName, Collection<String> roles) throws ProfileException
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
public Tenant removeRoles(String tenantName, Collection<String> roles) throws ProfileException
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
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
-
-