Search in sources :

Example 1 with JobNotFoundException

use of bio.terra.service.job.exception.JobNotFoundException 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);
    }
}
Also used : FlightState(bio.terra.stairway.FlightState) FlightNotFoundException(bio.terra.stairway.exception.FlightNotFoundException) DatabaseOperationException(bio.terra.stairway.exception.DatabaseOperationException) JobUnauthorizedException(bio.terra.service.job.exception.JobUnauthorizedException) JobNotFoundException(bio.terra.service.job.exception.JobNotFoundException) FlightMap(bio.terra.stairway.FlightMap) JobServiceShutdownException(bio.terra.service.job.exception.JobServiceShutdownException) InternalStairwayException(bio.terra.service.job.exception.InternalStairwayException)

Aggregations

InternalStairwayException (bio.terra.service.job.exception.InternalStairwayException)1 JobNotFoundException (bio.terra.service.job.exception.JobNotFoundException)1 JobServiceShutdownException (bio.terra.service.job.exception.JobServiceShutdownException)1 JobUnauthorizedException (bio.terra.service.job.exception.JobUnauthorizedException)1 FlightMap (bio.terra.stairway.FlightMap)1 FlightState (bio.terra.stairway.FlightState)1 DatabaseOperationException (bio.terra.stairway.exception.DatabaseOperationException)1 FlightNotFoundException (bio.terra.stairway.exception.FlightNotFoundException)1