use of io.gravitee.rest.api.service.exceptions.TenantNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class TenantServiceImpl method findByIdAndReference.
@Override
public TenantEntity findByIdAndReference(String tenantId, String referenceId, TenantReferenceType tenantReferenceType) {
try {
LOGGER.debug("Find tenant by ID: {}", tenantId);
Optional<Tenant> optTenant = tenantRepository.findByIdAndReference(tenantId, referenceId, repoTenantReferenceType(tenantReferenceType));
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);
}
}
Aggregations