Search in sources :

Example 1 with GeolocationService

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();
    }
}
Also used : GeolocationService(org.opennms.features.geolocation.api.GeolocationService) GeolocationQuery(org.opennms.features.geolocation.api.GeolocationQuery) GeolocationInfo(org.opennms.features.geolocation.api.GeolocationInfo) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST)

Aggregations

POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 GeolocationInfo (org.opennms.features.geolocation.api.GeolocationInfo)1 GeolocationQuery (org.opennms.features.geolocation.api.GeolocationQuery)1 GeolocationService (org.opennms.features.geolocation.api.GeolocationService)1