use of org.craftercms.profile.exceptions.TenantExistsException in project profile by craftercms.
the class TenantServiceImpl method createTenant.
@Override
public Tenant createTenant(Tenant tenant) throws ProfileException {
checkIfTenantActionIsAllowed(null, TenantAction.CREATE_TENANT);
// Make sure ID is null, we want it auto-generated
tenant.setId(null);
try {
tenantRepository.insert(tenant);
} catch (DuplicateKeyException e) {
throw new TenantExistsException(tenant.getName());
} catch (MongoDataException e) {
throw new I10nProfileException(ERROR_KEY_CREATE_TENANT_ERROR, e, tenant.getName());
}
logger.debug(LOG_KEY_TENANT_CREATED, tenant);
return tenant;
}
Aggregations