use of bio.terra.service.job.exception.JobServiceShutdownException in project jade-data-repo by DataBiosphere.
the class JobService method enumerateJobs.
public List<JobModel> enumerateJobs(int offset, int limit, AuthenticatedUserRequest userReq) {
boolean canListAnyJob = checkUserCanListAnyJob(userReq);
// if the user has access to all jobs, then fetch everything
// otherwise, filter the jobs on the user
List<FlightState> flightStateList;
try {
FlightFilter filter = new FlightFilter();
if (!canListAnyJob) {
filter.addFilterInputParameter(JobMapKeys.SUBJECT_ID.getKeyName(), FlightFilterOp.EQUAL, userReq.getSubjectId());
}
flightStateList = stairway.getFlights(offset, limit, filter);
} catch (StairwayException stairwayEx) {
throw new InternalStairwayException(stairwayEx);
} catch (InterruptedException ex) {
throw new JobServiceShutdownException("Job service interrupted", ex);
}
List<JobModel> jobModelList = new ArrayList<>();
for (FlightState flightState : flightStateList) {
JobModel jobModel = mapFlightStateToJobModel(flightState);
jobModelList.add(jobModel);
}
return jobModelList;
}
use of bio.terra.service.job.exception.JobServiceShutdownException in project jade-data-repo by DataBiosphere.
the class JobService method verifyUserAccess.
private void verifyUserAccess(String jobId, AuthenticatedUserRequest userReq) {
try {
FlightState flightState = stairway.getFlightState(jobId);
FlightMap inputParameters = flightState.getInputParameters();
String flightSubjectId = inputParameters.get(JobMapKeys.SUBJECT_ID.getKeyName(), String.class);
if (!StringUtils.equals(flightSubjectId, userReq.getSubjectId())) {
throw new JobUnauthorizedException("Unauthorized");
}
} catch (DatabaseOperationException ex) {
throw new InternalStairwayException("Stairway exception looking up the job", ex);
} catch (FlightNotFoundException ex) {
throw new JobNotFoundException("Job not found", ex);
} catch (InterruptedException ex) {
throw new JobServiceShutdownException("Job service interrupted", ex);
}
}
Aggregations