agave-jobs/jobs-api/src/main/java/org/iplantc/service/jobs/resources/JobManageResource.java
/**
	 * This method represents the HTTP GET action. Using the job id from the
	 * URL, the job information is retrieved from the databse and sent to the
	 * user as a {@link org.json.JSONObject JSONObject}. If the job id is
	 * invalid for any reason, a HTTP
	 * {@link org.restlet.data.Status#CLIENT_ERROR_BAD_REQUEST 400} code is
	 * sent. If an internal error occurs due to connectivity issues, etc, a
	 * {@link org.restlet.data.Status#SERVER_ERROR_INTERNAL 500} code is sent.
	 */
This method represents the HTTP GET action. Using the job id from the
URL, the job information is retrieved from the databse and sent to the
user as a  org.json.JSONObject JSONObject. If the job id is
invalid for any reason, a HTTP
org.restlet.data.Status#CLIENT_ERROR_BAD_REQUEST 400 code is
sent. If an internal error occurs due to connectivity issues, etc, a
org.restlet.data.Status#SERVER_ERROR_INTERNAL 500 code is sent.
This method represents the HTTP GET action . Using the job id from the URL the job information is retrieved from the databse and sent to the user as a org . json . JSONObject JSONObject . If the job id is invalid for any reason a HTTP org . restlet . data . Status#CLIENT_ERROR_BAD_REQUEST 400 code is sent . If an internal error occurs due to connectivity issues etc a org . restlet . data . Status#SERVER_ERROR_INTERNAL 500 code is sent .
@Override
	public Representation represent(Variant variant) throws ResourceException
	{
		AgaveLogServiceClient.log(AgaveLogServiceClient.ServiceKeys.JOBS02.name(), 
				AgaveLogServiceClient.ActivityKeys.JobsGetByID.name(), 
				username, "", getRequest().getClientInfo().getUpstreamAddress());
		if (!ServiceUtils.isValid(sJobId))
		{
			getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
			return new IplantErrorRepresentation("Job id cannot be empty");
		}
		try
		{
			job = JobDao.getByUuid(sJobId);
			if (job == null) 
			{
	            String msg = "No job found with job id " + sJobId + "."; 
	            log.error(msg);
				getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
				return new IplantErrorRepresentation(msg);
			}
			else if (!job.isVisible()) {
                String msg = "Job with uuid " + sJobId + " is not visible.";
                log.error(msg);
                getResponse().setStatus(Status.CLIENT_ERROR_NOT_FOUND);
                return new IplantErrorRepresentation(msg);
			}
			else if (new JobPermissionManager(job, username).canRead(username))
			{
				return new IplantSuccessRepresentation(job.toJSON());
			}
			else
			{
				getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN);
				return new IplantErrorRepresentation(
						"User does not have permission to view this job");
			}
		}
		catch (JobException e)
		{
			getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
			return new IplantErrorRepresentation("Invalid job id "
					+ e.getMessage());
		}
		catch (Exception e)
		{
			getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
			return new IplantErrorRepresentation(e.getMessage());
		}
		finally {
			try { HibernateUtil.closeSession(); } catch (Throwable ignored) {}
		}
	}
@ Override public Representation represent ( Variant variant ) throws ResourceException { AgaveLogServiceClient . log ( AgaveLogServiceClient . ServiceKeys . JOBS02 . name ( ) , AgaveLogServiceClient . ActivityKeys . JobsGetByID . name ( ) , username , "" , getRequest ( ) . getClientInfo ( ) . getUpstreamAddress ( ) ) ; if ( ! ServiceUtils . isValid ( sJobId ) ) { getResponse ( ) . setStatus ( Status . CLIENT_ERROR_BAD_REQUEST ) ; return new IplantErrorRepresentation ( "Job id cannot be empty" ) ; } try { job = JobDao . getByUuid ( sJobId ) ; if ( job == null ) { String msg = "No job found with job id " + sJobId + "." ; log . error ( msg ) ; getResponse ( ) . setStatus ( Status . CLIENT_ERROR_NOT_FOUND ) ; return new IplantErrorRepresentation ( msg ) ; } else if ( ! job . isVisible ( ) ) { String msg = "Job with uuid " + sJobId + " is not visible." ; log . error ( msg ) ; getResponse ( ) . setStatus ( Status . CLIENT_ERROR_NOT_FOUND ) ; return new IplantErrorRepresentation ( msg ) ; } else if ( new JobPermissionManager ( job , username ) . canRead ( username ) ) { return new IplantSuccessRepresentation ( job . toJSON ( ) ) ; } else { getResponse ( ) . setStatus ( Status . CLIENT_ERROR_FORBIDDEN ) ; return new IplantErrorRepresentation ( "User does not have permission to view this job" ) ; } } catch ( JobException e ) { getResponse ( ) . setStatus ( Status . CLIENT_ERROR_BAD_REQUEST ) ; return new IplantErrorRepresentation ( "Invalid job id " + e . getMessage ( ) ) ; } catch ( Exception e ) { getResponse ( ) . setStatus ( Status . SERVER_ERROR_INTERNAL ) ; return new IplantErrorRepresentation ( e . getMessage ( ) ) ; } finally { try { HibernateUtil . closeSession ( ) ; } catch ( Throwable ignored ) { } } }
This method represents the HTTP GET action.
This method represents the HTTP GET action .
// can't set a stopped job back to running. Bad request