use of ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate in project irida by phac-nml.
the class OAuthTokenRestTemplateTest method setUp.
@Before
public void setUp() throws URISyntaxException {
tokenService = mock(RemoteAPITokenService.class);
serviceURI = new URI("http://uri");
remoteAPI = new RemoteAPI("service name", serviceURI.toString(), "a service", "clientId", "clientSecret");
restTemplate = new OAuthTokenRestTemplate(tokenService, remoteAPI);
}
use of ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate in project irida by phac-nml.
the class RemoteRepositoryImpl method getServiceStatus.
/**
* {@inheritDoc}
*/
@Override
public boolean getServiceStatus(RemoteAPI remoteAPI) {
OAuthTokenRestTemplate restTemplate = new OAuthTokenRestTemplate(tokenService, remoteAPI);
ResponseEntity<String> forEntity = restTemplate.getForEntity(remoteAPI.getServiceURI(), String.class);
return forEntity.getStatusCode() == HttpStatus.OK;
}
use of ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate in project irida by phac-nml.
the class RemoteRepositoryImpl method list.
/**
* {@inheritDoc}
*/
@Override
public List<Type> list(String uri, RemoteAPI remoteAPI) {
OAuthTokenRestTemplate restTemplate = new OAuthTokenRestTemplate(tokenService, remoteAPI);
ResponseEntity<ListResourceWrapper<Type>> exchange = restTemplate.exchange(uri, HttpMethod.GET, HttpEntity.EMPTY, listTypeReference);
List<Type> resources = exchange.getBody().getResource().getResources();
for (Type r : resources) {
r = setRemoteStatus(r, remoteAPI);
}
return resources;
}
use of ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate in project irida by phac-nml.
the class RemoteRepositoryImpl method read.
/**
* {@inheritDoc}
*/
@Override
public Type read(String uri, RemoteAPI remoteAPI) {
OAuthTokenRestTemplate restTemplate = new OAuthTokenRestTemplate(tokenService, remoteAPI);
ResponseEntity<ResourceWrapper<Type>> exchange = restTemplate.exchange(uri, HttpMethod.GET, HttpEntity.EMPTY, objectTypeReference);
Type resource = exchange.getBody().getResource();
resource = setRemoteStatus(resource, remoteAPI);
return resource;
}
use of ca.corefacility.bioinformatics.irida.repositories.remote.resttemplate.OAuthTokenRestTemplate in project irida by phac-nml.
the class SampleRemoteRepositoryImpl method getSampleMetadata.
/**
* {@inheritDoc}
*/
public Map<String, MetadataEntry> getSampleMetadata(Sample sample) {
logger.trace("Requesting sample metadata for sample " + sample.getSelfHref());
RemoteAPI remoteAPI = sample.getRemoteStatus().getApi();
OAuthTokenRestTemplate restTemplate = new OAuthTokenRestTemplate(tokenService, remoteAPI);
// get the metadata link
Link metadataLink = sample.getLink(METADATA_REL);
// request metadata response
ResponseEntity<ResourceWrapper<SampleMetadataWrapper>> exchange = restTemplate.exchange(metadataLink.getHref(), HttpMethod.GET, HttpEntity.EMPTY, metadataTypeReference);
// pull metadata response from request
Map<String, MetadataEntry> resource = exchange.getBody().getResource().getMetadata();
return resource;
}
Aggregations