use of org.craftercms.profile.utils.db.TenantUpdater in project profile by craftercms.
the class TenantServiceImpl method verifyNewProfiles.
@Override
public Tenant verifyNewProfiles(String tenantName, final boolean verify) throws ProfileException {
Tenant tenant = updateTenant(tenantName, new UpdateCallback() {
@Override
public void doWithTenant(TenantUpdater tenantUpdater) throws ProfileException {
tenantUpdater.setVerifyNewProfiles(verify);
}
});
logger.debug(LOG_KEY_VERIFY_NEW_PROFILES_FLAG_SET, tenantName, verify);
return tenant;
}
use of org.craftercms.profile.utils.db.TenantUpdater in project profile by craftercms.
the class TenantServiceImpl method addRoles.
@Override
public Tenant addRoles(String tenantName, final Collection<String> roles) throws ProfileException {
Tenant tenant = updateTenant(tenantName, new UpdateCallback() {
@Override
public void doWithTenant(TenantUpdater tenantUpdater) throws ProfileException {
tenantUpdater.addAvailableRoles(roles);
}
});
logger.debug(LOG_KEY_ROLES_ADDED, roles, tenantName);
return tenant;
}
use of org.craftercms.profile.utils.db.TenantUpdater in project profile by craftercms.
the class TenantServiceImpl method updateTenant.
@Override
public Tenant updateTenant(final Tenant tenant) throws ProfileException {
final String tenantName = tenant.getName();
Tenant updatedTenant = updateTenant(tenant.getName(), new UpdateCallback() {
@Override
public void doWithTenant(TenantUpdater tenantUpdater) throws ProfileException {
Tenant originalTenant = tenantUpdater.getTenant();
Collection<String> originalRoles = originalTenant.getAvailableRoles();
Collection<String> newRoles = tenant.getAvailableRoles();
Collection<AttributeDefinition> originalDefinitions = originalTenant.getAttributeDefinitions();
Collection<AttributeDefinition> newDefinitions = tenant.getAttributeDefinitions();
Collection<String> removedRoles = CollectionUtils.subtract(originalRoles, newRoles);
Collection<AttributeDefinition> removedDefinitions = CollectionUtils.subtract(originalDefinitions, newDefinitions);
for (String removedRole : removedRoles) {
removeRoleFromProfiles(tenantName, removedRole);
}
for (AttributeDefinition removedDefinition : removedDefinitions) {
removeAttributeFromProfiles(tenantName, removedDefinition.getName());
}
tenantUpdater.setVerifyNewProfiles(tenant.isVerifyNewProfiles());
tenantUpdater.setSsoEnabled(tenant.isSsoEnabled());
tenantUpdater.setAvailableRoles(tenant.getAvailableRoles());
tenantUpdater.setAttributeDefinitions(tenant.getAttributeDefinitions());
}
});
for (AttributeDefinition definition : updatedTenant.getAttributeDefinitions()) {
addDefaultValue(tenantName, definition.getName(), definition.getDefaultValue());
}
return updatedTenant;
}
use of org.craftercms.profile.utils.db.TenantUpdater in project profile by craftercms.
the class TenantServiceImpl method removeRoles.
@Override
public Tenant removeRoles(final String tenantName, final Collection<String> roles) throws ProfileException {
Tenant tenant = updateTenant(tenantName, new UpdateCallback() {
@Override
public void doWithTenant(TenantUpdater tenantUpdater) throws ProfileException {
for (String role : roles) {
removeRoleFromProfiles(tenantName, role);
}
tenantUpdater.removeAvailableRoles(roles);
}
});
logger.debug(LOG_KEY_ROLES_REMOVED, roles, tenantName);
return tenant;
}
use of org.craftercms.profile.utils.db.TenantUpdater in project profile by craftercms.
the class TenantServiceImpl method addAttributeDefinitions.
@Override
public Tenant addAttributeDefinitions(final String tenantName, final Collection<AttributeDefinition> attributeDefinitions) throws ProfileException {
Tenant tenant = updateTenant(tenantName, new UpdateCallback() {
@Override
public void doWithTenant(TenantUpdater tenantUpdater) throws ProfileException {
tenantUpdater.addAttributeDefinitions(attributeDefinitions);
}
});
for (AttributeDefinition definition : tenant.getAttributeDefinitions()) {
addDefaultValue(tenantName, definition.getName(), definition.getDefaultValue());
}
logger.debug(LOG_KEY_ATTRIBUTE_DEFINITIONS_ADDED, attributeDefinitions, tenantName);
return tenant;
}
Aggregations