use of org.opennms.netmgt.measurements.api.exceptions.FilterException in project opennms by OpenNMS.
the class FilterEngine method filter.
/**
* Successively applies all of the filters.
*/
public void filter(final List<FilterDef> filterDefinitions, final RowSortedTable<Long, String, Double> table) throws FilterException {
Preconditions.checkNotNull(filterDefinitions, "filterDefinitions argument");
Preconditions.checkNotNull(table, "table argument");
for (FilterDef filterDef : filterDefinitions) {
Filter filter = getFilter(filterDef);
if (filter == null) {
throw new FilterException("No filter implementation found for {}", filterDef.getName());
}
try {
filter.filter(table);
} catch (Throwable t) {
throw new FilterException(t, "An error occurred while applying filter {}", t.getMessage());
}
}
}
use of org.opennms.netmgt.measurements.api.exceptions.FilterException in project opennms by OpenNMS.
the class MeasurementsRestService method query.
/**
* Retrieves the measurements of many resources and performs
* arbitrary calculations on these.
*
* This a read-only query, however we use a POST instead of GET
* since the request parameters are difficult to express in a query string.
*/
@POST
@Path("/")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_ATOM_XML })
@Transactional(readOnly = true)
public QueryResponse query(final QueryRequest request) {
Preconditions.checkState(service != null);
LOG.debug("Executing query with {}", request);
QueryResponse response = null;
try {
response = service.query(request);
} catch (ExpressionException e) {
throw getException(Status.BAD_REQUEST, e, "An error occurred while evaluating an expression: {}", e.getMessage());
} catch (FilterException | ValidationException e) {
throw getException(Status.BAD_REQUEST, e, e.getMessage());
} catch (ResourceNotFoundException e) {
throw getException(Status.NOT_FOUND, e, e.getMessage());
} catch (FetchException e) {
throw getException(Status.INTERNAL_SERVER_ERROR, e, e.getMessage());
} catch (Exception e) {
throw getException(Status.INTERNAL_SERVER_ERROR, e, "Query failed: {}", e.getMessage());
}
// Return a 204 if there are no columns
if (response.getColumns().length == 0) {
throw getException(Status.NO_CONTENT, "No content.");
}
return response;
}
Aggregations