agave-jobs/jobs-api/src/main/java/org/iplantc/service/jobs/resources/JobManageResource.java
/**
	 * This method represents the HTTP DELETE action. Using this method, the
	 * user can effectively kill a running job. If the job id included in the
	 * URL is invalid, a HTTP
	 * {@link org.restlet.data.Status#CLIENT_ERROR_BAD_REQUEST 400} code is
	 * sent. If a problem occurs killing the job a HTTP
	 * {@link org.restlet.data.Status#SERVER_ERROR_INTERNAL 500} code is sent.
	 */
This method represents the HTTP DELETE action. Using this method, the
user can effectively kill a running job. If the job id included in the
URL is invalid, a HTTP
org.restlet.data.Status#CLIENT_ERROR_BAD_REQUEST 400 code is
sent. If a problem occurs killing the job a HTTP
org.restlet.data.Status#SERVER_ERROR_INTERNAL 500 code is sent.
This method represents the HTTP DELETE action . Using this method the user can effectively kill a running job . If the job id included in the URL is invalid a HTTP org . restlet . data . Status#CLIENT_ERROR_BAD_REQUEST 400 code is sent . If a problem occurs killing the job a HTTP org . restlet . data . Status#SERVER_ERROR_INTERNAL 500 code is sent .
@Override
	public void removeRepresentations()
	{
		AgaveLogServiceClient.log(AgaveLogServiceClient.ServiceKeys.JOBS02.name(), 
				AgaveLogServiceClient.ActivityKeys.JobsDelete.name(), 
				username, "", getRequest().getClientInfo().getUpstreamAddress());
		if (!ServiceUtils.isValid(sJobId))
		{
			getResponse().setEntity(
					new IplantErrorRepresentation("Job id cannot be empty"));
			getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
			return;
		}
		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);
				getResponse().setEntity(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);
                getResponse().setEntity(new IplantErrorRepresentation(msg));
			}
			else if (new JobPermissionManager(job, username).canWrite(username))
			{
				String message = null;
				try {
					JobManager.hide(job.getId(), username);
				}
				catch (JobTerminationException e) {
					message = e.getMessage();
				}
				getResponse().setEntity(new IplantSuccessRepresentation(message, null));
				getResponse().setStatus(Status.SUCCESS_OK);
			}
			else
			{
				getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN);
				getResponse().setEntity(new IplantErrorRepresentation(
						"User does not have permission to view this job"));
			}
		}
		catch (JobException e)
		{
			getResponse().setEntity(
					new IplantErrorRepresentation(e.getMessage()));
			getResponse().setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
			log.error("Failed to hide job " + sJobId, e);
		}
		catch (Throwable e)
		{
			getResponse().setEntity(
					new IplantErrorRepresentation("Job deletion failed"));
			getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
			log.error("Failed to hide job " + sJobId, e);
		}
		finally {
			try { HibernateUtil.closeSession(); } catch (Throwable ignored) {}
		}
	}
@ Override public void removeRepresentations ( ) { AgaveLogServiceClient . log ( AgaveLogServiceClient . ServiceKeys . JOBS02 . name ( ) , AgaveLogServiceClient . ActivityKeys . JobsDelete . name ( ) , username , "" , getRequest ( ) . getClientInfo ( ) . getUpstreamAddress ( ) ) ; if ( ! ServiceUtils . isValid ( sJobId ) ) { getResponse ( ) . setEntity ( new IplantErrorRepresentation ( "Job id cannot be empty" ) ) ; getResponse ( ) . setStatus ( Status . CLIENT_ERROR_BAD_REQUEST ) ; return ; } 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 ) ; getResponse ( ) . setEntity ( 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 ) ; getResponse ( ) . setEntity ( new IplantErrorRepresentation ( msg ) ) ; } else if ( new JobPermissionManager ( job , username ) . canWrite ( username ) ) { String message = null ; try { JobManager . hide ( job . getId ( ) , username ) ; } catch ( JobTerminationException e ) { message = e . getMessage ( ) ; } getResponse ( ) . setEntity ( new IplantSuccessRepresentation ( message , null ) ) ; getResponse ( ) . setStatus ( Status . SUCCESS_OK ) ; } else { getResponse ( ) . setStatus ( Status . CLIENT_ERROR_FORBIDDEN ) ; getResponse ( ) . setEntity ( new IplantErrorRepresentation ( "User does not have permission to view this job" ) ) ; } } catch ( JobException e ) { getResponse ( ) . setEntity ( new IplantErrorRepresentation ( e . getMessage ( ) ) ) ; getResponse ( ) . setStatus ( Status . CLIENT_ERROR_BAD_REQUEST ) ; log . error ( "Failed to hide job " + sJobId , e ) ; } catch ( Throwable e ) { getResponse ( ) . setEntity ( new IplantErrorRepresentation ( "Job deletion failed" ) ) ; getResponse ( ) . setStatus ( Status . SERVER_ERROR_INTERNAL ) ; log . error ( "Failed to hide job " + sJobId , e ) ; } finally { try { HibernateUtil . closeSession ( ) ; } catch ( Throwable ignored ) { } } }
This method represents the HTTP DELETE action.
This method represents the HTTP DELETE action .