use of io.gravitee.repository.exceptions.TechnicalException 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);
}
}
use of io.gravitee.repository.exceptions.TechnicalException in project gravitee-management-rest-api by gravitee-io.
the class TenantServiceImpl method delete.
@Override
public void delete(final String tenantId) {
try {
Optional<Tenant> tenantOptional = tenantRepository.findById(tenantId);
if (tenantOptional.isPresent()) {
tenantRepository.delete(tenantId);
auditService.createPortalAuditLog(Collections.singletonMap(TENANT, tenantId), TENANT_DELETED, new Date(), null, tenantOptional.get());
tenantRepository.delete(tenantId);
}
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to delete tenant {}", tenantId, ex);
throw new TechnicalManagementException("An error occurs while trying to delete tenant " + tenantId, ex);
}
}
use of io.gravitee.repository.exceptions.TechnicalException in project gravitee-management-rest-api by gravitee-io.
the class UserServiceImpl method findByIds.
@Override
public Set<UserEntity> findByIds(List<String> ids) {
try {
LOGGER.debug("Find users by ID: {}", ids);
Set<User> users = userRepository.findByIds(ids);
if (!users.isEmpty()) {
return users.stream().map(u -> this.convert(u, false)).collect(Collectors.toSet());
}
Optional<String> idsAsString = ids.stream().reduce((a, b) -> a + '/' + b);
if (idsAsString.isPresent()) {
throw new UserNotFoundException(idsAsString.get());
} else {
throw new UserNotFoundException("?");
}
} catch (TechnicalException ex) {
Optional<String> idsAsString = ids.stream().reduce((a, b) -> a + '/' + b);
LOGGER.error("An error occurs while trying to find users using their ID {}", idsAsString, ex);
throw new TechnicalManagementException("An error occurs while trying to find users using their ID " + idsAsString, ex);
}
}
use of io.gravitee.repository.exceptions.TechnicalException in project gravitee-management-rest-api by gravitee-io.
the class UserServiceImpl method findById.
@Override
public UserEntity findById(String id) {
try {
LOGGER.debug("Find user by ID: {}", id);
Optional<User> optionalUser = userRepository.findById(id);
if (optionalUser.isPresent()) {
return convert(optionalUser.get(), false);
}
// should never happen
throw new UserNotFoundException(id);
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to find user using its ID {}", id, ex);
throw new TechnicalManagementException("An error occurs while trying to find user using its ID " + id, ex);
}
}
use of io.gravitee.repository.exceptions.TechnicalException in project gravitee-management-rest-api by gravitee-io.
the class UserServiceImpl method findByIdWithRoles.
@Override
public UserEntity findByIdWithRoles(String id) {
try {
LOGGER.debug("Find user by ID: {}", id);
Optional<User> optionalUser = userRepository.findById(id);
if (optionalUser.isPresent()) {
return convert(optionalUser.get(), true);
}
// should never happen
throw new UserNotFoundException(id);
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to find user using its ID {}", id, ex);
throw new TechnicalManagementException("An error occurs while trying to find user using its ID " + id, ex);
}
}
Aggregations