Search in sources :

Example 1 with SequenceFileMessageConverter

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();
}
Also used : SequenceFileMessageConverter(ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.SequenceFileMessageConverter) Path(java.nio.file.Path) HttpHeaders(org.springframework.http.HttpHeaders) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) HttpEntity(org.springframework.http.HttpEntity) HttpMessageConverter(org.springframework.http.converter.HttpMessageConverter) OAuthTokenRestTemplate(ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate)

Aggregations

SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)1 OAuthTokenRestTemplate (ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate)1 SequenceFileMessageConverter (ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.SequenceFileMessageConverter)1 Path (java.nio.file.Path)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpHeaders (org.springframework.http.HttpHeaders)1 HttpMessageConverter (org.springframework.http.converter.HttpMessageConverter)1