use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.
the class ProjectSynchronizationServiceTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
syncService = new ProjectSynchronizationService(projectService, sampleService, objectService, metadataTemplateService, projectRemoteService, sampleRemoteService, singleEndRemoteService, pairRemoteService, tokenService);
api = new RemoteAPI();
expired = new Project();
expired.setId(1L);
RemoteStatus expStatus = new RemoteStatus("http://expired", api);
expStatus.setId(1L);
expStatus.setLastUpdate(new Date(1));
expStatus.setSyncStatus(RemoteStatus.SyncStatus.SYNCHRONIZED);
expired.setSyncFrequency(ProjectSyncFrequency.WEEKLY);
expired.setRemoteStatus(expStatus);
upToDate = new Project();
upToDate.setId(2L);
RemoteStatus upToDateStatus = new RemoteStatus("http://upToDate", api);
upToDateStatus.setId(2L);
upToDateStatus.setLastUpdate(new Date());
upToDateStatus.setSyncStatus(RemoteStatus.SyncStatus.SYNCHRONIZED);
upToDate.setSyncFrequency(ProjectSyncFrequency.WEEKLY);
upToDate.setRemoteStatus(upToDateStatus);
neverSync = new Project();
neverSync.setId(3L);
RemoteStatus neverSyncStatus = new RemoteStatus("http://never", api);
neverSyncStatus.setId(3L);
neverSyncStatus.setLastUpdate(new Date());
neverSyncStatus.setSyncStatus(RemoteStatus.SyncStatus.SYNCHRONIZED);
neverSync.setSyncFrequency(ProjectSyncFrequency.NEVER);
neverSync.setRemoteStatus(neverSyncStatus);
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.
the class ProjectSynchronizationService method findMarkedProjectsToSync.
/**
* Find projects which should be synchronized and launch a synchornization
* task.
*/
public synchronized void findMarkedProjectsToSync() {
// mark any projects which should be synched first
findProjectsToMark();
List<Project> markedProjects = projectService.getProjectsWithRemoteSyncStatus(SyncStatus.MARKED);
logger.trace("Checking for projects to sync");
for (Project project : markedProjects) {
/*
* Set the correct authorization for the user who's syncing the
* project
*/
User readBy = project.getRemoteStatus().getReadBy();
setAuthentication(readBy);
logger.debug("Syncing project at " + project.getRemoteStatus().getURL());
try {
RemoteAPI api = project.getRemoteStatus().getApi();
tokenService.updateTokenFromRefreshToken(api);
syncProject(project);
} catch (IridaOAuthException e) {
logger.trace("Can't sync project " + project.getRemoteStatus().getURL() + " due to oauth error:", e);
project.getRemoteStatus().setSyncStatus(SyncStatus.UNAUTHORIZED);
projectService.update(project);
} catch (Exception e) {
logger.debug("An error occurred while synchronizing project " + project.getRemoteStatus().getURL(), e);
project.getRemoteStatus().setSyncStatus(SyncStatus.ERROR);
projectService.update(project);
} finally {
// clear the context holder when you're done
SecurityContextHolder.clearContext();
logger.debug("Done project " + project.getRemoteStatus().getURL());
}
}
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.
the class SequenceFilePairRemoteServiceImpl method getSequenceFilePairsForSample.
/**
* {@inheritDoc}
*/
@Override
public List<SequenceFilePair> getSequenceFilePairsForSample(Sample sample) {
Link link = sample.getLink(SAMPLE_SEQENCE_FILE_PAIRS_REL);
String href = link.getHref();
RemoteAPI remoteApiForURI = getRemoteApiForURI(href);
return repository.list(href, remoteApiForURI);
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.
the class SequencingObjectRemoteServiceImpl method mirrorSequencingObject.
@Override
public Type mirrorSequencingObject(Type seqObject) {
Set<SequenceFile> files = seqObject.getFiles();
for (SequenceFile file : files) {
String fileHref = file.getSelfHref();
RemoteAPI api = getRemoteApiForURI(fileHref);
Path downloadRemoteSequenceFile = sequenceFileRemoteRepository.downloadRemoteSequenceFile(fileHref, api);
file.setFile(downloadRemoteSequenceFile);
}
return seqObject;
}
use of ca.corefacility.bioinformatics.irida.model.RemoteAPI in project irida by phac-nml.
the class SingleEndSequenceFileRemoteServiceImpl method getUnpairedFilesForSample.
/**
* {@inheritDoc}
*/
@Override
public List<SingleEndSequenceFile> getUnpairedFilesForSample(Sample sample) {
Link link = sample.getLink(SAMPLE_SEQENCE_FILE_UNPAIRED_REL);
String href = link.getHref();
RemoteAPI remoteApiForURI = getRemoteApiForURI(href);
return repository.list(href, remoteApiForURI);
}
Aggregations