use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.
the class DataController method getSeriesAsCsv.
@RequestMapping(value = "/{seriesId}/data", produces = { "text/csv" }, method = RequestMethod.GET)
public void getSeriesAsCsv(HttpServletResponse response, @PathVariable String seriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) throws Exception {
RequestUtils.overrideQueryLocaleWhenSet(locale, query);
IoParameters map = QueryParameters.createFromQuery(query);
LOGGER.debug("get data collection csv for '{}' with query: {}", seriesId, map);
RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(seriesId, map);
checkAgainstTimespanRestriction(parameters.getTimespan());
checkForUnknownDatasetIds(map, seriesId);
response.setCharacterEncoding(DEFAULT_RESPONSE_ENCODING);
if (Boolean.parseBoolean(map.getOther("zip"))) {
response.setContentType(MimeType.APPLICATION_ZIP.toString());
} else {
response.setContentType(MimeType.TEXT_CSV.toString());
}
final String datasetType = parameters.getValueType();
createIoFactory(datasetType).withSimpleRequest(parameters).createHandler(MimeType.TEXT_CSV.toString()).writeBinary(response.getOutputStream());
}
use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.
the class DataController method getSeriesAsZippedCsv.
@RequestMapping(value = "/{seriesId}/data", produces = { "application/zip" }, method = RequestMethod.GET)
public void getSeriesAsZippedCsv(HttpServletResponse response, @PathVariable String seriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam(required = false) MultiValueMap<String, String> query) throws Exception {
RequestUtils.overrideQueryLocaleWhenSet(locale, query);
IoParameters map = QueryParameters.createFromQuery(query);
LOGGER.debug("get data collection zip for '{}' with query: {}", seriesId, map);
RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(seriesId, map);
checkAgainstTimespanRestriction(parameters.getTimespan());
checkForUnknownDatasetIds(map, seriesId);
response.setCharacterEncoding(DEFAULT_RESPONSE_ENCODING);
response.setContentType(MimeType.APPLICATION_ZIP.toString());
final String datasetType = parameters.getValueType();
createIoFactory(datasetType).withSimpleRequest(parameters).createHandler(MimeType.APPLICATION_ZIP.toString()).writeBinary(response.getOutputStream());
}
use of org.n52.io.response.dataset.Data in project series-rest-api by 52North.
the class DataController method getRawSeriesData.
@RequestMapping(value = "/{seriesId}/data", method = RequestMethod.GET, params = { RawFormats.RAW_FORMAT })
public void getRawSeriesData(HttpServletResponse response, @PathVariable String seriesId, @RequestHeader(value = Parameters.HttpHeader.ACCEPT_LANGUAGE) String locale, @RequestParam MultiValueMap<String, String> query) {
RequestUtils.overrideQueryLocaleWhenSet(locale, query);
IoParameters map = QueryParameters.createFromQuery(query);
checkForUnknownDatasetIds(map, seriesId);
LOGGER.debug("getSeriesCollection() with query: {}", map);
RequestSimpleParameterSet parameters = RequestSimpleParameterSet.createForSingleSeries(seriesId, map);
writeRawData(parameters, response);
}
use of org.n52.io.response.dataset.Data 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.io.response.dataset.Data in project arctic-sea by 52North.
the class ElasticsearchAdminHandler method initTransportMode.
/**
* Starts client mode in {@link TransportClient} remote mode
*/
private void initTransportMode() {
Objects.requireNonNull(settings.getClusterName());
Objects.requireNonNull(settings.getClusterNodes());
Settings.Builder tcSettings = Settings.settingsBuilder();
tcSettings.put("cluster.name", settings.getClusterName());
TransportClient cl = TransportClient.builder().settings(tcSettings).build();
// nodes has format host[:port]
settings.getClusterNodes().stream().forEach(i -> {
InetSocketTransportAddress address = null;
if (i.contains(":")) {
try {
String[] split = i.split(":");
address = new InetSocketTransportAddress(InetAddress.getByName(split[0]), Integer.valueOf(split[1]));
} catch (UnknownHostException e) {
logConnectionError(i, e);
}
} else {
try {
// default communication port
address = new InetSocketTransportAddress(InetAddress.getByName(i), 9300);
} catch (UnknownHostException e) {
logConnectionError(i, e);
}
}
if (address != null) {
cl.addTransportAddress(address);
}
});
this.client = cl;
logger.info("ElasticSearch data handler starting in Remote mode");
}
Aggregations