use of io.gravitee.rest.api.service.exceptions.EventNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class InstanceServiceImpl method findByEvent.
@Override
public InstanceEntity findByEvent(String eventId) {
try {
LOGGER.debug("Find instance by event ID: {}", eventId);
EventEntity event = eventService.findById(eventId);
List<String> environments = Stream.of(event.getProperties().get(ENVIRONMENTS_HRIDS_PROPERTY).split(", ")).filter(env -> !StringUtils.isEmpty(env)).collect(Collectors.toList());
List<String> organizations = Stream.of(event.getProperties().get(ORGANIZATIONS_HRIDS_PROPERTY).split(", ")).filter(org -> !StringUtils.isEmpty(org)).collect(Collectors.toList());
return convert(event, environments, organizations);
} catch (EventNotFoundException enfe) {
throw new InstanceNotFoundException(eventId);
}
}
use of io.gravitee.rest.api.service.exceptions.EventNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class EventServiceImpl method findById.
@Override
public EventEntity findById(String id) {
try {
LOGGER.debug("Find event by ID: {}", id);
Optional<Event> event = eventRepository.findById(id);
if (event.isPresent()) {
return convert(event.get());
}
throw new EventNotFoundException(id);
} catch (TechnicalException ex) {
LOGGER.error("An error occurs while trying to find an event using its ID {}", id, ex);
throw new TechnicalManagementException("An error occurs while trying to find an event using its ID " + id, ex);
}
}
Aggregations