use of org.n52.series.spi.srv.RawDataService in project series-rest-api by 52North.
the class TimeseriesDataController method processRawDataRequest.
private void processRawDataRequest(HttpServletResponse response, RequestSimpleParameterSet query) {
if (!timeseriesDataService.supportsRawData()) {
throwNewRawDataQueryNotSupportedException();
}
final RawDataService rawDataService = timeseriesDataService.getRawDataService();
try (InputStream inputStream = rawDataService.getRawData(query)) {
if (inputStream == null) {
throw new ResourceNotFoundException("No raw data found.");
}
response.setContentType(query.getFormat());
IOUtils.copyLarge(inputStream, response.getOutputStream());
} catch (IOException e) {
throw new InternalServerException("Error while querying raw data", e);
}
}
use of org.n52.series.spi.srv.RawDataService in project series-rest-api by 52North.
the class TimeseriesDataController method processRawDataRequest.
private void processRawDataRequest(HttpServletResponse response, IoParameters parameters) {
if (!timeseriesDataService.supportsRawData()) {
throwNewRawDataQueryNotSupportedException();
}
final RawDataService rawDataService = timeseriesDataService.getRawDataService();
try (InputStream inputStream = rawDataService.getRawData(parameters)) {
response.setContentType(parameters.getFormat());
IOUtils.copyLarge(inputStream, response.getOutputStream());
} catch (IOException e) {
throw new InternalServerException("Error while querying raw data", e);
}
}
use of org.n52.series.spi.srv.RawDataService in project series-rest-api by 52North.
the class DataController method writeRawData.
private void writeRawData(IoParameters parameters, HttpServletResponse response) throws InternalServerException, ResourceNotFoundException, BadRequestException {
LOGGER.debug("get raw data collection with parameters: {}", parameters);
if (!dataService.supportsRawData()) {
throw new BadRequestException("Querying of raw timeseries data is not supported " + "by the underlying service!");
}
final RawDataService rawDataService = dataService.getRawDataService();
try (InputStream inputStream = rawDataService.getRawData(parameters)) {
response.setContentType(parameters.getRawFormat());
IOUtils.copyLarge(inputStream, response.getOutputStream());
} catch (IOException e) {
throw new InternalServerException("Error while querying raw data", e);
}
}
use of org.n52.series.spi.srv.RawDataService in project series-rest-api by 52North.
the class DataController method writeRawData.
private void writeRawData(RequestSimpleParameterSet parameters, HttpServletResponse response) throws InternalServerException, ResourceNotFoundException, BadRequestException {
if (!dataService.supportsRawData()) {
throw new BadRequestException("Querying of raw timeseries data is not supported " + "by the underlying service!");
}
final RawDataService rawDataService = dataService.getRawDataService();
try (InputStream inputStream = rawDataService.getRawData(parameters)) {
if (inputStream == null) {
throw new ResourceNotFoundException("No raw data found.");
}
response.setContentType(parameters.getRawFormat());
IOUtils.copyLarge(inputStream, response.getOutputStream());
} catch (IOException e) {
throw new InternalServerException("Error while querying raw data", e);
}
}
Aggregations