use of io.gravitee.rest.api.service.exceptions.InstanceNotFoundException 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.InstanceNotFoundException in project gravitee-management-rest-api by gravitee-io.
the class HealthCheckServiceImpl method getGatewayMetadata.
private Map<String, String> getGatewayMetadata(String gateway) {
Map<String, String> metadata = new HashMap<>();
try {
InstanceEntity instance = instanceService.findById(gateway);
metadata.put("hostname", instance.getHostname());
metadata.put("ip", instance.getIp());
if (instance.getTenant() != null) {
metadata.put("tenant", instance.getTenant());
}
} catch (InstanceNotFoundException infe) {
metadata.put("deleted", "true");
}
return metadata;
}
Aggregations