Search in sources :

Example 1 with TenantNotFoundException

use of io.gravitee.management.service.exceptions.TenantNotFoundException in project gravitee-management-rest-api by gravitee-io.

the class TenantServiceImpl method findById.

@Override
public TenantEntity findById(String tenantId) {
    try {
        LOGGER.debug("Find tenant by ID: {}", tenantId);
        Optional<Tenant> optTenant = tenantRepository.findById(tenantId);
        if (!optTenant.isPresent()) {
            throw new TenantNotFoundException(tenantId);
        }
        return convert(optTenant.get());
    } catch (TechnicalException ex) {
        LOGGER.error("An error occurs while trying to find tenant by ID", ex);
        throw new TechnicalManagementException("An error occurs while trying to find tenant by ID", ex);
    }
}
Also used : Tenant(io.gravitee.repository.management.model.Tenant) TechnicalException(io.gravitee.repository.exceptions.TechnicalException) TenantNotFoundException(io.gravitee.management.service.exceptions.TenantNotFoundException) TechnicalManagementException(io.gravitee.management.service.exceptions.TechnicalManagementException)

Aggregations

TechnicalManagementException (io.gravitee.management.service.exceptions.TechnicalManagementException)1 TenantNotFoundException (io.gravitee.management.service.exceptions.TenantNotFoundException)1 TechnicalException (io.gravitee.repository.exceptions.TechnicalException)1 Tenant (io.gravitee.repository.management.model.Tenant)1