use of org.n52.web.common.Stopwatch in project series-rest-api by 52North.
the class StationsParameterController method getItem.
@RequestMapping(value = "/{item}", method = RequestMethod.GET)
public ModelAndView getItem(@PathVariable("item") String procedureId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) {
RequestUtils.overrideQueryLocaleWhenSet(locale, query);
IoParameters map = QueryParameters.createFromQuery(query);
map = IoParameters.ensureBackwardsCompatibility(map);
// TODO check parameters and throw BAD_REQUEST if invalid
Stopwatch stopwatch = Stopwatch.startStopwatch();
Object result = parameterService.getParameter(procedureId, map);
logRequestTime(stopwatch);
if (result == null) {
throw new ResourceNotFoundException("Found no station with given id.");
}
return new ModelAndView().addObject(result);
}
use of org.n52.web.common.Stopwatch in project series-rest-api by 52North.
the class StationsParameterController method getCollection.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView getCollection(@RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) {
RequestUtils.overrideQueryLocaleWhenSet(locale, query);
IoParameters map = QueryParameters.createFromQuery(query);
map = IoParameters.ensureBackwardsCompatibility(map);
if (map.isExpanded()) {
Stopwatch stopwatch = Stopwatch.startStopwatch();
OutputCollection<?> result = parameterService.getExpandedParameters(map);
logRequestTime(stopwatch);
// TODO add paging
return new ModelAndView().addObject(result.getItems());
} else {
Stopwatch stopwatch = Stopwatch.startStopwatch();
OutputCollection<?> result = parameterService.getCondensedParameters(map);
logRequestTime(stopwatch);
// TODO add paging
return new ModelAndView().addObject(result.getItems());
}
}
use of org.n52.web.common.Stopwatch in project series-rest-api by 52North.
the class TimeseriesDataController method getTimeseriesData.
private DataCollection<QuantityData> getTimeseriesData(RequestSimpleParameterSet parameters) {
Stopwatch stopwatch = Stopwatch.startStopwatch();
DataCollection<QuantityData> timeseriesData = parameters.isGeneralize() ? new GeneralizingQuantityService(timeseriesDataService).getData(parameters) : timeseriesDataService.getData(parameters);
LOGGER.debug("Processing request took {} seconds.", stopwatch.stopInSeconds());
return timeseriesData;
}
use of org.n52.web.common.Stopwatch in project arctic-sea by 52North.
the class Service method logResponse.
private void logResponse(HttpServletRequest request, HttpServletResponse response, long count, Stopwatch stopwatch) {
long elapsed = stopwatch.stop().elapsed(TimeUnit.MILLISECONDS);
this.serviceEventBus.submit(new OutgoingResponseEvent(request, response, count, elapsed));
LOGGER.debug("Outgoing response for request No. {} is committed = {} (took {} ms)", count, response.isCommitted(), elapsed);
}
use of org.n52.web.common.Stopwatch in project arctic-sea by 52North.
the class Service method put.
@RequestMapping(method = RequestMethod.PUT)
public void put(HttpServletRequest request, HttpServletResponse response) throws IOException {
Stopwatch stopwatch = Stopwatch.createStarted();
long currentCount = logRequest(request);
try {
getBinding(request).doPutOperation(request, response);
} catch (HTTPException exception) {
onHttpException(request, response, exception);
} finally {
logResponse(request, response, currentCount, stopwatch);
}
}
Aggregations