use of ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.SequenceFileMessageConverter in project irida by phac-nml.
the class SequenceFileRemoteRepositoryImpl method downloadRemoteSequenceFile.
/**
* {@inheritDoc}
*/
@Override
public Path downloadRemoteSequenceFile(String uri, RemoteAPI remoteAPI, MediaType... mediaTypes) {
SequenceFile file = read(uri, remoteAPI);
OAuthTokenRestTemplate restTemplate = new OAuthTokenRestTemplate(tokenService, remoteAPI);
// add the sequence file message converter
List<HttpMessageConverter<?>> converters = restTemplate.getMessageConverters();
converters.add(new SequenceFileMessageConverter(file.getFileName()));
restTemplate.setMessageConverters(converters);
// add the application/fastq accept header
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setAccept(Arrays.asList(mediaTypes));
HttpEntity<Path> requestEntity = new HttpEntity<Path>(requestHeaders);
// get the file
ResponseEntity<Path> exchange = restTemplate.exchange(uri, HttpMethod.GET, requestEntity, Path.class);
return exchange.getBody();
}
Aggregations