use of org.opennms.features.geolocation.api.GeolocationService in project opennms by OpenNMS.
the class GeolocationRestService method getLocations.
@POST
@Path("/")
public Response getLocations(GeolocationQueryDTO queryDTO) {
final GeolocationService service = getServiceRegistry().findProvider(GeolocationService.class);
if (service == null) {
return temporarilyNotAvailable();
}
try {
validate(queryDTO);
GeolocationQuery query = toQuery(queryDTO);
final List<GeolocationInfo> locations = service.getLocations(query);
if (locations.isEmpty()) {
return Response.noContent().build();
}
return Response.ok(locations).build();
} catch (InvalidQueryException ex) {
return Response.status(Response.Status.BAD_REQUEST).entity(ex.getMessage()).build();
}
}
Aggregations