Search in sources :

Example 1 with JobNotFoundException

use of bio.terra.workspace.service.job.exception.JobNotFoundException in project terra-workspace-manager by DataBiosphere.

the class JobService method verifyUserAccess.

/**
 * Ensure the user in the user request has permission to read the workspace associated with the
 * Job ID. Throws ForbiddenException if not.
 *
 * @param jobId - ID of running job
 * @param userRequest - original user request
 */
private void verifyUserAccess(String jobId, AuthenticatedUserRequest userRequest) {
    try {
        FlightState flightState = stairwayComponent.get().getFlightState(jobId);
        FlightMap inputParameters = flightState.getInputParameters();
        UUID workspaceId = inputParameters.get(WorkspaceFlightMapKeys.WORKSPACE_ID, UUID.class);
        flightBeanBag.getWorkspaceService().validateWorkspaceAndAction(userRequest, workspaceId, SamWorkspaceAction.READ);
    } catch (DatabaseOperationException | InterruptedException ex) {
        throw new InternalStairwayException("Stairway exception looking up the job", ex);
    } catch (FlightNotFoundException ex) {
        throw new JobNotFoundException("Job not found", ex);
    }
}
Also used : FlightState(bio.terra.stairway.FlightState) FlightNotFoundException(bio.terra.stairway.exception.FlightNotFoundException) DatabaseOperationException(bio.terra.stairway.exception.DatabaseOperationException) JobNotFoundException(bio.terra.workspace.service.job.exception.JobNotFoundException) FlightMap(bio.terra.stairway.FlightMap) UUID(java.util.UUID) InternalStairwayException(bio.terra.workspace.service.job.exception.InternalStairwayException)

Aggregations

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 InternalStairwayException (bio.terra.workspace.service.job.exception.InternalStairwayException)1 JobNotFoundException (bio.terra.workspace.service.job.exception.JobNotFoundException)1 UUID (java.util.UUID)1