Search in sources :

Example 1 with TenantExistsException

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;
}
Also used : I10nProfileException(org.craftercms.profile.api.exceptions.I10nProfileException) MongoDataException(org.craftercms.commons.mongo.MongoDataException) TenantExistsException(org.craftercms.profile.exceptions.TenantExistsException) DuplicateKeyException(org.craftercms.commons.mongo.DuplicateKeyException)

Aggregations

DuplicateKeyException (org.craftercms.commons.mongo.DuplicateKeyException)1 MongoDataException (org.craftercms.commons.mongo.MongoDataException)1 I10nProfileException (org.craftercms.profile.api.exceptions.I10nProfileException)1 TenantExistsException (org.craftercms.profile.exceptions.TenantExistsException)1